Closed
[Documentation|文档反馈]: [aclnnInplaceOne] 资料 dtype 表声明支持 UINT16,实现接口层白名单未列,实测第一段返回 161002 #4284
liuhanwen8Add on  21 days agoClosed at  1 day ago
liuhanwen8
liuhanwen8
21 days ago Create

一、文档链接(必填)

https://gitcode.com/cann/ops-math/blob/master/math/ones_like/docs/aclnnInplaceOne.md

  • 接口:aclnnInplaceOne(aclnn_ones.h)
  • 关联实现:math/ones_like/op_api/aclnn_ones.cpp、math/ones_like/op_kernel_aicpu/ones_like_aicpu.cpp、math/ones_like/op_host/ones_like_def.cpp

二、问题文档片段(必填)

片段 1(第 78 行,dtype 支持列) —— 逐字复制:

      <td>FLOAT、FLOAT16、DOUBLE、INT8、INT16、INT32、INT64、UINT8、UINT16、BOOL、BFLOAT16</td>

片段 2(第 133-136 行,161002 错误码子项) —— 逐字复制:

      <td>ACLNN_ERR_PARAM_INVALID</td>
      <td>161002</td>
      <td>selfRef的数据类型不在支持范围之内。</td>

三、存在的问题

1. dtype 支持表与实现不一致(UINT16)

资料第 78 行声明 11 项 dtype,其中含 UINT16。但接口层白名单没有它:

math/ones_like/op_api/aclnn_ones.cpp 的 ASCEND910B_DTYPE_SUPPORT_LIST(10 项,无 DT_UINT16):

static const std::initializer_list<op::DataType> ASCEND910B_DTYPE_SUPPORT_LIST = {
    op::DataType::DT_FLOAT,  op::DataType::DT_FLOAT16, op::DataType::DT_INT8,  op::DataType::DT_INT16,
    op::DataType::DT_INT32,  op::DataType::DT_INT64,   op::DataType::DT_UINT8, op::DataType::DT_BOOL,
    op::DataType::DT_DOUBLE, op::DataType::DT_BF16};

而 math/ones_like/op_kernel_aicpu/ones_like_aicpu.cpp:60 确实实现了 uint16:

    case DT_UINT16:
      RangeOnesLike(start, end, static_cast<uint16_t *>(output_data));
      return KERNEL_STATUS_OK;

三方状态:资料说有、kernel 有实现、接口层不放行。

对照兄弟接口 aclnnInplaceZero,其接口层 math/zero_op/op_api/aclnn_zero.cpp:37-42 明确列了 DT_UINT16 并能正常执行 —— 说明本接口更可能是漏列,而不是产品限制。

2. 实测(Ascend 910B2 / CANN 9.2.0)

同一探针逐 dtype 跑 [4x4],初值填 0xAA:

fp32     rc1=0       rc2=0       good=16/16  first8=[00 00 80 3f ...]
fp16     rc1=0       rc2=0       good=16/16  first8=[00 3c 00 3c ...]
bf16     rc1=0       rc2=0       good=16/16  first8=[80 3f 80 3f ...]
fp64     rc1=0       rc2=0       good=16/16  first8=[00 00 00 00 00 00 f0 3f ...]
int8     rc1=0       rc2=0       good=16/16  first8=[01 01 01 01 ...]
uint8    rc1=0       rc2=0       good=16/16  first8=[01 01 01 01 ...]
int16    rc1=0       rc2=0       good=16/16  first8=[01 00 01 00 ...]
uint16   rc1=161002  (rejected)
int32    rc1=0       rc2=0       good=16/16  first8=[01 00 00 00 ...]
int64    rc1=0       rc2=0       good=16/16  first8=[01 00 00 00 00 00 00 00 ...]
bool     rc1=0       rc2=0       good=16/16  first8=[01 01 01 01 ...]

uint16 在第一段即返回 161002(ACLNN_ERR_PARAM_INVALID),算子未执行。精度线另在 16 条 uint16 用例上复现同一现象(10 条 FS 类 + 6 条 NV 类),确定性线三条开关腿结论一致。

3. 错误码表未覆盖 rank 越界

资料同表声明维度 0-8,实测 rank=9..16 全部返回 161002(实现有 OP_CHECK_MAX_DIM),但第 133-136 行的 161002 只挂了 dtype 一条子项,未给出维度越界的说明。仓内另一份资料 experimental/math/ones_like/docs/aclnnInplaceOne.md:116 反而列了该子项 —— 两份资料对同一错误码的覆盖面不一致。

4. 建议

二选一:

  • 若产品确实支持 uint16:把 DT_UINT16 补进 ASCEND910B_DTYPE_SUPPORT_LIST;
  • 若不支持:从第 78 行 dtype 列删除 UINT16,并在 161002 下补「维度超过 8 维」子项;同时统一 experimental/ 副本的 dtype 列(该副本现写 7 项,与 ones_like_def.cpp 的 OpDef 一致,与主档不一致)。

复现脚本

import os, re, subprocess, sys
REPO = os.environ["REPO_ROOT"]
DOC = os.path.join(REPO, "math/ones_like/docs/aclnnInplaceOne.md")
IMPL = os.path.join(REPO, "math/ones_like/op_api/aclnn_ones.cpp")
KERNEL = os.path.join(REPO, "math/ones_like/op_kernel_aicpu/ones_like_aicpu.cpp")
declared = re.search(r"<td>([A-Z0-9、]+)</td>\s*\n\s*<td>ND</td>",
                     open(DOC, encoding="utf-8").read()).group(1)
src = open(IMPL, encoding="utf-8").read()
i = src.find("ASCEND910B_DTYPE_SUPPORT_LIST")
print("doc 含 UINT16 :", "UINT16" in declared)
print("impl 含 DT_UINT16 :", "DT_UINT16" in src[i:i+400])
print("kernel 有 case DT_UINT16 :", "case DT_UINT16" in open(KERNEL, encoding="utf-8").read())
if "UINT16" in declared and "DT_UINT16" not in src[i:i+400]:
    print("[DEFECT] 资料声明 UINT16 但接口层白名单未列"); sys.exit(1)
sys.exit(0)
likedislike
liuhanwen8liuhanwen8
21 days ago Added label: documentation
陈思
陈思Collaborators
20 days ago Comments:

您好,感谢反馈!

问题分析

核查版本中,资料 dtype 列包含 UINT16,而 aclnn_ones.cpp 的两组接口白名单均未列 DT_UINT16,CheckDtypeValid 失败会在第一段返回 161002;AICPU kernel 则确有 case DT_UINT16。因此接口层与文档支持列表存在可核实的不一致,kernel 有该分支还不能单独证明整条产品调用路径已具备正式支持。另一个缺口也成立:接口有最大维度检查,但资料 161002 表目前只说明 dtype 不支持。

核查源码与资料为 cann/ops-math@8c1f633e3679f83b55a237c552f842cdcf80462f:math/ones_like/op_api/aclnn_ones.cpp、math/ones_like/op_kernel_aicpu/ones_like_aicpu.cpp、math/ones_like/docs/aclnnInplaceOne.md。

处理方向

一个可行方向是先确认 UINT16 的产品支持意图,再选择补接口白名单并验证整条调用链,或收敛文档支持面;两种选择都应同时补充最大维度报错说明。experimental 副本和主资料也需按各自适用实现与产品范围核对,避免仅机械统一列表。

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

已确认该问题属实,根因是 aclnnInplaceOne 接口层 dtype 白名单漏列 UINT16,而不是资料写错。

  • 资料 dtype 表(11 项)与实现栈一致:l0op 的 AICPU dtype 白名单、AICPU OpDef、kernel 的 case DT_UINT16 均包含 UINT16,A2 执行链路的 ViewCopy 也支持 UINT16;兄弟接口 aclnnInplaceZero 的白名单同样含 DT_UINT16。
  • math/ones_like/op_api/aclnn_ones.cpp 与 experimental/math/ones_like/op_api/aclnn_ones.cpp 的 ASCEND910_DTYPE_SUPPORT_LIST、ASCEND910B_DTYPE_SUPPORT_LIST 均缺少 DT_UINT16,导致第一段直接返回 161002。

修复方案(仅新增,不做删除):

  1. 两份白名单补入 DT_UINT16,并各补一条 UINT16 成功 UT;
  2. 按实测在 161002 下补充「selfRef 维度超过 8 维」子项(中英文资料);
  3. experimental 资料的 dtype 列与主档、实际接口对齐为 11 项。

验证(Atlas A2 910B3 / CANN 9.3.0):

  • 修改前 uint16 第一段返回 161002;修改后加载本仓新构建库,rc1=0 rc2=0,16/16 元素为 1;
  • 其余已声明 dtype(fp32/fp16/bf16/fp64/int8/uint8/int16/int32/int64/bool)行为不变,rank=9 仍返回 161002;
  • op_api UT:main 26/26、experimental 2/2 通过。

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

likedislike
fitZepHYrfitZepHYrCollaborators
17 days ago Removed responsible person VoyageZhou
fitZepHYrfitZepHYrCollaborators
17 days ago Assign m0_55003149 as responsible person
fitZepHYrfitZepHYrCollaborators
17 days ago Deleted associated pull request: fix(ones_like): 补充 aclnnInplaceOne UINT16 接口白名单并补齐资料错误码
fitZepHYrfitZepHYrCollaborators
17 days ago Associated pull request
fitZepHYrfitZepHYrCollaborators
17 days ago Deleted associated pull request: fix(ones_like): 补充 aclnnInplaceOne UINT16 接口白名单并补齐资料错误码
weike
weikeCollaborators
1 day ago Comments:

问题已在PR: https://gitcode.com/cann/ops-math/pull/7149/discuss 修复,在ASCEND910B_DTYPE_SUPPORT_LIST 白名单中增加uint16,CheckDtypeValid类型校验不再报错161002

likedislike
weikeweikeCollaborators
1 day ago changed custom state from 进行中 to 已完成
weikeweikeCollaborators
1 day ago Close issue