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

Function BM_ScatterHelper

tensorflow/core/kernels/scatter_op_test.cc:241–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240template <typename Index>
241static void BM_ScatterHelper(int iters, int embedding_size, const char* op) {
242 testing::StopTiming();
243 const int kRows = 10000000 / embedding_size;
244 std::vector<float> values;
245 values.reserve(kRows);
246 for (int i = 0; i < kRows * embedding_size; i++) {
247 values.push_back(i);
248 }
249 const int kNumUpdates = 1000;
250 random::PhiloxRandom philox(301, 17);
251 random::SimplePhilox rnd(&philox);
252 std::vector<Index> indices;
253 std::vector<float> updates;
254 for (int i = 0; i < kNumUpdates; i++) {
255 indices.push_back(rnd.Uniform(kRows));
256 for (int j = 0; j < embedding_size; j++) {
257 updates.push_back(i * 10 + j);
258 }
259 }
260
261 ScatterUpdateBM bm;
262 bm.MakeBenchmarkOp(op, DataTypeToEnum<Index>::v());
263 bm.AddInputFromArray<float>(TensorShape({kRows, embedding_size}), values);
264 bm.AddInputFromArray<Index>(TensorShape({kNumUpdates}), indices);
265 bm.AddInputFromArray<float>(TensorShape({kNumUpdates, embedding_size}),
266 updates);
267 testing::ItemsProcessed((static_cast<int64>(kNumUpdates) * embedding_size) *
268 iters);
269 testing::StartTiming();
270 while (iters-- > 0) {
271 Status s = bm.RunOpKernel();
272 }
273 testing::StopTiming();
274}
275
276static void BM_ScatterUpdateInt32(int iters, int embedding_size) {
277 BM_ScatterHelper<int32>(iters, embedding_size, "ScatterUpdate");

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