1 #include "caffe2/core/init.h" 2 #include "caffe2/predictor/emulator/std_output_formatter.h" 7 C10_DEFINE_int(warmup, 10000,
"The number of iterations to warm up.");
8 C10_DEFINE_int(iter, 10000000,
"The number of iterations to run.");
9 C10_DEFINE_int(threads, 32,
"The number of threads to run.");
10 C10_DEFINE_int(runs, 10,
"The number of independent runs.");
16 "The number of threads to build predictors.");
19 C10_DEFINE_string(run_net,
"",
"The given net to benchmark.");
20 C10_DEFINE_string(init_net,
"",
"The given net to initialize.");
21 C10_DEFINE_string(data_net,
"",
"The given net to get input data.");
25 "The path of the file that " 26 "stores input dimesions of all the operators in the run net. " 27 "Each element of the array is a mapping from " 28 "operator index to its input dimension.");
32 "The path of the file that " 33 "stores input types of all the operators in the run net. " 34 "Each element of the array is a mapping from " 35 "operator index to its input types.");
40 void BenchmarkRunner::benchmark(
const BenchmarkParam& param) {
42 std::vector<float> durations_ms;
43 for (
size_t run = 0; run < FLAGS_runs; ++run) {
44 LOG(WARNING) <<
"Starting run " << run + 1;
45 LOG(INFO) <<
"Warming up " << FLAGS_threads <<
" threads with " 46 << FLAGS_warmup <<
" iterations...";
47 param.emulator->run(FLAGS_warmup);
49 LOG(INFO) <<
"Starting benchmark with " << FLAGS_iter <<
" iterations...";
50 pre_benchmark_setup();
51 const auto duration_ms =
52 param.profiler->profile([&]() { param.emulator->run(FLAGS_iter); });
54 durations_ms.emplace_back(duration_ms);
55 auto throughput = FLAGS_iter / (duration_ms / MS_IN_SECOND);
56 LOG(INFO) <<
"Benchmark run finished in " << duration_ms / MS_IN_SECOND
58 <<
"Throughput:\t\t" << throughput <<
" iterations/s\n";
60 post_benchmark_cleanup();
61 LOG(INFO) <<
"Run " << run + 1 <<
" finished";
63 LOG(WARNING) << param.formatter->format(
64 durations_ms, FLAGS_threads, FLAGS_iter);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...