Skip to content

Commit 3ad02ef

Browse files
authored
[Fix] Prevent divide-by-zero error on Ascend device for bbox_overlaps (open-mmlab#2646)
1 parent 869dbf1 commit 3ad02ef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
1212
if (mode == 1) {
1313
modeStr = "iof";
1414
}
15+
float offset_ = 1;
16+
if (offset == 0) {
17+
offset_ = 0.01;
18+
}
1519
at::Tensor bboxes = at::ones_like(bboxes2);
1620
at::Tensor gtboxes = at::ones_like(bboxes1);
1721
bboxes = aligned ? bboxes2.transpose(0, 1) : bboxes2;
@@ -22,7 +26,7 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
2226
.Input(gtboxes)
2327
.Output(ious)
2428
.Attr("mode", modeStr)
25-
.Attr("eps", (float)offset)
29+
.Attr("eps", offset_)
2630
.Attr("aligned", aligned)
2731
.Run();
2832
}

0 commit comments

Comments
 (0)