Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion monai/inferers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def sliding_window_inference(

# account for any overlapping sections
for ss in range(len(output_image_list)):
output_image_list[ss] = output_image_list[ss].detach()
output_image_list[ss] = output_image_list[ss]
_map = count_map_list.pop(0)
for _i in range(output_image_list[ss].shape[1]):
output_image_list[ss][:, _i : _i + 1, ...] /= _map
Expand Down
4 changes: 3 additions & 1 deletion tests/test_sliding_window_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ def test_default_device(self, data_type):
def compute(data):
return data + 1

inputs.requires_grad = True
result = sliding_window_inference(inputs, roi_shape, sw_batch_size, compute)
self.assertTrue(result.requires_grad)
np.testing.assert_string_equal(inputs.device.type, result.device.type)
expected_val = np.ones((1, 3, 16, 15, 7), dtype=np.float32) + 1
np.testing.assert_allclose(result.cpu().numpy(), expected_val)
np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val)

@parameterized.expand(list(itertools.product(TEST_TORCH_AND_META_TENSORS, ("cpu", "cuda"), ("cpu", "cuda", None))))
@skip_if_no_cuda
Expand Down
3 changes: 2 additions & 1 deletion tests/test_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.networks import eval_mode
from monai.networks.nets.vit import ViT
from tests.utils import SkipIfBeforePyTorchVersion, test_script_save
from tests.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_script_save

TEST_CASE_Vit = []
for dropout_rate in [0.6]:
Expand Down Expand Up @@ -59,6 +59,7 @@
TEST_CASE_Vit.append(test_case)


@skip_if_quick
class TestViT(unittest.TestCase):
@parameterized.expand(TEST_CASE_Vit)
def test_shape(self, input_param, input_shape, expected_shape):
Expand Down
9 changes: 8 additions & 1 deletion tests/test_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
from monai.networks.blocks.warp import Warp
from monai.transforms import LoadImaged
from monai.utils import GridSampleMode, GridSamplePadMode
from tests.utils import SkipIfBeforePyTorchVersion, SkipIfNoModule, download_url_or_skip_test, testing_data_config
from tests.utils import (
SkipIfBeforePyTorchVersion,
SkipIfNoModule,
download_url_or_skip_test,
skip_if_quick,
testing_data_config,
)

LOW_POWER_TEST_CASES = [ # run with BUILD_MONAI=1 to test csrc/resample, BUILD_MONAI=0 to test native grid_sample
[
Expand Down Expand Up @@ -98,6 +104,7 @@
TEST_CASES += CPP_TEST_CASES


@skip_if_quick
class TestWarp(unittest.TestCase):
def setUp(self):
config = testing_data_config("images", "Prostate_T2W_AX_1")
Expand Down