Merged
feat: 自定义算子注册支持 engine and priority,常量折叠适配 #4918
duhuaAdd on Sep 11
feat: 自定义算子注册支持 engine and priority,常量折叠适配 #4918
Merged
duhuaAdd on Sep 11
duhua
duhuaCollaborators
Sep 11

Pull Request

描述

本 PR 主要实现自定义算子按 engine、priority 和 backend 注册/查询/创建,并将其适配到常量折叠 Host CPU 执行路径,同时保留原有注册接口的兼容行为。

主要变更:

  • 新增 OpRegistrationPriority(kTop / kBottom)、OpEngine,扩展 CustomOpRegistry 的注册、查询、实例创建和能力获取接口,注册维度为 (op_type, engine_type, priority, backend)。
  • 扩展 CustomOpFactory 与 CustomOpCreatorRegister,新增带 priority/engine 的 API;默认接口保持使用 engine = OpEngine::kCustom、priority = kTop。
  • 新增 REG_OP_WITH_PRIORITY 宏,支持为自定义算子显式指定 backend、priority 和 engine,并保留既有注册宏。
  • ConstantFoldingPass::RunOpKernel 优先处理 OpEngine::kHostCpu engine 下的 bottom-priority Host CPU 自定义算子;命中后通过 HostCpuExecuteOp 执行,未命中时回退原有 OpKernelRegistry 路径,创建失败不错误回退。
  • 补充 registry priority/engine 及常量折叠执行路径 UT,覆盖注册查询、实例缓存与隔离、非法/重复注册、优先级选择和 legacy kernel 回退行为。
  • 辅助修复 stub graph target 体积:将 ge_log.h 从公共头 args_format_desc.h 移到实际使用日志宏的实现文件,减少 Ascend031 tiny.arm runtime 包中 libgraph.so 的链接依赖。

变更类型

关联的Issue

无

如何测试

  1. 新增的 custom-op registry 与 constant-folding UT 覆盖 engine/priority 注册、实例缓存、优先级选择、执行失败及 legacy kernel 回退场景。

核对清单

其他信息

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for duhua's contribution.)
duhuaduhuaCollaborators
Sep 11 Added label: enhancement
duhuaduhuaCollaborators
Sep 11 Created pull request, commit 05de3330
CANN-robotCANN-robotCollaborators
Sep 11 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 11 Comments:

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
compiler/engines/nn_engine ✅ yangyongqiang0606, kobemini (2/2) ✅ yangyongqiang0606 (1/1)
inc/graph_metadef/external ✅ 王涛, kobemini, yangyongqiang0606 (3/2) ✅ 王涛 (1/1)
repo-cann/ge ✅ 王涛, yangyongqiang0606, kobemini (3/2) ✅ 王涛, yangyongqiang0606 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 11 Set yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9 as approver
188 messages are collapsed here。 See more
王涛
王涛Collaborators
Sep 14 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 14 Added label: lgtm
yangyongqiang
yangyongqiangCollaborators
Sep 14 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 14 Added label: approved
CANN-robotCANN-robotCollaborators
Sep 14 Merged pull request