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

Function BM_ParseTensorName

tensorflow/core/graph/tensor_id_test.cc:42–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void BM_ParseTensorName(int iters, int arg) {
43 testing::StopTiming();
44 random::PhiloxRandom philox(301, 17);
45 random::SimplePhilox rnd(&philox);
46 std::vector<string> names;
47 for (int i = 0; i < 100; i++) {
48 string name;
49 switch (arg) {
50 case 0: { // Generate random names
51 size_t len = Skewed(&rnd, 4);
52 while (name.size() < len) {
53 name += rnd.OneIn(4) ? '0' : 'a';
54 }
55 if (rnd.OneIn(3)) {
56 strings::StrAppend(&name, ":", rnd.Uniform(12));
57 }
58 break;
59 }
60 case 1:
61 name = "W1";
62 break;
63 case 2:
64 name = "t0003";
65 break;
66 case 3:
67 name = "weights";
68 break;
69 case 4:
70 name = "weights:17";
71 break;
72 case 5:
73 name = "^weights";
74 break;
75 default:
76 LOG(FATAL) << "Unexpected arg";
77 break;
78 }
79 names.push_back(name);
80 }
81 testing::StartTiming();
82 TensorId id;
83 int index = 0;
84 int sum = 0;
85 while (--iters > 0) {
86 id = ParseTensorName(names[index++ % names.size()]);
87 sum += id.second;
88 }
89 VLOG(2) << sum; // Prevent compiler from eliminating loop body
90}
91BENCHMARK(BM_ParseTensorName)->Arg(0)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(5);
92
93TEST(TensorIdTest, IsTensorIdControl) {

Callers

nothing calls this directly

Calls 9

StopTimingFunction · 0.85
SkewedFunction · 0.85
StartTimingFunction · 0.85
ParseTensorNameFunction · 0.85
OneInMethod · 0.80
UniformMethod · 0.80
StrAppendFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected