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

Function RunBenchmark

tensorflow/tools/benchmark/benchmark_model.cc:284–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284Status RunBenchmark(const std::vector<InputLayerInfo>& inputs,
285 const std::vector<string>& outputs,
286 const std::vector<string>& targets, Session* session,
287 StatSummarizer* stats, int64* inference_time_us) {
288 std::vector<std::pair<string, tensorflow::Tensor> > input_tensors;
289 CreateTensorsFromInputInfo(inputs, &input_tensors);
290
291 std::vector<tensorflow::Tensor> output_tensors;
292
293 tensorflow::Status s;
294
295 RunOptions run_options;
296 if (stats != nullptr) {
297 run_options.set_trace_level(RunOptions::FULL_TRACE);
298 }
299
300 RunMetadata run_metadata;
301 const int64 start_time = Env::Default()->NowMicros();
302 s = session->Run(run_options, input_tensors, outputs, targets,
303 &output_tensors, &run_metadata);
304 const int64 end_time = Env::Default()->NowMicros();
305 *inference_time_us = end_time - start_time;
306
307 if (!s.ok()) {
308 LOG(ERROR) << "Error during inference: " << s;
309 return s;
310 }
311
312 if (stats != nullptr) {
313 assert(run_metadata.has_step_stats());
314 const StepStats& step_stats = run_metadata.step_stats();
315 stats->ProcessStepStats(step_stats);
316 }
317
318 return s;
319}
320
321Status TimeMultipleRuns(double sleep_seconds, int num_runs, double max_time_s,
322 const std::vector<InputLayerInfo>& inputs,

Callers 1

TimeMultipleRunsFunction · 0.85

Calls 6

DefaultFunction · 0.85
ProcessStepStatsMethod · 0.80
NowMicrosMethod · 0.45
RunMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected