3 #include "caffe2/core/observer.h" 4 #include "caffe2/core/operator.h" 5 #include "caffe2/quantization/server/dnnlowp.h" 6 #include "caffe2/quantization/server/dynamic_histogram.h" 21 : min(std::numeric_limits<float>::max()),
22 max(std::numeric_limits<float>::lowest()),
23 total_min(std::numeric_limits<float>::max()),
24 total_max(std::numeric_limits<float>::lowest()),
27 void Update(
float cur_min,
float cur_max) {
28 min = std::min(min, cur_min);
29 max = std::max(max, cur_max);
30 total_min = std::min(total_min, cur_min);
31 total_max = std::max(total_max, cur_max);
35 float total_min, total_max;
40 std::vector<TensorInfo> tensor_infos;
48 std::shared_ptr<OperatorInfo> GetInfo() {
55 std::shared_ptr<OperatorInfo> info_;
56 bool warning_printed_ =
false;
65 const std::string& out_file_name,
72 const std::string& out_file_name,
73 bool print_total_min_max =
false);
76 const std::string out_file_name_;
77 std::vector<std::shared_ptr<OutputMinMaxObserver::OperatorInfo>>
87 std::vector<dnnlowp::DynamicHistogram> histograms;
88 std::vector<dnnlowp::DynamicHistogram> total_histograms;
97 std::shared_ptr<Info> info_;
98 bool warning_printed_ =
false;
105 const std::string& out_file_name,
108 bool mul_nets =
false);
112 void Stop()
override;
114 const std::string& out_file_name,
115 bool print_total_min_max =
false);
117 int dump_freq_, cnt_;
123 const std::string out_file_name_;
124 std::vector<std::shared_ptr<HistogramObserver::Info>> hist_infos_;
135 const std::string& min_max_file_name,
136 bool is_weight =
false,
137 const std::string& qparams_output_file_name =
"");
149 const std::string& histogram_file_name,
150 bool is_weight =
false,
151 const std::string& qparams_output_file_name =
"");
Use this to implement a Observer using the Observer Pattern template.
Set quantization parameters of operators based on min/max collected from OutputMinMaxObserver.
Given min/max, collect histogram.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Set quantization parameters of operators based on min/max collected from OutputMinMaxObserver.