tensorflow/core/graph/collective_order_test.cc
//
// Here ci denotes a collective node with `instance_key` i.  `a` and `b` are
// inputs, `id` is identity node.
Here ci denotes a collective node with `instance_key` i.
Here ci denotes a collective node with ` instance_key ` i .
std::unique_ptr<Graph> InitGraph() {
  GraphDefBuilder builder(GraphDefBuilder::kFailImmediately);
  const string dev0 = "/job:localhost/replica:0/task:0/device:CPU:0";
  const string dev1 = "/job:localhost/replica:0/task:0/device:CPU:1";
  Node* a = ops::SourceOp("TestParams",
                          builder.opts().WithName("a").WithDevice(dev0));
  Node* b = ops::SourceOp("TestParams",
                          builder.opts().WithName("b").WithDevice(dev1));
  Node* c1_0 = CollectiveReduceNode(&builder, a, "c1_0", dev0, 1);
  Node* c1_1 = CollectiveReduceNode(&builder, b, "c1_1", dev1, 1);
  Node* id0 = ops::UnaryOp(
      "Identity", c1_0,
      builder.opts().WithName("id0").WithDevice(dev0).WithAttr("T", DT_FLOAT));
  Node* id1 = ops::UnaryOp(
      "Identity", c1_1,
      builder.opts().WithName("id1").WithDevice(dev1).WithAttr("T", DT_FLOAT));
  CollectiveReduceNode(&builder, id0, "c2_0", dev0, 2);
  CollectiveReduceNode(&builder, id1, "c2_1", dev1, 2);
  CollectiveReduceNode(&builder, id0, "c3_0", dev0, 3);
  CollectiveReduceNode(&builder, id1, "c3_1", dev1, 3);
  std::unique_ptr<Graph> graph = absl::make_unique<Graph>(OpRegistry::Global());
  Status s = GraphDefBuilderToGraph(builder, graph.get());
  if (!s.ok()) {
    LOG(FATAL) << "Error building graph " << s;
  }
  return graph;
}
std :: unique_ptr < Graph > InitGraph ( ) { GraphDefBuilder builder ( GraphDefBuilder :: kFailImmediately ) ; const string dev0 = " " ; const string dev1 = " " ; Node * a = ops :: SourceOp ( " " , builder . opts ( ) . WithName ( " " ) . WithDevice ( dev0 ) ) ; Node * b = ops :: SourceOp ( " " , builder . opts ( ) . WithName ( " " ) . WithDevice ( dev1 ) ) ; Node * c1_0 = CollectiveReduceNode ( & builder , a , " " , dev0 , 1 ) ; Node * c1_1 = CollectiveReduceNode ( & builder , b , " " , dev1 , 1 ) ; Node * id0 = ops :: UnaryOp ( " " , c1_0 , builder . opts ( ) . WithName ( " " ) . WithDevice ( dev0 ) . WithAttr ( " " , DT_FLOAT ) ) ; Node * id1 = ops :: UnaryOp ( " " , c1_1 , builder . opts ( ) . WithName ( " " ) . WithDevice ( dev1 ) . WithAttr ( " " , DT_FLOAT ) ) ; CollectiveReduceNode ( & builder , id0 , " " , dev0 , 2 ) ; CollectiveReduceNode ( & builder , id1 , " " , dev1 , 2 ) ; CollectiveReduceNode ( & builder , id0 , " " , dev0 , 3 ) ; CollectiveReduceNode ( & builder , id1 , " " , dev1 , 3 ) ; std :: unique_ptr < Graph > graph = absl :: make_unique < Graph > ( OpRegistry :: Global ( ) ) ; Status s = GraphDefBuilderToGraph ( builder , graph . get ( ) ) ; if ( ! s . ok ( ) ) { LOG ( FATAL ) << " " << s ; } return graph ; }
Here ci denotes a collective node with `instance_key` i.
Here ci denotes a collective node with ` instance_key ` i .