Pull Request已成功合入, 合并人@CANN-robot
(感谢 liu-lu 的贡献)变更摘要
此 PR 主要围绕"常量折叠和 infershape 整改",对 math 算子模块进行统一整改:将多个算子的内核注册宏从 REGISTER_CPU_KERNEL 替换为 OPS_MATH_REGISTER_CPU_KERNELV2,将 SelectV2 的算子定义从 JSON 配置文件迁移到 C++ OpDef 类,并为 SearchSorted 新增 InferShape 实现。这些改动涉及 6 个算子的内核注册、1 个算子的定义方式重构以及 1 个算子的 shape 推导补齐。
主要改动
-
内核注册宏统一替换: 将
Add、Round、SearchSorted、SelectV2、Square、SquaredDifference共 6 个算子中的REGISTER_CPU_KERNEL替换为OPS_MATH_REGISTER_CPU_KERNELV2,并新增#include "aicpu/math_aicpu_register.h"头文件引用,实现注册方式的统一。 -
SelectV2算子定义从 JSON 迁移到 C++OpDef: 删除了select_v2.json配置文件(31 行),新增select_v2_aicpu_def.cpp,通过继承OpDef类定义SelectV2的输入输出数据类型约束,并调用ApplyMathAICpuDefaultCfg和ExtendCfgInfo完成配置。 -
SearchSorted新增 InferShape 实现: 新增search_sorted_infershape.cpp,实现InferShape4SearchSorted函数——将输出 shape 设置为与values输入相同的 shape,并通过IMPL_OP_INFERSHAPE(SearchSorted)注册。 -
分类规则补充: 在
classify_rule.yaml中新增ops/ops-math/math/search_sorted/op_host/路径,将SearchSorted的 host 端代码纳入分类管理。


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 |
|---|---|---|
| math/add | ✅ 冯彤, 宋恺 (2/2) | ✅ 宋恺, 冯彤 (2/1) |
| math/round | ✅ 冯彤, 宋恺 (2/2) | ✅ 冯彤, 宋恺 (2/1) |
| math/search_sorted | ✅ 刘伟, 冯彤, 宋恺 (3/2) | ✅ 冯彤, 宋恺, 刘伟 (3/1) |
| math/square | ✅ 冯彤, 宋恺 (2/2) | ✅ 宋恺, 冯彤 (2/1) |
| 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
liu-lu, thanks for your pull request. All authors of the commits have signed the CLA. 👍


描述
本 PR 为 6 个 AICPU 算子(add、round、search_sorted、select_v2、square、squared_difference)使能 GE 图编译期常量折叠,并对 search_sorted、select_v2 进行 infershape/OpDef 整改。
变更内容
1. 常量折叠使能(6 算子)
HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2HOSTCPU TRUEREGISTER_CPU_KERNEL→OPS_MATH_REGISTER_CPU_KERNELV2#include "aicpu/math_aicpu_register.h";HOSTCPU TRUE,将算子编入 host 侧折叠 so(libopconstant_folding_math.so)。2. infershape / OpDef 整改
op_host/search_sorted_infershape.cpp,实现InferShape4SearchSorted,输出 shape 取 values(input1)的 shape;op_kernel_aicpu/select_v2_aicpu_def.cpp(基于 OpDef 注册输入输出数据类型),删除旧select_v2.json(JSON 配置方式),统一为 OpDef 注册链路。关联的Issue
#2847
测试
根据代码变更,测试场景如下:
编译构建测试
HOSTCPU TRUE配置变更正确;libopconstant_folding_math.so中已编入上述 6 个算子的 host 侧 kernel。常量折叠验证
InferShape 验证(search_sorted)
算子注册/加载验证(select_v2)
算子泛化
文档更新
本 PR 不涉及 README/aclnn 接口文档更新。
类型标签