fix resize bug (#61166)
authorBBuf <1182563586@qq.com>
Fri, 27 Aug 2021 17:42:24 +0000 (10:42 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 27 Aug 2021 17:49:31 +0000 (10:49 -0700)
commit6ab3a210983b7eee417e7cd92a8ad2677065e470
treec971be4986d50c9c8fc8f23afb45bc9432540f0c
parent538c30a713a1ee2a3d654c3e1cdf9cc20b7d8c72
fix resize bug (#61166)

Summary:
I think the original intention here is to only take effect in the case of align_corners (because output_size = 1 and the divisor will be 0), but it affects non-align_corners too. For example:

```python
input = torch.tensor(
        np.arange(1, 5, dtype=np.int32).reshape((1, 1, 2, 2)) )
m = torch.nn.Upsample(scale_factor=0.5, mode="bilinear")
of_out = m(input)
```

The result we expect should be [[[[2.5]]]]

but pytorch get [[[[1.0]]]] which is different from OpenCV  and PIL, this pr try to fixed it。

Pull Request resolved: https://github.com/pytorch/pytorch/pull/61166

Reviewed By: malfet

Differential Revision: D30543178

Pulled By: heitorschueroff

fbshipit-source-id: 21a4035483981986b0ae4a401ef0efbc565ccaf1
aten/src/ATen/native/UpSample.h
aten/src/ATen/native/cuda/UpSample.cuh
test/test_nn.py