Unable to compile custom-ops built against TF2.4 (Windows)

129 views
Skip to first unread message

Sean Morgan

unread,
Nov 30, 2020, 1:50:49 PM11/30/20
to SIG Build
Hi SIG Build,

I'm attempting to compile TensorFlow Addons built against TF2.4rc3 but am running into an error on Windows builds. It's compiled using MSVC2019 and the same custom ops compile fine when using Windows+TF2.3 (they also compile fine for macos+TF2.4 and linux+TF2.4):

It should be related to the tf-core includes since it compiles fine for previous TF versions. Also, it's not specific to the below custom-op code since it'll fail on any custom-op I try to compile. I also verified this same error on my local windows machine. 

Are there any flags I need to pass to MSVC2019 in order to get custom-ops to compile with TF2.4? I didn't see anything new on the tensorflow/tensorflow repo, but was hoping someone from the SIG / TF-Build team would be able to help.

```
[90 / 134] [Prepa] Executing genrule @local_config_tf//:tf_header_include; 4s
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 8s local
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 31s local
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 40s local
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 62s local
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 90s local
[90 / 134] Executing genrule @local_config_tf//:tf_header_include; 108s local
ERROR: D:/a/addons/addons/tensorflow_addons/custom_ops/seq2seq/BUILD:7:1: C++ compilation of rule '//tensorflow_addons/custom_ops/seq2seq:_beam_search_ops.so' failed (Exit 2)
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): warning C4003: not enough arguments for function-like macro invocation 'REGISTER_OP_IMPL'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): warning C4002: too many arguments for function-like macro invocation 'SHOULD_REGISTER_OP'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2059: syntax error: '||'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2039: 'value': is not a member of '`global namespace''
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2146: syntax error: missing ')' before identifier 'value'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2065: 'value': undeclared identifier
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2059: syntax error: ')'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'tensorflow::register_op::OpDefBuilderWrapper'
tensorflow_addons/custom_ops/seq2seq/cc/ops/beam_search_ops.cc(26): note: No constructor could take the source type, or constructor overload resolution was ambiguous
```

Lukas Geiger

unread,
Nov 30, 2020, 4:14:57 PM11/30/20
to SIG Build, seanm...@outlook.com
Hi Sean,

I ran into a very similar Windows build issue some time ago in another project. Using `--copt=/Zc:preprocessor --host_copt=/Zc:preprocessor` on Windows fixed it for me on CI. TensorFlow also added similar flags in this commit.

Best,
Lukas

Austin Anderson

unread,
Nov 30, 2020, 5:48:11 PM11/30/20
to SIG Build, lukas.g...@gmail.com, seanm...@outlook.com
Thanks, Lukas!

For others who might encounter this problem, I added a note to TF 2.4's release notes, see here: https://github.com/tensorflow/tensorflow/pull/44220#issuecomment-736101033

Reply all
Reply to author
Forward
0 new messages