Caffe2 - C++ API
A deep learning, cross platform ML framework
std_output_formatter.h
1 #pragma once
2 #include "output_formatter.h"
3 
4 namespace caffe2 {
5 namespace emulator {
6 
7 const uint64_t MS_IN_SECOND = 1000;
8 
9 /*
10  * Print the output of the emulator run to stdout.
11  */
13  private:
14  template <typename T>
15  static float get_mean(const std::vector<T>& values) {
16  float sum = std::accumulate(values.begin(), values.end(), 0.0);
17  return sum / values.size();
18  }
19 
20  template <typename T>
21  static float get_stdev(const std::vector<T>& values) {
22  auto mean = get_mean(values);
23  double sq_sum =
24  std::inner_product(values.begin(), values.end(), values.begin(), 0.0);
25  return std::sqrt(sq_sum / values.size() - mean * mean);
26  }
27 
28  public:
29  std::string format(
30  const std::vector<float>& durations_ms,
31  uint64_t threads,
32  uint64_t iterations) override {
33  auto mean = get_mean(durations_ms);
34  auto throughput = iterations / (mean / MS_IN_SECOND);
35  return std::string("\n\n====================================\n") +
36  "Predictor benchmark finished with " + c10::to_string(threads) +
37  " threads.\nThroughput:\t\t" + c10::to_string(throughput) +
38  " iterations/s\nVariation:\t\t" +
39  c10::to_string(get_stdev(durations_ms) * 100 / mean) +
40  "%\n====================================";
41  }
42 };
43 
44 } // namespace emulator
45 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13