評價此頁

PerChannelMinMaxObserver#

class torch.ao.quantization.observer.PerChannelMinMaxObserver(ch_axis=0, dtype=torch.quint8, qscheme=torch.per_channel_affine, reduce_range=False, quant_min=None, quant_max=None, factory_kwargs=None, eps=1.1920928955078125e-07, is_dynamic=False, **kwargs)[原始碼]#

用於基於執行時的逐通道最小/最大值計算量化引數的觀察者模組。

此觀察器使用張量的 min/max 統計資訊來計算每通道的量化引數。該模組記錄輸入張量的執行最小值和最大值,並使用此統計資訊來計算量化引數。

引數
  • ch_axis – 通道軸

  • 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.

量化引數的計算方式與 MinMaxObserver 中的相同,不同之處在於執行的 min/max 值是按通道儲存的。因此,縮放因子和零點也按通道計算。

注意

如果執行最小值等於執行最大值,則縮放因子和零點將設定為 1.0 和 0。

reset_min_max_vals()[原始碼]#

重置 min/max 值。