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

Function BM_CSE

tensorflow/core/graph/optimizer_cse_test.cc:349–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349static void BM_CSE(int iters, int op_nodes) {
350 testing::StopTiming();
351 string s;
352 for (int in = 0; in < 10; in++) {
353 s += strings::Printf("node { name: 'in%04d' op: 'Input'}", in);
354 }
355 random::PhiloxRandom philox(301, 17);
356 random::SimplePhilox rnd(&philox);
357 for (int op = 0; op < op_nodes; op++) {
358 s += strings::Printf(
359 "node { name: 'op%04d' op: 'Mul' attr { key: 'T' value { "
360 "type: DT_FLOAT } } input: ['in%04d', 'in%04d' ] }",
361 op, rnd.Uniform(10), rnd.Uniform(10));
362 }
363
364 bool first = true;
365 while (iters > 0) {
366 Graph* graph = new Graph(OpRegistry::Global());
367 InitGraph(s, graph);
368 int N = graph->num_node_ids();
369 if (first) {
370 testing::SetLabel(strings::StrCat("Per graph node. Nodes: ", N));
371 first = false;
372 }
373 {
374 testing::StartTiming();
375 OptimizeCSE(graph, nullptr);
376 testing::StopTiming();
377 }
378 iters -= N; // Our benchmark units are individual graph nodes,
379 // not whole graphs
380 delete graph;
381 }
382}
383BENCHMARK(BM_CSE)->Arg(1000)->Arg(10000);
384
385} // namespace

Callers

nothing calls this directly

Calls 9

StopTimingFunction · 0.85
PrintfFunction · 0.85
SetLabelFunction · 0.85
StartTimingFunction · 0.85
OptimizeCSEFunction · 0.85
UniformMethod · 0.80
InitGraphFunction · 0.70
StrCatFunction · 0.50
num_node_idsMethod · 0.45

Tested by

no test coverage detected