-
Notifications
You must be signed in to change notification settings - Fork 27.4k
torch.nn.functional.interpolate nearest behaviour changed in PyTorch 1.9 and appears incorrect #62237
Description
🐛 Bug
torch.nn.functional.interpolate with mode='nearest' has changed in PyTorch 1.9. The previous behaviour is more logical given a scale factor so close to 1.0 should not affect the nearest pixel.
To Reproduce
Steps to reproduce the behavior:
import torch
import torch.nn.functional as F
t_in = torch.tensor([[[1.0, 2.0]]])
t_out = F.interpolate(t_in, scale_factor=1.00001, recompute_scale_factor=False)
print(t_in)
print(t_out)
PyTorch 1.8
tensor([[[1., 2.]]])
tensor([[[1., 2.]]])
Torch 1.9
tensor([[[1., 2.]]])
tensor([[[1., 1.]]])
Expected behavior
t_out to be printed as tensor([[[1., 2.]]]) matching PyTorch 1.8
Environment
Pytorch 1.8
Collecting environment information...
PyTorch version: 1.8.0
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.18.4
Libc version: glibc-2.25
Python version: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] (64-bit runtime)
Python platform: Linux-5.3.0-42-generic-x86_64-with-Ubuntu-18.04-bionic
Is CUDA available: False
CUDA runtime version: No CUDA
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
Versions of relevant libraries:
[pip3] numpy==1.18.1
[pip3] torch==1.8.0
[pip3] torchvision==0.9.0
[conda] Could not collect
Pytorch 1.9
PyTorch version: 1.9.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.18.4
Libc version: glibc-2.25
Python version: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] (64-bit runtime)
Python platform: Linux-5.3.0-42-generic-x86_64-with-Ubuntu-18.04-bionic
Is CUDA available: False
CUDA runtime version: No CUDA
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
Versions of relevant libraries:
[pip3] numpy==1.18.1
[pip3] torch==1.9.0
[pip3] torchvision==0.10.0
[conda] Could not collect
cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @anjali411