MovingAverageMinMaxObserver#
- class torch.ao.quantization.observer.MovingAverageMinMaxObserver(averaging_constant=0.01, dtype=torch.quint8, qscheme=torch.per_tensor_affine, reduce_range=False, quant_min=None, quant_max=None, eps=1.1920928955078125e-07, is_dynamic=False, **kwargs)[原始碼]#
用於根據最小和最大值的移動平均值計算量化引數的觀察者模組。
此觀察者根據傳入張量的最小值的移動平均值和最大值的移動平均值來計算量化引數。該模組記錄傳入張量的平均最小值和最大值,並使用此統計資訊來計算量化引數。
- 引數
averaging_constant – 最小/最大值的平均常數。
dtype – dtype argument to the quantize node needed to implement the reference model spec.
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.
移動平均最小值/最大值計算如下:
其中 是執行平均最小值/最大值, 是傳入張量, 是
averaging_constant。然後,縮放因子 (scale) 和零點 (zero point) 的計算方法與
MinMaxObserver相同。注意
僅適用於
torch.per_tensor_affine量化方案。注意
如果執行最小值等於執行最大值,則縮放因子和零點將分別設定為 1.0 和 0。