tensorflow/compiler/tf2xla/graph_compiler_util.cc
// CollectArgNodes collects _Arg nodes from the graph, and performs basic
// sanity-checking to ensure the index and type attributes of each node are
// initialized correctly.
CollectArgNodes collects _Arg nodes from the graph, and performs basic
sanity-checking to ensure the index and type attributes of each node are
initialized correctly.
CollectArgNodes collects _Arg nodes from the graph and performs basic sanity - checking to ensure the index and type attributes of each node are initialized correctly .
Status CollectArgNodes(const Graph& graph, std::vector<Node*>* arg_nodes) {
  std::map<int, Node*> indexed_arg_nodes;
  for (Node* n : graph.nodes()) {
    if (n->type_string() == FunctionLibraryDefinition::kArgOp) {
      int index;
      TF_RETURN_IF_ERROR(GetNodeAttr(n->attrs(), "index", &index));
      auto insert_result = indexed_arg_nodes.insert({index, n});
      if (!insert_result.second) {
        const Node* dup = insert_result.first->second;
        return errors::InvalidArgument(
            "Multiple ", FunctionLibraryDefinition::kArgOp,
            " nodes with index ", index, ", ", FormatNodeForError(*n), " and ",
            FormatNodeForError(*dup));
      }
    }
  }
  arg_nodes->clear();
  for (const auto& index_node : indexed_arg_nodes) {
    const int arg_nodes_size = arg_nodes->size();
    if (index_node.first != arg_nodes_size) {
      return errors::InvalidArgument(
          "Expected ", FunctionLibraryDefinition::kArgOp, " node with index ",
          arg_nodes->size(), ", but got index ", index_node.first);
    }
    arg_nodes->push_back(index_node.second);
  }
  return Status::OK();
}
Status CollectArgNodes ( const Graph & graph , std :: vector < Node * > * arg_nodes ) { std :: map < int , Node * > indexed_arg_nodes ; for ( Node * n : graph . nodes ( ) ) { if ( n -> type_string ( ) == FunctionLibraryDefinition :: kArgOp ) { int index ; TF_RETURN_IF_ERROR ( GetNodeAttr ( n -> attrs ( ) , " " , & index ) ) ; auto insert_result = indexed_arg_nodes . insert ( { index , n } ) ; if ( ! insert_result . second ) { const Node * dup = insert_result . first -> second ; return errors :: InvalidArgument ( " " , FunctionLibraryDefinition :: kArgOp , " " , index , " " , FormatNodeForError ( * n ) , " " , FormatNodeForError ( * dup ) ) ; } } } arg_nodes -> clear ( ) ; for ( const auto & index_node : indexed_arg_nodes ) { const int arg_nodes_size = arg_nodes -> size ( ) ; if ( index_node . first != arg_nodes_size ) { return errors :: InvalidArgument ( " " , FunctionLibraryDefinition :: kArgOp , " " , arg_nodes -> size ( ) , " " , index_node . first ) ; } arg_nodes -> push_back ( index_node . second ) ; } return Status :: OK ( ) ; }
CollectArgNodes collects _Arg nodes from the graph, and performs basic
sanity-checking to ensure the index and type attributes of each node are
initialized correctly.
CollectArgNodes collects _Arg nodes from the graph and performs basic sanity - checking to ensure the index and type attributes of each node are initialized correctly .