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

Function BM_ScatterNdHelper

tensorflow/core/kernels/scatter_nd_op_test.cc:254–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252
253template <typename Index>
254static void BM_ScatterNdHelper(int iters, int embedding_size, const char* op) {
255 testing::StopTiming();
256 const int kRows = 10000000 / embedding_size;
257 std::vector<float> values;
258 values.reserve(kRows);
259 for (int i = 0; i < kRows * embedding_size; i++) {
260 values.push_back(i);
261 }
262 const int kNumUpdates = 1000;
263 random::PhiloxRandom philox(301, 17);
264 random::SimplePhilox rnd(&philox);
265 std::vector<Index> indices;
266 std::vector<float> updates;
267 for (int i = 0; i < kNumUpdates; i++) {
268 indices.push_back(rnd.Uniform(kRows));
269 for (int j = 0; j < embedding_size; j++) {
270 updates.push_back(i * 10 + j);
271 }
272 }
273
274 ScatterNdUpdateBM bm;
275 bm.MakeBenchmarkOp(op, DataTypeToEnum<Index>::v());
276 bm.AddInputFromArray<float>(TensorShape({kRows, embedding_size}), values);
277 bm.AddInputFromArray<Index>(TensorShape({kNumUpdates}), indices);
278 bm.AddInputFromArray<float>(TensorShape({kNumUpdates, embedding_size}),
279 updates);
280 testing::ItemsProcessed((static_cast<int64>(kNumUpdates) * embedding_size) *
281 iters);
282 testing::StartTiming();
283 while (iters-- > 0) {
284 Status s = bm.RunOpKernel();
285 }
286 testing::StopTiming();
287}
288
289static void BM_ScatterNdUpdateInt32(int iters, int embedding_size) {
290 BM_ScatterNdHelper<int32>(iters, embedding_size, "ScatterNdUpdate");

Callers

nothing calls this directly

Calls 9

StopTimingFunction · 0.85
ItemsProcessedFunction · 0.85
StartTimingFunction · 0.85
UniformMethod · 0.80
TensorShapeClass · 0.50
reserveMethod · 0.45
push_backMethod · 0.45
MakeBenchmarkOpMethod · 0.45
RunOpKernelMethod · 0.45

Tested by

no test coverage detected