Returns graph containing "num" const nodes. If 'sequential' is true, make sure all constants are executed sequentially in the graph by adding control dependencies.
| 96 | // true, make sure all constants are executed sequentially in the |
| 97 | // graph by adding control dependencies. |
| 98 | static Graph* ManyConsts(int num, bool sequential) { |
| 99 | Graph* g = new Graph(OpRegistry::Global()); |
| 100 | Node* prev = nullptr; |
| 101 | for (int i = 0; i < num; ++i) { |
| 102 | Tensor c(DT_FLOAT, TensorShape({})); |
| 103 | c.scalar<float>()() = i; |
| 104 | Node* curr = test::graph::Constant(g, c); |
| 105 | if (sequential && prev != nullptr) { |
| 106 | g->AddControlEdge(prev, curr); |
| 107 | } |
| 108 | prev = curr; |
| 109 | } |
| 110 | return g; |
| 111 | } |
| 112 | |
| 113 | static void BM_ManyConsts_Parallel(int iters, int num) { |
| 114 | testing::ItemsProcessed(static_cast<int64>(iters) * num); |
no test coverage detected