AffineQuantizedObserverBase¶
- class torch.ao.quantization.observer.AffineQuantizedObserverBase(mapping_type, target_dtype, granularity, quant_min=None, quant_max=None, eps=None, scale_dtype=None, zero_point_dtype=None, preserve_zero=True, zero_point_domain=ZeroPointDomain.INT, **kwargs)[source][source]¶
用於仿射量化的觀察器模組 (https://github.com/pytorch/ao/tree/main/torchao/quantization#affine-quantization)
- 引數
block_size (granularity and) – 量化的粒度,必須至少指定一個,如果兩者都指定,block_size 優先。當前支援的粒度型別有 PerTensor 和 PerAxis
args (其他) – 請參閱 :class:torchao.dtypes.AffineQuantizedTensor
- abstract calculate_qparams()[source][source]¶
根據附加到觀察器模組的統計資料計算量化引數,並返回由縮放因子 (scale) 和零點 (zero_point) 張量組成的元組
- 返回型別
- classmethod with_args(**kwargs)[source]¶
允許建立類工廠的封裝器。
當需要建立具有相同建構函式引數但不同例項的類時,這很有用。可與 _callable_args 結合使用
示例
>>> Foo.with_args = classmethod(_with_args) >>> foo_builder = Foo.with_args(a=3, b=4).with_args(answer=42) >>> foo_instance1 = foo_builder() >>> foo_instance2 = foo_builder() >>> id(foo_instance1) == id(foo_instance2) False