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

Function RewriteWithName

tensorflow/compiler/aot/codegen.cc:160–165  ·  view source on GitHub ↗

Returns code rewritten by replacing all rewrite pairs, with an extra rewrite for the name. Note that the rewriting strategy is roughly O(N*M), where N is the size of the code and M is the number of rewrites. It's fine for now since N and M are pretty small. TODO(toddw): If this becomes a problem, we should be able to change the algorithm to O(N) by using a state machine, e.g. regexps or a real

Source from the content-addressed store, hash-verified

158// algorithm to O(N) by using a state machine, e.g. regexps or a real
159// text-templating mechanism.
160string RewriteWithName(const string& name, string code,
161 const std::vector<std::pair<string, string>>& rewrites) {
162 absl::StrReplaceAll(rewrites, &code);
163 absl::StrReplaceAll({{"{{NAME}}", name}}, &code);
164 return code;
165}
166
167// Generate methods for args (inputs).
168Status GenArgMethods(const tf2xla::Config& config,

Callers 3

GenArgMethodsFunction · 0.85
GenResultMethodsFunction · 0.85
GenVariableMethodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected