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
| 158 | // algorithm to O(N) by using a state machine, e.g. regexps or a real |
| 159 | // text-templating mechanism. |
| 160 | string 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). |
| 168 | Status GenArgMethods(const tf2xla::Config& config, |
no outgoing calls
no test coverage detected