improve stability of test_nms_cuda (#2044)
* improve stability of test_nms_cuda This change addresses two issues: _create_tensors_with_iou() creates test data for the NMS tests. It takes care to ensure at least one pair of boxes (1st and last) have IoU around the threshold for the test. However, the constructed IoU for that pair is _so_ close to the threshold that rounding differences (presumably) between CPU and CUDA implementations may result in one suppressing a box in the pair and the other not. Adjust the construction to ensure the IoU for the box pair is near the threshold, but far-enough above that both implementations should agree. Where 2 boxes have nearly or exactly the same score, the CPU and CUDA implementations may order them differently. Adjust test_nms_cuda() to check only that the non-suppressed box lists include the same members, without regard for ordering. * adjust assertion in test_nms_cuda The CPU and CUDA nms implementations each sort the box scores as part of their work, but the sorts they use are not stable. So boxes with the same score maybe be processed in opposite order by the two implmentations. Relax the assertion in test_nms_cuda (following the model in pytorch's test_topk()) to allow the test to pass if the output differences are caused by similarly-scored boxes. * improve stability of test_nms_cuda Adjust _create_tensors_with_iou() to ensure we create at least one box just over threshold that should be suppressed.
Showing
Please register or sign in to comment