已合并
refactor: 移除 dynamic_rnn/dynamic_rnnv2 系列 TF 插件并修复 einsum TF 插件注册 #9925
refactor: 移除 dynamic_rnn/dynamic_rnnv2 系列 TF 插件并修复 einsum TF 插件注册 #9925
已合并
Nice try创建于 10 天前
Nice try
Nice try成员
10 天前

描述

改动原因

dynamic_rnn / dynamic_rnnv2 的 TensorFlow 框架插件此前迁移到本仓后,会引发部分用例 ATC 失败,
本次先行下线处理:删除通过 REGISTER_CUSTOM_OP 注册 TF 源算子映射的 3 个 *_tf_plugin.cpp(共 -244 行)。
同时修复 batch_mat_mul_v3 下 einsum TF 插件的注册:Einsum 算子具有变长(DYNAMIC_INPUT)输入,
原 AutoMappingByOpFn 静态映射无法承载动态输入个数,改用动态映射接口 ParseParamsFn + AutoMappingFnDynamic 完成映射。

改动方法

  1. 删除 rnn/dynamic_rnn/framework/block_lstm_tf_plugin.cpp(-106):
    REGISTER_CUSTOM_OP("DynamicRNN").OriginOpType("BlockLSTM"),将 TF BlockLSTM 解析为 DynamicRNN(cell_type=BLOCKLSTM);
    ParseParamsRNN 透传 forget_bias/cell_clip/use_peephole;ParseOpToGraphRNN 按输入索引重建子图并映射输出。
  2. 删除 rnn/dynamic_rnn/framework/dynamic_rnn_tf_plugin.cpp(-96):
    注册 TF DynamicRNN/DynamicRnn → DynamicRNN;FusionParseParamsFn(DynamicRNNParserParams)基于融合子图节点解析:
    检测 Transpose 节点推断 time_major=false,从 Const 节点(lstm_cell/add/y)解析 forget_bias,输入 1 format 置 HWCN。
  3. 删除 rnn/dynamic_rnnv2/framework/dynamic_rnnv2_tf_plugin.cpp(-42):
    注册 TF DynamicRnnV2/DynamicRnnv2WithoutSeqlength/DynamicRnnv2WithSeqlength → DynamicRNN/DynamicRNNV2,设置 is_misplaced=true。
  4. 修改 matmul/batch_mat_mul_v3/framework/einsum_tf_plugin.cpp(+5 -3):
    • AutoMappingFnEinSum 入参由 const ge::Operator& 改为 const google::protobuf::Message*,
      内部由 AutoMappingByOpFn(op_src, op) 改为 AutoMappingFnDynamic(op_src, op, value),value["in"]=("x","N");
    • 注册由 .ParseParamsByOperatorFn(...) 改为 .ParseParamsFn(...)。
      依据代码:CANN Einsum 算子原型为 DYNAMIC_INPUT(x) + REQUIRED_ATTR(equation) + REQUIRED_ATTR(N)
      (common/inc/op_graph/op_nn_proto_extend.h),映射表将 TF 源输入 "in" 映射到动态输入 "x" 并同步数量属性 "N",
      与 index/concat_offset/framework/concat_offset_tf_plugin.cpp 处理动态输入/输出个数的用法一致。

构建侧无需改动:cmake/func.cmake 中 add_tf_plugin_sources() 通过 file(GLOB FRAMEWORK_DIR/*_tf_plugin.cpp)
自动收集编译,删除即不再参与构建;framework/CMakeLists.txt 仅调用 add_onnx_plugin_sources(),
保留的 ONNX 插件 npu_lstm_onnx_plugin.cpp、npu_lstm_cell_onnx_plugin.cpp 不受影响。

关联的Issue

测试

未新增测试用例。静态检查:仓库内无其他文件显式引用被删除的插件符号或文件名(git grep 验证),
tf_plugin 源文件由 CMake glob 自动收集,删除后无构建残留引用。

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Nice try 的贡献)
Nice tryNice try成员
10 天前 创建了 pull request,commit 0ecf8c60
atomgit-bot
atomgit-bot
10 天前 评论:

变更摘要

该 PR 旨在移除 dynamic_rnn 系列算子面向 TensorFlow 框架的插件注册代码(源分支名为 revert-dynamic,属于回退性质改动),共删除 3 个源文件、244 行代码,无新增内容。删除后,BlockLSTMDynamicRNNDynamicRnnDynamicRnnV2DynamicRNNV2 等 TF 源算子将不再通过自定义算子插件映射到 GE 侧的 DynamicRNN/DynamicRNNV2 算子。

主要改动

  • 删除 block_lstm_tf_plugin.cpp: 移除将 TF BlockLSTM 算子注册映射为 DynamicRNNImplyType::TVM)的插件,包括属性解析函数 ParseParamsRNN(解析 forget_biascell_clipuse_peephole)以及图构建函数 ParseOpToGraphRNN(构建 CastDynamicRNN 子图并设置输入输出索引)。
  • 删除 dynamic_rnn_tf_plugin.cpp: 移除 TF 原生 DynamicRNNDynamicRnn 两个源算子类型的自定义算子注册,以及融合子图解析函数 DynamicRNNParserParams(通过检测 Transpose 节点与 lstm_cell/add/y 常量节点恢复 time_majorforget_bias 属性并更新输入 HWCN 格式描述)。
  • 删除 dynamic_rnnv2_tf_plugin.cpp: 移除 DynamicRnnV2DynamicRnnv2WithoutSeqlengthDynamicRnnv2WithSeqlength 三个 TF 源算子到 DynamicRNN/DynamicRNNV2 的注册逻辑,其中 ParseParamsDynamicRNN 中设置 is_misplaced 属性的行为也随之移除。
likedislike
不准确?
atomgit-bot
atomgit-bot
10 天前 评论:

代码审查

✅ 未发现问题

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

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
matmul 陈琦, 汤平川 (2/2) 陈琦 (1/1)
rnn 汤平川, 陈兴宇, 陈琦 (3/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

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

likedislike
CANN-robotCANN-robot成员
10 天前 将zengjuan,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,su-yueming,chenqi317,wang-xing001,liubo75,tangweiwei2,chenxingyu18,pingchuantang,qianzehong,liuchuangdev设为评审人
CANN-robotCANN-robot成员
10 天前 将kevin_huang1234,su-yueming,wang-xing001,chenxingyu18,pingchuantang,qianzehong,liuchuangdev设为审查人
yuning_chen
yuning_chen成员
9 天前 评论:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!

likedislike
Nice try
Nice try成员
9 天前 评论:

compile

likedislike
Nice tryNice try成员
9 天前 预合并成功(commit_id: e16cfeb134efc73d00ce87a6233f701006c05f0d)
CANN-robot
CANN-robot成员
9 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:ci-pipeline-running
此处折叠了6条事件消息 查看更多
CANN-robotCANN-robot成员
9 天前 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
9 天前 评论:

Notification

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

likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:cann-cla/yes
此处折叠了6条事件消息 查看更多
CANN-robotCANN-robot成员
9 天前 添加了label:cann-cla/yes
Nice try
Nice try成员
9 天前 评论:

compile

likedislike
Nice tryNice try成员
9 天前 预合并成功(commit_id: 82190144034b67e950bd62ed87c649c38f99aa72)
CANN-robot
CANN-robot成员
9 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
9 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9 天前 添加了label:ci-pipeline-passed
yuning_chen
yuning_chen成员
9 天前 评论:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!

likedislike
Nice tryNice try成员
9 天前 修改标题为 “refactor: 移除 dynamic_rnn/dynamic_rnnv2 系列 TF 插件并修复 einsum TF 插件注册”,原标题为“rm tf plugin of dynamic_rnn”
Nice tryNice try成员
9 天前 修改了pull request 的描述
chenxingyu18成员
9 天前 评论:

/lgtm
/approve

likedislike
TangPC
TangPC成员
9 天前 评论:

/lgtm
/approve

likedislike
chenqi317成员
9 天前 评论:

/lgtm
/approve

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