3 #include "caffe2/core/operator.h" 4 #include "caffe2/quantization/server/dnnlowp.h" 5 #include "caffe2/utils/eigen_utils.h" 13 void PropagateOutputTensorQuantizationParams(
16 const TensorQuantizationParams& qparams);
25 TensorQuantizationParams GetInputTensorQuantizationParamsOf(
28 const QuantizationFactory* qfactory,
29 bool is_weight =
false);
31 void SetStaticQuantizationParams(
34 const TensorQuantizationParams& qparams);
40 bool HasStaticQuantization(
42 int output_index = 0);
48 TensorQuantizationParams GetStaticQuantizationParamsOf(
59 const T* QuantizeInputIfNeeded(
62 const TensorQuantizationParams& qparams,
63 std::vector<T>& temp);
66 const T* RowWiseQuantizeInputIfNeeded(
69 const std::vector<TensorQuantizationParams>& qparams,
70 std::vector<T>& temp);
73 float sum_sq{0}, sum_err_sq{0};
76 float max_err_actual{0}, max_err_ref{0};
80 void MeasureQuantizationError(
86 void ReportQuantizationError(
93 std::unique_ptr<QuantizationFactory> GetQuantizationFactoryOf(
96 void AdjustOutputTensorQuantizationParamsWithFollowedBy(
98 const std::string& followed_by);
100 void ParseDNNLowPOperatorArguments(
102 bool* dequantize_output =
nullptr,
103 bool* measure_quantization_error =
nullptr,
104 std::string* followed_by =
nullptr);
106 caffe2::NetDef AddScaleZeroOffsetArgumentsWithHistogram(
107 caffe2::NetDef net_def,
108 const std::string& histogram_file_name);