Pull Request has been successfully merged by CANN-robot.
(Thank you for yefeicoding's contribution.)变更摘要
本 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:




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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


/compile


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


请添加 ci-pipeline-passed 标签


/lgtm
/approve


您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@yourealize @kevin_huang1234 @lwx1255555 @yangyang016 @renruhai @gitee-duhuiping @fengying555682 @caiwenwen @yanglu-1 @chaotang233 @pingchuantang @zhajianqing123 @su-yueming @Chen_HaoWen @qianzehong @u010470851 @wang-xing001


/lgtm


/approve


描述
三个算子的图模式注册(
op_graph/*_proto.h的REG_OP)与图模式 shape/dtype 推导(共享foreach_utils/op_host/foreach_infershape.cpp或算子自带 infershape)已具备,但缺少可运行的 GEIR 样例,README 的图模式行仍是占位-。本 PR 补齐这两项: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.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弃用告警。RunGraph结果打印便于上机核验。文档更新
foreach/foreach_cos/README.md、foreach/foreach_cos/README_en.mdforeach/foreach_sinh/README.md、foreach/foreach_sinh/README_en.mdforeach/foreach_pow_scalar_and_tensor/README.md、foreach/foreach_pow_scalar_and_tensor/README_en.md类型标签
AI/Agent生成声明