已合并
[AscendNPU IR] [PlanMemory] Fix: fix planmemory level1 reuse on pong buffers #1414
[AscendNPU IR] [PlanMemory] Fix: fix planmemory level1 reuse on pong buffers #1414
已合并
SL25创建于 7月7日
SL25成员
7月7日

描述 Description

  1. Only first buffer(not other relation entries) can reuse in level1. If current entry is not first buffer, stage1 should be conflict.
  2. Fix level1 multi-buffer reuse multi-buffer when buffer sizes are equal.

类型 Category

  • Bug修复 Bugfix
  • 新功能 New feature
  • 代码风格更新(格式化,局部变量)Style changes
  • 重构(即不是新增功能,也不是修改bug的代码变动)Refactor
  • 构建过程或辅助工具的变动 Build-related
  • 文档内容更新 Docs

Checklist

  • 我的代码遵循这个项目的代码风格 My code follows the project's code style
  • 我已经自己测试过我的代码 I have self-tested my code
  • 我已经更新了相应的文档 I have updated the relevant documentation
  • 我已经根据需要更新了对应的变更日志 I have updated the changelog as needed
  • 我已经在标题中正确使用了类型标签(例如:feat:, fix:)I have correctly used type labels in the title (e.g., feat:, fix:)
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 SL25 的贡献)
SSL25成员
7月7日 创建了 pull request,commit bd57bbd2
atomgit-bot
atomgit-bot
7月7日 评论:

变更摘要

此 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_reusetest_mem_inplace_level1_less_buffers_reuse 两个用例,分别验证等尺寸多缓冲区复用和不同 multi_buffer 配置下的复用行为,均通过 CHECK-NOT: memref.alloc() 断言复用成功。
likedislike
不准确?
atomgit-bot
atomgit-bot
7月7日 评论:

代码审查

审查总结

审查文件清单:

  • 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 场景下循环界限变更的未记录行为变化,可能是有意改进也可能是副作用,影响范围有限。其余变更均为格式调整或防御性检查,无功能影响。

⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。

likedislike
不准确?
ascend-robot
ascend-robot成员
7月7日 评论:

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

likedislike
ascend-robotascend-robot成员
7月7日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
7月7日 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
SSL25成员
7月7日 修改了pull request 的描述
SSL25成员
7月7日 修改了pull request 的描述
SSL25成员
7月7日 修改了pull request 的描述
ascend-robotascend-robot成员
7月7日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
7月7日 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7月7日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7月7日 评论:

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

likedislike
ascend-robotascend-robot成员
7月7日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7月7日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月7日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月7日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月7日 评论:
阶段 任务名 状态 详情
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
流水线 PR-pipeline_ascendnpu-ir-A5-copy >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[Jacky_XH, xiechenye]评论有效
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
SSL25成员
7月7日 update merge request[project id: 7494336, iid: 1414, commit_id: e9fea99665ec37e5748445028945f033d59394e3] virtual merging success
SSL25成员
7月7日 强制推送  1 个提交:82ab8f7e-[AscendNPU IR] [PlanMemory] Fix: fix planmemory level1 reuse on pong buffers
SSL25成员
7月7日 update merge request[project id: 7494336, iid: 1414, commit_id: 30298d59d1f44af3de26bb13096859fd5f850a1a] virtual merging success
ascend-robotascend-robot成员
7月7日 删除了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月7日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
ascend-robotascend-robot成员
7月7日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
7月7日 评论:

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

likedislike
SSL25成员
7月7日 修改了pull request 的描述
ascend-robot
ascend-robot成员
7月7日 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7月7日 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月7日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7月7日 评论:

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

likedislike
ascend-robotascend-robot成员
7月7日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7月7日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7月7日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月7日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月7日 评论:
阶段 任务名 状态 详情
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
流水线 PR-pipeline_ascendnpu-ir-A5-copy >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[Jacky_XH, xiechenye]评论有效
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
SL25成员
7月7日 评论:

compile#openlibing

likedislike
SL25成员
7月7日 评论:

compile#openlibing

likedislike
ascend-robot
ascend-robot成员
7月7日 评论:

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

likedislike
ascend-robotascend-robot成员
7月7日 添加了label:SC-SUCC
chengchen89
chengchen89成员
7月8日 评论:

/lgtm
/approve

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:approved
chenxiangting
chenxiangting成员
7月8日 评论:

/lgtm
/approve

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:lgtm
ascend-robotascend-robot成员
7月8日 合入了pull request,合并节点 SHA:015d1531d087673eacc509ed5a0beb4db2b3d6db