Merged
GLU InferDataType 推导注册 #13469
esok11Add on 18 days ago
GLU InferDataType 推导注册 #13469
Merged
esok11Add on 18 days ago
esok11
esok11Collaborators
18 days ago

描述

GLU 算子(activation/glu)在 op_graph 目录下只有 glu_proto.h(REG_OP 原型)与空的 fusion_pass/,缺少图模式 InferDataType 推导注册;host 侧仅通过 op_host/glu_infershape.cpp 的 IMPL_OP_INFERSHAPE(GLU) 提供 InferShape。本 PR 为 RT2.0 图模式补齐 GLU 的 InferDataType 推导注册。

改动方法

  • 新增 activation/glu/op_graph/glu_graph_infer.cpp,通过 IMPL_OP(GLU).InferDataType(InferDataTypeForGlu) 注册图侧 dtype 推导。
  • InferDataTypeForGlu 的实现:先对 context 判空(为空时 OP_LOGE("GLU", "InferDataType context is nullptr.") 并返回 ge::GRAPH_FAILED),记录起始 OP_LOGD;随后 GetInputDataType(GLU_IN_X) 取输入 x 的 dtype,SetOutputDataType(GLU_OUT_Y, dtype) 直接作为输出 y 的 dtype,并返回该调用的状态;最后记录结束 OP_LOGD。输出与输入同类型,与 op_graph/glu_proto.h 中 “y: Has the same type as x” 以及 op_host/glu_def.cpp 中 x/y 均注册 DT_FLOAT16、DT_BF16、DT_FLOAT 的契约一致。
  • 索引常量定义在匿名 namespace:GLU_IN_X = 0(输入 x)、GLU_OUT_Y = 0(输出 y)。
  • 未改动 op_host/glu_def.cpp 与 op_host/glu_infershape.cpp,未新增 InferFormat 注册。
  • 无需改动 op_graph/CMakeLists.txt:add_graph_plugin_sources()(cmake/func.cmake:1113)通过 file(GLOB_RECURSE GRAPH_PLUGIN_SRCS ${SOURCE_DIR}/*.cpp) 自动收集 op_graph 下的新增源文件。

关联的Issue

测试

本 PR 仅新增图侧 InferDataType 推导注册,未新增 UT/ST 用例;activation/glu/tests/ut/op_host 下现有 test_glu_infershape.cpp、test_glu_tiling.cpp 仍覆盖 host 侧逻辑,tests/st 下 aclnnGlu、arch35 用例覆盖执行通路。建议验证:图模式(GE IR)构造 GLU 节点,确认输出 y 的 dtype 与输入 x 一致(float16 / bfloat16 / float32)。

文档更新

无文档变更。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for esok11's contribution.)
esok11esok11Collaborators
18 days ago Created pull request, commit 408af3f9
atomgit-bot
atomgit-bot
18 days ago Comments:

变更摘要

本 PR 为 activation/glu 算子补充图模式下的数据类型推导能力:新增 glu_graph_infer.cpp,在其中实现 InferDataTypeForGlu 函数,并通过 IMPL_OP(GLU).InferDataType(...) 将数据类型推导逻辑注册到 GLU 算子的算子实现注册表中,使 GLU 在整图编译阶段即可确定输出数据类型。

主要改动

  • 新增数据类型推导入口: 新增 InferDataTypeForGlu,接收 gert::InferDataTypeContext 上下文,作为 GLU 算子 InferDataType 的实现函数。
  • 输入输出索引常量定义: 在匿名命名空间中定义 GLU_IN_X = 0 与 GLU_OUT_Y = 0,用常量替代直接写死的输入/输出下标。
  • 输出 dtype 与输入对齐: 读取输入 GLU_IN_X 的数据类型,并通过 SetOutputDataType 将其设置为输出 GLU_OUT_Y 的数据类型,即输出数据类型随输入数据类型推导。
  • 空上下文校验与日志: 通过 OP_CHECK_IF 判断 context 为 nullptr 时返回 ge::GRAPH_FAILED,并在推导前后使用 OP_LOGD 输出节点名日志;最终返回 SetOutputDataType 的执行结果。
  • 算子注册声明: 使用 IMPL_OP(GLU).InferDataType(InferDataTypeForGlu) 完成注册,使该推导逻辑接入图模式流程。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
18 days ago Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
18 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
18 days ago Comments:

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
activation ✅ 王星, 黄迪 (2/2) ✅ 王星, 黄迪 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
18 days ago Set zengjuan,u010470851,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,chenxingyu18,liujie12345678,east_yang,pingchuantang,Chen_HaoWen,qianzehong as approver
CANN-robotCANN-robotCollaborators
18 days ago Set u010470851,kevin_huang1234,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,wang-xing001,chenxingyu18,liujie12345678,east_yang,pingchuantang,Chen_HaoWen,qianzehong as approver
esok11
esok11Collaborators
18 days ago Comments:

/compile

likedislike
esok11esok11Collaborators
18 days ago Pre merge succeeded (commit_id: ef4e97c320253760f7715690dc2dd139ce80b0f3)
CANN-robot
CANN-robotCollaborators
18 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
18 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
18 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
18 days ago Added label: ci-pipeline-passed
yuning_chen
yuning_chenCollaborators
18 days ago Comments:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@pingchuantang @Chen_HaoWen @wang-xing001 @yourealize @kevin_huang1234 @qianzehong

likedislike
esok11esok11Collaborators
18 days ago Change title to "feat(glu): 补齐 op_graph InferDataType 推导注册", originally titled "inferdatatype".
esok11esok11Collaborators
18 days ago Modify description of pull request
esok11esok11Collaborators
18 days ago Set as a draft.
esok11esok11Collaborators
18 days ago Change title to "[WIP]inferdatatype", originally titled "feat(glu): 补齐 op_graph InferDataType 推导注册".
wang-xing001
wang-xing001Collaborators
18 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
18 days ago Added label: approved
esok11esok11Collaborators
18 days ago Change title to "[WIP]GLU InferDataType 推导注册", originally titled "[WIP]inferdatatype".
kevin_huang1234
kevin_huang1234Collaborators
18 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
18 days ago Added label: lgtm
CANN-robot
CANN-robotCollaborators
18 days ago Comments:

The MR can not be merged, because of this MR is work in process.

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
esok11esok11Collaborators
18 days ago Draft state has been cancelled
esok11
esok11Collaborators
18 days ago Comments:

/check-pr

likedislike
CANN-robotCANN-robotCollaborators
18 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
18 days ago Merged pull request