Skip to content

Commit

Permalink
[Fix] Prevent divide-by-zero error on Ascend device for bbox_overlaps (
Browse files Browse the repository at this point in the history
  • Loading branch information
dflhw committed Mar 15, 2023
1 parent 126077d commit 9a671e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
if (mode == 1) {
modeStr = "iof";
}
float offset_ = 1;
if (offset == 0) {
offset_ = 0.01;
}
at::Tensor bboxes = at::ones_like(bboxes2);
at::Tensor gtboxes = at::ones_like(bboxes1);
bboxes = aligned ? bboxes2.transpose(0, 1) : bboxes2;
Expand All @@ -22,7 +26,7 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
.Input(gtboxes)
.Output(ious)
.Attr("mode", modeStr)
.Attr("eps", (float)offset)
.Attr("eps", offset_)
.Attr("aligned", aligned)
.Run();
}
Expand Down

0 comments on commit 9a671e4

Please sign in to comment.