已合并
新增 SortedNMS 算子 Ascend 950 实现 #1236
黄晓彬创建于 19 天前
新增 SortedNMS 算子 Ascend 950 实现 #1236
已合并
黄晓彬创建于 19 天前
黄晓彬成员
19 天前

描述

在ops-cv仓库新增SortedNMS算子,支持在已按分数降序排列的候选框序列上,按照IoU阈值贪心选择非抑制框,输出被选中框在原始boxes中的索引。

关联的Issue

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

测试

1 完成200+泛化用例验证
2 完成 100+三方精度对比和性能对比
3 二级冒烟通过

文档更新

新增了 objdetect/sorted_nms/README.md 文件

类型标签

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

变更摘要

此 PR 为 SortedNMS 算子新增完整的算子实现,包括算子注册、tiling 逻辑、SIMT 内核、形状推导、测试用例及平台配置。旧版 SortedNMS 注册从 op_cv_proto_extend.h 中移除,迁移至独立的算子目录 objdetect/sorted_nms/,并扩展了多核 pairwise mask 策略以支持更大规模的包围框数量(1025–8192)。新增的 AscendC 内核实现针对 ascend950 平台,支持 float16/float32 的独立 dtype 组合。

主要改动

  • 移除旧版算子注册:从 common/inc/op_graph/op_cv_proto_extend.h 中删除原有的 SortedNMS 算子定义(含输入输出签名与注释),为新的独立实现腾出空间。
  • 新增独立算子注册:在 objdetect/sorted_nms/op_graph/sorted_nms_proto.h 中重新注册 SortedNMS,定义 6 个输入(boxessorted_scoresinput_indicesmax_output_sizeiou_thresholdscore_threshold)、1 个输出(selected_indices)及 offset 属性,并放宽 boxessorted_scores 的 dtype 允许独立设定。
  • 新增 Tiling 与多核策略:在 objdetect/sorted_nms/op_host/arch35/sorted_nms_tiling_arch35.cpp 中实现 tiling 函数 SortedNMSTilingFunc,根据 boxesNum 选择单核(<1025 或 >8192)或 pairwise mask 多核(1025–8192)策略,并计算 workspace 大小及 SortedNMSTilingData 参数。
  • 新增 SIMT 内核实现:在 objdetect/sorted_nms/op_kernel/arch35/sorted_nms_simt.h 中实现 Process 入口及核心函数 SortedNMSSingleCoreBuildPairwiseMasks/BuildPairwiseMasksLocalSelectFromPairwiseMasks,支持多核并行构建 pairwise 抑制掩码以及基于 UB 局部缓存优化 float16 场景的 IOU 计算。
  • 新增算子定义与形状推导:在 sorted_nms_def.cpp 中定义 OpDefAICoreConfig(含 4 种 dtype 组合的动态编译/动态形状支持);在 sorted_nms_infershape.cpp 中实现输出形状为 [UNKNOWN_DIM] 及形状范围推导。
  • 新增二进制配置与平台注册:在 sorted_nms_binary.json 中为 ascend950 注册 4 种 dtype 组合的内核二进制;在 ascendc_config.json 中将 SortedNMS 加入 AscendC 算子清单。
  • 新增测试与黄金参考:在 tests/assets/golden.py 中提供顺序 NMS 的 Python 参考实现与 compare 比较逻辑;在 examples/test_geir_sorted_nms.cpp 中提供 GEIR 端到端示例测试。
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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
*/*/README.md 汤平川, 陈娇, 刘伟 (3/2) 陈娇 (1/1)
*/*/op_graph/*_proto.h 王永光, 刘伟, 汤平川 (3/2) 王永光 (1/1)
*/*/op_graph/*_proto_extend.h 王永光, 刘伟, 汤平川 (3/2) 王永光 (1/1)
*/*/op_host/*_def.cpp 刘伟, 汤平川, 王永光 (3/2) 王永光 (1/1)
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 天前 将zhou-qilong,gitee-duhuiping,rxtfeng,loov1,tang-lei01,zhangzijie,zl_hw,liu-wei,gitcode-chenjiao,pingchuantang,llimwang,zhouwenfang,gubaocheng,wangyongguang,wuyao51511,caiwenwen设为评审人
CANN-robotCANN-robot成员
19 天前 将zhou-qilong,gitee-duhuiping,rxtfeng,loov1,tang-lei01,zhangzijie,zl_hw,liu-wei,gitcode-chenjiao,pingchuantang,llimwang,zhouwenfang,gubaocheng,wangyongguang,wuyao51511,caiwenwen设为审查人
黄晓彬成员
19 天前 评论:

compile

likedislike
黄晓彬成员
19 天前 update merge request[project id: 7657293, iid: 1236, commit_id: ec9c53fd473e3bbba4201250f2ca3238df4993f5] virtual merging success
CANN-robotCANN-robot成员
19 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
19 天前 评论:

流水线任务触发成功
任务链接 [00c095e96aee4e76a9c521676937c80c][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Pre ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ⚠️ WARNING >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_harmony-infer-chs-cv ✅ SUCCESS
UT_Test_harmony-infer-cpro-cv ✅ SUCCESS
UT_Test_report_lcov ✅ SUCCESS

[2026-08-05 22:34:05]    CI执行结束

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

流水线任务触发成功
任务链接 [061021ccb16742e2b8d89b4a14d8180f][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ❌ FAILED >>>>> >>>>>
likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:api-check-failed
此处折叠了6条事件消息 查看更多
CANN-robotCANN-robot成员
19 天前 添加了label:cann-cla/yes
黄晓彬成员
19 天前 评论:

compile

likedislike
黄晓彬成员
19 天前 update merge request[project id: 7657293, iid: 1236, commit_id: a1fe9d96dc0764603eb98821797ec0058420f11f] virtual merging success
CANN-robotCANN-robot成员
19 天前 删除了label:ci-pipeline-failedapi-check-failed
CANN-robotCANN-robot成员
19 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
19 天前 评论:

流水线任务触发成功
任务链接 [50a5a50b33ca4f41892f98d9f064fc74][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Pre ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ⚠️ WARNING >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_harmony-infer-chs-cv ✅ SUCCESS
UT_Test_harmony-infer-cpro-cv ✅ SUCCESS
UT_Test_report_lcov ✅ SUCCESS

[2026-08-05 22:49:39]    CI执行结束

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

流水线任务触发成功
任务链接 [be1872373b15443b97222bf7edd51bc4][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>

[2026-08-05 22:42:31]    CI执行结束

likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:api-check-failed
此处折叠了6条事件消息 查看更多
黄晓彬成员
18 天前 修改了pull request 的描述
wangyongguang成员
18 天前 评论:

/approve

likedislike
TangPC
TangPC成员
18 天前 评论:

/lgtm
/approve

likedislike
吴瑶成员18 天前进行代码检视1
objdetect/sorted_nms/README.md
@@ -0,0 +1,0 @@
1+# SortedNMS
吴瑶18 天前评论:

新增算子需补充op_list.md

likedislike
吴瑶成员18 天前进行代码检视1
objdetect/sorted_nms/README.md
@@ -0,0 +4,4 @@
4+ 
5+|产品 | 是否支持 |
6+|:-------------------------|:----------:|
7+| Ascend 950PR/Ascend 950DT | √ |
吴瑶18 天前评论:

产品名加标签

likedislike
chenjiao成员
17 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:approved
黄晓彬成员
17 天前 解决了最后一个问题
liu-wei
liu-wei成员
17 天前 评论:

/lgtm
/approve

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