@@ -17,8 +17,9 @@ at::Tensor nms_kernel_impl(
1717 dets.scalar_type () == scores.scalar_type (),
1818 " dets should have the same type as scores" );
1919
20- if (dets.numel () == 0 )
20+ if (dets.numel () == 0 ) {
2121 return at::empty ({0 }, dets.options ().dtype (at::kLong ));
22+ }
2223
2324 auto x1_t = dets.select (1 , 0 ).contiguous ();
2425 auto y1_t = dets.select (1 , 1 ).contiguous ();
@@ -47,8 +48,9 @@ at::Tensor nms_kernel_impl(
4748
4849 for (int64_t _i = 0 ; _i < ndets; _i++) {
4950 auto i = order[_i];
50- if (suppressed[i] == 1 )
51+ if (suppressed[i] == 1 ) {
5152 continue ;
53+ }
5254 keep[num_to_keep++] = i;
5355 auto ix1 = x1[i];
5456 auto iy1 = y1[i];
@@ -58,8 +60,9 @@ at::Tensor nms_kernel_impl(
5860
5961 for (int64_t _j = _i + 1 ; _j < ndets; _j++) {
6062 auto j = order[_j];
61- if (suppressed[j] == 1 )
63+ if (suppressed[j] == 1 ) {
6264 continue ;
65+ }
6366 auto xx1 = std::max (ix1, x1[j]);
6467 auto yy1 = std::max (iy1, y1[j]);
6568 auto xx2 = std::min (ix2, x2[j]);
@@ -69,8 +72,9 @@ at::Tensor nms_kernel_impl(
6972 auto h = std::max (static_cast <scalar_t >(0 ), yy2 - yy1);
7073 auto inter = w * h;
7174 auto ovr = inter / (iarea + areas[j] - inter);
72- if (ovr > iou_threshold)
75+ if (ovr > iou_threshold) {
7376 suppressed[j] = 1 ;
77+ }
7478 }
7579 }
7680 return keep_t .narrow (/* dim=*/ 0 , /* start=*/ 0 , /* length=*/ num_to_keep);
0 commit comments