From fe96d355cd46ed206c31af2ba291dd1c65707833 Mon Sep 17 00:00:00 2001 From: huangzhengxiang <100776727+huangzhengxiang@users.noreply.github.com> Date: Mon, 10 Oct 2022 14:44:48 +0800 Subject: [PATCH] fix a possible divided-by-zero bug Since we have poly_center.x /= cnt; poly_center.y /= cnt; in the code, we potentially face divided-by-zero issue when bboxes aren't intersecting with each other, as no intersection exists, cnt=0. --- mmdet3d/ops/iou3d/src/iou3d_kernel.cu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmdet3d/ops/iou3d/src/iou3d_kernel.cu b/mmdet3d/ops/iou3d/src/iou3d_kernel.cu index 861aea3c..d4c379ad 100644 --- a/mmdet3d/ops/iou3d/src/iou3d_kernel.cu +++ b/mmdet3d/ops/iou3d/src/iou3d_kernel.cu @@ -194,6 +194,8 @@ __device__ inline float box_overlap(const float *box_a, const float *box_b) { } } + if (!cnt) return 0.0; + // check corners for (int k = 0; k < 4; k++) { if (check_in_box2d(box_a, box_b_corners[k])) {