Pull Request已成功合入, 合并人@CANN-robot
(感谢 tramp-ll 的贡献)变更摘要
此 PR 主要修复了 foreach 系列算子示例代码中调用 aclrtMemcpy 后未检查返回值的规范性问题。在所有受影响的示例文件中,对每次 aclrtMemcpy 调用后增加了 CHECK_RET 宏判断,确保设备到主机的内存拷贝失败时能够及时打印错误信息并返回错误码。此外,还清理了一处未使用的变量。
主要改动
- 统一增加
aclrtMemcpy返回值检查: 在 137 个foreach算子示例文件(涵盖foreach_abs、foreach_acos、foreach_add_list、foreach_add_scalar、foreach_mul_list、foreach_sin等全部算子变体)中,每个aclrtMemcpy调用后均新增了CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return ret);检查逻辑,确保 Device-to-Host 拷贝失败时能正确报错并终止程序。 - 清理未使用变量: 在
foreach/foreach_maximum_scalar/examples/test_aclnn_foreach_maximum_scalar.cpp中,移除了声明但未使用的局部变量float alphaValue = 5.2f;及其后续多余空行。


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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| */*/docs/acl*.md | ✅ 周文芳, 韩小龙, 杜慧萍, 陈娇 (4/2) | ✅ 杜慧萍, 陈娇 (2/1) |
| ** | ✅ 陈娇, 韩小龙 (2/2) | ✅ 陈娇, 韩小龙 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
tramp-ll, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [dd5b3b702deb44dc9ad44f3cc8d8d633][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-07-22 10:36:29] CI执行结束


流水线任务触发成功
任务链接 [a1a1d394271246c382b2360dc7da714d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| SCA | ✅ SUCCESS | >>>>> |
[2026-07-22 10:27:21] CI执行结束


/lgtm
/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


/lgtm
/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


/lgtm


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
查建青


描述
foreach 示例代码增加aclrtMemcpy返回值校验
关联的Issue
Issue: https://gitcode.com/cann/ops-nn/issues/4219
测试
编译通过
文档更新
更新foreach系列算子md资料
类型标签
AI/Agent生成声明