已合并
fix: handle ScalarData inputs in CV fusion #1954
fix: handle ScalarData inputs in CV fusion #1954
已合并
ling-DT创建于 6 天前
ling-DT成员
6 天前

Pull Request

描述

修复 CV Fusion 生成代码将 ScalarData 误当作 GM Tensor 输入的问题。跳过常量输入的 Global Buffer 绑定,并按输入类型分别初始化 GM 地址和标量参数,避免生成 float{nullptr} 以及对标量调用 SetGlobalBuffer

变更类型

关联的Issue

  • Fixes #298

如何测试

  1. 基于 20061b3a1c32 编译 aihac_codegenpyautofuse
  2. 更新 CANN AutoFusion 运行库,开启 MM Fusion 执行 tc_af_inductor_netexit_rmsnorm_lm_head_logit_softcap
  3. 编译输出与参考输出均为 torch.Size([4, 256, 4096])torch.bfloat16,数值校验通过。

核对清单

其他信息

源分支基于本地 develop 分支,目标分支为 cann/graph-autofusion:develop

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 ling-DT 的贡献)
Lling-DT成员
6 天前 创建了 pull request,commit 0fc968ff
atomgit-bot
atomgit-bot
6 天前 评论:

变更摘要

该 PR 修复 CV Fusion 代码生成时将 ScalarData(常量/标量输入)误当作 GM Tensor 处理的问题,涉及 autofuse/codegen/codegen_kernel.cpp 中的 Kernel::GlobalTensorAssignAutoFusionVector。改动后常量输入不再参与 Global Buffer 绑定,生成的 ArgumentsParams 及实际入参初始化会按输入类型区分:GM 地址类型(kGmAddrT)输入用 nullptr 初始化,标量输入改用 0 初始化,避免生成 float{nullptr} 以及对标量调用 SetGlobalBuffer

主要改动

  • 跳过常量输入的 Global Buffer 绑定:在 Kernel::GlobalTensorAssign 中新增对 tensor->second.is_constant 的判断,常量(ScalarData)输入直接 continue,不再对其调用 SetGlobalBuffer
  • 按类型初始化 ArgumentsParams 结构体成员:在 AutoFusionVector 生成 ArgumentsParams 结构体时,依据 input.type.name == kGmAddrT.name 判断,GM 地址输入保持 {nullptr} 初始化,标量输入改为 {0}
  • 实际入参初始化同样按类型区分:在 AutoFusionVector 生成入参对象的初始化处应用相同的 is_gm_input 判断,标量参数以 {0} 而非 nullptr 初始化,杜绝对标量类型生成 {nullptr} 的非法初始化。
likedislike
不准确?
atomgit-bot
atomgit-bot
6 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
6 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6 天前 评论:

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/graph-autofusion yangyongqiang0606, xchu42, xuyafei (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

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

likedislike
此处折叠了66条消息 查看更多
xuyafei成员
5 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
5 天前 添加了label:lgtm
yangyongqiang
yangyongqiang成员
5 天前 评论:

/approve

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