Merged
feat: aclnnTopk 支持 sortLen 超 int32 上限的 RadixTopK int64 索引 #10291
feat: aclnnTopk 支持 sortLen 超 int32 上限的 RadixTopK int64 索引 #10291
Merged
Nice tryAdd on Sep 11
Nice try
Nice tryCollaborators
Sep 11

描述

本改动为 aclnnTopk 接口接入 RadixTopK 的 int64 大 shape 路径:当排序轴长度 sortLen 超过 int32 上限(2147483647)时,RadixTopK 支持判定改为要求 indices 输出为 int64 并放行,同时在 positiveDim 等于 lastDim 分支对 int64 索引直接透传,绕过暂不接管该场景的 Sort/GatherElementsV2 组合。此外修正两条参数校验错误日志的字符串拼接格式。

改动原因

  • 原 IsRadixTopKSupported 在 sortLen > int32 上限时直接判不支持(shapeCheck=false),超大 shape 只能落到 TopKV2 排序方案;而 TopKV2 在该量级会产生约 59.5GB workspace 导致 OOM,且比例门控在该量级失去意义。
  • Sort/GatherElementsV2 组合(用于按值排序重排索引)暂不接管 int64 大 shape,需直接透传 RadixTopK 输出的 int64 索引。

改动方法

  • IsRadixTopKSupported 增加 op::DataType indicesDType 入参:sortLen > MAX_INT32_INPUTSIZE 时 shapeCheck = (indicesDType == op::DataType::DT_INT64),k 比例不设限;两处调用点同步传入 indicesDType。
  • positiveDim == lastDim 分支:当 indicesCast 为 DT_INT64 时 indicesCastInt32 = indicesCast(直接透传);否则维持原 Sort + GatherElementsV2 逻辑。
  • 修正两处 OP_LOGE 字符串拼接中多余的空格。

关联的Issue

测试

本次改动仅涉及 op_api 支持性判定与索引透传分支,仓库中未包含对应测试代码改动。

文档更新

无

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Nice try's contribution.)
Nice tryNice tryCollaborators
Sep 11 Created pull request, commit 9402a561
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
index ✅ 汤平川, 陈兴宇 (2/2) ✅ 陈兴宇, 汤平川 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 11 Set zengjuan,chenfeng61,chaotang233,kevin_huang1234,FelixTang7,crystalhu,yangyang016,fanqirui,wangrui_,su-yueming,chenqi317,wang-xing001,liubo75,tangweiwei2,chenxingyu18,pingchuantang,qianzehong as approver
CANN-robotCANN-robotCollaborators
Sep 11 Set chenfeng61,kevin_huang1234,FelixTang7,wangrui_,su-yueming,wang-xing001,chenxingyu18,pingchuantang,qianzehong as approver
84 messages are collapsed here。 See more
TangPC
TangPCCollaborators
28 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
28 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
28 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
28 days ago Merged pull request
CANN-robot
CANN-robotCollaborators
28 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike