快捷方式

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 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源