Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion detectron2/layers/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def batched_nms(
# to decide whether to use coordinate trick or for loop to implement batched_nms. So we
# just call it directly.
# Fp16 does not have enough range for batched NMS, so adding float().
return box_ops.batched_nms(boxes.float(), scores, idxs, iou_threshold)
if scores.dtype == torch.float64:
res = box_ops.batched_nms(boxes.double(), scores, idxs, iou_threshold)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why put the whole line in the if statement and not just the actual value that depends on it? For example:

boxes_value = boxes.double() if scores.data == torch.float64 else boxes.float()
return box_ops.batched_nms(boxes_value, scores, idxs, iou_threshold)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

else:
res = box_ops.batched_nms(boxes.float(), scores, idxs, iou_threshold)
return res


# Note: this function (nms_rotated) might be moved into
Expand Down