aclnnAddLayerNormQuant 算子在 Regbase(Ascend950)架构上,空 Tensor 早返回判断条件为 outScales1Out->IsEmpty()。static 量化场景下 outScales 输出无实际意义(static 量化使用 input scales,不依赖 output scales),其是否为空不能作为空 Tensor 的判据。当 x1 为空但 outScales1Out 不为空时,该条件不成立,算子未走早返回,继续执行导致异常。
aclnnAddLayerNormQuant
outScales1Out->IsEmpty()
outScales
outScales1Out
x1
{0, 64}
gamma
{64}
quantMode="static"
{1}
aclnnAddLayerNormQuantGetWorkspaceSize
static 量化场景下,当 x1 为空时应以 x1->IsEmpty() 作为早返回判据(返回 ACL_SUCCESS 且 workspaceSize==0),而非依赖 outScales1Out 是否为空。
x1->IsEmpty()
ACL_SUCCESS
workspaceSize==0
修复前:x1 为空但 outScales1Out 非空时,未走早返回路径,算子执行异常。 修复后:UT 用例 static_outer_axis_empty(x1={0,64})和 static_normalized_axis_empty(x1={2,0})均验证返回 ACL_SUCCESS 且 workspaceSize==0。
static_outer_axis_empty
static_normalized_axis_empty
修复方案:引入 IsDynamicQuant 区分 dynamic/static 量化,新增 regbaseEmptySkip 判据(dynamic 看 outScales1Out、static 看 x1),将 Regbase 早返回条件由 outScales1Out->IsEmpty() 改为 regbaseEmptySkip。
IsDynamicQuant
regbaseEmptySkip
关联 PR:https://gitcode.com/cann/ops-nn/pull/9903
Describe the current behavior / 问题描述 (Mandatory / 必填)
aclnnAddLayerNormQuant算子在 Regbase(Ascend950)架构上,空 Tensor 早返回判断条件为outScales1Out->IsEmpty()。static 量化场景下outScales输出无实际意义(static 量化使用 input scales,不依赖 output scales),其是否为空不能作为空 Tensor 的判据。当 x1 为空但outScales1Out不为空时,该条件不成立,算子未走早返回,继续执行导致异常。Environment / 环境信息 (Mandatory / 必填)
aclnnAddLayerNormQuantSteps to reproduce the issue / 重现步骤 (Mandatory / 必填)
x1shape 为{0, 64}、gammashape 为{64}、quantMode="static"、outScales1Outshape 为{1}(非空)。aclnnAddLayerNormQuantGetWorkspaceSize。Describe the expected behavior / 预期结果 (Mandatory / 必填)
static 量化场景下,当 x1 为空时应以
x1->IsEmpty()作为早返回判据(返回ACL_SUCCESS且workspaceSize==0),而非依赖outScales1Out是否为空。Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
修复前:x1 为空但
outScales1Out非空时,未走早返回路径,算子执行异常。修复后:UT 用例
static_outer_axis_empty(x1={0,64})和static_normalized_axis_empty(x1={2,0})均验证返回ACL_SUCCESS且workspaceSize==0。Special notes for this issue/备注 (Optional / 选填)
修复方案:引入
IsDynamicQuant区分 dynamic/static 量化,新增regbaseEmptySkip判据(dynamic 看 outScales1Out、static 看 x1),将 Regbase 早返回条件由outScales1Out->IsEmpty()改为regbaseEmptySkip。关联 PR:https://gitcode.com/cann/ops-nn/pull/9903