已合并
bounding_box_decode #1307
wuao创建于 3 天前
bounding_box_decode #1307
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wuao 的贡献)atomgit-bot
3 天前 评论:
3 天前 评论:
变更摘要
本 PR 新增了 bounding_box_decode 算子(目标检测边界框解码)的完整实现,覆盖 ascend950 架构。改动包括算子定义与注册、shape/dtype 推理、host 侧 tiling 切分逻辑、kernel 端解码计算,以及配套的 golden 脚本和单元测试。核心解码流程为:根据 rois(anchor box)计算宽高与中心,结合 deltas 反标准化得到 dx/dy/dw/dh,再通过 gw/gh/gx/gy 计算并裁剪出 bboxes,支持 fp32 与 fp16 两种数据类型以及空张量场景。
主要改动
- 算子定义与注册: 在
bounding_box_decode_def.cpp中新增BoundingBoxDecode算子定义,声明rois、deltas两个输入和bboxes输出(支持DT_FLOAT16/DT_FLOAT、FORMAT_ND),并定义means、stds、max_shape、wh_ratio_clip属性及ascend950的 AICore 配置。 - Shape 与 Dtype 推理: 新增
InferShapeForBoundingBoxDecode和InferDataTypeForBoundingBoxDecode,输出形状与输入保持一致([N, 4]),校验 rank 为 2、最后一维为 4、两输入形状/类型一致,并支持未知 rank 与空张量(N=0)场景。 - Host 侧 Tiling 逻辑: 新增
TilingFunc及BoundingBoxDecodePreCheck/ComputeMultiCoreSplit/ComputeUbSplit等逻辑,完成多核按 box 数切分、UB 按 256B 对齐切分、异常校验、属性透传,以及基于 dtype 的TilingKey设置与空张量分支处理。 - Kernel 端解码实现: 新增
BoundingBoxDecodeKernel及多个__simd_vf__向量函数(AnchorPreVF、DeltaDeStdVF、DecodeGwGxVF、BoxClipVF),实现 anchor 预处理、delta 反标准化、exp解码与裁剪,fp32 路径使用自定义 Cody-Waite+Taylor 高精度exp,fp16 路径使用 NPU 硬件Reg::Exp。 - 测试与参考实现: 新增
golden.py提供 torch 参考实现与容差配置,并新增 tiling 单元测试(覆盖 fp32/fp16、空张量、多核、非法 shape/dtype 等场景)、infershape 单元测试,以及一个ge运行示例。


atomgit-bot
3 天前 评论:
3 天前 评论:
3 天前 添加了label:cann-cla/yes
CANN-robot
3 天前 评论:
3 天前 评论:
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.
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 | ✅ 张磊, 陈娇, 周奇龙 (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
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
wow5523, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了117条消息 查看更多
2 天前 添加了label:lgtm
CANN-robot
2 天前 评论:
2 天前 评论:
The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


1 天前 解决了最后一个问题
1 天前 合入了pull request
描述
本 PR 新增了 bounding_box_decode 算子(目标检测边界框解码)的完整实现,覆盖 ascend950 架构。改动包括算子定义与注册、shape/dtype 推理、host 侧 tiling 切分逻辑、kernel 端解码计算,以及配套的 golden 脚本和单元测试。核心解码流程为:根据 rois(anchor box)计算宽高与中心,结合 deltas 反标准化得到 dx/dy/dw/dh,再通过 gw/gh/gx/gy 计算并裁剪出 bboxes,支持 fp32 与 fp16 两种数据类型以及空张量场景。
主要改动
1)算子定义与注册: 在 bounding_box_decode_def.cpp 中新增 BoundingBoxDecode 算子定义,声明 rois、deltas 两个输入和 bboxes 输出(支持 DT_FLOAT16/DT_FLOAT、FORMAT_ND),并定义 means、stds、max_shape、wh_ratio_clip 属性及 ascend950 的 AICore 配置。
Shape 与 Dtype 推理: 新增 InferShapeForBoundingBoxDecode 和 InferDataTypeForBoundingBoxDecode,输出形状与输入保持一致([N, 4]),校验 rank 为 2、最后一维为 4、两输入形状/类型一致,并支持未知 rank 与空张量(N=0)场景。
2)Host 侧 Tiling 逻辑: 新增 TilingFunc 及 BoundingBoxDecodePreCheck/ComputeMultiCoreSplit/ComputeUbSplit 等逻辑,完成多核按 box 数切分、UB 按 256B 对齐切分、异常校验、属性透传,以及基于 dtype 的 TilingKey 设置与空张量分支处理。
3)Kernel 端解码实现: 新增 BoundingBoxDecodeKernel 及多个 simd_vf 向量函数(AnchorPreVF、DeltaDeStdVF、DecodeGwGxVF、BoxClipVF),实现 anchor 预处理、delta 反标准化、exp 解码与裁剪,fp32 路径使用自定义 Cody-Waite+Taylor 高精度 exp,fp16 路径使用 NPU 硬件 Reg::Exp。
4)测试与参考实现: 新增 golden.py 提供 torch 参考实现与容差配置,并新增 tiling 单元测试(覆盖 fp32/fp16、空张量、多核、非法 shape/dtype 等场景)、infershape 单元测试,以及一个 ge 运行示例。
关联的Issue
https://gitcode.com/cann/ops-cv/issues/754
测试
文档更新
类型标签