WeightQuantBatchMatmul
产品支持情况
| 产品 | 是否支持 |
|---|---|
| Ascend 950PR/Ascend 950DT | × |
| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | × |
| Atlas 推理系列产品 | × |
| Atlas 训练系列产品 | × |
功能说明
-
算子功能:完成一个输入为伪量化场景的矩阵乘计算,并可以实现对于输出的量化计算。
-
计算公式:
result=self@ANTIQUANT(mat2)+biasresult = self @ ANTIQUANT(mat2) + bias
公式中的mat2mat2为伪量化场景的输入,其反量化公式ANTIQUANT(mat2)ANTIQUANT(mat2)为
ANTIQUANT(mat2)=(mat2+antiquantOffset)∗antiquantScaleANTIQUANT(mat2) = (mat2 + antiquantOffset) * antiquantScale
当需要对输出进行量化处理时,其量化公式为
result=QUANT(self@ANTIQUANT(mat2)+bias)=(self@ANTIQUANT(mat2)+bias)∗quantScale+quantOffset\begin{aligned} result &= QUANT(self @ ANTIQUANT(mat2) + bias) \\ &= (self @ ANTIQUANT(mat2) + bias) * quantScale + quantOffset \\ \end{aligned}
当不需要对输出再进行量化操作时,其计算公式为
result=self@ANTIQUANT(mat2)+biasresult = self @ ANTIQUANT(mat2) + bias
参数说明
| 参数名 | 输入/输出/属性 | 描述 | 数据类型 | 数据格式 |
|---|---|---|---|---|
| x1 | 输入 | 公式中的输入self。 | FLOAT16 | ND |
| x2 | 输入 | 公式中的输入mat2。 | INT8 | ND |
| bias | 输入 | 公式中的输入bias。 | FLOAT32 | ND |
| antiquantScale | 输入 | 反量化参数中的缩放因子,对应公式中的antiquantScale。 | FLOAT32 | - |
| antiquantOffset | 输入 | 反量化参数中的偏置因子,对应公式中的antiquantOffset。 | FLOAT32 | - |
| quantScale | 输入 | 量化参数中的缩放因子,对应公式中的quantScale。 | FLOAT32 | - |
| quantOffset | 输入 | 量化参数中的偏置因子,对应公式中的quantOffset。 | FLOAT32 | - |
| out | 输出 | 公式中的result。 | FLOAT16,INT8 | ND |
约束说明
- 不支持空tensor。
- 支持连续tensor,非连续tensor只支持转置场景。
调用说明
| 调用方式 | 样例代码 | 说明 |
|---|---|---|
| aclnn接口 | test_aclnn_weight_quant_batch_mat_mul | 通过 aclnnWeightQuantBatchMatmul 调用WeightQuantBatchMatmul算子。 |