[Fix] Prevent divide-by-zero error on Ascend device for bbox_overlaps (#2644)

pull/2670/head
liuhw 2023-03-15 23:07:41 +08:00 committed by GitHub
parent 126077df5e
commit 9a671e48fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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;
@ -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();
}