已关闭
[Bug-Report|缺陷反馈]: Scatter 算子 tiling 阶段负数 axis 绕过首轴校验导致kenrel进行错误计算 #5190
zhang-wenbo-beat创建于  13 天前关闭于  11 天前
zhang-wenbo-beat
zhang-wenbo-beat成员
13 天前 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Scatter 算子 tiling 阶段对 axis 属性的校验存在缺陷。GetShapeAttrsInfo 中仅检查 axis == 0(首轴不支持),但负数 axis 会绕过该校验

以 1 维输入为例,传入 axis=-1(语义上等价于首轴 0):

  • -1 != 0,通过 axis == 0 校验;
  • 随后在 MergeDims 中执行负数归一化 tmpAbsAxis = oldDims + axis = 1 + (-1) = 0;
  • MergeDims 仅做范围校验 tmpAbsAxis < 0 || tmpAbsAxis >= oldDims,不复查 == 0;
  • 于是 axis=0 漏到下游计算路径,触发不支持的 axis=0 场景,可能导致越界访问或结果异常。

涉及文件:index/scatter/op_host/arch35/scatter_tiling_arch35.cpp

关键代码(当前):

// GetShapeAttrsInfo
const int64_t* axisPtr = attrs->GetAttrPointer<int64_t>(AXIS_INDEX);
axis = (axisPtr == nullptr) ? 0 : *axisPtr;
if (axis == 0) {  // 负数 axis 在此处绕过
    ...
}

// MergeDims
int32_t tmpAbsAxis = axis < 0 ? oldDims + axis : axis;  // 此处归一化为 0
if (tmpAbsAxis < 0 || tmpAbsAxis >= oldDims) { ... }     // 不检查 == 0

Environment / 环境信息 (Mandatory / 必填)

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

  • 硬件:Ascend950
  • CANN 版本:9.2.0
  • Tiling 目录:arch35(SUPPORT_TILING_DIR=arch35,对应 ascend950/3510)
  • 仓库:CANN/ops-nn master

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

  1. 构造一个 1 维输入张量(如 shape=[N]);
  2. 调用 Scatter 算子,axis 属性传入负数(如 axis=-1,表示沿首轴操作);
  3. 触发 tiling 流程:axis=-1GetShapeAttrsInfo 中未被拦截,进入 MergeDims 归一化为 0;
  4. axis=0 进入下游 kernel 计算路径,产生越界访问或非预期行为。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
axis=-1 在 1 维输入下语义等价首轴 0,应在 tiling 阶段被正确识别并拦截报错(如"axis does not support 0"),不应进入下游计算。负数 axis 应在 axis == 0 校验之前完成归一化,使归一化后等于 0 的情况被首轴校验捕获;同时过于负的 axis(归一化后仍 < 0 或 >= inputDims)也应一并拦截。

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
NA

Special notes for this issue/备注 (Optional / 选填)

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

likedislike
zhang-wenbo-beatzhang-wenbo-beat成员
13 天前 添加了label:bug-report
zhang-wenbo-beatzhang-wenbo-beat成员
13 天前 将 zhang-wenbo-beat 设为负责人
CANN-robotCANN-robot成员
11 天前 关闭了 issue
CANN-robotCANN-robot成员
11 天前 添加了label:resolved