評價此頁

QFunctional#

class torch.ao.nn.quantized.QFunctional[source]#

已量化操作的包裝器類。

此類的例項可用於代替 torch.ops.quantized 字首。請參閱下面的示例用法。

注意

此類不提供 forward 掛鉤。而是必須使用底層函式之一(例如 add)。

示例

>>> q_add = QFunctional()
>>> a = torch.quantize_per_tensor(torch.tensor(3.0), 1.0, 0, torch.qint32)
>>> b = torch.quantize_per_tensor(torch.tensor(4.0), 1.0, 0, torch.qint32)
>>> q_add.add(a, b)  # Equivalent to ``torch.ops.quantized.add(a, b, 1.0, 0)``
有效操作名稱
  • add

  • cat

  • mul

  • add_relu

  • add_scalar

  • mul_scalar