Repository: Project-MONAI/MONAI

Issue:
missing cuda test cases
**Describe the bug**
```python
Python 3.8.0 (default, Nov  6 2019, 21:49:08) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tests.utils import TEST_NDARRAYS
>>> print(TEST_NDARRAYS)
(<built-in function array>, <built-in method as_tensor of type object at 0x7f53e1f3b9c0>, functools.partial(<class 'monai.data.meta_tensor.MetaTensor'>, meta={'a': 'b', 'affine': tensor([[2., 0., 0., 0.],
        [0., 2., 0., 0.],
        [0., 0., 2., 0.],
        [0., 0., 0., 1.]])}))
>>> import torch
>>> print(torch.cuda.is_available())
True
>>> 
```
`TEST_NDARRAYS` should include the cuda-base test cases when cuda is available.


Discussion:

Resolving patch:
diff --git a/monai/transforms/croppad/array.py b/monai/transforms/croppad/array.py
--- a/monai/transforms/croppad/array.py
+++ b/monai/transforms/croppad/array.py
@@ -398,8 +398,8 @@ def compute_slices(
             return list(roi_slices)
         else:
             if roi_center is not None and roi_size is not None:
-                roi_center_t = convert_to_tensor(data=roi_center, dtype=torch.int16, wrap_sequence=True)
-                roi_size_t = convert_to_tensor(data=roi_size, dtype=torch.int16, wrap_sequence=True)
+                roi_center_t = convert_to_tensor(data=roi_center, dtype=torch.int16, wrap_sequence=True, device="cpu")
+                roi_size_t = convert_to_tensor(data=roi_size, dtype=torch.int16, wrap_sequence=True, device="cpu")
                 _zeros = torch.zeros_like(roi_center_t)
                 half = (
                     torch.divide(roi_size_t, 2, rounding_mode="floor")
diff --git a/monai/utils/type_conversion.py b/monai/utils/type_conversion.py
--- a/monai/utils/type_conversion.py
+++ b/monai/utils/type_conversion.py
@@ -99,7 +99,7 @@ def get_dtype(data: Any):
 def convert_to_tensor(
     data,
     dtype: Optional[torch.dtype] = None,
-    device: Optional[torch.device] = None,
+    device: Union[None, str, torch.device] = None,
     wrap_sequence: bool = False,
     track_meta: bool = False,
 ):


Test patch:
diff --git a/tests/padders.py b/tests/padders.py
--- a/tests/padders.py
+++ b/tests/padders.py
@@ -98,6 +98,8 @@ def pad_test_kwargs(self, unchanged_slices, **input_param):
                             result = result.cpu()
                         assert_allclose(result[unchanged_slices], im, type_test=False)
                         # we should have the same as the input plus some 2s (if value) or 1s and 2s (if constant_values)
+                        if isinstance(im, torch.Tensor):
+                            im = im.detach().cpu().numpy()
                         expected_vals = np.unique(im).tolist()
                         expected_vals += [2] if "value" in kwargs else [1, 2]
                         assert_allclose(np.unique(result), expected_vals, type_test=False)
diff --git a/tests/test_k_space_spike_noised.py b/tests/test_k_space_spike_noised.py
--- a/tests/test_k_space_spike_noised.py
+++ b/tests/test_k_space_spike_noised.py
@@ -20,7 +20,7 @@
 from monai.data.synthetic import create_test_image_2d, create_test_image_3d
 from monai.transforms import KSpaceSpikeNoised
 from monai.utils.misc import set_determinism
-from tests.utils import TEST_NDARRAYS
+from tests.utils import TEST_NDARRAYS, assert_allclose
 
 TESTS = []
 for shape in ((128, 64), (64, 48, 80)):
@@ -91,7 +91,7 @@ def test_dict_matches(self, im_shape, im_type):
 
         t = KSpaceSpikeNoised(KEYS, loc, k_intensity)
         out = t(deepcopy(data))
-        np.testing.assert_allclose(out[KEYS[0]], out[KEYS[1]])
+        assert_allclose(out[KEYS[0]], out[KEYS[1]], type_test=False)
 
 
 if __name__ == "__main__":
diff --git a/tests/utils.py b/tests/utils.py
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -736,10 +736,10 @@ def test_local_inversion(invertible_xform, to_invert, im, dict_key=None):
     assert_allclose(im_inv.affine, im_ref.affine, atol=1e-3, rtol=1e-3)
 
 
-TEST_TORCH_TENSORS: Tuple[Callable] = (torch.as_tensor,)
+TEST_TORCH_TENSORS: Tuple = (torch.as_tensor,)
 if torch.cuda.is_available():
     gpu_tensor: Callable = partial(torch.as_tensor, device="cuda")
-    TEST_NDARRAYS = TEST_TORCH_TENSORS + (gpu_tensor,)
+    TEST_TORCH_TENSORS = TEST_TORCH_TENSORS + (gpu_tensor,)
 
 DEFAULT_TEST_AFFINE = torch.tensor(
     [[2.0, 0.0, 0.0, 0.0], [0.0, 2.0, 0.0, 0.0], [0.0, 0.0, 2.0, 0.0], [0.0, 0.0, 0.0, 1.0]]