已合并
fix: 刷新缓存中的shapeDepend 输出的 acl tensor地址 #719
fix: 刷新缓存中的shapeDepend 输出的 acl tensor地址 #719
已合并
liuyi424创建于 13 天前
liuyi424
13 天前

描述

individual op 的 args 缓存会保存 shape 依赖输出的 aclTensor *。后续调用命中缓存时,原逻辑只更新 kernel 使用的 TensorData 地址,没有更新 outPutShapeMap,导致输出 shape 仍可能回刷到首次调用的 tensor;该 tensor 已释放或内存被复用时,会在 SetStorageShape 处发生 coredump。

本次修改:

  • 在旧缓存和 V2 缓存的输出地址更新路径中,同步刷新 outPutShapeMap
  • 增加缓存旧 tensor、当前 tensor及最终 shape 回刷目标的 DFX 日志。
  • 增加回归测试,覆盖两个缓存命中更新入口。

关联的Issue

关联issue #309

测试

已通过冒烟测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 liuyi424 的贡献)
Lliuyi424
13 天前 创建了 pull request,commit b2630e27
atomgit-bot
atomgit-bot
13 天前 评论:

变更摘要

此 PR 修复了一个由缓存命中时 outPutShapeMapaclTensor* 指针未同步更新引发的 coredump 问题。在 individual op 的 args 缓存复用场景下,原有逻辑仅更新了 kernel 使用的 TensorData 地址,但 outPutShapeMap 仍持有首次调用时创建的 aclTensor* 指针。当这些旧 tensor 已被释放或内存被复用时,后续的 SetStorageShape 操作会写入非法地址导致崩溃。本次修改在 NnopbaseUpdateOutputAddrUpdateArgsIoAddr 两条缓存更新路径中新增 NnopbaseUpdateOutputShapeTensorMap 调用,确保 outPutShapeMap 中保存的 shape 依赖输出 tensor 指针指向当前有效地址,同时补充了 DFX 日志和回归测试。

主要改动

  • 新增 NnopbaseUpdateOutputShapeTensorMap 函数:在 indv_update_tensor.cpp 中实现,负责在缓存命中时将缓存的 outPutShapeMap 中的旧 aclTensor* 指针替换为当前调用传入的新 tensor 指针,并输出 DFX 日志记录旧/新 tensor 地址。
  • NnopbaseUpdateOutputAddr 中同步刷新 shape tensor 映射:在该函数末尾调用 NnopbaseUpdateOutputShapeTensorMap(dstTensors, tensors),覆盖旧缓存路径的 shape 回刷。
  • UpdateArgsIoAddr 中同步刷新 shape tensor 映射:在该函数末尾调用 NnopbaseUpdateOutputShapeTensorMap(dstTensors, tensors),覆盖 V2 缓存路径的 shape 回刷。
  • NnopbaseExecutorRefreshOutputShape 中增加 DFX 日志:新增两条 OP_LOGI 日志,分别记录 output shape tensor 数量与缓存状态,以及每次 shape 回刷时的 tensor 指针、维度数和具体 shape 值。
  • 新增回归测试 CacheHitUpdatesOutputShapeTensorMap:覆盖 NnopbaseUpdateOutputAddrUpdateArgsIoAddr 两条路径,验证缓存命中后 outPutShapeMap 中的 tensor 指针已从首次调用创建的对象更新为当前调用的对象。
likedislike
atomgit-bot
atomgit-bot
13 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
13 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
13 天前 评论:

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/opbase pengjiahao96, 宋恺 (2/2) pengjiahao96 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

liuyi424, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
13 天前 将zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
13 天前 将zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng设为审查人
liuyi424
13 天前 评论:

compile

likedislike
Lliuyi424
13 天前 update merge request[project id: 7649482, iid: 719, commit_id: 098660d7ce6e0301185866c7c414046988805d71] virtual merging success
此处折叠了8条事件消息 查看更多
CANN-robotCANN-robot成员
11 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
11 天前 评论:

Notification

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

likedislike
Lliuyi424
11 天前 update merge request[project id: 7649482, iid: 719, commit_id: 7d365269c12fda8a0515543fe5d2a60248af3db9] virtual merging success
Lliuyi424
11 天前 强制推送  1 个提交:acc30431-fix: 刷新缓存中的输出shape tensor地址
Lliuyi424
11 天前 update merge request[project id: 7649482, iid: 719, commit_id: 40e58d20899e6538ab0f847c776e1f4777fbe852] virtual merging success
CANN-robotCANN-robot成员
11 天前 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
11 天前 添加了label:cann-cla/yes
Lliuyi424
11 天前 修改了pull request 的描述
liuyi424
11 天前 评论:

compile

likedislike
Lliuyi424
11 天前 update merge request[project id: 7649482, iid: 719, commit_id: 4b8a8b348eafd19c193e1d451ebc78f2072087b5] virtual merging success
CANN-robotCANN-robot成员
11 天前 添加了label:ci-pipeline-running
liuyi424
11 天前 评论:

compile

likedislike
CANN-robotCANN-robot成员
11 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
11 天前 添加了label:ci-pipeline-passed
liuyi424
6 天前 评论:

compile

likedislike
Lliuyi424
6 天前 update merge request[project id: 7649482, iid: 719, commit_id: c2050c8ef5b2db25e3d101c92628f7817bef1889] virtual merging success
此处折叠了5条事件消息 查看更多
Lliuyi424
6 天前 修改标题为 “fix: 刷新缓存中的shapeDepend 输出的 acl tensor地址”,原标题为“fix: 刷新缓存中的输出shape tensor地址”
pengjiahao96
pengjiahao96成员
6 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:approved
songkai111成员
5 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
5 天前 添加了label:lgtm
CANN-robotCANN-robot成员
5 天前 关闭了关联的issue
CANN-robotCANN-robot成员
5 天前 合入了pull request