Initialize the following graph: a | c1 / \ // c4 id / \ // c2 c3 Here ci denotes a collective node with `instance_key` i. `a` is an input, `id` is identity node.
| 164 | // Here ci denotes a collective node with `instance_key` i. `a` is an input, |
| 165 | // `id` is identity node. |
| 166 | std::unique_ptr<Graph> InitGraph2() { |
| 167 | GraphDefBuilder builder(GraphDefBuilder::kFailImmediately); |
| 168 | const string dev0 = "/job:localhost/replica:0/task:0/device:CPU:0"; |
| 169 | Node* a = ops::SourceOp("TestParams", |
| 170 | builder.opts().WithName("a").WithDevice(dev0)); |
| 171 | Node* c1 = CollectiveReduceNode(&builder, a, "c1", dev0, 1); |
| 172 | CollectiveReduceNode(&builder, c1, "c4", dev0, 4); |
| 173 | Node* id = ops::UnaryOp( |
| 174 | "Identity", c1, |
| 175 | builder.opts().WithName("id").WithDevice(dev0).WithAttr("T", DT_FLOAT)); |
| 176 | CollectiveReduceNode(&builder, id, "c2", dev0, 2); |
| 177 | CollectiveReduceNode(&builder, id, "c3", dev0, 3); |
| 178 | |
| 179 | std::unique_ptr<Graph> graph = absl::make_unique<Graph>(OpRegistry::Global()); |
| 180 | Status s = GraphDefBuilderToGraph(builder, graph.get()); |
| 181 | if (!s.ok()) { |
| 182 | LOG(FATAL) << "Error building graph " << s; |
| 183 | } |
| 184 | return graph; |
| 185 | } |
| 186 | |
| 187 | // Tests that in the graph created by `InitGraph2`, we add the following control |
| 188 | // edges after calling `OrderCollectives`: c4 -> c3, c3 -> c2. c4->c2 is |
no test coverage detected