MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / InitGraph2

Function InitGraph2

tensorflow/core/graph/collective_order_test.cc:166–185  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

164// Here ci denotes a collective node with `instance_key` i. `a` is an input,
165// `id` is identity node.
166std::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

Callers 1

TESTFunction · 0.85

Calls 9

SourceOpFunction · 0.85
CollectiveReduceNodeFunction · 0.85
GraphDefBuilderToGraphFunction · 0.85
WithAttrMethod · 0.80
UnaryOpFunction · 0.70
WithDeviceMethod · 0.45
WithNameMethod · 0.45
getMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected