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