线性

torch.ao.nn.quantized.dynamic.Linear(in_features, out_features, bias_=True, dtype=torch.qint8)[源代码]

这是一个具有浮点张量输入和输出的动态量化线性模块。我们采用了与torch.nn.Linear相同的接口,请参阅https://pytorch.org/docs/stable/nn.html#torch.nn.Linear以获取详细文档。

类似于torch.nn.Linear,属性将在模块创建时被随机初始化,并会在之后被覆盖。

变量
  • weight (Tensor) – 模块的非可学习量化权重,形状为(out_features,in_features)(\text{out\_features}, \text{in\_features})

  • bias (Tensor) – 模块的非可学习浮点偏差,形状为 (out_features)(\text{out\_features})。如果设置 biasTrue,则该偏差值会被初始化为零。

示例:

>>> m = nn.quantized.dynamic.Linear(20, 30)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 30])
classmethodfrom_float(mod, use_precomputed_fake_quant=False)[源代码]

从浮点模块或qparams_dict创建动态量化模块

参数

mod (Module) – 一个浮点模块,该模块可以通过 torch.ao.quantization 工具生成,或者由用户自行提供。

classmethodfrom_reference(ref_qlinear)[源代码]

从参考量化模块创建一个 (fbgemm/qnnpack) 动态量化模块:
:param ref_qlinear: 参考量化模块,可以由 :param torch.ao.quantization 函数生成,或者由用户提供的。
:type ref_qlinear: Module

本页目录