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

Function BM_SubgraphHelper

tensorflow/core/graph/subgraph_test.cc:345–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343REGISTER_OP("Op").Input("i: float").Output("o: float");
344
345static void BM_SubgraphHelper(int iters, int num_nodes,
346 bool use_function_convention) {
347 DeviceAttributes device_info;
348 device_info.set_name("/job:a/replica:0/task:0/cpu:0");
349 device_info.set_device_type(DeviceType(DEVICE_CPU).type());
350 device_info.set_incarnation(0);
351
352 testing::StopTiming();
353 Graph g(OpRegistry::Global());
354 { // Scope for temporary variables used to construct g.
355 GraphDefBuilder b(GraphDefBuilder::kFailImmediately);
356 Node* last_node = nullptr;
357 for (int i = 0; i < num_nodes; i++) {
358 string name = strings::StrCat("N", i);
359 if (i > 0) {
360 last_node = ops::UnaryOp("Op", last_node, b.opts().WithName(name));
361 } else {
362 last_node = ops::SourceOp("In", b.opts().WithName(name));
363 }
364 }
365 TF_CHECK_OK(GraphDefBuilderToGraph(b, &g));
366 }
367
368 std::vector<string> fed;
369 if (num_nodes > 1000) {
370 fed.push_back(strings::StrCat("N", num_nodes - 1000));
371 }
372 std::vector<string> fetch;
373 std::vector<string> targets = {strings::StrCat("N", num_nodes - 1)};
374 testing::StartTiming();
375 while (--iters > 0) {
376 Graph* subgraph = new Graph(OpRegistry::Global());
377 CopyGraph(g, subgraph);
378 subgraph::RewriteGraphMetadata metadata;
379 TF_CHECK_OK(subgraph::RewriteGraphForExecution(
380 subgraph, fed, fetch, targets, device_info, use_function_convention,
381 &metadata));
382 delete subgraph;
383 }
384}
385
386static void BM_Subgraph(int iters, int num_nodes) {
387 BM_SubgraphHelper(iters, num_nodes, false /* use_function_convention */);

Callers 2

BM_SubgraphFunction · 0.85

Calls 13

DeviceTypeClass · 0.85
StopTimingFunction · 0.85
SourceOpFunction · 0.85
GraphDefBuilderToGraphFunction · 0.85
StartTimingFunction · 0.85
RewriteGraphForExecutionFunction · 0.85
UnaryOpFunction · 0.70
CopyGraphFunction · 0.70
typeMethod · 0.65
StrCatFunction · 0.50
set_nameMethod · 0.45
WithNameMethod · 0.45

Tested by

no test coverage detected