快捷方式

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 优先。当前支持的粒度类型有 PerTensorPerAxis

  • args (其他) – 请参阅 :class:torchao.dtypes.AffineQuantizedTensor

abstract calculate_qparams()[source][source]

根据附加到观察器模块的统计数据计算量化参数,并返回由缩放因子 (scale) 和零点 (zero_point) 张量组成的元组

返回类型

元组[torch.Tensor, torch.Tensor]

abstract forward(input)[source][source]

forward 函数应接收输入张量,更新内部统计数据,并返回原始输入张量

返回类型

张量

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

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源