已合并
fix: 修复 HostCPU Where 动态输出 StorageShape 未更新导致的精度问题 #4744
ZhuXincheng创建于 9月4日
fix: 修复 HostCPU Where 动态输出 StorageShape 未更新导致的精度问题 #4744
已合并
ZhuXincheng创建于 9月4日
ZhuXincheng
ZhuXincheng成员
9月4日

Pull Request

描述

修复 Runtime2 HostCPU 直调路径中,Where 等动态输出算子执行后仅更新 OriginShape、未同步更新 StorageShape,导致下游按预分配最大 Shape 读取尾部无效数据的精度问题。

问题原因

  • Where 的输出元素个数由运行时输入数据决定,编译阶段只能得到 ShapeRange。
  • 输出内存按照 ShapeRange 上界预分配,例如最大 Shape 为 [2, 1]。
  • HostCPU 算子执行后将实际 OriginShape 更新为 [1, 1],但 AicpuHostExecFunc 原逻辑执行完 HostCPU 函数后直接返回,没有完成 OriginShape 到 StorageShape 的转换。
  • 下游 Dump/NetOutput 仍按照旧的 StorageShape [2, 1] 计算有效数据长度,导致未写入的尾部内存被作为有效数据输出。

修改内容

  • 在 AicpuHostExecFunc 执行 HostCPU 算子函数成功后获取 ComputeNodeInfo。
  • 调用 TransformAllOutputsShape,基于实际 OriginShape、OriginFormat、StorageFormat 和补维规则重新计算所有输出的 StorageShape。
  • 本修改不会缩小已经按照最大 Shape 申请的输出缓冲区,只会修正运行时有效数据的 Shape 元数据。

变更类型

关联的 Issue

无。

如何测试

  1. 编译 ut_fast_runtime2_test。
  2. 运行 AicpuKernelLaunchUT 相关用例,16 个用例全部通过。
  3. 验证 HostCPU 函数将 OriginShape 从 [2, 1] 更新为 [1, 1] 后,AicpuHostExecFunc 会同步将 StorageShape 更新为 [1, 1]。

核对清单

其他信息

对于 OriginFormat 与 StorageFormat 相同的 ND 输出,本次转换结果等价于使用实际 OriginShape 更新 StorageShape;对于格式不同的输出,仍会执行标准补维和格式转换,不能简单地将两者直接赋值。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 ZhuXincheng 的贡献)
ZhuXinchengZhuXincheng成员
9月4日 添加了label:enhancement
ZhuXinchengZhuXincheng成员
9月4日 创建了 pull request,commit 2e609a4e
CANN-robotCANN-robot成员
9月4日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月4日 评论:

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
repo-cann/ge ✅ kobemini, yangyongqiang0606, zhanj (3/2) ✅ yangyongqiang0606 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
9月4日 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为评审人
此处折叠了12条事件消息 查看更多
CANN-robotCANN-robot成员
9月7日 移除了审查人fu-jun2
ZhuXincheng
ZhuXincheng成员
9月7日 评论:

compile

likedislike
ZhuXinchengZhuXincheng成员
9月7日 预合并成功(commit_id: 5602a8ab1176bc83d16d5d673b784c89cfd63fae)
CANN-robot
CANN-robot成员
9月7日 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9月7日 添加了label:ci-pipeline-running
ZhuXinchengZhuXincheng成员
9月7日 取消了草稿状态
ZhuXinchengZhuXincheng成员
9月7日 修改标题为 “fix: 修复 HostCPU Where 动态输出 StorageShape 未更新导致的精度问题”,原标题为“【wip】: where 算子精度问题”
ZhuXinchengZhuXincheng成员
9月7日 修改了pull request 的描述
CANN-robotCANN-robot成员
9月7日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月7日 添加了label:ci-pipeline-passed
GengChao
GengChao成员
9月7日 评论:

/lgtm

likedislike
zhanj
zhanj成员
9月7日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
9月7日 添加了label:lgtm
yangyongqiang
yangyongqiang成员
29 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
29 天前 添加了label:approved
CANN-robotCANN-robot成员
29 天前 合入了pull request