module owlite.calib.minmax_calibrator
class MinmaxCalibrator
Minmax Calibrator Class.
The MinMaxCalibration calibrator stores the maximum value and minimum value encountered in the passed data, utilizing this value as the quantization range. When the original data is represented by $$X$$, the step_size
and zero_point
are caculated as:
$$ \text{step_size}=\frac{\max{x \in X}(x) - \min{x \in X}(x) }{\text{quant_max}-\text{quant_min}} \ \text{zero_point} = - \frac{\min_{x \in X}(x)}{\text{step_size}} + \text{quant_min} $$
For symmetric quantization:
$$ \text{step_size}=\frac{\max_{x \in X}(|x|)}{\text{quant_max}-\text{quant_min}} \text{zero_point} = 0 $$
Attributes:
max_value
(torch.Tensor
,optional
): maximum value of data passing through the quantizer.min_value
(torch.Tensor
,optional
): minimum value of data passing through the quantizer.
method __init__
python
__init__(quantizer: 'FakeQuantizer')
method prepare
python
prepare() → RemovableHandle
method update
python
update() → None
Updated: 2024-06-13T23:42:41