Skip to content

Commit 2630fbf

Browse files
committed
Merge remote-tracking branch 'origin/dev' into fix-zarr
2 parents b49ce64 + eaa901c commit 2630fbf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

monai/networks/nets/swin_unetr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,9 @@ def forward(self, x):
782782
x1 = x[:, 1::2, 0::2, 0::2, :]
783783
x2 = x[:, 0::2, 1::2, 0::2, :]
784784
x3 = x[:, 0::2, 0::2, 1::2, :]
785-
x4 = x[:, 1::2, 0::2, 1::2, :]
786-
x5 = x[:, 0::2, 1::2, 0::2, :]
787-
x6 = x[:, 0::2, 0::2, 1::2, :]
785+
x4 = x[:, 1::2, 1::2, 0::2, :]
786+
x5 = x[:, 1::2, 0::2, 1::2, :]
787+
x6 = x[:, 0::2, 1::2, 1::2, :]
788788
x7 = x[:, 1::2, 1::2, 1::2, :]
789789
x = torch.cat([x0, x1, x2, x3, x4, x5, x6, x7], -1)
790790
x = self.norm(x)

tests/test_load_image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape):
217217
@SkipIfNoModule("kvikio")
218218
@parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4])
219219
def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
220-
test_image = np.random.rand(128, 128, 128)
220+
if torch.__version__.endswith("nv24.8"):
221+
# related issue: https://github.com/Project-MONAI/MONAI/issues/8274
222+
# for this version, use randint test case to avoid the issue
223+
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
224+
else:
225+
test_image = np.random.rand(128, 128, 128)
221226
with tempfile.TemporaryDirectory() as tempdir:
222227
for i, name in enumerate(filenames):
223228
filenames[i] = os.path.join(tempdir, name)
@@ -233,7 +238,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
233238
input_param_cpu = input_param.copy()
234239
input_param_cpu["to_gpu"] = False
235240
result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames)
236-
self.assertTrue(torch.allclose(result_cpu, result.cpu(), atol=1e-6))
241+
assert_allclose(result_cpu, result.cpu(), atol=1e-6)
237242

238243
@parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9])
239244
def test_itk_reader(self, input_param, filenames, expected_shape):

0 commit comments

Comments
 (0)