Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhang-song-rui 的贡献)变更摘要
此 PR 统一修正了 math 模块下 29 个示例代码文件中 CHECK_RET 宏的调用格式,移除了宏第二个参数中 return ret 语句末尾多余的分号(;),使代码风格符合 CHECK_RET 宏的规范用法。
主要改动
- 规范
CHECK_RET宏调用格式:在bitwise_and、bitwise_or、bitwise_xor、greater、mod、select、tanh_grad等多个算子的示例代码中,将CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT(...); return ret;);统一修正为CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT(...); return ret);,去除了return ret后多余的独立分号。 - 涉及 29 个文件的一致性修改:所有受影响的文件均为各算子
examples/目录下的test_aclnn_*.cpp示例文件,改动模式完全相同,均为工作空间分配失败时的错误处理分支中的CHECK_RET调用。


代码审查
现在让我完成最后的梳理(Section X-pre),检查是否有遗漏的共址次要缺陷或其他问题……所有变更均已审核。while(0) → while (0) 变更纯粹是格式调整,无语法影响。核心问题 — CHECK_RET 尾随分号移除 — 已报告。
审查总结
| 优先级 | 数量 | 说明 |
|---|---|---|
| P0 | 1 | CHECK_RET(...) 宏调用移除尾随分号,导致 do { ... } while (0) 语法错误,涉及 24 个文件 |
逐文件审查结果
| 文件 | 结论 |
|---|---|
math/bitwise_and/docs/aclnnBitwiseAndTensor.md |
⚠️ P0 — CHECK_RET 尾随分号移除 |
math/bitwise_and/docs/aclnnBitwiseAndTensorOut&aclnnInplaceBitwiseAndTensorOut.md |
⚠️ P0 — 同上 |
math/bitwise_and/docs/aclnnInplaceBitwiseAndScalar.md |
⚠️ P0 — 同上 |
math/bitwise_and/docs/aclnnInplaceBitwiseAndTensor.md |
⚠️ P0 — 同上 |
math/bitwise_and/examples/test_aclnn_bitwise_and_tensor.cpp |
⚠️ P0 — 同上(锚定文件) |
math/bitwise_or/docs/aclnnBitwiseOrTensor&aclnnInplaceBitwiseOrTensor.md |
⚠️ P0 — 同上 |
math/bitwise_or/examples/test_aclnn_bitwise_or_tensor.cpp |
⚠️ P0 — 同上 |
math/bitwise_or/examples/test_aclnn_inplace_bitwise_or_tensor.cpp |
⚠️ P0 — 同上 |
math/bitwise_xor/docs/aclnnBitwiseXorTensor&aclnnInplaceBitwiseXorTensor.md |
⚠️ P0 — 同上 |
math/bitwise_xor/examples/test_aclnn_bitwise_xor_tensor.cpp |
⚠️ P0 — 同上 |
math/bitwise_xor/examples/test_aclnn_inplace_bitwise_xor_tensor.cpp |
⚠️ P0 — 同上 |
math/gcd/docs/aclnnGcd.md |
✅ 无问题(仅 while(0) → while (0) 格式调整) |
math/greater/docs/aclnnGtTensor&aclnnInplaceGtTensor.md |
⚠️ P0 — CHECK_RET 尾随分号移除 |
math/greater/examples/test_aclnn_gt_tensor.cpp |
⚠️ P0 — 同上 |
math/greater/examples/test_aclnn_inplace_gt_tensor.cpp |
⚠️ P0 — 同上 |
math/greater_equal/docs/aclnnGeTensor&aclnnInplaceGeTensor.md |
⚠️ P0 — 同上 |
math/less/docs/aclnnLtScalar&aclnnInplaceLtScalar.md |
✅ 无问题(仅 while(0) → while (0) 格式调整) |
math/less/docs/aclnnLtTensor&aclnnInplaceLtTensor.md |
✅ 无问题(仅 while(0) → while (0) 格式调整) |
math/less_equal/docs/aclnnLeScalar&aclnnInplaceLeScalar.md |
✅ 无问题(仅 while(0) → while (0) 格式调整) |
math/less_equal/docs/aclnnLeTensor&aclnnInplaceLeTensor.md |
✅ 无问题(仅 while(0) → while (0) 格式调整) |
math/mod/docs/aclnnFmodScalar&aclnnInplaceFmodScalar.md |
⚠️ P0 — CHECK_RET 尾随分号移除 |
math/mod/docs/aclnnFmodTensor&aclnnInplaceFmodTensor.md |
⚠️ P0 — 同上 |
math/mod/examples/test_aclnn_fmod_scalar.cpp |
⚠️ P0 — 同上 |
math/mod/examples/test_aclnn_fmod_tensor.cpp |
⚠️ P0 — 同上 |
math/select/docs/aclnnSWhere.md |
⚠️ P0 — 同上 |
math/select/examples/test_aclnn_s_where.cpp |
⚠️ P0 — 同上 |
math/sub/docs/aclnnRsub.md |
⚠️ P0 — 同上 |
math/tanh_grad/docs/aclnnTanhBackward.md |
⚠️ P0 — 同上 |
math/tanh_grad/examples/test_aclnn_tanh_backward.cpp |
⚠️ P0 — 同上 |
整体风险评估
高风险。 此 DIFF 在 24 个文件中移除了 CHECK_RET(...) 宏调用的尾随分号。由于 CHECK_RET 展开为 do { ... } while (0) 惯用法,缺少尾随分号会导致 C/C++ 语法错误,直接影响 .cpp 测试文件的编译以及 .md 文档中示例代码的正确性。建议回退所有移除尾随分号的更改,或改用正确的修复方式(移除宏参数 return ret; 中的分号,保留宏调用末尾的分号)。while(0) → while (0) 的 5 个文件为纯粹的空白格式调整,无风险。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


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 | ✅ 陈娇, wangrui_, 张磊 (3/2) | ✅ 陈娇 (1/1) |
| math/bitwise_and | ✅ 宋恺, wangrui_, 张磊, 王林木 (4/2) | ✅ 王林木, 宋恺, wangrui_, 张磊 (4/1) |
| math/bitwise_or | ✅ 宋恺, wangrui_, 张磊, 王林木 (4/2) | ✅ 宋恺, wangrui_, 张磊, 王林木 (4/1) |
| math/bitwise_xor | ✅ 王林木, 宋恺, wangrui_, 张磊 (4/2) | ✅ 王林木, 宋恺, wangrui_, 张磊 (4/1) |
| math/greater | ✅ 宋恺, wangrui_, 张磊, 王林木 (4/2) | ✅ 王林木, 宋恺, wangrui_, 张磊 (4/1) |
| math/mod | ✅ 宋恺, wangrui_, 张磊, 王林木 (4/2) | ✅ 王林木, 宋恺, wangrui_, 张磊 (4/1) |
| math/select | ✅ 张磊, 王林木, 宋恺, wangrui_ (4/2) | ✅ 张磊, 王林木, 宋恺, wangrui_ (4/1) |
| math/tanh_grad | ✅ wangrui_, 张磊, 王林木, 宋恺 (4/2) | ✅ wangrui_, 张磊, 王林木, 宋恺 (4/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhang-song-rui, thanks for your pull request. All authors of the commits have signed the CLA. 👍


描述
规范
math/目录下相关算子的示例代码格式,不涉及功能逻辑变更:CHECK_RET(..., return ret;);统一为CHECK_RET(..., return ret);,涉及 24 个文件、29 处。while(0)统一为while (0),涉及 less、less_equal、gcd 共 5 个文件、10 处。关联的Issue
https://gitcode.com/cann/ops-math/issues/2527
测试
文档更新
更新了 less、less_equal、gcd、not_equal 算子的示例文档格式;同时规范了相关算子文档及 examples 中的
CHECK_RET写法。类型标签