Repository: pytorch
Issue: MPS device throws error for `F.adaptive_avg_pool2d`
Labels: module: crash,triaged,module: mps

### 🐛 Describe the bug

`F.adaptive_avg_pool2d` throws an error on MPS device, when reducing odd-sized input to even sized output. CPU works just fine.

Code to reproduce:

```python
import torch
import torch.nn.functional as F

mps=torch.device('mps')
cpu=torch.device('cpu')

x = torch.rand(1, 256, 26, 39)
out_size = 2

out = F.adaptive_avg_pool2d(x.to(cpu), out_size)
print(f'{out.shape=}')
out_mps = F.adaptive_avg_pool2d(x.to(mps), out_size)
print(f'{out_mps.shape=}')
```

output:
```
out.shape=torch.Size([1, 256, 2, 2])
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [25], in <cell line: 12>()
     10 out = F.adaptive_avg_pool2d(x.to(cpu), out_size)
     11 print(f'{out.shape=}')
---> 12 out_mps = F.adaptive_avg_pool2d(x.to(mps), out_size)
     13 print(f'{out_mps.shape=}')

File /opt/homebrew/Caskroom/miniforge/base/envs/pytorch/lib/python3.9/site-packages/torch/nn/functional.py:1214, in adaptive_avg_pool2d(input, output_size)
   1212     return handle_torch_function(adaptive_avg_pool2d, (input,), input, output_size)
   1213 _output_size = _list_with_default(output_size, input.size())
-> 1214 return torch._C._nn.adaptive_avg_pool2d(input, _output_size)

RuntimeError: Adaptive pool MPS: input sizes must be divisible by output sizes.
```

Desired behavior - same as for CPU

### Versions

```
Collecting environment information...
PyTorch version: 2.1.0.dev20230305
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.2 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: version 3.23.1
Libc version: N/A

Python version: 3.9.10 | packaged by conda-forge | (main, Feb  1 2022, 21:25:34)  [Clang 11.1.0 ] (64-bit runtime)
Python platform: macOS-13.2-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 M1 Pro

Versions of relevant libraries:
[pip3] mypy==0.990
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.24.2
[pip3] numpy-quaternion==2022.4.2
[pip3] pytest-mypy==0.9.1
[pip3] pytorch-lightning==1.9.0
[pip3] pytorch3d==0.2.5
[pip3] torch==2.1.0.dev20230305
[pip3] torch-dimcheck==0.0.1
[pip3] torch-localize==0.1.0
[pip3] torch-lr-finder==0.2.1
[pip3] torch-model-archiver-nightly==2022.11.16
[pip3] torch-receptive-field==0.0.1
[pip3] torch-workflow-archiver-nightly==2022.11.16
[pip3] torchaudio==2.0.0.dev20230227
[pip3] torchfile==0.1.0
[pip3] torchgeometry==0.1.2
[pip3] torchmetrics==0.11.1
[pip3] torchserve==0.6.1
[pip3] torchserve-nightly==2022.11.16
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.13.0
[pip3] torchvision==0.15.0.dev20230227
[conda] numpy                     1.24.2                   pypi_0    pypi
[conda] numpy-quaternion          2022.4.2                 pypi_0    pypi
[conda] pytorch-lightning         1.9.0                    pypi_0    pypi
[conda] pytorch3d                 0.2.5                    pypi_0    pypi
[conda] torch                     2.1.0.dev20230305          pypi_0    pypi
[conda] torch-dimcheck            0.0.1                    pypi_0    pypi
[conda] torch-localize            0.1.0                    pypi_0    pypi
[conda] torch-lr-finder           0.2.1                    pypi_0    pypi
[conda] torch-model-archiver-nightly 2022.11.16               pypi_0    pypi
[conda] torch-receptive-field     0.0.1                    pypi_0    pypi
[conda] torch-workflow-archiver-nightly 2022.11.16               pypi_0    pypi
[conda] torchaudio                2.0.0.dev20230227          pypi_0    pypi
[conda] torchfile                 0.1.0                    pypi_0    pypi
[conda] torchgeometry             0.1.2                    pypi_0    pypi
[conda] torchmetrics              0.11.1                   pypi_0    pypi
[conda] torchserve                0.6.1                    pypi_0    pypi
[conda] torchserve-nightly        2022.11.16               pypi_0    pypi
[conda] torchsummary              1.5.1                    pypi_0    pypi
[conda] torchtext                 0.13.0                   pypi_0    pypi
[conda] torchvision               0.15.0.dev20230227          pypi_0    pypi
```

cc @kulinseth @albanD @malfet @DenisVieriu97 @jhavukainen @razarmehr @abhudev