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

Function ManyConsts

tensorflow/core/kernels/constant_op_test.cc:98–111  ·  view source on GitHub ↗

Returns graph containing "num" const nodes. If 'sequential' is true, make sure all constants are executed sequentially in the graph by adding control dependencies.

Source from the content-addressed store, hash-verified

96// true, make sure all constants are executed sequentially in the
97// graph by adding control dependencies.
98static 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
113static void BM_ManyConsts_Parallel(int iters, int num) {
114 testing::ItemsProcessed(static_cast<int64>(iters) * num);

Callers 2

BM_ManyConsts_ParallelFunction · 0.85
BM_ManyConsts_SequentialFunction · 0.85

Calls 3

ConstantFunction · 0.70
TensorShapeClass · 0.50
AddControlEdgeMethod · 0.45

Tested by

no test coverage detected