當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch QFunctional用法及代碼示例

本文簡要介紹python語言中 torch.nn.quantized.QFunctional 的用法。

用法:

class torch.nn.quantized.QFunctional

量化操作的包裝類。

可以使用此類的實例來代替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

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.quantized.QFunctional。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。