MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / InferSourceFileName

Function InferSourceFileName

tensorflow/python/framework/python_op_gen_main.cc:91–106  ·  view source on GitHub ↗

Use the name of the current executable to infer the C++ source file where the REGISTER_OP() call for the operator can be found. Returns the name of the file. Returns an empty string if the current executable's name does not follow a known pattern.

Source from the content-addressed store, hash-verified

89// Returns an empty string if the current executable's name does not
90// follow a known pattern.
91string InferSourceFileName(const char* argv_zero) {
92 StringPiece command_str = io::Basename(argv_zero);
93
94 // For built-in ops, the Bazel build creates a separate executable
95 // with the name gen_<op type>_ops_py_wrappers_cc containing the
96 // operators defined in <op type>_ops.cc
97 const char* kExecPrefix = "gen_";
98 const char* kExecSuffix = "_py_wrappers_cc";
99 if (absl::ConsumePrefix(&command_str, kExecPrefix) &&
100 str_util::EndsWith(command_str, kExecSuffix)) {
101 command_str.remove_suffix(strlen(kExecSuffix));
102 return strings::StrCat(command_str, ".cc");
103 } else {
104 return string("");
105 }
106}
107
108void PrintAllPythonOps(const std::vector<string>& op_list,
109 const std::vector<string>& api_def_dirs,

Callers 1

mainFunction · 0.85

Calls 4

BasenameFunction · 0.85
EndsWithFunction · 0.85
ConsumePrefixFunction · 0.50
StrCatFunction · 0.50

Tested by

no test coverage detected