Pull Request已成功合入, 合并人@CANN-robot
(感谢 ddssz 的贡献)变更摘要
本 PR 修复 quant_batch_matmul_inplace_add 示例中 MXFP8 ACLNN 调用的 workspace 内存泄漏问题:AclnnQuantBatchMatmulInplaceAddTest 中调用 aclrtMalloc 成功分配 workspace 后,正常返回与后续错误返回路径均未执行配对的 aclrtFree。修复方式是在 workspace 分配的 if 块之后构造 std::unique_ptr<void, aclError (*)(void*)> workspaceAddrPtr(workspaceAddr, aclrtFree),让 workspace 生命周期覆盖后续算子调用与流同步,并在函数退出时自动释放;同时补充了文件末尾缺失的换行符。
主要改动
- 引入 RAII 管理 workspace 释放:在
workspaceAddr分配成功之后新增std::unique_ptr<void, aclError (*)(void*)> workspaceAddrPtr(workspaceAddr, aclrtFree),以aclrtFree作为自定义删除器,使函数在正常返回、CHECK_RET提前返回及零 workspace 路径上均能自动释放内存,避免泄漏。 - 补全文件末尾换行:在
test_aclnn_quant_batch_matmul_inplace_add_mxfp8.cpp末尾为关闭的main函数大括号补上换行符(消除 "No newline at end of file" 提示)。


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 |
|---|---|---|
| matmul | ✅ 杨阳, 王子韬 (2/2) | ✅ 杨阳 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


compile


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


/lgtm


您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!


/lgtm
/approve


描述
QuantBatchMatmulInplaceAdd 的 MXFP8 ACLNN 示例在成功分配 workspace 后,正常返回和后续错误返回路径均缺少配对的 aclrtFree。
在 workspace 分配的 if 块之后构造
std::unique_ptr<void, aclError (*)(void*)> workspaceAddrPtr(workspaceAddr, aclrtFree);,使 workspace 的生命周期覆盖后续算子调用和流同步,并在函数退出时自动释放。关联的Issue
关联 Issue:#5608
测试
文档更新
无。
类型标签
AI/Agent生成声明