Pull Request has been successfully merged by CANN-robot.
(Thank you for wenqi_wu's contribution.)变更摘要
本 PR 针对社区对 aclnnForeachDivList 提出的问题单完成闭环,核心是将其 out 约束恢复为文档原始契约:out 的 shape size 应大于等于入参 x1 的 shape size,而不再要求逐元素完全相等。对应地在 op_api 参数校验与 arch35 tiling 两条路径上同步放宽校验方向,并补充 op_api UT 与 arch35 tiling UT 用例守护新口径,同时在报错信息与错误码上报上做对齐。此外按 PR 描述还包含 tests/ut/op_host/op_api/ 的构建挂载与 docs/aclnnForeachDivList.md 的文档更新。
主要改动
- op_api 放宽 out shape 校验:
aclnn_foreach_div_list.cpp中CheckShape将原来的OP_CHECK_SHAPE_NOT_EQUAL逐元素完全相等校验替换为按元素数比较,仅当outSize < x1Size时判定失败,允许 out 元素数大于 x1 或同元素数异 shape。 - out 维度上限与错误码上报: 同一函数中新增对
(*out)[i]的OP_CHECK_MAX_DIM维度检查(最多 8 维),失配时通过OP_LOGE_WITHOUT_REPORT与REPORT_PREDEFINED_ERR_MSG("EZ0015")携带param_name/op_name/incorrect_size/reason上报参数错误。 - arch35 tiling 校验方向对齐:
foreach_div_list_tiling.cpp的CheckTensorListInfo将 out 与 x1 的 shape size 比较由!=改为<,错误日志改为输出实际的 out 与 x1 元素数,与公共ForeachCommonTiling同族算子口径保持一致。 - arch35 tiling UT 补充正负例:
test_foreach_div_list_tiling.cpp新增RunTilingOutShapeCase辅助函数,并新增 out 元素数更大(GRAPH_SUCCESS)与更小(GRAPH_FAILED)两个用例。 - 新增 op_api UT 文件:
test_aclnn_foreach_div_list.cpp新增 8 个用例,覆盖基线、out 更大、同 numel 异 shape、out 更小、out 列表双向失配、x2 shape 失配与不支持 dtype,统一断言ACLNN_ERR_PARAM_INVALID,兼作 #35/#36 的错误码口径守护。
🧩 本次 Review 已使用自定义 Skill:




Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| */*/README.md | ✅ 王星, 汤平川, 陈娇 (3/2) | ✅ 陈娇 (1/1) |
| */*/docs/acl*.md | ✅ 陈娇, 王星, 汤平川 (3/2) | ✅ 陈娇 (1/1) |
| foreach | ✅ 王星, 汤平川 (2/2) | ✅ 王星, 汤平川 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
wenqi_wu, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@qianzehong @east_yang @fengying555682 @fanqirui @caiwenwen @yanglu-1 @gitcode-chenjiao @gitee-duhuiping @chaotang233 @wang-xing001 @wangrui_ @chenxingyu18 @zhajianqing123 @renruhai


out 的校验从 shape 一致放宽成只比 shape size 之后,shape 本身就不再受约束了。
- 现在代码看来原来的 OP_CHECK_SHAPE_NOT_EQUAL 被整体替换成只比较 outSize 与 x1Size 的大小关系,tiling 侧的 CheckTensorListInfo 同样只比较 GetShapeSize()。
- 可能存在有 out 的 shape 与 x1 不一致却能通过校验的问题,例如 x1 是 [2, 3] 而 out 传成 [6] 或 [3, 2],算子按元素数写满 out,返回给用户的张量 shape 与文档里"shape 与入参 x1 一致"的约定不符。
- 建议可以在放宽 size 约束的同时补一条 shape 相等的校验,只把 storage shape size 放宽为大于等于,这样与 README 的描述保持一致。


/lgtm
/approve


/approve


感谢指出 README 与 aclnn 文档的矛盾——确认属实:本 PR 原只更新了 docs/aclnnForeachDivList.md 的 out 行,漏改了 README.md 的 y 行,已在 commit 618e26a24 补齐(README y 行同步为"shape size大于等于入参x1的shape size"),两份文档现已一致。
关于"补 shape 相等校验、仅放宽 storage shape size"的建议,说明保留"元素数大于等于"口径的两点依据,请评审权衡:
- 社区问题单 #37 的原始诉求即此口径:其 PROBE-001(out=(2,4) vs x1=(2,3),numel 8≥6)、PROBE-002((3,2) 同 numel 异 shape)、PROBE-003((6,) 同 numel 降维)三例均明确要求按文档"shape size 大于等于"放行;若收紧为 shape 相等,三例将重新被 161002 拒绝,等于推翻问题单诉求。
- 族内一致性与公共实现口径:同族 ForeachAddcdivScalar 已合入的 PR#13111 为同款行为(op_api 与 arch35 tiling 均为元素数 ≥,其对应社区问题单 #7 与本单同源、同文档模板措辞);且 arch22/910B 路径走公共
ForeachCommonTiling,其输出校验本就是"仅 src 元素数 > dst 才拒、允许异 shape"(foreach_tiling_class.h),本 PR 恰是使 arch35 与公共口径对齐。补一条说明:ForeachAddcdivScalar 的 README 存在同样的历史行文(PR#13111 亦只改了 aclnn 文档),将另提纯文档 PR 对齐,保持族内两份文档一致。
行为正确性方面:真机(Ascend950PR)探针已验证 out=(2,4)/(3,2)/(6,) 执行成功且逐元素数值正确、out 尾部不被越界改写(x1 元素数写入语义),op_api UT 8 例与 arch35 tiling UT 5 例看护该口径(commit 618e26a24)。
如您仍认为契约应收紧为"out shape 与 x1 一致",建议作为族级契约决策统一裁决(届时 ForeachAddcdivScalar/ForeachDivList 的 op_api+tiling 及已发布文档需一并调整),我可以在本 PR 或后续 PR 按裁决方向实施,请示下。


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm
/approve


/lgtm
/approve


您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@wang-xing001 @pingchuantang @caiwenwen @yanglu-1 @gitcode-chenjiao @gitee-duhuiping @fengying555682


/approve


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


已确认并处理:参数说明表为 raw HTML
描述
针对社区对
aclnnForeachDivList提出的 3 个问题单(wangyueting/changwei_jiaoyiming #35/#36/#37)完成闭环:CheckShape的 out 校验由逐元素完全相等放宽为 out 元素数 ≥ x1(并补 out rank≤8,EZ0015 注册错误码上报);arch35 tiling 由"元素数相等"改为 ">="(对齐公共ForeachCommonTiling与 foreach_abs / ForeachAddcdivScalar(PR#13111) 同族口径);文档 out 行恢复"shape size大于等于"。测试补强:
tests/ut/op_host/op_api/构建挂载(父级 CMakeLists 补 add_subdirectory 循环与 OP_API_UT 注册);关联的Issue
测试
bash build.sh -u --ops=foreach_div_list -j64全绿(arch22 tiling 2/2 + op_api 8/8(新增) + kernel 3/3);--soc=ascend950全绿(arch35 tiling 5/5,含新增 2 例 + op_api 8/8)--pkg --soc=ascend950出包并隔离安装文档更新
docs/aclnnForeachDivList.md:out 行恢复"shape size大于等于入参x1的shape size";错误码表 shape 行补注(含 out shape size 小于 x1)类型标签
AI/Agent生成声明