已合并
feat: 添加LeftShift算子TensorFlow框架插件 #3957
songkai111创建于 7月9日
feat: 添加LeftShift算子TensorFlow框架插件 #3957
已合并
songkai111创建于 7月9日
songkai111成员
7月9日

描述

将 LeftShift 算子的 TensorFlow 插件迁移到 ops-math 仓库。新增 math/left_shift/framework/left_shift_tf_plugin.cpp 文件,通过 REGISTER_CUSTOM_OP 宏注册 LeftShift 算子的 TensorFlow 框架适配插件。

该插件主要完成以下配置:

  • 框架类型:TensorFlow(FrameworkType(TENSORFLOW))
  • 原始算子类型:LeftShift(OriginOpType("LeftShift"))
  • 参数解析方式:自动映射(ParseParamsByOperatorFn(AutoMappingByOpFn))
  • 执行类型:AI_CPU(ImplyType(ImplyType::AI_CPU))

关联的Issue

  • #2202

测试

待补充:二级冒烟测试、算子泛化测试等。

文档更新

无需文档更新。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 songkai111 的贡献)
Ssongkai111成员
7月9日 创建了 pull request,commit 7694876c
atomgit-bot
atomgit-bot
7月9日 评论:

变更摘要

此 PR 将 LeftShift 算子的 TensorFlow 插件迁移至 ops-math 仓,新增了 math/left_shift/framework/left_shift_tf_plugin.cpp 文件,用于注册 LeftShift 算子的 TF 框架适配逻辑。

主要改动

  • 新增 left_shift_tf_plugin.cpp 文件:在 math/left_shift/framework/ 目录下新建 TF 插件源文件,包含版权声明、头文件引用及算子注册实现。
  • 实现 AutoMappingByOpFnLeftShift 映射函数:该函数封装 AutoMappingByOpFn 实现算子自动映射,并在失败/成功时分别通过 OP_LOGE 和 OP_LOGI 输出日志。
  • 注册 LeftShift 算子为 TF 框架插件:通过 REGISTER_CUSTOM_OP("LeftShift") 宏将算子注册为 TENSORFLOW 框架的 AI_CPU 类型算子,指定原始算子类型为 "LeftShift" 并绑定解析函数。
likedislike
不准确?
atomgit-bot
atomgit-bot
7月9日 评论:

代码审查

审查总结

本次变更文件共 1 个,已全部审查完毕:

  • math/left_shift/framework/left_shift_tf_plugin.cpp:发现 1 个 P3 问题(包装函数丢弃 AutoMappingByOpFn 的原始错误码,统一返回 FAILED,可能损失错误诊断信息)。

发现问题按优先级统计:

  • P0:0
  • P1:0
  • P2:0
  • P3:1

整体风险评估:低风险。 该变更是一个新增的 TensorFlow 插件注册文件,结构与项目中已有的 arg_min_tf_plugin.cpp 模式一致。代码逻辑简单、无内存管理问题、无安全漏洞、无并发风险。唯一的 P3 问题是在错误路径上丢弃了原始错误码,属于轻微的错误处理精度问题,不影响功能正确性。

⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。

likedislike
不准确?
CANN-robotCANN-robot成员
7月9日 添加了label:cann-cla/no
CANN-robot
CANN-robot成员
7月9日 评论:

CLA Signature Guide

@songkai111 , thanks for your pull request.

The following commit(s) have not signed Contributor License Agreement (CLA).

Commit Reason
7f191028 迁移LeftShift算子tf插件到... the email is not signed for CLA! please check if it is correct and the same as your signed email.

If you need to sign CLA, you can click here to sign the CLA.

If you need to check if the email is set up correctly, you can click here to do it in the FAQs.

After signing the CLA or updating the email, you must comment /check-cla to check the CLA status again.

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

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


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/ops-math ✅ 王林木, 张磊 (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

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

likedislike
CANN-robotCANN-robot成员
7月9日 将zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,llimwang,gubaocheng,andong_hw,zhanw_coding设为评审人
CANN-robotCANN-robot成员
7月9日 将zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,llimwang,gubaocheng,andong_hw,zhanw_coding设为审查人
songkai111成员
7月9日 评论:

compile

likedislike
Ssongkai111成员
7月9日 预合并成功(commit_id: afadd339aa7da7934b859ee6c83f90427f7d58c4)
CANN-robotCANN-robot成员
7月9日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月9日 评论:

流水线任务触发成功
任务链接 [c906f75b3af54edbae6caf46191d6671][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
Compile_harmony-infer-chs-math ✅ SUCCESS >>>>>

[2026-07-09 21:21:53]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

流水线任务触发成功
任务链接 [4970c549344043d9a235c5dca6fa9705][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>

[2026-07-09 21:17:51]    CI执行结束

likedislike
Ssongkai111成员
7月9日 预合并成功(commit_id: 120dcc97f839c5bf4a0ad7247d00efad9323eced)
此处折叠了10条事件消息 查看更多
CANN-robotCANN-robot成员
7月10日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
7月10日 评论:

Notification

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

likedislike
songkai111成员
7月10日 评论:

compile

likedislike
Ssongkai111成员
7月10日 预合并成功(commit_id: fde0155dc258abd54facf02f456d2851d07b4ada)
CANN-robotCANN-robot成员
7月10日 删除了label:api-check-pass
CANN-robotCANN-robot成员
7月10日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月10日 评论:

流水线任务触发成功
任务链接 [f2814ba8715b45c187071977e9c8df01][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
Compile_harmony-infer-chs-math ✅ SUCCESS >>>>>

[2026-07-10 09:25:46]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
7月10日 评论:

流水线任务触发成功
任务链接 [f6fe402f1d104c8fb3392d06878082af][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>

[2026-07-10 09:13:39]    CI执行结束

likedislike
Ssongkai111成员
7月10日 修改标题为 “feat: 添加LeftShift算子TensorFlow框架插件”,原标题为“迁移LeftShift算子tf插件到ops-math仓”
Ssongkai111成员
7月10日 修改了pull request 的描述
CANN-robotCANN-robot成员
7月10日 添加了label:api-check-pass
CANN-robotCANN-robot成员
7月10日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月10日 添加了label:ci-pipeline-passed
llimwang成员
7月10日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月10日 添加了label:approved
zl_hw成员
7月10日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
7月10日 添加了label:lgtm
CANN-robotCANN-robot成员
7月10日 关闭了关联的issue
CANN-robotCANN-robot成员
7月10日 合入了pull request