diff options
author | Nick Kreeger <kreeger@google.com> | 2018-08-17 14:26:35 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-17 14:31:18 -0700 |
commit | c4ccab7a95835ec12af16938ba0c17cc7c1f17e0 (patch) | |
tree | a1144890c0eaeda823fac1272a6326939ec97491 /tensorflow | |
parent | f67c02ce213e0420d91de61f896f1716a4943e7e (diff) |
Move FindInputArg() for ApiDef::Arg to op_def_util.cc and cleanup Python/c++ references.
This method is currently duplicated in Python code and will be used for TypeScript generation.
PiperOrigin-RevId: 209207139
Diffstat (limited to 'tensorflow')
-rw-r--r-- | tensorflow/cc/framework/cc_op_gen.cc | 9 | ||||
-rw-r--r-- | tensorflow/core/framework/op_def_util.cc | 9 | ||||
-rw-r--r-- | tensorflow/core/framework/op_def_util.h | 5 | ||||
-rw-r--r-- | tensorflow/python/framework/python_op_gen.cc | 9 | ||||
-rw-r--r-- | tensorflow/python/framework/python_op_gen_internal.cc | 9 |
5 files changed, 14 insertions, 27 deletions
diff --git a/tensorflow/cc/framework/cc_op_gen.cc b/tensorflow/cc/framework/cc_op_gen.cc index dfdef88945..c20ea95a15 100644 --- a/tensorflow/cc/framework/cc_op_gen.cc +++ b/tensorflow/cc/framework/cc_op_gen.cc @@ -508,15 +508,6 @@ bool HasOptionalAttrs( return false; } -const ApiDef::Arg* FindInputArg(StringPiece name, const ApiDef& api_def) { - for (int i = 0; i < api_def.in_arg_size(); ++i) { - if (api_def.in_arg(i).name() == name) { - return &api_def.in_arg(i); - } - } - return nullptr; -} - struct OpInfo { // graph_op_def: The OpDef used by the runtime, has the names that // must be used when calling NodeBuilder. diff --git a/tensorflow/core/framework/op_def_util.cc b/tensorflow/core/framework/op_def_util.cc index 9be0dc69d2..3597f43d51 100644 --- a/tensorflow/core/framework/op_def_util.cc +++ b/tensorflow/core/framework/op_def_util.cc @@ -172,6 +172,15 @@ const OpDef::ArgDef* FindInputArg(StringPiece name, const OpDef& op_def) { return nullptr; } +const ApiDef::Arg* FindInputArg(StringPiece name, const ApiDef& api_def) { + for (int i = 0; i < api_def.in_arg_size(); ++i) { + if (api_def.in_arg(i).name() == name) { + return &api_def.in_arg(i); + } + } + return nullptr; +} + #define VALIDATE(EXPR, ...) \ do { \ if (!(EXPR)) { \ diff --git a/tensorflow/core/framework/op_def_util.h b/tensorflow/core/framework/op_def_util.h index 0ba1325a03..4f67a258d3 100644 --- a/tensorflow/core/framework/op_def_util.h +++ b/tensorflow/core/framework/op_def_util.h @@ -20,6 +20,7 @@ limitations under the License. #define TENSORFLOW_FRAMEWORK_OP_DEF_UTIL_H_ #include <string> +#include "tensorflow/core/framework/api_def.pb.h" #include "tensorflow/core/framework/op_def.pb.h" #include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/platform/protobuf.h" @@ -47,6 +48,10 @@ OpDef::AttrDef* FindAttrMutable(StringPiece name, OpDef* op_def); // Returns nullptr if no such attr is found. const OpDef::ArgDef* FindInputArg(StringPiece name, const OpDef& op_def); +// Searches api_def for input argument with the indicated name. +// Returns nullptr if no such attr is found. +const ApiDef::Arg* FindInputArg(StringPiece name, const ApiDef& api_def); + // Produce a human-readable version of an op_def that is more concise // than a text-format proto. Excludes descriptions. string SummarizeOpDef(const OpDef& op_def); diff --git a/tensorflow/python/framework/python_op_gen.cc b/tensorflow/python/framework/python_op_gen.cc index 76d4c2017c..2022fbcbaa 100644 --- a/tensorflow/python/framework/python_op_gen.cc +++ b/tensorflow/python/framework/python_op_gen.cc @@ -102,15 +102,6 @@ string TensorPBString(const TensorProto& pb) { return strings::StrCat("\"\"\"", ProtoShortDebugString(pb), "\"\"\""); } -const ApiDef::Arg* FindInputArg(StringPiece name, const ApiDef& api_def) { - for (int i = 0; i < api_def.in_arg_size(); ++i) { - if (api_def.in_arg(i).name() == name) { - return &api_def.in_arg(i); - } - } - return nullptr; -} - class GenEagerPythonOp : public python_op_gen_internal::GenPythonOp { public: GenEagerPythonOp(const OpDef& op_def, const ApiDef& api_def, diff --git a/tensorflow/python/framework/python_op_gen_internal.cc b/tensorflow/python/framework/python_op_gen_internal.cc index 031b4a384e..f2270342b0 100644 --- a/tensorflow/python/framework/python_op_gen_internal.cc +++ b/tensorflow/python/framework/python_op_gen_internal.cc @@ -483,15 +483,6 @@ const ApiDef::Attr* FindAttr(StringPiece name, const ApiDef& api_def) { return nullptr; } -const ApiDef::Arg* FindInputArg(StringPiece name, const ApiDef& api_def) { - for (int i = 0; i < api_def.in_arg_size(); ++i) { - if (api_def.in_arg(i).name() == name) { - return &api_def.in_arg(i); - } - } - return nullptr; -} - GenPythonOp::GenPythonOp(const OpDef& op_def, const ApiDef& api_def, const string& function_name) : op_def_(op_def), |