| 59 | } |
| 60 | |
| 61 | void RemoveFakeSinks(FunctionDef* function_def) { |
| 62 | // Map from identity node names to their input tensor strings |
| 63 | std::map<string, string> identity_map; |
| 64 | for (const auto& node : function_def->node_def()) { |
| 65 | if (node.op() == "Identity" && node.input_size() == 1) { |
| 66 | identity_map[node.name()] = node.input(0); |
| 67 | } |
| 68 | } |
| 69 | for (const auto& output_arg : function_def->signature().output_arg()) { |
| 70 | const string& tensor = function_def->ret().at(output_arg.name()); |
| 71 | const string& output_node = tensor.substr(0, tensor.find(':')); |
| 72 | if (identity_map.find(output_node) != identity_map.end()) { |
| 73 | (*function_def->mutable_ret())[output_arg.name()] = |
| 74 | identity_map.at(output_node); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | Status ApplyRewrites(OpKernelContext* ctx, |
| 80 | const std::function<RewriterConfig(void)> config_factory, |
no test coverage detected