aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/selective_registration.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-10-07 13:16:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-10-07 14:31:27 -0700
commitc37847c1e5aedf5f33151895bdcbf9de89bbd759 (patch)
tree065c17d838488f7276db436160552a47b689cc47 /tensorflow/core/framework/selective_registration.h
parentecdee38a534133ecd7ba18e58527cc4120277190 (diff)
Change selective registration to avoid use of strstr and strcmp that are not
constexpr for all compilers. Change the requirement for ops_to_register.h: it must now define the macros, not the specific functions or variables. This gives that header more control over the exact definition to use, making it easier to try different constexpr expressions. Change: 135516295
Diffstat (limited to 'tensorflow/core/framework/selective_registration.h')
-rw-r--r--tensorflow/core/framework/selective_registration.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/tensorflow/core/framework/selective_registration.h b/tensorflow/core/framework/selective_registration.h
index 751e2cde84..fae83282ed 100644
--- a/tensorflow/core/framework/selective_registration.h
+++ b/tensorflow/core/framework/selective_registration.h
@@ -35,20 +35,27 @@ limitations under the License.
// for a tool that can be used to generate ops_to_register.h.
#include "ops_to_register.h"
-// Op kernel classes for which ShouldRegisterOpKernel returns false will not be
-// registered.
-#define SHOULD_REGISTER_OP_KERNEL(clz) \
- (strstr(kNecessaryOpKernelClasses, "," clz ",") != nullptr)
-
-// Ops for which ShouldRegisterOp returns false will not be registered.
-#define SHOULD_REGISTER_OP(op) ShouldRegisterOp(op)
-
-// If kRequiresSymbolicGradients is false, then no gradient ops are registered.
-#define SHOULD_REGISTER_OP_GRADIENT kRequiresSymbolicGradients
+// ops_to_register should define macros for:
+//
+// SHOULD_REGISTER_OP_KERNEL(clz)
+// SHOULD_REGISTER_OP(op)
+// SHOULD_REGISTER_OP_GRADIENT
+// # same as SHOULD_REGISTER_OP, but invoked from a non-constexpr location.
+// SHOULD_REGISTER_OP_NON_CONSTEXPR(op)
+//
+// Except for SHOULD_REGISTER_OP_NON_CONSTEXPR, the macros should be defined
+// using constexprs. See selective_registration_util.h for some utilities that
+// can be used.
+#if (!defined(SHOULD_REGISTER_OP_KERNEL) || !defined(SHOULD_REGISTER_OP) || \
+ !defined(SHOULD_REGISTER_OP_GRADIENT) || \
+ !defined(SHOULD_REGISTER_OP_NON_CONSTEXPR))
+static_assert(false, "ops_to_register.h must define SHOULD_REGISTER macros");
+#endif
#else
-#define SHOULD_REGISTER_OP_KERNEL(filename) true
+#define SHOULD_REGISTER_OP_KERNEL(clz) true
#define SHOULD_REGISTER_OP(op) true
+#define SHOULD_REGISTER_OP_NON_CONSTEXPR(op) true
#define SHOULD_REGISTER_OP_GRADIENT true
#endif