aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/tools/selective_registration_header_lib.py
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-05-23 14:48:39 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-23 14:52:33 -0700
commitf333979e0d8625bca09c96478503c896fda24f25 (patch)
tree4bf78f69a363a7428e1c704e8a791f622494ac2c /tensorflow/python/tools/selective_registration_header_lib.py
parent630005aa52786529027ec34d4e4f002fb00a3ed9 (diff)
Change the header generated for selective registration to use the isequals
defined in the header, instead of strcmp. strcmp is not a constexpr on all platforms. PiperOrigin-RevId: 156914421
Diffstat (limited to 'tensorflow/python/tools/selective_registration_header_lib.py')
-rw-r--r--tensorflow/python/tools/selective_registration_header_lib.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/tensorflow/python/tools/selective_registration_header_lib.py b/tensorflow/python/tools/selective_registration_header_lib.py
index 7be61ca379..7f7470994d 100644
--- a/tensorflow/python/tools/selective_registration_header_lib.py
+++ b/tensorflow/python/tools/selective_registration_header_lib.py
@@ -100,15 +100,6 @@ def get_header_from_ops_and_kernels(ops_and_kernels,
append('#define SHOULD_REGISTER_OP_KERNEL(clz) true')
append('#define SHOULD_REGISTER_OP_GRADIENT true')
else:
- append('constexpr inline bool ShouldRegisterOp(const char op[]) {')
- append(' return false')
- for op in sorted(ops):
- append(' || (strcmp(op, "%s") == 0)' % op)
- append(' ;')
- append('}')
- append('#define SHOULD_REGISTER_OP(op) ShouldRegisterOp(op)')
- append('')
-
line = '''
namespace {
constexpr const char* skip(const char* x) {
@@ -147,6 +138,15 @@ def get_header_from_ops_and_kernels(ops_and_kernels,
'kNecessaryOpKernelClasses))')
append('')
+ append('constexpr inline bool ShouldRegisterOp(const char op[]) {')
+ append(' return false')
+ for op in sorted(ops):
+ append(' || isequal(op, "%s")' % op)
+ append(' ;')
+ append('}')
+ append('#define SHOULD_REGISTER_OP(op) ShouldRegisterOp(op)')
+ append('')
+
append('#define SHOULD_REGISTER_OP_GRADIENT ' + (
'true' if 'SymbolicGradient' in ops else 'false'))