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

Function BM_Helper

tensorflow/core/distributed_runtime/rpcbench_test.cc:169–214  ·  view source on GitHub ↗

TODO: Support sharding and depth.

Source from the content-addressed store, hash-verified

167
168// TODO: Support sharding and depth.
169static void BM_Helper(int iters, int width, int num_stages, int tensor_size,
170 bool use_multiple_devices) {
171 testing::StopTiming();
172 const Cluster* cluster = GetCluster();
173
174 // Creates a session.
175 std::unique_ptr<Session> session(NewSession(cluster->options));
176 GraphDef def = CreateGraphDef(num_stages, width, tensor_size,
177 use_multiple_devices, cluster);
178 graph::SetDefaultDevice(cluster->devices[0].name(), &def);
179
180 TF_CHECK_OK(session->Create(def));
181
182 // Randomly initialize the input.
183 Tensor x(DT_FLOAT, TensorShape({tensor_size, 1}));
184
185 testing::SetLabel(
186 strings::StrCat(def.node_size(), " nodes; ",
187 use_multiple_devices ? "Multi device" : "Single device",
188 "; tensor bytes/send: ", tensor_size * sizeof(float)));
189
190 std::vector<Tensor> outputs;
191
192 // Do a few warmup iterations.
193 for (int i = 0; i < 3; i++) {
194 outputs.clear();
195 TF_CHECK_OK(session->Run({{"x", x}}, {"y:0"}, {}, &outputs));
196 CHECK_EQ(size_t{1}, outputs.size());
197
198 if (i == 0) {
199 // Print out x, and y.
200 const Tensor& y = outputs[0];
201 VLOG(1) << DebugString(x, y, tensor_size);
202 }
203 }
204
205 // Iterations.
206 testing::StartTiming();
207 for (int i = 0; i < iters; i++) {
208 outputs.clear();
209 TF_CHECK_OK(session->Run({{"x", x}}, {"y:0"}, {}, &outputs));
210 CHECK_EQ(size_t{1}, outputs.size());
211 }
212 testing::StopTiming();
213 TF_CHECK_OK(session->Close());
214}
215static void BM_ShardedProgram(int iters, int width, int num_stages) {
216 BM_Helper(iters, width, num_stages, 2 /*tensor_size*/, true /*multi-device*/);
217}

Callers 3

BM_ShardedProgramFunction · 0.85
BM_RPCFunction · 0.85
BM_SingleDeviceFunction · 0.85

Calls 15

StopTimingFunction · 0.85
GetClusterFunction · 0.85
SetDefaultDeviceFunction · 0.85
SetLabelFunction · 0.85
StartTimingFunction · 0.85
CreateGraphDefFunction · 0.70
DebugStringFunction · 0.70
nameMethod · 0.65
NewSessionFunction · 0.50
TensorShapeClass · 0.50
StrCatFunction · 0.50
CreateMethod · 0.45

Tested by

no test coverage detected