Caffe2 - C++ API
A deep learning, cross platform ML framework
quantization_error_minimization.h
1 #pragma once
2 
3 #include "dnnlowp.h"
4 
5 namespace dnnlowp {
6 
8  public:
9  virtual TensorQuantizationParams ChooseQuantizationParams(
10  const Histogram& hist,
11  bool preserve_sparsity = false,
12  int precision = 8) = 0;
13  virtual ~QuantizationErrorMinimization(){};
14 };
15 
17  public:
18  enum Kind {
19  L1,
20  L2,
21  };
22 
23  NormMinimization(Kind kind) : kind_(kind) {}
24 
28  TensorQuantizationParams NonlinearQuantizationParamsSearch(
29  const Histogram& hist,
30  bool preserve_sparsity = false,
31  int precision = 8);
32 
33  TensorQuantizationParams ChooseQuantizationParams(
34  const Histogram& hist,
35  bool preserve_sparsity = false,
36  int precision = 8) override;
37 
38  protected:
39  Kind kind_;
40 };
41 
43  public:
45 };
46 
48  public:
49  TensorQuantizationParams ChooseQuantizationParams(
50  const Histogram& hist,
51  bool preserve_sparsity = true,
52  int precision = 8) override;
53 }; // class P99QuantizationFactory
54 
55 } // namespace dnnlowp
bin_width = (max - min)/nbins ith bin (zero-based indexing) contains [i*bin_width, (i+1)*bin_width) with an exception that (nbins - 1)th bin contains [(nbins-1)*bin_width, nbins*bin_width]