Merged
新增算子rotated_overlaps #1339
新增算子rotated_overlaps #1339
Merged
Huang-PengAdd on Aug 19
Huang-Peng
Aug 19

描述

新增 RotatedOverlaps 算子的 Ascend 950 (arch35) 后端实现,落地在 ops-cv/objdetect/rotated_overlaps/。

主要改动

算子定义与形状推导(op_host/):

  • rotated_overlaps_def.cpp:注册 RotatedOverlaps OpDef(boxes/query_boxes 输入,output 输出)
  • rotated_overlaps_infershape.cpp:输出 shape 推导([B,N,K])
  • arch35/:Ascend950 tiling 实现(tiling_arch35 + tiling_data + tiling_key)

内核(op_kernel/):

  • arch35/rotated_overlaps_kernel.h:向量化内核,一个 core 负责完整 [b,n,:] 输出行;query tile 按向量 lane 处理,无地址写竞争;每 lane 构造凸多边形交点候选集(A 的 4 顶点在 B 内、B 的 4 顶点在 A 内、16 条边对交点)
  • rotated_overlaps_apt.cpp:950 内核入口

构建与配置:

  • CMakeLists.txt + op_host/config/ascend950/(binary JSON + simplified-key)+ scripts/kernel/binary_config/ascendc_config.json 注册

语义约束:

  • 输入 [x,y,w,h,theta](trans=false)或 [x1,y1,x2,y2,theta](trans=true),float32/ND;输出为交叠面积(非 IoU),theta 单位为度
  • 非有限坐标与退化矩形按非法处理,含非法框的配对输出零;首版支持 K <= 2000

测试:

  • ST:tests/assets/golden.py(独立参考实现)+ inputs.py + ttk csv;UT:infershape 单测

关联的Issue

关联Issue #772

测试

  • ST:arch35 ttk kernel 用例(ascend950)+ golden 独立参考对比
  • UT:test_rotated_overlaps_infershape

文档更新

更新 objdetect/rotated_overlaps/README.md,说明输入格式、语义约束与限制。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Huang-Peng's contribution.)
Huang-PengHuang-Peng
Aug 19 Created pull request, commit 3eb47492
atomgit-bot
atomgit-bot
Aug 19 Comments:

变更摘要

本 PR 新增 RotatedOverlaps 算子的 Ascend 950(arch35)后端实现,落地于 objdetect/rotated_overlaps/,覆盖算子定义、形状推导、tiling、向量化内核、构建配置与测试。输入为 [B,5,N] 的 boxes/query_boxes(trans=false 时格式为 [x,y,w,h,theta],trans=true 时为 [x1,y1,x2,y2,theta]),输出为 [B,N,K] 的交叠面积(非 IoU),仅支持 float32/ND,theta 单位为度;非有限坐标与退化矩形按非法处理(非法配对输出零),首版限制 K <= 2000。

主要改动

  • 算子定义与形状推导:rotated_overlaps_def.cpp 注册 RotatedOverlaps OpDef(boxes/query_boxes 输入、overlaps 输出、trans 属性及 ascend950 AICore 配置);rotated_overlaps_infershape.cpp 推导输出 [B,N,K],并校验 rank=3、坐标通道=5、batch 匹配、已知维度为正且 K 不超过 2000。
  • Ascend950 tiling 实现:rotated_overlaps_tiling_arch35.cpp 按输出行划分 core(rowsPerCore),依据 UB 容量从 128/96/64/32/8 中选取 tile 长度并计算 sin/cos 数学 workspace,通过 RotatedOverlapsTilingData 传递批大小、行数、tile 长度等参数,并依据 trans 与 use32Bit 组合设置 tiling key。
  • 向量化内核:arch35/rotated_overlaps_kernel.h 中一个 core 负责完整 [b,n,:] 输出行,query tile 按向量 lane 处理(无地址写竞争);每个 lane 构造 24 个凸多边形交点候选(A 的 4 顶点在 B 内、B 的 4 顶点在 A 内、16 条边对交点),经 32 路 bitonic 网络按伪角度 key 排序后以鞋带公式计算面积,非法框通过 PairValid 置零;rotated_overlaps_apt.cpp 提供按 trans/use32Bit 模板化的内核入口。
  • 构建与配置注册:新增 op_host/config/ascend950/rotated_overlaps_binary.json(float32/ND 的输入输出与 trans 属性声明)与 rotated_overlaps_simplified_key.ini,并在 scripts/kernel/binary_config/ascendc_config.json 中注册 RotatedOverlaps 的 ascend950 编译项。
  • 测试补充:ST 侧新增 tests/assets/golden.py(独立的 float64 Sutherland-Hodgman 裁剪参考实现)与 inputs.py(确定性边界用例与通用随机用例生成);UT 侧新增 test_rotated_overlaps_infershape.cpp 覆盖静态/动态形状推导及各类非法输入拒绝场景。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 19 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 19 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 19 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
*/*/README.md ✅ 汤平川, 陈娇, yue-ma (3/2) ✅ 陈娇 (1/1)
*/*/op_graph/*_proto.h ✅ yue-ma, 汤平川, 王永光 (3/2) ✅ 王永光 (1/1)
*/*/op_graph/*_proto_extend.h ✅ 王永光, yue-ma, 汤平川 (3/2) ✅ 王永光 (1/1)
*/*/op_host/*_def.cpp ✅ 王永光, yue-ma, 汤平川 (3/2) ✅ 王永光 (1/1)
repo-cann/ops-cv ✅ 汤平川, yue-ma (2/2) ✅ yue-ma, 汤平川 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
181 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 25 Added label: lgtm
chenjiao
chenjiaoCollaborators
Aug 25 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 25 Added label: approved
CANN-robotCANN-robotCollaborators
Aug 25 Closed associated issue
CANN-robotCANN-robotCollaborators
Aug 25 Merged pull request