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

Method Run

tensorflow/lite/tools/benchmark/benchmark_model.cc:112–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110TfLiteStatus BenchmarkModel::ResetInputsAndOutputs() { return kTfLiteOk; }
111
112Stat<int64_t> BenchmarkModel::Run(int min_num_times, float min_secs,
113 float max_secs, RunType run_type,
114 TfLiteStatus* invoke_status) {
115 Stat<int64_t> run_stats;
116 TFLITE_LOG(INFO) << "Running benchmark for at least " << min_num_times
117 << " iterations and at least " << min_secs << " seconds but"
118 << " terminate if exceeding " << max_secs << " seconds.";
119 int64_t now_us = profiling::time::NowMicros();
120 int64_t min_finish_us = now_us + static_cast<int64_t>(min_secs * 1.e6f);
121 int64_t max_finish_us = now_us + static_cast<int64_t>(max_secs * 1.e6f);
122
123 *invoke_status = kTfLiteOk;
124 for (int run = 0; (run < min_num_times || now_us < min_finish_us) &&
125 now_us <= max_finish_us;
126 run++) {
127 ResetInputsAndOutputs();
128 listeners_.OnSingleRunStart(run_type);
129 int64_t start_us = profiling::time::NowMicros();
130 TfLiteStatus status = RunImpl();
131 int64_t end_us = profiling::time::NowMicros();
132 listeners_.OnSingleRunEnd();
133
134 run_stats.UpdateStat(end_us - start_us);
135 util::SleepForSeconds(params_.Get<float>("run_delay"));
136 now_us = profiling::time::NowMicros();
137
138 if (status != kTfLiteOk) {
139 *invoke_status = status;
140 }
141 }
142
143 std::stringstream stream;
144 run_stats.OutputToStream(&stream);
145 TFLITE_LOG(INFO) << stream.str() << std::endl;
146
147 return run_stats;
148}
149
150TfLiteStatus BenchmarkModel::ValidateParams() { return kTfLiteOk; }
151

Callers 7

MainFunction · 0.45
TESTFunction · 0.45
MainFunction · 0.45
MainFunction · 0.45
RunFunction · 0.45
EvaluateModelForShardFunction · 0.45
InvokeMethod · 0.45

Calls 12

SleepForSecondsFunction · 0.85
ParseFlagsFunction · 0.85
ValidateParamsFunction · 0.85
UpdateStatMethod · 0.80
OutputToStreamMethod · 0.80
NowMicrosFunction · 0.50
RunFunction · 0.50
InitFunction · 0.50
OnSingleRunStartMethod · 0.45
OnSingleRunEndMethod · 0.45
OnBenchmarkStartMethod · 0.45
OnBenchmarkEndMethod · 0.45

Tested by 1

TESTFunction · 0.36