Merged
feat(foreach): 补充 ForeachCos/ForeachSinh/ForeachPowScalarAndTensor 的 GEIR 样例与 README 入口 #14557
feat(foreach): 补充 ForeachCos/ForeachSinh/ForeachPowScalarAndTensor 的 GEIR 样例与 README 入口 #14557
Merged
yefeicodingAdd on 5 days ago
yefeicoding
yefeicodingCollaborators
5 days ago

描述

三个算子的图模式注册(op_graph/*_proto.h 的 REG_OP)与图模式 shape/dtype 推导(共享 foreach_utils/op_host/foreach_infershape.cpp 或算子自带 infershape)已具备,但缺少可运行的 GEIR 样例,README 的图模式行仍是占位 -。本 PR 补齐这两项:

  • 新增 GEIR 样例(参照 foreach_addcmul_list 的实现方式,用 NamedIoNodeBuilder 按 IR 定义顺序构图,避免旧 Operator 序列化按端口名排序导致实例表错位):
    • foreach/foreach_cos/examples/test_geir_foreach_cos.cpp:2 个动态 x 实例(float32,值 1.0)→ 2 个动态 y 实例,RunGraph 后打印输出张量数与 y[0][0];
    • foreach/foreach_sinh/examples/test_geir_foreach_sinh.cpp:结构同上;
    • foreach/foreach_pow_scalar_and_tensor/examples/test_geir_foreach_pow_scalar_and_tensor.cpp:IR 为 INPUT(scalar) + DYNAMIC_INPUT(x),样例按此顺序先建 scalar(shape {1},值 2.0)再建 2 个动态 x 实例,输出期望 2^1 = 2。
  • README 入口:三个算子的 README.md / README_en.md 图模式行由 - 改为样例链接。

不涉及 kernel/tiling 改动,不影响算子行为。

关联的Issue

测试

  • 三个样例均以 g++ -c -std=c++17 对 CANN 9.2.0-beta.1 的 GE 头文件(graph/、ge/、op_graph/inc)编译通过,仅有仓库既有样例同样触发的 ge_error_codes.h 弃用告警。
  • 未上机运行:端到端运行需要 NPU 驱动库与已部署的自定义算子包,当前环境不具备;样例保留 RunGraph 结果打印便于上机核验。
  • 未改动 UT。

文档更新

  • foreach/foreach_cos/README.md、foreach/foreach_cos/README_en.md
  • foreach/foreach_sinh/README.md、foreach/foreach_sinh/README_en.md
  • foreach/foreach_pow_scalar_and_tensor/README.md、foreach/foreach_pow_scalar_and_tensor/README_en.md

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for yefeicoding's contribution.)
yefeicodingyefeicodingCollaborators
5 days ago Created pull request, commit 26498861
atomgit-bot
atomgit-bot
5 days ago Comments:

变更摘要

本 PR 为 ForeachCos、ForeachSinh、ForeachPowScalarAndTensor 三个算子补充可运行的 GEIR 图模式样例,并将对应 README.md / README_en.md 中图模式入口由占位 - 替换为样例链接。三个样例均在 examples/ 下新增,参照 foreach_addcmul_list 的写法,使用 NamedIoNodeBuilder 按 IR 定义顺序构建节点,规避旧 Operator 序列化按端口名排序导致的动态实例表错位问题;不涉及 kernel/tiling 与算子行为变更。

主要改动

  • 新增 ForeachCos 图模式样例:foreach/foreach_cos/examples/test_geir_foreach_cos.cpp 通过 op::Data 与 MkF32 构造 2 个动态 x 实例({4}、DT_FLOAT、值 1.0),用 NamedIoNodeBuilder 依次 AddInput / AddOutput 并 Build,再以 AddDataEdge、SetOutputs 连边,最后 Session::RunGraph 执行并打印张量数与 y[0][0]。
  • 新增 ForeachSinh 图模式样例:foreach/foreach_sinh/examples/test_geir_foreach_sinh.cpp 结构与 ForeachCos 一致,同为一入多实例动态张量列表输入,输出期望 sinh(1.0)。
  • 新增 ForeachPowScalarAndTensor 图模式样例:foreach/foreach_pow_scalar_and_tensor/examples/test_geir_foreach_pow_scalar_and_tensor.cpp 按 IR 顺序先构建静态输入 scalar(shape {1}、值 2.0)再构建 2 个动态 x 实例,端口从 1 开始累加,输出期望 2^1 = 2。
  • 统一构图与执行流程:三个样例共用 GetTime 日志、MkF32 造数与 CreateOppInGraph 接口,main 中依次执行 GEInitialize、AddGraph、RunGraph、delete session 与 GEFinalize,并在失败路径返回 FAILED。
  • README 图模式入口更新:三个算子目录下的 README.md 与 README_en.md 将图模式行的 - 改为指向新增 GEIR 样例的链接,使文档入口与实际样例对应(该部分文件未提供补丁内容,依据 PR 描述与文件清单归纳)。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
5 days ago Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
5 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
5 days ago Comments:

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)
foreach ✅ 汤平川, 上官秦南 (2/2) ✅ 汤平川 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

yefeicoding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
5 days ago Set zengjuan,u010470851,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,gitee-duhuiping,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,gitcode-chenjiao,chenxingyu18,liujie12345678,east_yang,lwx1255555,pingchuantang,Chen_HaoWen,qianzehong,fengying555682,caiwenwen,yanglu-1 as approver
CANN-robotCANN-robotCollaborators
5 days ago Set u010470851,kevin_huang1234,gitee-duhuiping,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,wang-xing001,gitcode-chenjiao,chenxingyu18,liujie12345678,east_yang,lwx1255555,pingchuantang,Chen_HaoWen,qianzehong,fengying555682,caiwenwen,yanglu-1 as approver
yefeicodingyefeicodingCollaborators
5 days ago Associated issue: [Requirement|需求建议]: 补充 ForeachCos/ForeachSinh/ForeachPowScalarAndTensor 的 GEIR 样例与 README 图模式入口
yefeicodingyefeicodingCollaborators
5 days ago Modify description of pull request
yefeicoding
yefeicodingCollaborators
5 days ago Comments:

/compile

likedislike
yefeicodingyefeicodingCollaborators
5 days ago Pre merge succeeded (commit_id: dcc2dc3cd17012415f7b0e5cbcfe16380a5cd302)
CANN-robot
CANN-robotCollaborators
5 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
5 days ago Added label: ci-pipeline-running
yefeicoding
yefeicodingCollaborators
5 days ago Comments:
likedislike
TangPC
TangPCCollaborators
5 days ago Comments:

请添加 ci-pipeline-passed 标签

likedislike
CANN-robotCANN-robotCollaborators
5 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
5 days ago Added label: ci-pipeline-passed
yefeicoding
yefeicodingCollaborators
5 days ago Comments:
likedislike
TangPC
TangPCCollaborators
5 days ago Comments:

/lgtm
/approve

likedislike
yuning_chen
yuning_chenCollaborators
5 days ago Comments:
sgqt12
sgqt12Collaborators
5 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
5 days ago Added label: lgtm
gitee-duhuiping
gitee-duhuipingCollaborators
5 days ago Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
5 days ago Added label: approved
CANN-robotCANN-robotCollaborators
5 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
5 days ago Merged pull request