-
Notifications
You must be signed in to change notification settings - Fork 7.1k
NMS behaviour w.r.t. fp16 vs fp32 #3371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@SiftingSands I'm not familiar with the C codes in torchvision, but I think float16 is not supported yet for nms. If you cast the float16 tensors to CPU you'll see an error throw |
Understood. I would have expected that error to show up on the GPU as well if FP16 is not supported. Is Feel free to close this issue if this behavior is expected. |
It should be not CPU only, and probably an error throw is indeed needed? @datumbox |
@SiftingSands thanks for reporting the issue. This is a indeed a bug and it's caused by numeric overflows. I'm going to send a PR to fix this soon. |
🐛 Bug
NMS gives significantly different outputs when switching boxes from FP32 to FP16. I couldn't find any related issue here or on the discussion board, and I didn't see an obvious cause from reading the docs.
To Reproduce
Call
torchvision.ops.nms(boxes, scores, iou_threshold=0.2)
boxes and scores (FP32) -> data.zip
NMS has one output.
Change boxes to float16 (I used
.to(torch.float16)
), and NMS gives 37 outputs (no suppression is performed?)I wasn't expecting type conversion from FP32 to FP16 to dramatically alter results. Let me know if this is just a case of user error.
Environment
Possible related issue?
The text was updated successfully, but these errors were encountered: