aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/op_def_builder.cc
diff options
context:
space:
mode:
authorGravatar Geoffrey Irving <geoffreyi@google.com>2016-04-20 14:58:57 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-20 16:01:43 -0700
commit30334d28c0ac0c2d0369c4f7f31f5b7ffff06ddd (patch)
treec65bac9a10386302ae769895e5652e0c3a206560 /tensorflow/core/framework/op_def_builder.cc
parentc3af083a6411d7facfded6f6087f6524696efc0d (diff)
Add a .Deprecated method to REGISTER_OP
This replaces the OP_DEPRECATED macro with something declarative, which in particular lets us throw exceptions at graph construction time based on deprecation. I've left the OP_DEPRECATED macro around in case uses elsewhere can't be expressed in a purely declarative manner. Change: 120386133
Diffstat (limited to 'tensorflow/core/framework/op_def_builder.cc')
-rw-r--r--tensorflow/core/framework/op_def_builder.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/tensorflow/core/framework/op_def_builder.cc b/tensorflow/core/framework/op_def_builder.cc
index 5931b1ace1..2d02ed3a42 100644
--- a/tensorflow/core/framework/op_def_builder.cc
+++ b/tensorflow/core/framework/op_def_builder.cc
@@ -541,6 +541,18 @@ OpDefBuilder& OpDefBuilder::SetAllowsUninitializedInput() {
return *this;
}
+OpDefBuilder& OpDefBuilder::Deprecated(int version, StringPiece explanation) {
+ if (op_def_.has_deprecation()) {
+ errors_.push_back(
+ strings::StrCat("Deprecated called twice for Op ", op_def_.name()));
+ } else {
+ OpDeprecation* deprecation = op_def_.mutable_deprecation();
+ deprecation->set_version(version);
+ deprecation->set_explanation(explanation.ToString());
+ }
+ return *this;
+}
+
Status OpDefBuilder::Finalize(OpDef* op_def) const {
std::vector<string> errors = errors_;
*op_def = op_def_;