Merged
feat(opdev): add external op task framework integration #962
feat(opdev): add external op task framework integration #962
Merged
su-yuemingAdd on Sep 29
su-yueming
su-yuemingCollaborators
Sep 29

描述

feat(opdev): add external op task framework integration
此前外部/自定义算子接入 ACLNN 执行框架需依赖 AI Core kernel launcher 或旧的描述符式接口,无法覆盖"实现方自主完成实现选择、tiling 与 kernel 下发"的场景。本 PR 在 opdev 层新增 Direct Invoke 任务接入框架,以三回调 SPI 替代原描述符式接口
原PR:https://gitcode.com/cann/opbase/pull/879/diffs

关联的Issue

#429

测试

文档更新

  • 新增接口文档 AddDirectInvokeTask.md ;
  • 更新 common_macros_and_classes.md 。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for su-yueming's contribution.)
su-yuemingsu-yuemingCollaborators
Sep 29 Created pull request, commit 568e7fbd
su-yuemingsu-yuemingCollaborators
Sep 29 Associated issue: [Requirement|需求建议]: add external op task framework integration
atomgit-bot
atomgit-bot
Sep 29 Comments:

变更摘要

本 PR 在 opdev 层引入外部/自定义算子的 Direct Invoke 任务接入框架,以三回调 SPI 替代原描述符式接口,覆盖"实现方自主完成实现选择、tiling 与 kernel 下发"的场景。新增头文件 include/nnopbase/opdev/direct_invoke_task.h 定义接入契约,并在 src/nnopbase/composite_op/aclnn_engine/direct_invoke_task.cpp 中实现任务注册、参数校验、workspace 分配与执行逻辑;同时新增 DIRECT_INVOKE 计算任务类型、OpArgContext 访问接口、打包/桩代码白名单及配套单元测试。

主要改动

  • 新增三回调 SPI 接入接口: 在 direct_invoke_task.h 中定义 DirectInvokePrepareFn、DirectInvokeLaunchFn、DirectInvokeDestroyFn 三个不可抛异常的回调类型与 DirectInvokeWorkspaceRequest 结构,并提供入口函数 AddDirectInvokeTask,明确 prepare 同步执行、launch/destroy 生命周期及状态释放语义。
  • 新增引擎中立的计算任务类型: 在 op_def.h 的 CoreType 枚举中新增 DIRECT_INVOKE,作为引擎中立的计算任务类别而非设备引擎标识。
  • 实现 Direct Invoke 任务注册与执行: 新增 DirectInvokeKernelLauncher 类及 AddDirectInvokeTask 实现,负责入参校验(回调、opType、可选输入/必选输出、入口 workspace 必须为空)、按 prepare 请求通过 AppendRequestedWorkspaces 分配 DT_UINT8 workspace、注册到 executor 并调用 AbandonCache 禁用设备任务缓存;Launch 中完成输入输出 dump、溢出检查与基于 opType 的 DFX 归因。
  • 扩展参数上下文查询接口: 在 op_arg_def.h 中新增 OpArgContext::GetOpArg 以按 OpArgDef 返回 OpArgList 指针,并将 ContainsOpArgType 改为 const,供新框架读取输入/输出/属性/workspace 参数。
  • 完善打包与桩生成配置: 在 opbase.xml 与 gen_stubapi.py 白名单中登记 direct_invoke_task.h,将其纳入对外安装头文件与 stub API 生成范围。
  • 新增单元测试覆盖: 在 tests/nnopbase/ut/composite_op/test_direct_invoke.cpp 中覆盖多回调分派、workspace 分配与校验、prepare/launch 失败路径的状态释放、可选输入与张量列表参数、缓存禁用与重复执行、以及回调边界不产生 profiling 归因等行为。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 29 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 29 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Sep 29 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 29 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
9.2.0 ✅ gcw_kUomxQ2l, 周奇龙 (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Set pengjiahao96,zhou-qilong,wangrui_,rxtfeng,loov1,tang-lei01,TianXL,jia0liang,zl_hw,songkai111,jiangtao_rts,gitcode-chenjiao,hanxiaolong,pingchuantang,llimwang,gubaocheng,wangyongguang,gcw_kUomxQ2l,Andy-lb as approver
CANN-robotCANN-robotCollaborators
Sep 29 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
su-yueming
su-yuemingCollaborators
Sep 29 Comments:

compile

likedislike
su-yuemingsu-yuemingCollaborators
Sep 29 Pre merge succeeded (commit_id: d7b42e66d09471c7c79493fcd884f83a2186da38)
su-yuemingsu-yuemingCollaborators
Sep 29 Modify description of pull request
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 29 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 29 Added label: ci-pipeline-passed
liulun0308
liulun0308Collaborators
Sep 29 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: approved
sunday
sundayCollaborators
Sep 29 Comments:

/lgtm
/approve

likedislike
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: 周奇龙

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 29 Merged pull request