直方图观察器¶
- class torch.ao.quantization.observer.HistogramObserver(bins=2048, upsample_rate=128, dtype=torch.quint8, qscheme=torch.per_tensor_affine, reduce_range=False, quant_min=None, quant_max=None, factory_kwargs=None, eps=1.1920928955078125e-07, is_dynamic=False, **kwargs)[源代码]¶
该模块记录张量值的运行直方图以及最小/最大值。
calculate_qparams将计算比例和零点。- Parameters
比例和零点计算如下:
- Create the histogram of the incoming inputs.
直方图是连续计算的,每个区间的范围会随着观察到的每个新张量的变化而变化。
- Search the distribution in the histogram for optimal min/max values.
搜索最小/最大值确保了相对于浮点模型的量化误差的最小化。
- Compute the scale and zero point the same way as in the
MinMaxObserver