Pull Request已成功合入, 合并人@CANN-robot
(感谢 tangqunzhang 的贡献)变更摘要
此 PR 将 compiler/graph/build/memory/memory_block.h 中的 MemoryNoReuseScope 和 OpMemoryType 两个普通 enum 重构为 enum class,以避免命名空间污染并提升类型安全性。同步更新了所有引用处(共 12 个文件),为枚举值添加 OpMemoryType:: 或 MemoryNoReuseScope:: 前缀,并将 MarkZeroCopyBlockAttr 的参数类型从 bool 改为 OpMemoryType。由于 enum class 禁止隐式整数转换,测试代码中部分原本利用隐式转换将枚举值传给 uint64_t 形参的写法也做了相应适配。
主要改动
-
枚举定义重构:
memory_block.h中enum MemoryNoReuseScope和enum OpMemoryType改为enum class MemoryNoReuseScope和enum class OpMemoryType,同时NodeTypeIndex的mem_type_默认值从kOutput改为OpMemoryType::kOutput。 -
业务代码全局适配:
block_mem_assigner.cc、block_mem_zero_copy.cc、block_type_list.cc、atomic_clean_checker.cc、dynamic_batch_mem_assigner.cc、graph_mem_assigner.cc、memory_block.cc中所有kOutput、kWorkspace、kOutputDesc、kInput均加OpMemoryType::前缀,kSessionNoReuse加MemoryNoReuseScope::前缀并辅以static_cast<MemoryNoReuseScope>显式转换。 -
MarkZeroCopyBlockAttr签名变更:block_mem_zero_copy.h和block_mem_zero_copy.cc中该函数第四个参数从bool mem_type改为OpMemoryType mem_type,内部比较从mem_type == kOutput改为mem_type == OpMemoryType::kOutput。 -
GetMemType静态方法中的 switch-case 适配:memory_block.h中NodeTypeIndex::GetMemType的 case 标签从kOutput/kWorkspace/kOutputDesc/kInput分别改为OpMemoryType::kOutput等。 -
测试代码适配:
block_mem_assigner_unittest.cc和mem_assigner_unittest.cc中,原来利用普通枚举隐式转换将OpMemoryType变量传给MemoryBlock构造函数(期望uint64_t)的写法改为直接声明uint64_t类型变量并赋RT_MEMORY_HBM;枚举值输出时添加static_cast<int>转换;所有比较和构造中的枚举值均加上作用域前缀。


🤖 本次改动均为数据 / 生成 / 二进制文件(如测试用例、锁文件、媒体资源),没有可审查的代码逻辑,已跳过 AI 代码审查。


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 |
|---|---|---|
| repo-cann/ge | ✅ kobemini, stevenaw0, 张德鹏, xchu42, lining23666 (5/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
tangqunzhang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm


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


Pull Request
描述
将compiler/graph/build/memory/memory_block.h中的MemoryNoReuseScope和OpMemoryType两个普通enum改为enum class,避免命名空间污染,提升类型安全。
同步更新所有引用处加OpMemoryType::或MemoryNoReuseScope::前缀,MarkZeroCopyBlockAttr参数类型从bool改为OpMemoryType。
变更类型
关联的Issue
如何测试
核对清单
其他信息
涉及12个文件,127 insertions, 113 deletions。