已合并
feat: 统一 OM2 任务启动回调并支持多类任务 #4596
ClarkXie创建于 8月27日
feat: 统一 OM2 任务启动回调并支持多类任务 #4596
已合并
ClarkXie创建于 8月27日
ClarkXie
ClarkXie成员
8月27日

Pull Request

描述

本 PR 统一 OM2 模型生成代码中 AICore、AICPU、TensorFlow AICPU 和 DSA 任务的启动回调流程,通过 GertModelLaunchTask 回调承接不同类型的任务启动,并保留未配置回调时直接调用运行时接口的 fallback 路径。

  • 新增统一的任务启动类型、参数和任务信息结构,供生成代码与 executor 回调使用。
  • AICore、AICPU、TensorFlow AICPU 和 DSA 生成代码通过对应的 distribute 流程发起回调或 fallback 启动,参数拷贝在启动返回后执行。
  • executor 回调集中处理数据 dump 查询、适用任务的 DFX 前处理、profiling 时间记录、运行时启动和任务 ID/DFX 后处理。
  • 保留 Custom 现有弱符号 Report 路径,不改变其任务启动流程。

变更类型

请选择本次引入的变更类型:

关联的Issue

本 PR 暂无关联 Issue。

如何测试

描述测试此变更的步骤和前提条件:

  1. 已执行 git diff --check,检查通过。
  2. 已核对生成器和 executor 回调代码,覆盖回调/fallback、Kernel V2、Stars Task、数据 dump 及 DFX/profiling 流程。
  3. 按本次变更约定,未编译、未运行 UT/ST。

核对清单

其他信息

本 PR 仅涉及 OM2 任务启动回调、运行时 executor 回调和相关生成代码;按当前范围不修改独立设计文档。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 ClarkXie 的贡献)
ClarkXieClarkXie成员
8月27日 创建了 pull request,commit aa4e1011
atomgit-bot
atomgit-bot
8月27日 评论:

变更摘要

本 PR 统一 OM2 的 kernel launch 回调机制:新增 GertLaunchType 枚举(GERT_LAUNCH_KERNEL/GERT_LAUNCH_DSA)、GertKernelLaunchParams、GertDsaLaunchParams、GertLaunchParams union、GertTaskLaunchInfo 及 GertLaunchFunc 回调类型,重构 GertModelCallbacks(移除 report_task_preprocess/report_task_postprocess/get_data_dump_enabled,新增 launch_func 字段)。executor 侧以通用 LaunchTask 按 launch_type 分发,codegen 侧 AICore 分发流程改为统一组装 GertTaskLaunchInfo 并调用回调;DSA 分支与 Custom 弱符号 Report 路径(ReportDfxTaskPreprocess/ReportDfxTaskPostprocess)均保留,为后续 SQE launch 接入预留。

主要改动

  • 新增统一 launch 回调接口(inc/framework/runtime/dump/model_dump_c_api.h 与 stable_part_provider.cc 生成的稳定代码):新增 GertLaunchType、GertKernelLaunchParams、GertDsaLaunchParams、GertLaunchParams、GertTaskLaunchInfo 及 GertLaunchFunc 定义;GertModelCallbacks 删除三个旧回调字段,仅保留 report_model_base_info 并新增 launch_func。
  • executor 实现通用分发(om2_model_executor.cc):新增 LaunchTask 按 launch_type 分发到 LaunchKernelTask/LaunchDsaTask;LaunchKernelTask 依次完成 ReportDfxTaskPreprocess、aclrtLaunchKernelV2 下发、aclrtGetThreadLastTaskId 记录 task_id 及 ReportDfxTaskPostprocess;LaunchDsaTask 预留并返回 ACL_ERROR_API_NOT_SUPPORT,GertModelCallbacks 初始化改为 launch_func = LaunchTask。
  • AICore 分发流程改造(kernel_task_code_builder.cc):KernelTaskDistribute 签名由 (io_addrs, args_info, func_handle, block_dim, stream, config) 改为 (launch_info, launch_func, instance_handle),优先走 launch_func 回调;分发前改为通过 AssembleOm2TaskInfo 组装 Om2TaskInfo 并构造 GertKernelLaunchParams/GertLaunchParams/GertTaskLaunchInfo,移除 ReportOm2TaskPreprocess/ReportLaunchedOm2Task 调用,MemcpyS args 拷贝移到 launch 之后。
  • 模型类新增 launch 回调成员(om2_model_class_generator_base.cc/.h、interface_file_code_generator.cc、resources_file_code_generator.cc、load_and_run_file_code_generator.cc):模型类新增 launch_func_(GertLaunchFunc)字段,构造函数中初始化为 nullptr,Load 阶段在 callbacks 非空且 launch_func 非空时将其赋值给 launch_func_。
  • 测试同步更新(om2_codegen_unittest.cc、program_generator_unittest.cc):接口 dump 测试校验新增 launch 结构体存在且旧字段 report_task_preprocess/report_task_postprocess/get_data_dump_enabled 已移除;新增 AICore 生成代码使用统一回调的测试,校验 KernelTaskDistribute(&launch_info, ...) 新签名及 AssembleOm2TaskInfo 组装流程。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月27日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月27日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月27日 评论:

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
repo-cann/ge ✅ yangyongqiang0606, Mexyy (2/2) ✅ yangyongqiang0606 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
此处折叠了321条消息 查看更多
夏国正成员
8月29日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
8月29日 添加了label:lgtm
yangyongqiang
yangyongqiang成员
8月29日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
8月29日 添加了label:approved
CANN-robotCANN-robot成员
8月29日 合入了pull request