torch_npu.npu_weight_quant_batchmatmul

功能描述

该接口用于实现矩阵乘计算中weight输入和输出的量化操作,支持per-tensor、per-channel、per-group多场景量化。

不同产品支持的量化算法不同,如表1所示。

表1 支持的量化场景

产品型号

量化方式

Atlas 推理系列产品

per-tensor、per-channel

Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件

per-tensor、per-channel、per-group

Atlas A3 训练系列产品/Atlas A3 推理系列产品

per-tensor、per-channel、per-group

接口原型

1
torch_npu.npu_weight_quant_batchmatmul(Tensor x, Tensor weight, Tensor antiquant_scale, Tensor? antiquant_offset=None, Tensor? quant_scale=None, Tensor? quant_offset=None, Tensor? bias=None, int antiquant_group_size=0, int inner_precise=0) -> Tensor

参数说明

输出说明

输出为Tensor类型,代表计算结果。当输入存在quant_scale时输出数据类型为int8,当输入不存在quant_scale时输出数据类型和输入x一致。

约束说明

支持的型号

调用示例