• 文档 >
  • 量化 >
  • 量化 API 参考 >
  • AffineQuantizedObserverBase
快捷键

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 (粒度及) – 量化粒度,必须指定至少一个,如果两个都指定,则 block_size 优先。当前支持的粒度类型为 PerTensor 和 PerAxis

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

抽象 calculate_qparams()[source][source] ¶

根据附加到观察模块的统计数据计算量化参数,并返回一个包含 scale 和 zero_point Tensor 的元组

返回类型:

tuple[torch.Tensor, torch.Tensor]

抽象 forward(input)[source][source] ¶

forward 函数应接受输入张量并更新内部统计信息,并返回原始输入 Tensor

返回类型:

张量

类方法 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 贡献者。

使用 Sphinx 构建,主题由 Read the Docs 提供。

文档

查看 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源