Skip to content

Commit bb15b1f

Browse files
committed
Try a fix for Windows issue
Signed-off-by: Eric Kerfoot <[email protected]>
1 parent f990ccc commit bb15b1f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

monai/networks/layers/spatial_transforms.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
from __future__ import annotations
1313

14-
from collections.abc import Sequence
1514
import sys
15+
from collections.abc import Sequence
1616

1717
import torch
1818
import torch.nn as nn
@@ -530,7 +530,7 @@ def forward(
530530

531531
# In some cases it's necessary to convert inputs to grid_sample from float64 to float32 to work around known
532532
# issues with PyTorch, see https://github.com/Project-MONAI/MONAI/pull/8429
533-
convert_f32 = sys.platform != "win32" and src.dtype == torch.float64 and src.device == torch.device("cpu")
533+
convert_f32 = sys.platform == "win32" and src.dtype == torch.float64 and src.device == torch.device("cpu")
534534

535535
# validate `theta`
536536
if not isinstance(theta, torch.Tensor):
@@ -595,11 +595,7 @@ def forward(
595595
grid = grid.to(torch.float32)
596596

597597
dst = nn.functional.grid_sample(
598-
input=_input,
599-
grid=grid,
600-
mode=self.mode,
601-
padding_mode=self.padding_mode,
602-
align_corners=self.align_corners,
598+
input=_input, grid=grid, mode=self.mode, padding_mode=self.padding_mode, align_corners=self.align_corners
603599
)
604600

605601
if convert_f32:

0 commit comments

Comments
 (0)