tensorflow/compiler/aot/codegen.cc
// 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
// text-templating mechanism.
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.

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
text-templating mechanism.
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 . 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 text - templating mechanism .
string RewriteWithName(const string& name, string code,
                       const std::vector<std::pair<string, string>>& rewrites) {
  absl::StrReplaceAll(rewrites, &code);
  absl::StrReplaceAll({{"{{NAME}}", name}}, &code);
  return code;
}
string RewriteWithName ( const string & name , string code , const std :: vector < std :: pair < string , string > > & rewrites ) { absl :: StrReplaceAll ( rewrites , & code ) ; absl :: StrReplaceAll ( { { " " , name } } , & code ) ; return code ; }
Returns code rewritten by replacing all rewrite pairs, with an extra rewrite
for the name.
Returns code rewritten by replacing all rewrite pairs with an extra rewrite for the name .