[Mac M1] `torch.mm` sometimes produces incorrect results
Labels: high priority, module: cpu, triaged, module: correctness (silent), module: arm, module: m1

### 🐛 Describe the bug

Observed unexpected nan outputs from the `torch.nn.functional.conv1d` function on M1 Mac

```python
# bug_demo.py

import torch

n_trials = 100
for ii in range(n_trials):
    a = torch.randn(1024, device='mps')
    b = torch.randn(499, device='mps')
    c = torch.nn.functional.conv1d(a.view(1, 1, -1), b.view(1, 1, -1))
    if torch.isnan(torch.sum(c)):
        print(f'mps: trial {ii}, nan elements {torch.isnan(c.squeeze()).nonzero().view(-1).cpu().numpy()}')
        
for ii in range(n_trials):
    a = torch.randn(1024, device='cpu')
    b = torch.randn(499, device='cpu')
    c = torch.nn.functional.conv1d(a.view(1, 1, -1), b.view(1, 1, -1))
    if torch.isnan(torch.sum(c)):
        print(f'cpu: trial {ii}, elements {torch.isnan(c.squeeze()).nonzero().view(-1).numpy()}')
```

Which results in:
```
$ python bug_demo.py
cpu: trial 1, nan elements [512 513 514 515 516 517 518 519 520 521 522 523]
cpu: trial 3, nan elements [514 515 520 521 524 525]
cpu: trial 6, nan elements [514 515 520 521 524 525]
cpu: trial 7, nan elements [520 521]
cpu: trial 21, nan elements [520 521]
cpu: trial 22, nan elements [514 515 518 519 520 521 522 523 524 525]
cpu: trial 23, nan elements [514 515 520 521 524 525]
cpu: trial 26, nan elements [514 515 518 519 520 521 522 523 524 525]
# ... 15 more trials

$ python bug_demo.py

$ python bug_demo.py
cpu: trial 4, nan elements [512 513 521 522 523]
cpu: trial 53, nan elements [512 513 521 522 523]
cpu: trial 67, nan elements [512 513 521 522 523]
cpu: trial 89, nan elements [512 513 521 522 523]

$ python bug_demo.py
mps: trial 36, nan elements [  0   1   2   3   4   5   ...  525]  # Notice: MPS.  All elements are nan
cpu: trial 1, nan elements [514 515 518 519 520 521 522 523 524 525]
# ... 12 more trials, all with the same nan elements
```

**Few observations:**
* The bug was observed both on CPU and MPS devices
* The bug occurs much more frequently on CPU than on MPS
  * For CPU it was observed almost on every run
  * For MPS it was observed once every 30/40 runs
* The bug occurs much more frequently when running first on MPS and then on CPU
* Most of the nan values were observed at the +- end of the output vector when running on CPU.  In this example, the output has 526 elements; unexpected nan values were observed most frequently on elements 520 and 521.  On MPS device, on the other hand, when it happened, *usually* the whole output vector was all nan
* The bug was observed even for deterministic inputs (e.g., `arange(0, L, ..., dtype=torch.float32)` instead of `randn(...)`), although less frequently
* On my very non-exhaustive set of trials, the problem didn't reproduce so frequently for shorter `a` and `b` vectors.  I managed to observe the problem on MPS for `a` with 512 elements and `b` with 299, but couldn't reproduce at all for shorter `b` (doesn't mean that it can't happen, though)

One last thing: the execution time on the MPS was > x100 than the run time on CPU.  For `n_trials = 1000`, it's `11.359s` vs `0.102s` (on M1 Max).

### Versions

Observed on the stable and the nightly builds.

Nightly build:
```
Collecting environment information...
PyTorch version: 1.13.0.dev20220710
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.4 (arm64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2.5)
CMake version: version 3.23.2
Libc version: N/A

Python version: 3.9.12 (main, Apr  5 2022, 01:52:34)  [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-12.4-arm64-arm-64bit
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
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.22.3
[pip3] torch==1.13.0.dev20220710
[pip3] torchvision==0.14.0.dev20220710
[conda] numpy                     1.22.3           py39h25ab29e_0
[conda] numpy-base                1.22.3           py39h974a1f5_0
[conda] pytorch                   1.13.0.dev20220710         py3.9_0    pytorch-nightly
[conda] torchvision               0.14.0.dev20220710        py39_cpu    pytorch-nightly
```

Stable build:
```
...
Versions of relevant libraries:
[pip3] numpy==1.22.3
[pip3] torch==1.12.0
[pip3] torchvision==0.13.0
[conda] numpy                     1.22.3           py39h25ab29e_0
[conda] numpy-base                1.22.3           py39h974a1f5_0
[conda] pytorch                   1.12.0                  py3.9_0    pytorch
[conda] torchvision               0.13.0                 py39_cpu    pytorch
```

cc @ezyang @gchanan @zou3519 @VitalyFedyunin @malfet @kulinseth @albanD