-
Notifications
You must be signed in to change notification settings - Fork 27.4k
F.interpolate returns NAN on MPS if align_corner is True. #144245
Description
🐛 Describe the bug
When using interpolate on MPS with align_corner=True, the result consists only of NaN value, which is inconsistent to the CPU implementation.
You can replicate this by the following code snippet:
import torch
import torch.nn.functional as F
test = torch.Tensor([[1],[2],[4]]).to("mps")
result = F.interpolate(test.unsqueeze(1), 3, mode="linear", align_corners=True).squeeze(1)
print(result)
# tensor([[nan, nan, nan],
# [nan, nan, nan],
# [nan, nan, nan]], device='mps:0')
test = torch.Tensor([[1],[2],[4]]).to("cpu")
result = F.interpolate(test.unsqueeze(1), 3, mode="linear", align_corners=True).squeeze(1)
print(result)
# tensor([[1., 1., 1.],
# [2., 2., 2.],
# [4., 4., 4.]])Versions
Collecting environment information...
PyTorch version: 2.5.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: macOS 15.1 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.4)
CMake version: Could not collect
Libc version: N/A
Python version: 3.11.9 (main, Jun 29 2024, 14:01:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] (64-bit runtime)
Python platform: macOS-15.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Apple M2
Versions of relevant libraries:
[pip3] flake8==7.1.1
[pip3] mypy==1.11.2
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] pytorch-forecasting==1.1.1
[pip3] pytorch-lightning==2.4.0
[pip3] pytorch_optimizer==2.12.0
[pip3] torch==2.5.1
[pip3] torchmetrics==1.4.1
[pip3] torchvision==0.19.0
[conda] Could not collect
cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki @kulinseth @malfet @DenisVieriu97 @jhavukainen