Repository: Project-MONAI/MONAI

Issue:
integration error -- IntegrationClassification2D
**Describe the bug**
from the test of 0f17aa991592fc6e635e86da3061b5dd3d669597
```
MONAI version: 0.7.0rc1
Numpy version: 1.18.1
Pytorch version: 1.9.0+cu102
MONAI flags: HAS_EXT = True, USE_COMPILED = True
MONAI rev id: 0f17aa991592fc6e635e86da3061b5dd3d669597

Optional dependencies:
Pytorch Ignite version: 0.4.5
Nibabel version: 3.2.1
scikit-image version: 0.15.0
Pillow version: 8.3.2
Tensorboard version: 2.1.0
gdown version: 3.13.1
TorchVision version: 0.10.0+cu102
tqdm version: 4.62.2
lmdb version: 0.98
psutil version: 5.6.7
pandas version: 0.24.2
einops version: 0.3.2

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

coverage
integration
tests/test_integration_classification_2d.py
MONAI version: 0.7.0rc1
Numpy version: 1.18.1
Pytorch version: 1.9.0+cu102
MONAI flags: HAS_EXT = True, USE_COMPILED = True
MONAI rev id: 0f17aa991592fc6e635e86da3061b5dd3d669597

Optional dependencies:
Pytorch Ignite version: 0.4.5
Nibabel version: 3.2.1
scikit-image version: 0.15.0
Pillow version: 8.3.2
Tensorboard version: 2.1.0
gdown version: 3.13.1
TorchVision version: 0.10.0+cu102
tqdm version: 4.62.2
lmdb version: 0.98
psutil version: 5.6.7
pandas version: 0.24.2
einops version: 0.3.2

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

----------
Epoch 1/4
Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /pytorch/c10/core/TensorImpl.h:1156.)
not found best_metric_model.pth, training skipped?
MONAI version: 0.7.0rc1
Numpy version: 1.18.1
Pytorch version: 1.9.0+cu102
MONAI flags: HAS_EXT = True, USE_COMPILED = True
MONAI rev id: 0f17aa991592fc6e635e86da3061b5dd3d669597

Optional dependencies:
Pytorch Ignite version: 0.4.5
Nibabel version: 3.2.1
scikit-image version: 0.15.0
Pillow version: 8.3.2
Tensorboard version: 2.1.0
gdown version: 3.13.1
TorchVision version: 0.10.0+cu102
tqdm version: 4.62.2
lmdb version: 0.98
psutil version: 5.6.7
pandas version: 0.24.2
einops version: 0.3.2

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

----------
Epoch 1/4
ENamed tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /pytorch/c10/core/TensorImpl.h:1156.)
E
======================================================================
ERROR: test_timing (__main__.IntegrationClassification2D)
----------------------------------------------------------------------
RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/__w/MONAI/MONAI/tests/utils.py", line 466, in _wrapper
    raise RuntimeError(res.traceback) from res
RuntimeError: Traceback (most recent call last):
  File "/__w/MONAI/MONAI/tests/utils.py", line 418, in run_process
    output = func(*args, **kwargs)
  File "/__w/MONAI/MONAI/tests/utils.py", line 491, in _call_original_func
    return f(*args, **kwargs)
  File "/__w/MONAI/MONAI/tests/test_integration_classification_2d.py", line 274, in test_timing
    self.train_and_infer()
  File "/__w/MONAI/MONAI/tests/test_integration_classification_2d.py", line 245, in train_and_infer
    self.data_dir, self.train_x, self.train_y, self.val_x, self.val_y, device=self.device
  File "/__w/MONAI/MONAI/tests/test_integration_classification_2d.py", line 115, in run_training_test
    outputs = model(inputs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/nets/densenet.py", line 248, in forward
    x = self.features(x)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/container.py", line 139, in forward
    input = module(input)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 443, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 440, in _conv_forward
    self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same


======================================================================
ERROR: test_training (__main__.IntegrationClassification2D)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_integration_classification_2d.py", line 268, in test_training
    results = self.train_and_infer(i)
  File "tests/test_integration_classification_2d.py", line 245, in train_and_infer
    self.data_dir, self.train_x, self.train_y, self.val_x, self.val_y, device=self.device
  File "tests/test_integration_classification_2d.py", line 115, in run_training_test
    outputs = model(inputs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/__w/MONAI/MONAI/monai/networks/nets/densenet.py", line 248, in forward
    x = self.features(x)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/container.py", line 139, in forward
    input = module(input)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 443, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 440, in _conv_forward
    self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

----------------------------------------------------------------------
Ran 2 tests in 56.399s
```


Discussion:

Resolving patch:
diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py
--- a/monai/transforms/spatial/array.py
+++ b/monai/transforms/spatial/array.py
@@ -526,7 +526,7 @@ def __call__(
             align_corners=self.align_corners if align_corners is None else align_corners,
             reverse_indexing=True,
         )
-        output: torch.Tensor = xform(img_t.unsqueeze(0), transform_t, spatial_size=output_shape).squeeze(0)
+        output: torch.Tensor = xform(img_t.unsqueeze(0), transform_t, spatial_size=output_shape).float().squeeze(0)
         self._rotation_matrix = transform
         out: NdarrayOrTensor
         out, *_ = convert_to_dst_type(output, dst=img, dtype=output.dtype)


Test patch: