昇腾社区首页
中文
注册

aclnnCalculateMatmulWeightSizeV2

支持的产品型号

Atlas 推理系列产品 Atlas A2训练系列产品/Atlas 800I A2推理产品

接口原型

aclnnStatus aclnnCalculateMatmulWeightSizeV2(const aclIntArray *tensorShape, aclDataType dataType, uint64_t *weightTensorSize)

功能描述

  • 算子功能: 在Matmul算子ND格式输入下,计算如果要转换到NZ格式下需要占用的空间大小(单位为元素个数),仅支持Float16, INT8数据类型,该接口仅仅用于判断对weight Tensor进行预处理需要使用多少size才可使Matmul算子执行性能最优。输入tensorShape最少是2维(n,k),最多是6维(batch,n,k)。 例如:

输入【510, 510】Float16 该函数出于性能角度考虑,会将shape变化为【512,512】 因此函数会将引用输入修改为262144

输入【510, 270】INT8 该函数出于性能角度考虑,会将shape变化为【512,288】 因此函数会将引用输入修改为147456

  • 计算公式Float16:result=Align(Shapesize[0],16)Align(Shapesize[1],16)Float16: result = Align(Shapesize[0], 16) * Align(Shapesize[1], 16) INT8result=Align(Shapesize[0],16)Align(Shapesize[1],32)INT8: result = Align(Shapesize[0], 16) * Align(Shapesize[1], 32)

aclnnCalculateMatmulWeightSizeV2

  • 参数说明:

    • tensorShape(const aclIntArray *, 计算输入):用于表达该次Matmul载入权重矩阵的Shape, 输入shape最少是2维(n,k),最多是6维(batch,n,k)。
    • weightDtype(op::DataType *, 计算输入):weight的Dtype, 支持Float16、INT8。
    • weightTensorSize(uint64_t *, 计算输出):转换为NZ格式所占用的空间大小(单位为元素个数)。
  • 返回值:

    aclnnStatus:返回状态码,具体参见undefined

    [object Object]

约束与限制

调用示例

  • 以Atlas 推理系列产品为例,tensorShape为二维的场景示例代码如下,仅供参考,具体编译和执行过程请参考undefined
  • tensorShape为多维(3-6维)的场景示例代码请参考undefined
[object Object]