tensorflow/compiler/tf2xla/rearrange_function_argument_pass.cc
// For While node, given mapping between original input index and rearranged
// input index, reorder output edges for the node. DT_RESOURCE outputs are
// removed from the node and we will use the node's corresponding input for the
// edge.
For While node, given mapping between original input index and rearranged
input index, reorder output edges for the node. DT_RESOURCE outputs are
removed from the node and we will use the node's corresponding input for the
edge.
For While node given mapping between original input index and rearranged input index reorder output edges for the node . DT_RESOURCE outputs are removed from the node and we will use the node ' s corresponding input for the edge .
Status ReorderOutputEdges(Graph* g, Node* n, int input_count,
                          int resource_input_count,
                          const std::vector<int>& index_mapping) {
  std::vector<const Edge*> output_edges;
  for (const Edge* e : n->out_edges()) {
    if (e->IsControlEdge()) {
      continue;
    }
    output_edges.push_back(e);
  }
  for (const Edge* e : output_edges) {
    int src_output = e->src_output();
    int new_src_output = index_mapping.at(src_output);
    Node* dst = e->dst();
    int dst_input = e->dst_input();
    g->RemoveEdge(e);
    if (new_src_output < input_count - resource_input_count) {
      g->AddEdge(n, new_src_output, dst, dst_input);
    } else {
      const Edge* input_edge;
      TF_RETURN_IF_ERROR(n->input_edge(new_src_output, &input_edge));
      g->AddEdge(input_edge->src(), input_edge->src_output(), dst, dst_input);
    }
  }
  return Status::OK();
}
Status ReorderOutputEdges ( Graph * g , Node * n , int input_count , int resource_input_count , const std :: vector < int > & index_mapping ) { std :: vector < const Edge * > output_edges ; for ( const Edge * e : n -> out_edges ( ) ) { if ( e -> IsControlEdge ( ) ) { continue ; } output_edges . push_back ( e ) ; } for ( const Edge * e : output_edges ) { int src_output = e -> src_output ( ) ; int new_src_output = index_mapping . at ( src_output ) ; Node * dst = e -> dst ( ) ; int dst_input = e -> dst_input ( ) ; g -> RemoveEdge ( e ) ; if ( new_src_output < input_count - resource_input_count ) { g -> AddEdge ( n , new_src_output , dst , dst_input ) ; } else { const Edge * input_edge ; TF_RETURN_IF_ERROR ( n -> input_edge ( new_src_output , & input_edge ) ) ; g -> AddEdge ( input_edge -> src ( ) , input_edge -> src_output ( ) , dst , dst_input ) ; } } return Status :: OK ( ) ; }
For While node, given mapping between original input index and rearranged
input index, reorder output edges for the node.
For While node given mapping between original input index and rearranged input index reorder output edges for the node .