Closed
[Documentation|文档反馈]: foreach 同族六接口对 out 的 Tensor 个数要求 3:3 不一致,且六份资料都只约束单块 shape #7936
liuhanwen8Add on 20 days agoClosed at 5 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
east_yang
20 days ago Comments:
20 days ago Comments:
/unassign @Tian_1122


20 days ago Removed responsible person Tian_1122
20 days ago Assign tramp-ll as responsible person
11 days ago Assign east_yang as responsible person, remove original responsible person: tramp-ll
11 days ago Assign east_yang as responsible person, remove original responsible person: tramp-ll
11 days ago Assign Tian_1122 as responsible person
11 days ago Removed responsible person east_yang
10 days ago Assign tramp-ll as responsible person
tramp-ll
10 days ago Comments:
10 days ago Comments:
目前均统一为out的tensor个数可以大于等于x的tensor个数


6 days ago Deleted associated pull request: fix(foreach): #8272资料补256披露、#8677/#8679/#8680/#8681四个ScalarList转手写支持非连续输出
6 days ago Deleted associated pull request: fix(foreach): #8272资料补256披露、#8677/#8679/#8680/#8681四个ScalarList转手写支持非连续输出
yuning_chen
6 days ago Comments:
6 days ago Comments:
问题成立。空 Tensor 场景被误拒或跳过校验。建议:①numel()==0 且 shape 合法时放行并短路;②错误码统一 ACLNN_ERR_PARAM_INVALID;③补 N=0/H·W=0 UT。
本条要点:关联:7929(同为 foreach 的 out 块数资料缺失;本条差异:7929 只说 AddScalar 的 561002 段缺子项,本条是同族六接口要求不一致 + 六份资料都只约束单块 shape)


tramp-ll
5 days ago Comments:
5 days ago Comments:
5 days ago changed custom state from 进行中 to 已完成
5 days ago Close issue
5 days ago Deleted associated pull request: fix(foreach): #8272资料补256披露、#8677/#8679/#8680/#8681四个ScalarList转手写支持非连续输出
5 days ago Deleted associated pull request: fix(foreach): #8272资料补256披露、#8677/#8679/#8680/#8681四个ScalarList转手写支持非连续输出
4 days ago Added label: resolved
关联:#7929(同为 foreach 的 out 块数资料缺失;本条差异:#7929 只说 AddScalar 的 561002 段缺子项,本条是同族六接口要求不一致 + 六份资料都只约束单块 shape)
现象
Atlas A2(910B3)上,按六份资料的
out行构造(x1 块、out2 块,每块 shape 与x相同,满足资料「shape size 大于等于入参
x的 shape size」),第一段返回分成两派:out=1out=2即同族、同硬件、同 CANN 版本,
out块数要求 3:3 分裂;六份资料的out行措辞完全一致(只有「支持空Tensor / 所有Tensor dtype 一致 / shape size 大于等于入参
x的 shape size」),没有任何一份说明
out的 Tensor 个数该等于什么。环境
设备 Atlas A2(910B3)单卡;CANN 9.2.0;仓
cann/ops-nnmasterb27fda24754e161dc8f489e5e0024f55ccdc69bd期望
六份资料的
out行统一补「out含多少个 Tensor」并统一实现口径:若「必须相等」,三个放行接口补校验;若「可多传」(与 #7740 一致),三个拒绝接口放开。
应得值依据
out行原文中shape size指单个 Tensor 的元素数。按这句构造(每块与
x同形、只多给一块)不违反任何一句,却有一半接口被拒。out都是aclTensorList*、资料措辞逐字相同,没有理由一半要
==、一半不要。这是族内自相矛盾,不依赖外部契约即可判定「至少有一半不符合应有行为」。可行性:
OP_CHECK_TENSORLIST_SIZE_EQUAL已在三个接口用了,host 侧取块数无成本。复现步骤
repro.cpp存盘,按块首注释编译;运行./repro得缺 out 上界校验: 3 / 6。out(aclTensorList*),确认每份都只写「shape size 大于等于入参x的shape size」;全文
Tensor个数只在aclnnForeachAddScalarV2.md的npu="950"段出现。复现脚本
实测输出(910B3 / CANN 9.2.0):
// g++ -std=c++17 -O1 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lopapi -lnnopbase -lascendcl #include <cstdio> #include <vector> #include "acl/acl.h" #include "aclnn/acl_meta.h" #include "aclnnop/aclnn_foreach_addcdiv_list.h" #include "aclnnop/aclnn_foreach_add_scalar_list.h" #include "aclnnop/aclnn_foreach_add_scalar_v2.h" #include "aclnnop/aclnn_foreach_addcdiv_scalar.h" #include "aclnnop/aclnn_foreach_addcdiv_scalar_list.h" #include "aclnnop/aclnn_foreach_addcdiv_scalar_v2.h" static aclTensor* mk(void* p, std::vector<int64_t> d) { std::vector<int64_t> st(d.size(), 1); for (int i = (int)d.size() - 2; i >= 0; --i) st[i] = st[i + 1] * d[i + 1]; return aclCreateTensor(d.data(), d.size(), ACL_FLOAT, st.data(), 0, ACL_FORMAT_ND, d.data(), d.size(), p); } int main() { aclInit(nullptr); aclrtSetDevice(0); const int64_t N = 8; const size_t B = N * 4; void *a=nullptr,*b=nullptr,*c=nullptr,*o1=nullptr,*o2=nullptr; for (void** q : {&a,&b,&c,&o1,&o2}) aclrtMalloc(q, B, ACL_MEM_MALLOC_HUGE_FIRST); std::vector<float> h(N, 1.5f); for (void* q : {a,b,c,o1,o2}) aclrtMemcpy(q, B, h.data(), B, ACL_MEMCPY_HOST_TO_DEVICE); std::vector<int64_t> d{N}; aclTensor *ta=mk(a,d),*tb=mk(b,d),*tc=mk(c,d),*to1=mk(o1,d),*to2=mk(o2,d),*scT=mk(o1,{1}); float sv = 2.0f; aclScalar *sc = aclCreateScalar(&sv, ACL_FLOAT), *sa[1] = {sc}; aclScalarList* SL = aclCreateScalarList(sa, 1); std::vector<aclTensor*> vx{ta},vy{tb},vz{tc},v1{to1},v2{to1,to2}; aclTensorList *LX=aclCreateTensorList(vx.data(),1),*LY=aclCreateTensorList(vy.data(),1); aclTensorList *LZ=aclCreateTensorList(vz.data(),1); aclTensorList *outs[2] = {aclCreateTensorList(v1.data(),1), aclCreateTensorList(v2.data(),2)}; const char* nm[] = {"AddcdivList","AddScalarList","AddScalarV2","AddcdivScalar","AddcdivScalarList","AddcdivScalarV2"}; int miss = 0; printf("interface out=1 out=2 verdict\n"); for (int k = 0; k < 6; ++k) { int r[2]; for (int j = 0; j < 2; ++j) { uint64_t w = 0; aclOpExecutor* e = nullptr; aclTensorList* o = outs[j]; if (k == 0) r[j] = (int)aclnnForeachAddcdivListGetWorkspaceSize(LX,LY,LZ,scT,o,&w,&e); else if (k == 1) r[j] = (int)aclnnForeachAddScalarListGetWorkspaceSize(LX,SL,o,&w,&e); else if (k == 2) r[j] = (int)aclnnForeachAddScalarV2GetWorkspaceSize(LX,sc,o,&w,&e); else if (k == 3) r[j] = (int)aclnnForeachAddcdivScalarGetWorkspaceSize(LX,LY,LZ,scT,o,&w,&e); else if (k == 4) r[j] = (int)aclnnForeachAddcdivScalarListGetWorkspaceSize(LX,LY,LZ,scT,o,&w,&e); else r[j] = (int)aclnnForeachAddcdivScalarV2GetWorkspaceSize(LX,LY,LZ,sc,o,&w,&e); } if (r[1] == 0) ++miss; printf("%-22s %-7d %-7d %s\n", nm[k], r[0], r[1], r[1] == 0 ? "**MISSING CHECK**" : "rejected"); } printf("缺 out 上界校验: %d / 6\n", miss); return 0; }影响
out每块与x同形、多留一块备用 buffer」时,三个接口报错(161001/161002)、另三个静默放行;报错文案没有一句指向「块数」,排查会落在 shape/dtype。
out块不会被写入(预填哨兵后保持哨兵值、接口仍返回 0),调用方若以为已填充会读到未初始化数据。按 #7740 需放开三个拒绝接口,否则另三个补
==。建议
out行统一补「out含多少个 Tensor」:明确是「必须等于x」还是「可大于等于」。OP_CHECK_TENSORLIST_SIZE_EQUAL;若「可大于等于」→三个拒绝接口放开并说明多出的块是否 no-op(不写)。
out的 Tensor 个数不满足约束」子项。