MovingAveragePerChannelMinMaxObserver#
- class torch.ao.quantization.observer.MovingAveragePerChannelMinMaxObserver(averaging_constant=0.01, ch_axis=0, dtype=torch.quint8, qscheme=torch.per_channel_affine, reduce_range=False, quant_min=None, quant_max=None, eps=1.1920928955078125e-07, is_dynamic=False, **kwargs)[原始碼]#
用於基於執行時的逐通道最小/最大值計算量化引數的觀察者模組。
此觀察器使用張量的 min/max 統計資訊來計算每個通道的量化引數。該模組記錄傳入張量的執行最小值和最大值,並使用此統計資訊來計算量化引數。
- 引數
averaging_constant – min/max 的平均常數。
ch_axis – 通道軸
dtype – 量化資料型別
qscheme – Quantization scheme to be used
reduce_range – Reduces the range of the quantized data type by 1 bit
quant_min – Minimum quantization value. If unspecified, it will follow the 8-bit setup.
quant_max – Maximum quantization value. If unspecified, it will follow the 8-bit setup.
eps (Tensor) – Epsilon value for float32, Defaults to torch.finfo(torch.float32).eps.
量化引數的計算方式與
MovingAverageMinMaxObserver中的相同,不同之處在於執行的 min/max 值是按通道儲存的。因此,比例因子(scales)和零點(zero points)也是按通道計算的。注意
如果執行的最小值等於執行的最大值,則比例因子和零點將設定為 1.0 和 0。