Merged
feat(pypto-pro): Support infer kernel type in pypto_compile_op #6614
poorwillAdd on Sep 22
feat(pypto-pro): Support infer kernel type in pypto_compile_op #6614
Merged
poorwillAdd on Sep 22
poorwill
poorwillCollaborators
Sep 22

feat(pypto-pro): Support infer kernel type in pypto_compile_op

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for poorwill's contribution.)
poorwillpoorwillCollaborators
Sep 22 Created pull request, commit da8ace6f
atomgit-bot
atomgit-bot
Sep 22 Comments:

变更摘要

该 PR 让 pypto_compile_op 不再固定按 KERNEL_TYPE_MIX_AIC_1_2 编译,而是从 codegen 结果与编译配置中推断实际的 kernel 类型(AIC only / AIV only / mix 1:1 / mix 1:2)。改动引入基于核心比值的 KernelMetaType 推断逻辑,并将物理核选择、编译目标命名、编译宏选项、infer 源生成以及 compile_info 元数据都改为随推断出的 kernel 类型变化;同时补充了对推断函数与编译目标生成逻辑的单元测试。

主要改动

  • 新增 kernel 类型推断:新增 _kernel_type_from_target / _kernel_type_from_codegen,通过 _KERNEL_TYPE_BY_CORE_RATIO 将 aic_per_block:aiv_per_block 比值映射为 KernelMetaType,并由 get_jit_compile_config().resolve_kernel_target 结合 has_cube / has_vector 得到目标,不支持的比值抛出 InvalidVal。
  • 编译目标按类型动态选择:将固定双核的 _MIX_CORE_COMPILE_TARGETS 替换为 _CORE_COMPILE_TARGETS 字典,新增 _compile_core_names 决定所需物理核、_compile_target_name 决定目标名(仅 mix 类型追加 _mix_aic / _mix_aiv)、_compile_target_options 按类型生成编译宏(MIX_CORE_MACRO、__MIX_CORE_AIC_RATION__、C310 相关宏等)。
  • infer 源与准备函数携带 kernel 类型:_gen_infer_cpp 新增 kernel_type 参数、_prepare_infer_cpp 改为返回 (infer_cpp_path, kernel_type),KERNEL_TASK_TYPE_DEFAULT 改用推断出的 kernel_type.name,取代硬编码的 KERNEL_TYPE_MIX_AIC_1_2。
  • compile_info 与 tiling 配置随类型更新:在 pypto_compile_op 中写入 default_kernel_type、no_set_kernel_type、tiling_key_kernel_type、raw_tiling_key_kernel_type,并按 kernel 类型设置 tiling_info.task_ration(1:1 为 1、1:2 为 2);同时逐 key 校验 codegen 推断类型一致,不一致抛 InvalidOperation,且仅对实际需要的核生成编译命令与 .mk。
  • 补充单元测试:在 test_generate_binary_headers.py 中新增用例,覆盖核心比值到 kernel 类型的映射、codegen 推断、core 名称、编译目标命名、编译选项以及 infer 源使用推断类型等行为。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 22 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 22 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
python/pypto_pro ✅ gaoxiang618, tsungl4 (2/2) ✅ gaoxiang618 (1/1)
repo-cann/pypto ✅ tsungl4, gaoxiang618 (2/2) ✅ tsungl4, gaoxiang618 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,WenboCodes as approver
5 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
poorwill
poorwillCollaborators
Sep 22 Comments:

compile

likedislike
poorwillpoorwillCollaborators
Sep 22 Pre merge succeeded (commit_id: 371ed07764e5a3fa57475009f6b5ed910031c4ff)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-failed
poorwillpoorwillCollaborators
Sep 23 Associated issue: [Task|任务跟踪]: pypto-pro二进制模式支持kernel type探测
poorwill
poorwillCollaborators
Sep 23 Comments:

compile

likedislike
poorwillpoorwillCollaborators
Sep 23 Pre merge succeeded (commit_id: 9adaf46977b738e97dc2874a9225b76d629c4f65)
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-passed
gaoxiang618
gaoxiang618Collaborators
Sep 23 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Added label: approved
lidongsheng
lidongshengCollaborators
Sep 23 Comments:

/lgtm
/approve

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