diff --git a/tests/test_ops/test_iou3d.py b/tests/test_ops/test_iou3d.py index 37fa417406b..6b4d552e8cf 100644 --- a/tests/test_ops/test_iou3d.py +++ b/tests/test_ops/test_iou3d.py @@ -96,14 +96,18 @@ def test_nms3d(device): assert np.allclose(inds.cpu().numpy(), np_inds) # test for many boxes - # np.random.seed(42) - # np_boxes = np.random.rand(555, 7).astype(np.float32) - # np_scores = np.random.rand(555).astype(np.float32) - # boxes = torch.from_numpy(np_boxes) - # scores = torch.from_numpy(np_scores) - # inds = nms3d(boxes.to(device), scores.to(device), iou_threshold=0.3) - - # assert len(inds.cpu().numpy()) == 176 + # In the float data type calculation process, sometimes float will be + # converted to double in CUDA kernel, always use float in MLU kernel. + # The difference between the mentioned above leads to different results. + if device != 'mlu': + np.random.seed(42) + np_boxes = np.random.rand(555, 7).astype(np.float32) + np_scores = np.random.rand(555).astype(np.float32) + boxes = torch.from_numpy(np_boxes) + scores = torch.from_numpy(np_scores) + inds = nms3d(boxes.to(device), scores.to(device), iou_threshold=0.3) + + assert len(inds.cpu().numpy()) == 176 @pytest.mark.parametrize('device', [