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

Function CreateGraphDef

tensorflow/core/distributed_runtime/rpcbench_test.cc:124–155  ·  view source on GitHub ↗

Make a program with specified number of stages and "width" ops per stage.

Source from the content-addressed store, hash-verified

122
123// Make a program with specified number of stages and "width" ops per stage.
124GraphDef CreateGraphDef(int num_stages, int width, int tensor_size,
125 bool use_multiple_devices, const Cluster* cluster) {
126 CHECK_GE(cluster->devices.size(), width);
127
128 using namespace ::tensorflow::ops; // NOLINT(build/namespaces)
129
130 Scope s = Scope::NewRootScope();
131
132 // x is from the feed.
133 Output x = Const(s.WithOpName("x"), 0.0f, {tensor_size, 1});
134
135 // Create stages.
136 std::vector<Output> last_stage;
137 last_stage.push_back(x);
138 for (int i = 0; i < num_stages; i++) {
139 std::vector<Output> this_stage;
140 for (int j = 0; j < width; j++) {
141 Output combine = AddN(
142 s.WithDevice(cluster->devices[use_multiple_devices ? j : 0].name()),
143 last_stage);
144 this_stage.push_back(combine);
145 }
146 last_stage = this_stage;
147 }
148
149 // Create output.
150 /* Output y =*/AddN(s.WithOpName("y"), last_stage);
151
152 GraphDef def;
153 TF_CHECK_OK(s.ToGraphDef(&def));
154 return def;
155}
156
157string DebugString(const Tensor& x, const Tensor& y, int tensor_size) {
158 CHECK_EQ(x.NumElements(), tensor_size);

Callers 1

BM_HelperFunction · 0.70

Calls 8

WithOpNameMethod · 0.80
nameMethod · 0.65
ConstFunction · 0.50
AddNFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
WithDeviceMethod · 0.45
ToGraphDefMethod · 0.45

Tested by

no test coverage detected