runtime 仓的 pkg_inc/aicpu_sched/cpu_kernels/ 当前对外仅提供一套 CpuKernel V1 注册/查询/执行接口(RegistCpuKernel / GetCpuKernel / RunCpuKernel / RunCpuKernelAsync 等)。上层(GE 常量折叠、opbase 调度等)希望按"V2 优先、V1 兜底"策略渐进式演进时,没有独立的 V2 接口面可用,导致:
pkg_inc/aicpu_sched/cpu_kernels/
RegistCpuKernel
GetCpuKernel
RunCpuKernel
RunCpuKernelAsync
creatorMap_
creatorMapV2_
IsRegisteredV2
GetAllRegisteredOpTypesV2
op_type → so handle
cpu_kernel.h
新增 V2 注册入口与宏:
AICPU_VISIBILITY bool RegistCpuKernelV2(const std::string &type, const KERNEL_CREATOR_FUN &fun); #define REGISTER_CPU_KERNELV2(type, clazz) /* 形态与 V1 对称,写入 V2 表 */
cpu_kernel_register.h
std::shared_ptr<CpuKernel> GetCpuKernelV2(const std::string &op_type)
nullptr
bool IsRegisteredV2(const std::string &op_type) const
std::vector<std::string> GetAllRegisteredOpTypesV2() const
uint32_t RunCpuKernelV2(CpuKernelContext &ctx)
uint32_t RunCpuKernelAsyncV2(...)
class RegisterarV2
Registerar
私有侧抽取公共逻辑:RunCpuKernelCommon / SetAsyncKernelContext / RunCpuKernelAsyncCommon,避免 V1/V2 之间复制粘贴。
RunCpuKernelCommon
SetAsyncKernelContext
RunCpuKernelAsyncCommon
AICPU_VISIBILITY
/assign
Background(背景信息)
runtime 仓的
pkg_inc/aicpu_sched/cpu_kernels/当前对外仅提供一套 CpuKernel V1 注册/查询/执行接口(RegistCpuKernel/GetCpuKernel/RunCpuKernel/RunCpuKernelAsync等)。上层(GE 常量折叠、opbase 调度等)希望按"V2 优先、V1 兜底"策略渐进式演进时,没有独立的 V2 接口面可用,导致:Origin(信息来源)
Benefit / Necessity(价值/作用)
creatorMap_与creatorMapV2_独立),可在不破坏现有算子注册的前提下接入 V2 实现。IsRegisteredV2不实例化 kernel,仅查表,配合 GE/opbase 侧"V2 优先"路由可以零额外开销快速分流。GetAllRegisteredOpTypesV2提供 V2 全量 op_type 枚举,让上层在 dlopen 后建立op_type → so handle的反向索引,运行期 O(1) 命中正确的 so。Design(设计方案)
1. 注册侧(
cpu_kernel.h)新增 V2 注册入口与宏:
AICPU_VISIBILITY bool RegistCpuKernelV2(const std::string &type, const KERNEL_CREATOR_FUN &fun); #define REGISTER_CPU_KERNELV2(type, clazz) /* 形态与 V1 对称,写入 V2 表 */2. 查询/执行侧(
cpu_kernel_register.h)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() constuint32_t RunCpuKernelV2(CpuKernelContext &ctx)uint32_t RunCpuKernelAsyncV2(...)class RegisterarV2Registerar对称私有侧抽取公共逻辑:
RunCpuKernelCommon/SetAsyncKernelContext/RunCpuKernelAsyncCommon,避免 V1/V2 之间复制粘贴。3. 兼容性
AICPU_VISIBILITY,符号导出与 V1 等价。验证方式