文件最后提交记录最后更新时间
19 天前
15 天前
15 天前
2 个月前
14 天前
15 天前
15 天前
2 个月前
23 天前
README

QuantMax

产品支持情况

产品 是否支持
Ascend 950PR/Ascend 950DT
Atlas A3 训练系列产品/Atlas A3 推理系列产品 ×
Atlas A2 训练系列产品/Atlas A2 推理系列产品 ×
Atlas 200I/500 A2 推理产品 ×
Atlas 推理系列产品 ×
Atlas 训练系列产品 ×

功能说明

  • 算子功能:根据输入的scale对输入x进行量化,并计算输入x的绝对值的最大值amax。

  • 计算公式:

    y=Cast(x×scale,dst_type,round_mode)y = \text{Cast}(x \times scale, \text{dst\_type}, \text{round\_mode})

    amax=max⁡(∣x∣)amax = \max(|x|)

    其中,xx表示输入张量,scalescale表示量化缩放因子,dst_type\text{dst\_type}指定输出类型,round_mode\text{round\_mode}指定舍入模式,amaxamax为输入张量所有元素绝对值的最大值。

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
x 输入 待量化的输入张量,对应公式中的x。支持1-8维任意shape。 FLOAT、FLOAT16、BFLOAT16 ND
scale 输入 量化缩放因子,对应公式中的scale。shape固定为[1]。 FLOAT ND
y 输出 量化后的输出张量,对应公式中的y。shape与x相同,数据类型由dst_type决定。 HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3 ND
amax 输出 x绝对值的最大值,对应公式中的amax。shape固定为[1],数据类型与x一致。 FLOAT、FLOAT16、BFLOAT16 ND
round_mode 属性 取值需为Cast API支持的有效舍入模式。 string -
dst_type 属性 指定输出量化数据类型。34=HIFLOAT8,35=FLOAT8_E5M2,36=FLOAT8_E4M3。 int -

约束说明

  • round_modedst_dtype的匹配关系:
    • dst_dtype3536时,round_mode必须为"rint"
    • dst_dtype34时,round_mode必须为"round""hybrid"

调用说明

调用方式 调用样例 说明
aclnn调用 test_aclnn_quant_max 通过aclnnQuantMax接口方式调用QuantMax算子。
图模式调用 - 通过算子IR构图方式调用QuantMax算子。