Pull Request已成功合入, 合并人@CANN-robot
(感谢 songkai111 的贡献)变更摘要
此 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"并绑定解析函数。


代码审查
审查总结
本次变更文件共 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 问题是在错误路径上丢弃了原始错误码,属于轻微的错误处理精度问题,不影响功能正确性。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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.


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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


compile


流水线任务触发成功
任务链接 [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执行结束


流水线任务触发成功
任务链接 [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执行结束


compile


流水线任务触发成功
任务链接 [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执行结束


流水线任务触发成功
任务链接 [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执行结束


描述
将 LeftShift 算子的 TensorFlow 插件迁移到 ops-math 仓库。新增
math/left_shift/framework/left_shift_tf_plugin.cpp文件,通过REGISTER_CUSTOM_OP宏注册 LeftShift 算子的 TensorFlow 框架适配插件。该插件主要完成以下配置:
FrameworkType(TENSORFLOW))OriginOpType("LeftShift"))ParseParamsByOperatorFn(AutoMappingByOpFn))ImplyType(ImplyType::AI_CPU))关联的Issue
测试
待补充:二级冒烟测试、算子泛化测试等。
文档更新
无需文档更新。
类型标签