已合并
feat: 提供 AICPU CpuKernel V2 注册与查询接口 #1522
pantong创建于 4月11日
feat: 提供 AICPU CpuKernel V2 注册与查询接口 #1522
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 pantong 的贡献)CANN-robot
4月11日 评论:
4月11日 评论:
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 |
|---|---|---|
| pkg_inc | ✅ 张子菁, zhangpengpeng8 (2/2) | ✅ 张子菁 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
pan-tong, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月11日 添加了label:cann-cla/yes
4月11日 将wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood设为评审人
4月11日 将wangtao43,ykl999,houyanbao,tingwood设为审查人
此处折叠了202条消息 查看更多
CANN-robot
5月18日 评论:
5月18日 评论:
The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


CANN-robot
5月18日 评论:
5月18日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: 张子菁.
Reviewers who wrote a comment of /lgtm are: 张子菁, zhangpengpeng8.


5月18日 关闭了关联的issue
5月18日 合入了pull request
Pull Request
描述
本 PR 在 runtime 仓的
pkg_inc/aicpu_sched/cpu_kernels/头文件中补充一套独立于现有 V1 的 CpuKernel V2 注册、查询、执行与枚举接口,为 GE 常量折叠等上层场景按"V2 优先、V1 兜底"渐进式演进提供底层 ABI 能力。1.
cpu_kernel.h新增 V2 注册入口与对称宏:
AICPU_VISIBILITY bool RegistCpuKernelV2(const std::string &type, const KERNEL_CREATOR_FUN &fun); #define REGISTER_CPU_KERNELV2(type, clazz) /* 形态与 REGISTER_CPU_KERNEL 对称 */REGISTER_CPU_KERNELV2通过 file-scope 静态全局变量调用RegistCpuKernelV2,把 creator 写入独立的 V2 注册表。2.
cpu_kernel_register.hclass CpuKernelRegister扩展如下 V2 接口(与 V1 对称、互不影响):std::shared_ptr<CpuKernel> GetCpuKernelV2(const std::string &op_type)creatorMapV2_,未命中返回nullptr,不回退 V1;不输出"未注册"日志,避免对回退路径产生误导bool IsRegisteredV2(const std::string &op_type) conststd::vector<std::string> GetAllRegisteredOpTypesV2() constop_type → so handle反向索引uint32_t RunCpuKernelV2(CpuKernelContext &ctx)uint32_t RunCpuKernelAsyncV2(CpuKernelContext &ctx, uint8_t wait_type, uint32_t wait_id, std::function<uint32_t()> cb)class RegisterarV2Registerar对称私有侧抽取公共逻辑:
RunCpuKernelCommon(ctx, type, kernel):去重 V1/V2 同步执行核心。SetAsyncKernelContext(type, wait_type, wait_id):复用异步 ctx 设置逻辑。RunCpuKernelAsyncCommon(...):去重 V1/V2 异步执行核心。成员新增
std::map<std::string, KERNEL_CREATOR_FUN> creatorMapV2_,与 V1creatorMap_完全隔离。变更类型
关联的Issue
关联 Issue #512
如何测试
1. 头文件兼容性
依赖
pkg_inc/aicpu_sched/cpu_kernels/cpu_kernel.h与cpu_kernel_register.h的现有 V1 用户代码回归编译,确认:RegistCpuKernel/REGISTER_CPU_KERNEL/GetCpuKernel/RunCpuKernel/RunCpuKernelAsync签名零变化。AICPU_VISIBILITY修饰,符号导出与 V1 一致。2. 配套仓 V2 接口联调
RegistCpuKernelV2/RegisterV2/ V2 系列方法的实现,编译通过。GetAllRegisteredOpTypesV2/IsRegisteredV2/RunCpuKernelV2,验证 V2 反向索引建立与 O(1) 命中。3. UT
依托 opbase 侧
CpuKernelRegisterUT 覆盖 V2 注册、查询、执行(同步/异步)行为。4. 端到端
联合 cann/runtime#1522、cann/ge#1824 进行常量折叠 V2 端到端验证:


核对清单
其他信息