Closed
[Bug-Report|缺陷反馈]: aclnnRange 空指针错误码返回 561103,资料错误码表声明 161001(start/end/step/out 四个位置全部如此) #4256
liuhanwen8Add on  20 days agoClosed at  6 days ago
liuhanwen8
liuhanwen8
20 days ago Create

现象

aclnnRange 在任一入参指针为空时,返回 561103(ACLNN_ERR_INNER_NULLPTR);而资料错误码表声明的是 161001(ACLNN_ERR_PARAM_NULLPTR)。四个位置(start / end / step / out)全部如此,两种确定性开关(ACL_OPT_DETERMINISTIC=0/1)下一致。

实测(Atlas A2 910B2,CANN 9.2.0):

置空的参数 第一段返回码 资料声明
start 561103 161001
end 561103 161001
step 561103 161001
out 561103 161001

复现脚本输出:

[D1 start=nullptr] phase1=561103 phase2=-1
[D1 end=nullptr  ] phase1=561103 phase2=-1
[D1 step=nullptr ] phase1=561103 phase2=-1
[D1 out=nullptr  ] phase1=561103 phase2=-1

期望

资料 math/range/docs/aclnnRange.md 的错误码表第一行:

返回码 错误码 描述
ACLNN_ERR_PARAM_NULLPTR 161001 传入的 start、end、step 或 out 是空指针。

161001 是「参数为空」的标准码;561103 属于内部错误族(ACLNN_ERR_INNER_NULLPTR),语义是「内部创建的对象为空」,不是「用户传了空指针」。

调用方按资料写 if (ret == 161001) 会漏判;按 561103 分流又会把「参数错」误报成「内部故障」,两者排查方向完全不同。

根因

math/range/op_api/aclnn_range.cpp:186-195:

inline static aclnnStatus CheckParams(const aclScalar* start, const aclScalar* end, const aclScalar* step,
                                      const aclTensor* out)
{
    // 1. 检查参数是否为空指针
    CHECK_RET(CheckNotNull(start, end, step, out), ACLNN_ERR_INNER_NULLPTR);   // ← 应为 ACLNN_ERR_PARAM_NULLPTR

    // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验
    CHECK_RET(CheckDtypeValid(start, end, step, out), ACLNN_ERR_PARAM_INVALID);

    // 3. 检查输入的数据的值是否合理
    CHECK_RET(CheckParamsLogic(start, end, step, out) == ACLNN_SUCCESS, ACLNN_ERR_PARAM_INVALID);
    return ACLNN_SUCCESS;
}

CheckNotNull 的返回值被透传成 ACLNN_ERR_INNER_NULLPTR(561103),与资料声明的 161001 不符。同仓 aclnn_arange.cpp:167 是同一写法,属同族共性问题。

环境

  • Atlas A2 训练系列产品(910B2),CANN 9.2.0
  • 仓库 cann/ops-math,master 1b415030
  • 头文件 /usr/local/Ascend/ascend-toolkit/latest/include/aclnnop/aclnn_range.h(9.2.0 发布件)

复现步骤

  1. source $ASCEND_HOME_PATH/set_env.sh,确认 ASCEND_OPP_PATH=$ASCEND_HOME_PATH/opp。
  2. g++ -std=c++17 -O2 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -I$ASCEND_HOME_PATH/include/aclnnop -L$ASCEND_HOME_PATH/lib64 -Wl,--allow-shlib-undefined -lascendcl -lopapi -lnnopbase
  3. 选一张 Health=OK 的卡(Health=Alarm 的 die 上 aclrtSetDevice 会永久挂死):PROBE_DEV=<n> ./repro start(再依次 end/step/out)
  4. 四组输出全部为 phase1=561103。

实测输出:

==== aclnnRange 空指针错误码 ====
[start] phase1=561103 (expect 161001 per doc)
[end]   phase1=561103 (expect 161001 per doc)
[step]  phase1=561103 (expect 161001 per doc)
[out]   phase1=561103 (expect 161001 per doc)

复现脚本

完整脚本见附件 aclnnRange_repro.cpp(d1 模式跑四组)。核心:

aclScalar* ps  = (which == "start") ? nullptr : s;
aclScalar* pe  = (which == "end")   ? nullptr : e;
aclScalar* pst = (which == "step")  ? nullptr : p;
aclTensor* po  = (which == "out")   ? nullptr : out;
uint64_t ws = 0;
aclOpExecutor* ex = nullptr;
aclnnStatus r1 = aclnnRangeGetWorkspaceSize(ps, pe, pst, po, &ws, &ex);
printf("[%s] phase1=%d (expect 161001 per doc)\n", which.c_str(), (int)r1);
likedislike
liuhanwen8liuhanwen8
20 days ago Added label: bug-report
陈思
陈思Collaborators
20 days ago Comments:

您好,核对 ae087b184,CheckParams 的参数判空失败仍返回 ACLNN_ERR_INNER_NULLPTR;而 错误码表 声明 start/end/step/out 为空应返回 ACLNN_ERR_PARAM_NULLPTR。四个参数共用这一检查,因此源码与您给出的 561103 现象一致。

建议将用户参数判空的返回码与文档约定对齐,保留真正内部对象创建失败的错误码,并对四个空参数及合法基线分别回归。此项发生在前端检查,不需要等待 kernel 根因调查;本轮未执行设备测试或修改代码。

likedislike
陈思陈思Collaborators
20 days ago Assign chen_0715 as responsible person
陈思陈思Collaborators
20 days ago Added label: pending-confirmation
陈思陈思Collaborators
20 days ago Removed label: pending-confirmation
CchenyifengCollaborators
20 days ago Assign VoyageZhou as responsible person
CchenyifengCollaborators
20 days ago Removed responsible person chen_0715
fitZepHYrfitZepHYrCollaborators
19 days ago Associated pull request
fitZepHYr
fitZepHYrCollaborators
19 days ago Comments:

已确认问题属实:aclnnRange 的 CheckParams 把 CheckNotNull 的失败返回透传成了 ACLNN_ERR_INNER_NULLPTR(561103),与资料声明的 161001 不符,start/end/step/out 四处一致。

补充一点:同族接口 aclnnArange 已在 upstream commit e8c3c219b(issue #2501)中修正为 ACLNN_ERR_PARAM_NULLPTR,实测安装包中 aclnnArange 已返回 161001;本次是 aclnnRange 的漏改。

修复:

  • math/range/op_api/aclnn_range.cpp 空指针校验失败返回码改为 ACLNN_ERR_PARAM_NULLPTR(一行,不改变校验逻辑、dtype 列表与执行流程);
  • 新增 aclnnRange_start/end/step/out_nullptr 四条 UT;
  • 资料已声明 161001,无需修改。

验证(A2 910B3 / CANN 9.3.0,新旧库对照):

  • start/end/step/out 置空:561103 → 161001;正常参数仍为 0;
  • bash build.sh -u --opapi --ops=range --soc=ascend910b:l2_range_test 6/6、l2_arange_test 2/2 PASSED。

兼容性:返回码由「内部对象为空」改为「参数为空」,与资料及仓库其它接口一致,内部空指针分支仍保留 561103。

PR:https://gitcode.com/cann/ops-math/merge_requests/6939

likedislike
CANN-robotCANN-robotCollaborators
6 days ago Close issue
CANN-robotCANN-robotCollaborators
6 days ago changed custom state from 进行中 to 已完成
CANN-robotCANN-robotCollaborators
6 days ago Added label: resolved