| 847 | } |
| 848 | |
| 849 | Status Conditional::AddOutputEdges( |
| 850 | Graph* graph, |
| 851 | std::unordered_map<Node*, OutputTensor>* merge_to_replacement) { |
| 852 | VLOG(2) << "AddOutputEdges for " << if_node_->name(); |
| 853 | int i = 0; |
| 854 | for (Node* node : merges_) { |
| 855 | TF_RETURN_IF_ERROR(parent_->AddIdentityNode(node, if_node_, i)); |
| 856 | std::vector<const Edge*> edges(node->out_edges().begin(), |
| 857 | node->out_edges().end()); |
| 858 | for (const Edge* edge : edges) { |
| 859 | Node* dst = edge->dst(); |
| 860 | int dst_input = edge->dst_input(); |
| 861 | if (edge->src_output() > 0) { |
| 862 | return errors::Unimplemented("Output of index (", edge->src_output(), |
| 863 | ") of merge node ", |
| 864 | FormatNodeForError(*node)); |
| 865 | } |
| 866 | |
| 867 | bool control_edge = edge->IsControlEdge(); |
| 868 | graph->RemoveEdge(edge); |
| 869 | if (control_edge) { |
| 870 | graph->AddControlEdge(if_node_, dst); |
| 871 | } else { |
| 872 | graph->AddEdge(if_node_, i, dst, dst_input); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | // Record corresponding output tensor in 'merge_to_replacement'. |
| 877 | (*merge_to_replacement)[node] = OutputTensor{if_node_, i}; |
| 878 | |
| 879 | ++i; |
| 880 | } |
| 881 | for (Node* n : external_control_outputs_) { |
| 882 | graph->AddControlEdge(if_node_, n); |
| 883 | } |
| 884 | |
| 885 | return Status::OK(); |
| 886 | } |
| 887 | |
| 888 | Status Conditional::BuildAndReplace( |
| 889 | Graph* graph, FunctionLibraryDefinition* library, |
nothing calls this directly
no test coverage detected