Closed
[Requirement|需求建议]: FE 融合 pass 打桩注册,编入 libopgraph_math.so #3450
yuyuanfengAdd on  Oct 9Closed at  Oct 9
yuyuanfeng
yuyuanfeng
Oct 9 Create

一、背景信息 (必填)

删除 canndev 后,FE(前端)融合 pass 表为空,原先由 canndev 提供的若干融合 pass 全部丢失。对 fusable-only 算子,在引擎选型阶段会因查不到对应融合 pass 而报 “Cannot find engine”;对 Stage 为 kAfterInferShape 的一类 pass 还会报 “pattern fusion is nullptr”。需要在 ops-math 侧补齐 FE 融合 pass 的注册,用名字占住 fe 表,使 FE 调度器能按名字桥接到 math 侧实现。

二、价值/作用 (必填)

  • 恢复 ascend950 上 9 个由 canndev 迁移过来的融合 pass 的融合能力,避免 fusable-only 算子在引擎选型阶段失败。
  • 采用“打桩注册”方式(只声明不实现),编译期与运行期双重条件保护,不引入对 GE 内部实现的硬链接依赖,删除 canndev 后仍能保证 FE 融合表完整。
  • 为后续 canndev 彻底下线提供兜底。

三、设计方案 (必填)

3.1 使能方式(涉及哪些框架:如Aclnn直调、Pytorch训练等)
  • 目标硬件:ascend950;构建/运行环境 ge_compiler >= 9.0.0 时生效。
  • 生效范围:随 libopgraph_math.so 编入,仅当“编译 soc 为 ascend950”且“ge_compiler 版本 >= 9.0.0”同时满足时注册才生效。
  • 非 ascend950 或其他 ge_compiler 版本:不编入 / 不注册,无副作用。
3.2 总体设计
  • 新增桩头文件 common/stub/inc/op_graph/fe_fusion_pass_registry_stub.h:声明 GE 的 fe 融合 pass 注册接口(GraphFusionPassType 枚举、PassAttr、PassDesc、FusionPassRegistry、FusionPassRegistrar)以及 STUB_REG_PASS 注册宏;只声明不实现,链接期允许未定义符号通过,运行期由动态链接器绑定到 libregister.so 的真实实现。
  • 新增 common/src/op_graph/fusion_pass_common.cpp:通过 STUB_REG_PASS 集中登记 9 个有 canndev 对应物的 pass 名字,编入 libopgraph_math.so。
  • 条件保护:外层编译期宏 OP_GRAPH_MATH_ASCEND950 限定仅 ascend950 编入;内层 GE_COMPILER_VERSION_NUM >= 90000000 限定 ge_compiler 版本;运行期再以弱符号 aclsysGetVersionNum 查询 ge_compiler 版本,>= 9.0.0 时才构造 FusionPassRegistrar 完成登记。
3.2.1 算子支持的数据类型

本需求为编译/注册机制,不涉及算子数据类型。

3.2.2 host侧设计
  • 注册发生在 libopgraph_math.so 静态初始化阶段;FusionPassRegistrar 构造函数有副作用,构造即完成登记,工厂 lambda 返回 nullptr(实际创建由 FE 侧 REG_FUSION_PASS 负责)。
  • 登记名单(名字 / 类型 / attr 均照抄 canndev 的 REG_PASS/REGISTER_PASS;attr:FORBIDDEN_CLOSE=0x01、SINGLE_SCENE_OPEN=0x04,3 参 REGISTER_PASS 默认 0):
    • ReduceMeanWithCastFusionPass — BUILT_IN_PREPARE_GRAPH_PASS, 0x05
    • PermuteFusionPass — BUILT_IN_GRAPH_PASS, 0x05
    • RandomUniformFusionPass — BUILT_IN_GRAPH_PASS, 0x01
    • TruncatedNormalFusionPass — BUILT_IN_GRAPH_PASS, 0x01
    • RandomStandardNormalFusionPass — BUILT_IN_GRAPH_PASS, 0x01
    • RandomUniformIntFusionPass — BUILT_IN_GRAPH_PASS, 0x01
    • DropOutV3FusionPass — BUILT_IN_GRAPH_PASS, 0x05
    • DropOutV3SplitFusionPass — BUILT_IN_GRAPH_PASS, 0x05(当前不在 OPP 白名单 3510(ascend950) 内,FE 会 force close 跳过,待 OPP 侧补名单后生效,故保留登记)
    • BernoulliFusionPass — BUILT_IN_GRAPH_PASS, 0
  • 不登记:CastlikeFusionPass、HistogramFusionPass(Stage 为 kAfterInferShape,不在 kCompatibleInherited 表里,登记后 FE 查不到实现会报 “pattern fusion is nullptr”);Globalavgpoolpass 本次不登记。
3.2.3 kernel侧设计

无。本需求仅涉及 FE 融合 pass 注册,不涉及 kernel 侧实现。

3.3 支持硬件

ascend950。

3.4 算子约束限制

  • 仅 ascend950 且 ge_compiler >= 9.0.0 时生效。
  • DropOutV3SplitFusionPass 已登记但当前不生效(不在 OPP support_fusion_pass.json 的 3510 名单内,FE 会 force close 跳过),待 OPP 补名单后生效。
  • 950 真机上的融合实际效果待补验证。

💡 备注(选填)

  • 关联 PR:#5140(fe: 融合 pass 打桩注册,编入 libopgraph_math.so)
  • 实现文件:common/stub/inc/op_graph/fe_fusion_pass_registry_stub.h、common/src/op_graph/fusion_pass_common.cpp、common/src/op_graph/CMakeLists.txt、common/CMakeLists.txt
  • 测试情况:ascend950 配置下 fusion_pass_common.cpp 编译通过、libopgraph_math.so 链接通过;桩引用的 FusionPassRegistrar 未定义符号与 libregister.so 导出的逐字符一致(_GLIBCXX_USE_CXX11_ABI=0);ldd 依赖全部可解析、dlopen libopgraph_math.so 成功、静态初始化未崩溃。
likedislike
yuyuanfengyuyuanfeng
Oct 9 Added label: requirement
CANN-robotCANN-robotCollaborators
Oct 9 Close issue
CANN-robotCANN-robotCollaborators
Oct 9 Added label: resolved