"ops/const_op.h",
"ops/standard_ops.h",
],
- override_file = "ops/op_gen_overrides.pbtxt",
pkg = "//tensorflow/core",
)
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:op_gen_lib",
- "//tensorflow/core:op_gen_overrides_proto_cc",
"//tensorflow/core:proto_text",
"//tensorflow/core:protos_all_cc",
],
"framework/cc_op_gen.h",
"framework/cc_op_gen_test.cc",
],
- data = [
- "//tensorflow/cc:ops/op_gen_overrides.pbtxt",
- ],
deps = [
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:op_gen_lib",
- "//tensorflow/core:op_gen_overrides_proto_cc",
"//tensorflow/core:proto_text",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
} // namespace
void WriteCCOps(const OpList& ops, const ApiDefMap& api_def_map,
- const string& dot_h_fname, const string& dot_cc_fname,
- const string& overrides_fnames) {
+ const string& dot_h_fname, const string& dot_cc_fname) {
Env* env = Env::Default();
- // Load the override map.
- OpGenOverrideMap override_map;
- if (!overrides_fnames.empty()) {
- TF_CHECK_OK(override_map.LoadFileList(env, overrides_fnames));
- }
-
// Write the initial boilerplate to the .h and .cc files.
std::unique_ptr<WritableFile> h = nullptr;
std::unique_ptr<WritableFile> cc = nullptr;
/// Result is written to files dot_h and dot_cc.
void WriteCCOps(const OpList& ops, const ApiDefMap& api_def_map,
- const string& dot_h_fname, const string& dot_cc_fname,
- const string& overrides_fnames);
+ const string& dot_h_fname, const string& dot_cc_fname);
} // namespace tensorflow
namespace {
void PrintAllCCOps(const std::string& dot_h, const std::string& dot_cc,
- const std::string& overrides_fnames, bool include_internal,
+ bool include_internal,
const std::vector<string>& api_def_dirs) {
OpList ops;
OpRegistry::Global()->Export(include_internal, &ops);
api_def_map.UpdateDocs();
- WriteCCOps(ops, api_def_map, dot_h, dot_cc, overrides_fnames);
+ WriteCCOps(ops, api_def_map, dot_h, dot_cc);
}
} // namespace
int main(int argc, char* argv[]) {
tensorflow::port::InitMain(argv[0], &argc, &argv);
- // TODO(annarev): Update this file to no longer take op_gen_overrides.pbtxt
- // as an argument.
- if (argc != 6) {
+ if (argc != 5) {
for (int i = 1; i < argc; ++i) {
fprintf(stderr, "Arg %d = %s\n", i, argv[i]);
}
fprintf(stderr,
- "Usage: %s out.h out.cc overrides1.pbtxt,2.pbtxt include_internal "
+ "Usage: %s out.h out.cc include_internal "
"api_def_dirs1,api_def_dir2 ...\n"
" include_internal: 1 means include internal ops\n",
argv[0]);
exit(1);
}
- bool include_internal = tensorflow::StringPiece("1") == argv[4];
+ bool include_internal = tensorflow::StringPiece("1") == argv[3];
std::vector<tensorflow::string> api_def_dirs = tensorflow::str_util::Split(
- argv[5], ",", tensorflow::str_util::SkipEmpty());
- tensorflow::PrintAllCCOps(argv[1], argv[2], argv[3], include_internal,
- api_def_dirs);
+ argv[4], ",", tensorflow::str_util::SkipEmpty());
+ tensorflow::PrintAllCCOps(argv[1], argv[2], include_internal, api_def_dirs);
return 0;
}
namespace tensorflow {
namespace {
-// TODO(annarev): Remove this op_gen_overrides.pbtxt reference.
-// It is needed only because WriteCCOps takes it as an argument.
-constexpr char kOverridesFnames[] =
- "tensorflow/cc/ops/op_gen_overrides.pbtxt";
constexpr char kBaseOpDef[] = R"(
op {
name: "Foo"
const auto internal_h_file_path = io::JoinPath(tmpdir, "test_internal.h");
const auto internal_cc_file_path = io::JoinPath(tmpdir, "test_internal.cc");
- WriteCCOps(ops, api_def_map, h_file_path, cc_file_path, kOverridesFnames);
+ WriteCCOps(ops, api_def_map, h_file_path, cc_file_path);
TF_ASSERT_OK(ReadFileToString(env, h_file_path, h_file_text));
TF_ASSERT_OK(
+++ /dev/null
-# array_ops
-op { name: "BroadcastArgs" rename_to: "BroadcastDynamicShape" }
-op { name: "BroadcastGradientArgs" hide: true }
-op { name: "ConcatOffset" skip: true } # Maybe should just be hidden?
-op { name: "Concat" skip: true }
-op { name: "ConcatV2" rename_to: "Concat" }
-op { name: "ExpandDims" input_rename: { from: "dim" to: "axis" } }
-op { name: "ListDiff" rename_to: "SetDiff1D" }
-op { name: "MirrorPadGrad" hide: true }
-op { name: "Reverse" skip: true }
-op { name: "ReverseV2" rename_to: "Reverse" }
-op { name: "Split" input_rename: { from: "split_dim" to: "axis" } }
-op { name: "SplitV" input_rename: { from: "split_dim" to: "axis" } }
-op { name: "Squeeze" attr_rename: { from: "squeeze_dims" to: "axis" } }
-op { name: "Pack" rename_to: "Stack" }
-op { name: "Unpack" rename_to: "Unstack" }
-op { name: "Select" rename_to: "Where3" input_rename: { from: "t" to: "x" } input_rename: { from: "e" to: "y" } }
-op { name: "Where" input_rename: { from: "input" to: "condition" } }
-
-
-# candidate_sampling_ops
-op { name: "ThreadUnsafeUnigramCandidateSampler", skip: true }
-
-# control_flow_ops
-# TODO(joshl): Hide Switch and Merge once we write and migrate users to
-# a Cond() API.
-#op { name: "Switch" hide: true }
-#op { name: "Merge" hide: true }
-op { name: "RefMerge" hide: true }
-op { name: "Exit" hide: true }
-op { name: "RefExit" hide: true }
-op { name: "Enter" hide: true }
-op { name: "RefEnter" hide: true }
-op { name: "RefIdentity" hide: true }
-
-# ctc_ops
-
-# data_flow_ops
-op { name: "FakeQueue" skip: true }
-op { name: "FIFOQueue" skip: true}
-op { name: "FIFOQueueV2" rename_to: "FIFOQueue" }
-op { name: "PaddingFIFOQueue" skip: true }
-op { name: "PaddingFIFOQueueV2" rename_to: "PaddingFIFOQueue" }
-op { name: "PriorityQueue" skip: true }
-op { name: "PriorityQueueV2" rename_to: "PriorityQueue" }
-op { name: "QueueClose" skip: true }
-op { name: "QueueCloseV2" rename_to: "QueueClose" }
-op { name: "QueueDequeue" skip: true }
-op { name: "QueueDequeueV2" rename_to: "QueueDequeue" }
-op { name: "QueueDequeueMany" skip: true }
-op { name: "QueueDequeueManyV2" rename_to: "QueueDequeueMany" }
-op { name: "QueueDequeueUpTo" skip: true }
-op { name: "QueueDequeueUpToV2" rename_to: "QueueDequeueUpTo" }
-op { name: "QueueEnqueue" skip: true }
-op { name: "QueueEnqueueV2" rename_to: "QueueEnqueue" }
-op { name: "QueueEnqueueMany" skip: true }
-op { name: "QueueEnqueueManyV2" rename_to: "QueueEnqueueMany" }
-op { name: "QueueSize" skip: true }
-op { name: "QueueSizeV2" rename_to: "QueueSize" }
-op { name: "RandomShuffleQueue" skip: true }
-op { name: "RandomShuffleQueueV2" rename_to: "RandomShuffleQueue" }
-op { name: "ReaderNumRecordsProduced" skip: true }
-op { name: "ReaderNumRecordsProducedV2" rename_to: "ReaderNumRecordsProduced" }
-op { name: "ReaderNumWorkUnitsCompleted" skip: true }
-op { name: "ReaderNumWorkUnitsCompletedV2" rename_to: "ReaderNumWorkUnitsCompleted" }
-op { name: "ReaderRead" skip: true }
-op { name: "ReaderReadUpTo" skip: true }
-op { name: "ReaderReadUpToV2" rename_to: "ReaderReadUpTo" }
-op { name: "ReaderReadV2" rename_to: "ReaderRead" }
-op { name: "ReaderReset" skip: true }
-op { name: "ReaderResetV2" rename_to: "ReaderReset" }
-op { name: "ReaderRestoreState" skip: true }
-op { name: "ReaderRestoreStateV2" rename_to: "ReaderRestoreState" }
-op { name: "ReaderSerializeState" skip: true }
-op { name: "ReaderSerializeStateV2" rename_to: "ReaderSerializeState" }
-op { name: "FixedLengthRecordReader" skip: true }
-op { name: "FixedLengthRecordReaderV2" rename_to: "FixedLengthRecordReader" }
-op { name: "IdentityReader" skip: true }
-op { name: "IdentityReaderV2" rename_to: "IdentityReader" }
-op { name: "TFRecordReader" skip: true }
-op { name: "TFRecordReaderV2" rename_to: "TFRecordReader" }
-op { name: "TextLineReader" skip: true }
-op { name: "TextLineReaderV2" rename_to: "TextLineReader" }
-
-# Skip hash table ops until we have better support in C++ (ops are currently
-# only used in contrib)
-op { name: "HashTable" skip: true }
-op { name: "InitializeTable" skip: true }
-op { name: "InitializeTableFromTextFile" skip: true }
-op { name: "LookupTableFind" skip: true }
-op { name: "LookupTableImport" skip: true }
-op { name: "LookupTableInsert" skip: true }
-op { name: "LookupTableSize" skip: true }
-op { name: "MutableDenseHashTable" skip: true }
-op { name: "MutableHashTable" skip: true }
-op { name: "MutableHashTableOfTensors" skip: true }
-
-# Stack ops are internal to control flow gradients (not yet implemented in C++)
-op { name: "Stack" skip: true }
-op { name: "StackClose" skip: true }
-op { name: "StackPop" skip: true }
-op { name: "StackPush" skip: true }
-op { name: "StackV2" skip: true }
-op { name: "StackCloseV2" skip: true }
-op { name: "StackPopV2" skip: true }
-op { name: "StackPushV2" skip: true }
-
-op { name: "TensorArrayCloseV2" skip: true }
-op { name: "TensorArrayCloseV3" rename_to: "TensorArrayClose" }
-op { name: "TensorArrayConcatV2" skip: true }
-op { name: "TensorArrayConcatV3" rename_to: "TensorArrayConcat" }
-op { name: "TensorArrayGatherV2" skip: true }
-op { name: "TensorArrayGatherV3" rename_to: "TensorArrayGather" }
-op { name: "TensorArrayGradV2" skip: true }
-op { name: "TensorArrayGradV3" rename_to: "TensorArrayGrad" }
-op { name: "TensorArrayReadV2" skip: true }
-op { name: "TensorArrayReadV3" rename_to: "TensorArrayRead" }
-op { name: "TensorArrayScatterV2" skip: true }
-op { name: "TensorArrayScatterV3" rename_to: "TensorArrayScatter" }
-op { name: "TensorArraySizeV2" skip: true }
-op { name: "TensorArraySizeV3" rename_to: "TensorArraySize" }
-op { name: "TensorArraySplitV2" skip: true }
-op { name: "TensorArraySplitV3" rename_to: "TensorArraySplit" }
-op { name: "TensorArrayV2" skip: true }
-op { name: "TensorArrayV3" rename_to: "TensorArray" }
-op { name: "TensorArrayWriteV2" skip: true }
-op { name: "TensorArrayWriteV3" rename_to: "TensorArrayWrite" }
-
-op { name: "WholeFileReader" skip: true }
-op { name: "WholeFileReaderV2" rename_to: "WholeFileReader" }
-
-# functional_ops
-
-# image_ops
-op { name: "AdjustContrastv2" rename_to: "AdjustContrast" }
-op { name: "ResizeBilinearGrad" hide: true }
-op { name: "ResizeBicubicGrad" hide: true }
-op { name: "ResizeNearestNeighborGrad" hide: true }
-
-# io_ops
-
-# linalg_ops
-op { name: "SelfAdjointEigV2" rename_to: "SelfAdjointEig" }
-
-# logging_ops
-op { name: "AudioSummaryV2" rename_to: "AudioSummary" }
-
-# lookup_ops
-op { name: "LookupTableFind" skip: true }
-op { name: "LookupTableFindV2" rename_to: "LookupTableFind" }
-op { name: "LookupTableInsert" skip: true }
-op { name: "LookupTableInsertV2" rename_to: "LookupTableInsert" }
-op { name: "LookupTableSize" skip: true }
-op { name: "LookupTableSizeV2" rename_to: "LookupTableSize" }
-op { name: "LookupTableExport" skip: true }
-op { name: "LookupTableExportV2" rename_to: "LookupTableExport" }
-op { name: "LookupTableImport" skip: true }
-op { name: "LookupTableImportV2" rename_to: "LookupTableImport" }
-op { name: "HashTable" skip: true }
-op { name: "HashTableV2" rename_to: "HashTable" }
-op { name: "MutableHashTable" skip: true }
-op { name: "MutableHashTableV2" rename_to: "MutableHashTable" }
-op { name: "MutableHashTableOfTensors" skip: true }
-op { name: "MutableHashTableOfTensorsV2" rename_to: "MutableHashTableOfTensors" }
-op { name: "MutableDenseHashTable" skip: true }
-op { name: "MutableDenseHashTableV2" rename_to: "MutableDenseHashTable" }
-op { name: "InitializeTable" skip: true }
-op { name: "InitializeTableV2" rename_to: "InitializeTable" }
-op { name: "InitializeTableFromTextFile" skip: true }
-op { name: "InitializeTableFromTextFileV2" rename_to: "InitializeTableFromTextFile" }
-
-# math_ops
-op { name: "All" alias: "ReduceAll" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Any" alias: "ReduceAny" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Max" alias: "ReduceMax" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Mean" alias: "ReduceMean" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Min" alias: "ReduceMin" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Mul" rename_to: "Multiply" alias: "Mul" }
-op { name: "Neg" rename_to: "Negate" alias: "Neg" }
-op { name: "Prod" alias: "ReduceProd" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "Sub" rename_to: "Subtract" alias: "Sub" }
-op { name: "Sum" alias: "ReduceSum" input_rename: { from: "reduction_indices" to: "axis" } }
-op { name: "SigmoidGrad" hide: true }
-op { name: "TanhGrad" hide: true }
-op { name: "InvGrad" hide: true }
-op { name: "ReciprocalGrad" hide: true }
-op { name: "SqrtGrad" hide: true }
-op { name: "RsqrtGrad" hide: true }
-
-# *Grad ops get hidden, only for use by the gradient code.
-op { name: "SigmoidGrad" hide: true }
-op { name: "TanhGrad" hide: true }
-op { name: "InvGrad" hide: true }
-op { name: "ReciprocalGrad" hide: true }
-op { name: "SqrtGrad" hide: true }
-op { name: "RsqrtGrad" hide: true }
-
-# nn_ops
-op { name: "AvgPoolGrad" hide: true }
-op { name: "LRNGrad" hide: true }
-op { name: "MaxPoolGrad" hide: true }
-op { name: "MaxPoolGradWithArgmax" hide: true }
-op { name: "ReluGrad" hide: true }
-op { name: "Relu6Grad" hide: true }
-op { name: "EluGrad" hide: true }
-op { name: "SeluGrad" hide: true }
-op { name: "SoftplusGrad" hide: true }
-op { name: "SoftsignGrad" hide: true }
-op { name: "FractionalAvgPoolGrad" hide: true }
-op { name: "FractionalMaxPoolGrad" hide: true }
-op { name: "TopKV2" rename_to: "TopK" }
-op { name: "BiasAddV1" skip: true } # Use BiasAdd instead
-
-# parsing_ops
-
-# random_ops
-
-op { name: "RandomStandardNormal" rename_to: "RandomNormal" }
-# script_ops
-# Calling Python functions from a C++ program isn't supported
-op { name: "PyFunc" skip: true }
-op { name: "PyFuncStateless" skip: true}
-
-# sdca_ops
-
-# state_ops
-
-op { name: "Variable" skip: true }
-op { name: "VariableV2" rename_to: "Variable" }
-
-# sparse_ops
-
-# string_ops
-
-# user_ops
-
-# training_ops
-
${cc_ops_target_dir}/${tf_cc_op_lib_name}.cc
${cc_ops_target_dir}/${tf_cc_op_lib_name}_internal.h
${cc_ops_target_dir}/${tf_cc_op_lib_name}_internal.cc
- COMMAND ${tf_cc_op_lib_name}_gen_cc ${cc_ops_target_dir}/${tf_cc_op_lib_name}.h ${cc_ops_target_dir}/${tf_cc_op_lib_name}.cc ${tensorflow_source_dir}/tensorflow/cc/ops/op_gen_overrides.pbtxt ${cc_ops_include_internal} ${tensorflow_source_dir}/tensorflow/core/api_def/base_api
+ COMMAND ${tf_cc_op_lib_name}_gen_cc ${cc_ops_target_dir}/${tf_cc_op_lib_name}.h ${cc_ops_target_dir}/${tf_cc_op_lib_name}.cc ${cc_ops_include_internal} ${tensorflow_source_dir}/tensorflow/core/api_def/base_api
DEPENDS ${tf_cc_op_lib_name}_gen_cc create_cc_ops_header_dir
)
],
)
-tf_proto_library_cc(
- name = "op_gen_overrides_proto",
- srcs = ["framework/op_gen_overrides.proto"],
- cc_api_version = 2,
- protodeps = tf_additional_all_protos(),
- visibility = ["//visibility:public"],
-)
-
cc_library(
name = "op_gen_lib",
srcs = ["framework/op_gen_lib.cc"],
deps = [
":lib",
":lib_internal",
- ":op_gen_overrides_proto_cc",
":protos_all_cc",
],
)
srcs = ["api_def/api_test.cc"],
data = [
":base_api_def",
- "//tensorflow/cc:ops/op_gen_overrides.pbtxt",
],
deps = [
":framework",
":lib_internal",
":lib_test_internal",
":op_gen_lib",
- ":op_gen_overrides_proto_cc",
":ops",
":protos_all_cc",
":test",
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_def.pb.h"
#include "tensorflow/core/framework/op_gen_lib.h"
-#include "tensorflow/core/framework/op_gen_overrides.pb.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/io/path.h"
#include <vector>
#include "tensorflow/core/framework/attr_value.pb.h"
-#include "tensorflow/core/framework/op_gen_overrides.pb.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/map_util.h"
#include "tensorflow/core/lib/strings/str_util.h"
return pbtxt;
}
-OpGenOverrideMap::OpGenOverrideMap() {}
-OpGenOverrideMap::~OpGenOverrideMap() {}
-
-Status OpGenOverrideMap::LoadFileList(Env* env, const string& filenames) {
- std::vector<string> v = str_util::Split(filenames, ",");
- for (const string& f : v) {
- TF_RETURN_IF_ERROR(LoadFile(env, f));
- }
- return Status::OK();
-}
-
-Status OpGenOverrideMap::LoadFile(Env* env, const string& filename) {
- if (filename.empty()) return Status::OK();
- string contents;
- TF_RETURN_IF_ERROR(ReadFileToString(env, filename, &contents));
- OpGenOverrides all;
- protobuf::TextFormat::ParseFromString(contents, &all);
- for (const auto& one : all.op()) {
- map_[one.name()].reset(new OpGenOverride(one));
- }
- return Status::OK();
-}
-
static void StringReplace(const string& from, const string& to, string* s) {
// Split *s into pieces delimited by `from`.
std::vector<string> split;
}
}
-const OpGenOverride* OpGenOverrideMap::ApplyOverride(OpDef* op_def) const {
- // Look up
- const auto iter = map_.find(op_def->name());
- if (iter == map_.end()) return nullptr;
- const OpGenOverride& proto = *iter->second;
-
- // Apply overrides from `proto`.
- if (!proto.rename_to().empty()) {
- op_def->set_name(proto.rename_to());
- RenameInDocs(proto.name(), proto.rename_to(), op_def);
- }
- for (const auto& attr_default : proto.attr_default()) {
- bool found = false;
- for (int i = 0; i < op_def->attr_size(); ++i) {
- if (op_def->attr(i).name() == attr_default.name()) {
- *op_def->mutable_attr(i)->mutable_default_value() =
- attr_default.value();
- found = true;
- break;
- }
- }
- if (!found) {
- LOG(WARNING) << proto.name() << " can't find attr " << attr_default.name()
- << " to override default";
- }
- }
- for (const auto& attr_rename : proto.attr_rename()) {
- bool found = false;
- for (int i = 0; i < op_def->attr_size(); ++i) {
- if (op_def->attr(i).name() == attr_rename.from()) {
- *op_def->mutable_attr(i)->mutable_name() = attr_rename.to();
- found = true;
- break;
- }
- }
- if (found) {
- RenameInDocs(attr_rename.from(), attr_rename.to(), op_def);
- } else {
- LOG(WARNING) << proto.name() << " can't find attr " << attr_rename.from()
- << " to rename";
- }
- }
- for (const auto& input_rename : proto.input_rename()) {
- bool found = false;
- for (int i = 0; i < op_def->input_arg_size(); ++i) {
- if (op_def->input_arg(i).name() == input_rename.from()) {
- *op_def->mutable_input_arg(i)->mutable_name() = input_rename.to();
- found = true;
- break;
- }
- }
- if (found) {
- RenameInDocs(input_rename.from(), input_rename.to(), op_def);
- } else {
- LOG(WARNING) << proto.name() << " can't find input "
- << input_rename.from() << " to rename";
- }
- }
- for (const auto& output_rename : proto.output_rename()) {
- bool found = false;
- for (int i = 0; i < op_def->output_arg_size(); ++i) {
- if (op_def->output_arg(i).name() == output_rename.from()) {
- *op_def->mutable_output_arg(i)->mutable_name() = output_rename.to();
- found = true;
- break;
- }
- }
- if (found) {
- RenameInDocs(output_rename.from(), output_rename.to(), op_def);
- } else {
- LOG(WARNING) << proto.name() << " can't find output "
- << output_rename.from() << " to rename";
- }
- }
-
- return &proto;
-}
namespace {
// Forward declare protos so their symbols can be removed from .so exports
class OpDef;
-class OpGenOverride;
inline string Spaces(int n) { return string(n, ' '); }
const std::vector<string>& multi_line_fields);
string PBTxtFromMultiline(StringPiece multiline_pbtxt);
-// Takes a list of files with OpGenOverrides text protos, and allows you to
-// look up the specific override for any given op.
-class OpGenOverrideMap {
- public:
- OpGenOverrideMap();
- ~OpGenOverrideMap();
-
- // `filenames` is a comma-separated list of file names. If an op
- // is mentioned in more than one file, the last one takes priority.
- Status LoadFileList(Env* env, const string& filenames);
-
- // Load a single file. If more than one file is loaded, later ones
- // take priority for any ops in common.
- Status LoadFile(Env* env, const string& filename);
-
- // Look up the override for `*op_def` from the loaded files, and
- // mutate `*op_def` to reflect the requested changes. Does not apply
- // 'skip', 'hide', or 'alias' overrides. Caller has to deal with
- // those since they can't be simulated by mutating `*op_def`.
- // Returns nullptr if op is not in any loaded file. Otherwise, the
- // pointer must not be referenced beyond the lifetime of *this or
- // the next file load.
- const OpGenOverride* ApplyOverride(OpDef* op_def) const;
-
- private:
- std::unordered_map<string, std::unique_ptr<OpGenOverride>> map_;
-};
// Takes a list of files with ApiDefs text protos, and allows you to
// look up the specific ApiDef for any given op.
+++ /dev/null
-// Defines the text format for adding per-op overrides for client
-// language op code generators.
-
-syntax = "proto3";
-
-package tensorflow;
-import "tensorflow/core/framework/attr_value.proto";
-
-// Used to override the default API & behavior in the generated code
-// for client languages, from what you would get from the OpDef alone.
-// This is so we can evolve the API while remaining backwards
-// compatible when interpretting old graphs. Overrides go in an
-// "op_gen_overrides.pbtxt" file with a text-format OpGenOverrides
-// message. Right now these only apply to the C++ API.
-// TODO(josh11b): In the future there will be a common set of overrides
-// and per-client-language overrides.
-//
-// WARNING: Be *very* careful using these features -- these overrides
-// can change the semantics of existing code. These changes may need
-// to wait until a major release of TensorFlow to avoid breaking our
-// compatibility promises.
-message OpGenOverride {
- // Name of the op to apply overrides to.
- string name = 1;
-
- // Do not include this op in the generated API.
- // If `skip` is true, all other overrides are ignored for this op.
- bool skip = 2;
-
- // Hide this op by putting it into an internal namespace (or whatever
- // is appropriate in the target language).
- bool hide = 3;
-
- // Use a different name in the API than the op's name. Note that
- // the op's name in `backticks` will also be replaced in the docs.
- string rename_to = 4;
-
- // Create *additional* API endpoints with different names (contrast
- // with rename_to, which affects the original name).
- repeated string alias = 5;
-
- // Map the name of an attr to a new default value to use. This
- // default will be used when creating new graphs, as opposed to the
- // default in the OpDef, which will be used when interpreting old
- // GraphDefs. If this attr is also renamed (using attr_rename
- // below), use the original name of the attr.
- message AttrDefault {
- string name = 1;
- AttrValue value = 2;
- }
- repeated AttrDefault attr_default = 6;
-
- // Change the name used to access attrs/inputs/outputs in the API
- // from what is used in the GraphDef. Note that these names in
- // `backticks` will also be replaced in the docs.
- message Rename {
- string from = 1;
- string to = 2;
- }
- repeated Rename attr_rename = 7;
- repeated Rename input_rename = 8;
- repeated Rename output_rename = 9;
-}
-
-message OpGenOverrides {
- repeated OpGenOverride op = 1;
-}
pkg="",
op_gen=clean_dep("//tensorflow/cc:cc_op_gen_main"),
deps=None,
- override_file=None,
include_internal_ops=0,
# ApiDefs will be loaded in the order specified in this list.
api_def_srcs=[]):
srcs = api_def_srcs[:]
- if override_file == None:
- override_arg = ","
- else:
- srcs += [override_file]
- override_arg = "$(location " + override_file + ")"
-
if not api_def_srcs:
api_def_args_str = ","
else:
srcs=srcs,
tools=[":" + tool] + tf_binary_additional_srcs(),
cmd=("$(location :" + tool + ") $(location :" + out_ops_file + ".h) " +
- "$(location :" + out_ops_file + ".cc) " + override_arg + " " +
+ "$(location :" + out_ops_file + ".cc) " +
str(include_internal_ops) + " " + api_def_args_str))
# Given a list of "op_lib_names" (a list of files in the ops directory
clean_dep("//tensorflow/cc:const_op"),
],
op_gen=clean_dep("//tensorflow/cc:cc_op_gen_main"),
- override_file=None,
include_internal_ops=0,
visibility=None,
# ApiDefs will be loaded in the order apecified in this list.
"ops/" + n,
pkg=pkg,
op_gen=op_gen,
- override_file=override_file,
include_internal_ops=include_internal_ops,
api_def_srcs=api_def_srcs)
subsrcs += ["ops/" + n + ".cc"]