已合并
fix(nms): 对齐 BatchMultiClassNonMaxSuppression 和 SortedNMS 的旧 InferShape 协议 #1508
fix(nms): 对齐 BatchMultiClassNonMaxSuppression 和 SortedNMS 的旧 InferShape 协议 #1508
已合并
黄晓彬创建于 19 天前
黄晓彬成员
19 天前

描述

BatchMultiClassNonMaxSuppression 的原 InferShape 固定输出 boxes [B,M,4]、count [B],与旧融合内部 transpose_box=true 需要的 boxes [B,4,M]、count [B,8] 不一致。本次按 transpose_box 恢复对应推导,并同步调整 Ascend950 tiling 的 scores 轴解析及 kernel 的 scores 索引、输出步长和 count padding 清零。正常 false 输入的计算协议和 NMS 筛选算法保持不变。

同时对齐 Batch 旧 GE 的动态 Shape 推导:batch 来自 scores,存在未知维度时保守推导为未知,浮点输出 dtype 跟随 scores;SortedNMS 保留输出 [-1]、ShapeRange [0,N],移除推导阶段过强的 rank/已知上界限制。具体输入合法性仍由 tiling 检查。

关联的Issue

https://gitcode.com/cann/ops-cv/issues/888

测试

  • 950 release kernel:BatchMultiClassNMS 208/208、SortedNMS 278/278,执行、精度和越界检查均通过。
  • 定向 GEIR:Batch 1 例 false、SortedNMS 3 例静态/动态图精度均通过。
  • A2兼容性问题验证通过

文档更新

不涉及

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 黄晓彬 的贡献)
黄黄晓彬成员
19 天前 创建了 pull request,commit 8e5d9587
atomgit-bot
atomgit-bot
19 天前 评论:

变更摘要

本 PR 用于对齐 BatchMultiClassNonMaxSuppression 与 SortedNMS 的旧 InferShape 协议:BatchMultiClassNonMaxSuppression 的原 InferShape 固定输出 boxes [B,M,4]、count [B],与旧融合内部 transpose_box=true 所需的 boxes [B,4,M]、count [B,8] 不一致,本次按 transposeBox 恢复对应推导,并同步调整 Ascend950 tiling 的 scores 轴解析及 kernel 的 scores 索引、输出步长和 count padding 清零;同时对齐 Batch 旧 GE 的动态 Shape 推导(batch 取自 scores,存在未知维度时保守推导为未知,浮点输出 dtype 跟随 scores),并放宽 SortedNMS 推导阶段过强的 rank/已知上界限制,具体输入合法性交由 tiling 检查。正常 false 输入的计算协议和 NMS 筛选算法保持不变,并补充了 Batch 的 InferShape UT。

主要改动

  • Batch InferShape 按 transposeBox 恢复旧输出协议(batch_multi_class_non_max_suppression_infershape.cpp):transposeBox=true 时 boxes 输出为 [B,4,M]、count 输出为 [B,8],否则维持 [B,M,4]/[B];batch 改为取自 scores 的 dim 0,且 scores 任一维度为未知时保守推导为 ge::UNKNOWN_DIM。
  • Batch 浮点输出 dtype 跟随 scores(batch_multi_class_non_max_suppression_infershape.cpp):InferDataTypeForBatchMultiClassNonMaxSuppression 由读取 boxes 类型改为读取 scores 类型推导 boxes/scores/classes 三个浮点输出的 dtype,count 仍为 DT_INT32。
  • 950 tiling 按 transposeBox 解析 scores 轴并校验转置输出契约(batch_multi_class_non_max_suppression_tiling_arch35.cpp):classesNum 与 boxesNum 在 scores 的 dim 1/dim 2 之间按 transposeBox 互换解析;ValidateOutputContract 新增对 [B,4,M] boxes 与 [B,8] count 的校验分支。
  • 950 kernel 适配 [B,C,N] scores 与转置输出布局(batch_multi_class_non_max_suppression_kernel.h):scores 偏移改为 (batchIndex * classesNum + classIndex) * boxesNum + boxIndex,boxes 输出按坐标维 stride maxTotalSize 写转置布局,count 写入使用 kPaddedCountStride(8)/kUnpaddedCountStride(1) 偏移并对 padding 位清零,nmsedNumGm_ 缓冲长度同步扩展。
  • SortedNMS 放宽 InferShape 限制(sorted_nms_infershape.cpp):移除 boxes rank 必须为 2、第二维必须为 4、shape range 首维必须已知等过强校验,输出保持 [-1]、ShapeRange [0,N],具体输入合法性交由 tiling 检查;同时补充 Batch 旧协议(转置输出、未知 batch、dtype 跟随 scores)的 UT 用例。
likedislike
不准确?
atomgit-bot
atomgit-bot
19 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
19 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
19 天前 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
19 天前 评论:

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/ops-cv ✅ 刘伟, 汤平川 (2/2) ✅ 汤平川, 刘伟 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robot成员
19 天前 将yue-ma,zhou-qilong,rxtfeng,loov1,zhangzijie,yourealize,zl_hw,liu-wei,pingchuantang,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
19 天前 将yue-ma,zhou-qilong,rxtfeng,loov1,zhangzijie,yourealize,zl_hw,liu-wei,pingchuantang,llimwang,gubaocheng设为审查人
黄黄晓彬成员
19 天前 修改标题为 “fix(nms): 对齐 BatchMultiClassNonMaxSuppression 和 SortedNMS 的旧 InferShape 协议”,原标题为“fix(nms): 对齐 Batch 和 SortedNMS 的旧 InferShape 协议”
黄晓彬成员
19 天前 评论:

compile

likedislike
黄黄晓彬成员
19 天前 预合并成功(commit_id: 3f569a4f99bf779265a85f44e5ec12927fc75adc)
CANN-robot
CANN-robot成员
19 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
19 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
19 天前 添加了label:ci-pipeline-passed
黄黄晓彬成员
19 天前 修改了pull request 的描述
黄黄晓彬成员
19 天前 修改了pull request 的描述
TangPC
TangPC成员
19 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:approved
liu-wei
liu-wei成员
19 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:lgtm
CANN-robotCANN-robot成员
19 天前 关闭了关联的issue
CANN-robotCANN-robot成员
19 天前 合入了pull request