From 5a1b6fecaaeb39ba48b6de0afca4f0f6b5187428 Mon Sep 17 00:00:00 2001 From: cathyzhang222 Date: Thu, 20 Oct 2022 19:15:56 +0800 Subject: [PATCH] skip test_case in test_iou3d --- tests/test_ops/test_iou3d.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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', [