Pull Request已成功合入, 合并人@ascend-robot
(感谢 SL25 的贡献)变更摘要
此 PR 修复了 PlanMemory 中 Level1 缓冲区复用策略的两个问题:1) 多缓冲区(multi-buffer)场景下,仅第一个缓冲区(非 other relation entries)允许在 Level1 中复用,否则应判定为冲突;2) 修正等尺寸缓冲区的多缓冲区互复用逻辑。修改集中在 VerifyConflictStage1 的条件判断与循环边界,以及 PlanRelationOtherBufferEntryAddress 的错误处理上,并新增两个 MLIR 测试用例覆盖修复场景。
主要改动
VerifyConflictStage1条件收严:将冲突判定条件从otherBufferEntries.size() < e->multiBufferNum改为otherBufferEntriesSize < e->multiBufferNum - 1 || e->otherBufferRelationEntries.empty(),确保只有第一个缓冲区可触发 Level1 复用,且历史条目数不足或当前条目非首缓冲区时均视为冲突。VerifyConflictStage1循环边界修正:循环上限从e->multiBufferNum改为otherBufferEntriesSize,避免在历史条目数少于multiBufferNum时越界访问。PlanRelationOtherBufferEntryAddress防御性断言:新增else分支调用llvm_unreachable("Does not support other buffer entries reuse in level1!"),对不支持的复用路径进行明确报错。- 新增测试用例:在
plan-memory.mlir中添加test_mem_inplace_level1_equal_buffers_reuse和test_mem_inplace_level1_less_buffers_reuse两个用例,分别验证等尺寸多缓冲区复用和不同multi_buffer配置下的复用行为,均通过CHECK-NOT: memref.alloc()断言复用成功。


代码审查
审查总结
审查文件清单:
bishengir/lib/Dialect/HIVM/Transforms/PlanMemory.cpp— 已审查,发现 1 个 P3 问题bishengir/test/Dialect/HIVM/plan-memory.mlir— 已审查,无问题
按优先级统计:
- P0: 0
- P1: 0
- P2: 0
- P3: 1
整体风险判断: 低风险。此 diff 的核心变更正确修复了 level1 中 multi-buffer 复用 multi-buffer 等大小场景下的 bug(旧代码要求 otherBufferEntries.size() >= e->multiBufferNum,导致等大小时被误判为冲突)。新增的 e->otherBufferRelationEntries.empty() 检查正确阻止了 relation entry 参与 level1 复用。唯一的 P3 发现是针对单 buffer 复用多 buffer 场景下循环界限变更的未记录行为变化,可能是有意改进也可能是副作用,影响范围有限。其余变更均为格式调整或防御性检查,无功能影响。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


✅ The pipeline is running (pipeline number: 238), Task URL link, please wait a moment ...


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-Ascend/AscendNPU-IR | ✅ 程琛, cxtjjcz (2/2) | ✅ cxtjjcz, 程琛 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
SL25, thanks for your pull request. All authors of the commits have signed the CLA. 👍


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


✅ The pipeline is running (pipeline number: 249), Task URL link, please wait a moment ...


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


libing-pipeline创建中,请等待……


/lgtm
/approve


/lgtm
/approve


描述 Description
类型 Category
Checklist
feat:,fix:)I have correctly used type labels in the title (e.g., feat:, fix:)