Pull Request已成功合入, 合并人@CANN-robot
(感谢 chendunyang 的贡献)变更摘要
本 PR 将 math/xlog1py/examples 下的 aclnn 示例(test_aclnn_xlog1py.cpp)从手动资源管理改造为 C++ RAII 管理,与同仓 math/is_finite、math/is_inf 示例风格对齐:引入基于 std::unique_ptr 的智能指针统一管理 ACL stream、设备内存和 aclTensor 的生命周期,并在 main 中通过 lambda 守卫统一回收设备与 ACL 全局资源,同时删除了各函数中分散的显式释放代码。
主要改动
- 新增 RAII 类型别名:定义
StreamPtr、DeviceMemPtr、TensorPtr(均为std::unique_ptr,分别绑定aclrtDestroyStream、aclrtFree、aclDestroyTensor作为删除器),并包含<memory>、<type_traits>头文件。 - 改造
Init接口:签名由int Init(int32_t deviceId, aclrtStream* stream)改为接收StreamPtr&、bool& initialized、bool& deviceSet,在aclInit和aclrtSetDevice成功后记录状态标志,并将创建的 stream 交由StreamPtr持有。 - 改造
CreateAclTensor与RunXlog1py:张量与设备内存改为通过DeviceMemPtr&、TensorPtr&管理,新增对aclCreateTensor返回空指针的CHECK_RET校验;RunXlog1py内调用改为.get()传参(workspace 同样用DeviceMemPtr管理),并删除函数末尾的手动aclDestroyTensor/aclrtFree清理段。 - 重构
main资源回收:使用std::shared_ptr<void>守卫(aclGuard)在退出时按deviceSet/initialized状态调用aclrtResetDevice与aclFinalize,同时移除结尾手动的aclrtDestroyStream/aclrtResetDevice/aclFinalize调用。 - 代码风格统一:按
is_finite/is_inf示例风格调整for循环、条件语句的换行与大括号格式(纯排版调整,不影响行为)。


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.
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 |
|---|---|---|
| repo-cann/ops-math | ✅ 周奇龙, andong_hw (2/2) | ✅ 周奇龙 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
qq_37913898, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [0fe636ec6cb3443e91f8373b83adda8d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ❌ FAILED | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |


流水线任务触发成功
任务链接 [b7402af7f2bb48678e2f738b6650d1b3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-08-19 17:33:13] CI执行结束


compile#UT_Test_experimental


流水线任务触发成功
任务链接 [6cc903ec20554eb9b9054aab0ffd8451][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-08-20 11:54:14] CI执行结束


流水线任务触发成功
任务链接 [c26bedb2f1e04968a1f47917993ff8ec][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-08-20 11:49:19] CI执行结束


描述
将
math/xlog1py/examples下的 aclnn 示例由手动资源管理改为 C++ RAII 管理,与同仓math/is_finite、math/is_inf示例风格保持一致。测试
未在 Ascend 环境实际编译运行;改动结构与已合并的
is_inf(PR #4531)一致。文档更新
无。
类型标签