| 502 | // that are produced by to_keep. to_keep inherits all to_remove inputs. |
| 503 | template <typename TensorT> |
| 504 | Status RemoveFollowingNode(Graph<TensorT>* graph, const Node* to_remove, |
| 505 | const Node* to_keep) { |
| 506 | // Make sure all inputs to to_remove are produced by to_keep. |
| 507 | for (auto input : graph->FindInputs(to_remove->id)) { |
| 508 | Node* producer = graph->FindProducer(input->id); |
| 509 | if (producer->id != to_keep->id) { |
| 510 | return InvalidArgumentError("To_remove node has other inputs"); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | for (auto input : graph->FindInputs(to_remove->id)) { |
| 515 | RETURN_IF_ERROR(graph->DeleteValue(input->id)); |
| 516 | } |
| 517 | for (auto output : graph->FindOutputs(to_remove->id)) { |
| 518 | RETURN_IF_ERROR(graph->SetProducer(to_keep->id, output->id)); |
| 519 | } |
| 520 | return graph->DeleteNode(to_remove->id); |
| 521 | } |
| 522 | |
| 523 | // Removes to_remove node. |
| 524 | // Requires that node has one input and one output; |
no test coverage detected