Closed
[Bug-Report|缺陷反馈]: aclnnForeachDivScalar 的 shape/rank 违规返回 161002,资料声明 561002 #7939
liuhanwen8Add on 20 days agoClosed at 17 days ago
20 days ago Added label: bug-report
east_yang
20 days ago Comments:
20 days ago Comments:
/assign @Tian_1122


20 days ago Assign Tian_1122 as responsible person
yuning_chen
19 days ago Comments:
19 days ago Comments:
初步分析
感谢反馈,我们已开始核对这个问题。
现象理解:缺陷反馈;aclnnForeachDivScalar 的 shape/rank 违规返回 161002,资料声明 561002。
当前判断:从描述看这是缺陷反馈「aclnnForeachDivScalar 的 shape/rank 违规返回 161002,资料声明 561002」。正文里出现报错信息(如 一句话结论:aclnnForeachDivScalar 在「x与out 的 shape 不满足约束」与「维度超过 8 维」两种场景下第一段返回 **161002**(ACLNN_ERR_PARAM_INVALID),而资料错误码表把这两条子项都列在 **561002**(ACLNN_ERR_IN…),更像实现或使用问题。以上为初步判断,待复现确认,不能当成已确认根因。 **涉及范围**:aclnnForeachDivScalar、aclnnForeachCos、aclnnop、aclnnForeachDivScalarGetWorkspaceSize、aclnn_foreach_cos、aclnn_foreach_div_scalar`
下一步:我们会继续对照代码/文档定位。
正文中的报错摘录:
一句话结论:aclnnForeachDivScalar在「x与out的 shape 不满足约束」与「维度超过 8 维」两种场景下第一段返回 **161002**(ACLNN_ERR_PARAM_INVALID),而资料错误码表把这两条子项都列在 **561002**(ACLNN_ERR_IN…`- 调用方按错误码分流时会走错分支:161002 被当作「参数非法(用户传错 dtype/shape)」,561002 被当作「内部 tiling 失败(ACLNN_ERR_INNER_TILING_ERROR,需报 CANN 侧问题)」。同一个「out形状写错」的用户错误被报成 tiling 内部错误,会…


yuning_chen
19 days ago Comments:
19 days ago Comments:
您好,该问题已收到,当前问题 @Tian_1122 正在处理中


18 days ago Associated pull request
17 days ago Close issue
17 days ago Added label: resolved
chenjiayi_
10 days ago Comments:
10 days ago Comments:
结论:资料与实现已在 PR#13610 中对齐,当前行为为 161002。
foreach/foreach_div_scalar/docs/aclnnForeachDivScalar.md:165-182:shape 约束与 8 维上限已归入ACLNN_ERR_PARAM_INVALID / 161002;561002子项当前只保留“scalar 元素个数为 1”的约束。foreach/foreach_div_scalar/op_host/op_api/aclnn_foreach_div_scalar.cpp:117-137:CheckShape用OP_CHECK_MAX_DIM与OP_CHECK_SHAPE_NOT_EQUAL拦截两类入参,CheckParams:140-151统一映射到ACLNN_ERR_PARAM_INVALID。
关联 PR 已合入,状态为已完成。如果还有后续需要,请重新提 issue。


9 days ago Assign chenjiayi_ as responsible person
9 days ago changed custom state from 进行中 to 已完成
1 day ago Removed responsible person chenjiayi_
现象
一句话结论:
aclnnForeachDivScalar在「x与out的 shape 不满足约束」与「维度超过 8 维」两种场景下第一段返回 161002(ACLNN_ERR_PARAM_INVALID),而资料错误码表把这两条子项都列在 561002(ACLNN_ERR_INNER_TILING_ERROR)下。与合法输入的对照(同一份复现程序,同一进程内先后执行):
x=fp32[2x3] scalar=fp32[1] out=fp32[2x3]x=fp32[1x2x3] scalar=fp32[1] out=fp32[2x3]x=fp32[1x1x1x1x1x1x1x1x3] out=fp32[1x1x1x1x1x1x1x1x3]期望
资料
docs/aclnnForeachDivScalar.md的「返回值 / 错误码表」原文:因此这两种入参应当返回 561002,而不是 161002。
仓库侧也能佐证码位应归属 561002:
foreach/foreach_cos/op_host/op_api/aclnn_foreach_cos.cpp与foreach/foreach_cosh/...的资料把同样的语义也写在 561002 下;本机 CANN 9.2.0 上aclnnForeachCos的 rank=9 用例实测返回 561002(error-scenario 判定 MATCH),而同族aclnnForeachDivScalar返回 161002 —— 同一份资料语义在兄弟接口上给了两个不同的码。环境
910B2),npu-smi 26.1.19.2.0,Linux aarch64,g++ 12.3.0cann/ops-nn7044c8328cfb3bb0a298034fd9c56f49aca0bbd7(2026-11-02git fetch后)复现步骤
repro.cppg++ -std=c++17 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -I$ASCEND_HOME_PATH/include/aclnnop -L$ASCEND_HOME_PATH/lib64 -lascendcl -lnnopbase -lopapi./repro[BASELINE]三段应为 0;[SHAPE]与[RANK9]的RET_GWS期望 561002,实测 161002复现脚本
#include <cstdio> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_foreach_div_scalar.h" static int64_t N(const std::vector<int64_t>& s){int64_t n=1;for(auto v:s)n*=v;return n;} static int Mk(const std::vector<int64_t>& sh,void** a,aclTensor** t){ size_t b=(size_t)N(sh)*sizeof(float); std::vector<float> h((size_t)N(sh),6.0f); if(aclrtMalloc(a,b,ACL_MEM_MALLOC_HUGE_FIRST)!=ACL_SUCCESS)return -1; aclrtMemcpy(*a,b,h.data(),b,ACL_MEMCPY_HOST_TO_DEVICE); std::vector<int64_t> st(sh.size(),1); for(int i=(int)sh.size()-2;i>=0;--i) st[i]=st[i+1]*sh[i+1]; *t=aclCreateTensor(sh.data(),sh.size(),ACL_FLOAT,st.data(),0,ACL_FORMAT_ND,sh.data(),sh.size(),*a); return *t?0:-1;} static void P(std::vector<int64_t> xs,std::vector<int64_t> os,const char* tag){ aclrtStream s=nullptr; aclInit(nullptr); aclrtSetDevice(0); aclrtCreateStream(&s); void *xa=nullptr,*oa=nullptr,*sa=nullptr; aclTensor *x=nullptr,*o=nullptr,*sc=nullptr; Mk(xs,&xa,&x); Mk(os,&oa,&o); Mk({1},&sa,&sc); aclTensor* xa2[1]={x}; aclTensor* oa2[1]={o}; aclTensorList* xl=aclCreateTensorList(xa2,1); aclTensorList* ol=aclCreateTensorList(oa2,1); uint64_t ws=0; aclOpExecutor* ex=nullptr; int r=aclnnForeachDivScalarGetWorkspaceSize(xl,sc,ol,&ws,&ex); printf("[%s] xRank=%zu RET_GWS=%d\n",tag,xs.size(),r); if(r==0){void* wp=nullptr; if(ws>0)aclrtMalloc(&wp,ws,ACL_MEM_MALLOC_HUGE_FIRST); int r2=aclnnForeachDivScalar(wp,ws,ex,s); printf("[%s] RET_EXEC=%d SYNC=%d\n",tag,r2,aclrtSynchronizeStream(s)); if(wp)aclrtFree(wp);} aclDestroyTensorList(xl); aclDestroyTensorList(ol); aclrtFree(xa); aclrtFree(oa); aclrtFree(sa); aclrtDestroyStream(s); aclrtResetDevice(0);} int main(){ P({2,3},{2,3},"BASELINE"); P({1,2,3},{2,3},"SHAPE"); P({1,1,1,1,1,1,1,1,3},{1,1,1,1,1,1,1,1,3},"RANK9"); aclFinalize(); return 0; }实测输出:
影响
ACLNN_ERR_INNER_TILING_ERROR,需报 CANN 侧问题)」。同一个「out形状写错」的用户错误被报成 tiling 内部错误,会把问题导向错误的处理路径(例如触发内部错误码上报/求助流程,而不是提示用户改 shape)。aclnnForeachCos/Cosh上实测是 561002,在aclnnForeachDivScalar上是 161002,用户无法用统一口径处理。建议
foreach/foreach_div_scalar/op_host/op_api/aclnn_foreach_div_scalar.cpp:150的CHECK_RET(CheckShape(self, out), ACLNN_ERR_PARAM_INVALID)与 CheckShape 内部的OP_CHECK_SHAPE_NOT_EQUAL失败路径改为返回ACLNN_ERR_INNER_TILING_ERROR(561002),并同步CheckDtypeValid中「列表内 dtype 不一致」子项(实测同族也有 161002/561002 混用)。Copy/Cos/Cosh/DivList/DivScalar/DivScalarList/DivScalarV2七个接口的「shape 违规」码位(当前DivList的资料本身就写 161002,与DivScalar写 561002 互相矛盾)。