Extreme slowdown of torch.mm for certain sizes and strides with bfloat16
Labels: module: cuda, triaged, module: bfloat16

### 🐛 Describe the bug

I noticed I was getting some extreme slowdowns of matrix multiplications that usually take much less time for similar shapes. It was only for certain shapes and memory layouts, and I've been able to put together a small reproducible example.

Running the following code:

```python
import torch
from timeit import timeit

# 100000 isn't important and could be any big number
# 100 could be any similar number but the slowdown goes away with significantly different values

m = torch.ones(100000, 100, dtype=torch.bfloat16, device="cuda")
def mm(t):
    torch.mm(t, m)
    torch.cuda.synchronize()

for i in range(1, 21):
    t = torch.ones(100000, i, dtype=torch.bfloat16, device="cuda").T
    mm(t)
    print(i, timeit(lambda: mm(t), number=10))
```
Results in:
```
1 0.00016830721870064735
2 0.00011278688907623291
3 0.0027380590327084064
4 0.00010453397408127785
5 0.0028314038645476103
6 0.0001054578460752964
7 0.002929423004388809
8 0.0001083549577742815
9 0.0030427640303969383
10 0.00010291696526110172
11 0.003144121030345559
12 0.00010385108180344105
13 0.0032425778917968273
14 0.00010714191012084484
15 0.003299999050796032
16 0.00010801898315548897
17 0.00010303501039743423
18 0.00011960999108850956
19 0.0001004338264465332
20 0.00010727089829742908
```
As you can see, certain odd dimension lengths (3,5,7,9,11,13,15) are ~30x slower than you'd expect!

I'm not super familiar with how performant 2-byte aligned memory ops are vs 4-byte which that could explain the odd lengths with bfloat16, but I still would hope to be better than 30x slower.

### Versions

```
PyTorch version: 1.13.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

GCC version: (Debian 8.3.0-6) 8.3.0
Clang version: Could not collect
CMake version: version 3.13.4
Libc version: glibc-2.28

Python version: 3.10.12 (main, Jun 12 2023, 08:08:55) [GCC 11.2.0] (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A100-SXM4-40GB
GPU 1: NVIDIA A100-SXM4-40GB
GPU 2: NVIDIA A100-SXM4-40GB
GPU 3: NVIDIA A100-SXM4-40GB
GPU 4: NVIDIA A100-SXM4-40GB
GPU 5: NVIDIA A100-SXM4-40GB
GPU 6: NVIDIA A100-SXM4-40GB
GPU 7: NVIDIA A100-SXM4-40GB

Nvidia driver version: 470.129.06
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       46 bits physical, 48 bits virtual
CPU(s):              96
On-line CPU(s) list: 0-95
Thread(s) per core:  2
Core(s) per socket:  24
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               85
Model name:          Intel(R) Xeon(R) CPU @ 2.20GHz
Stepping:            7
CPU MHz:             2200.216
BogoMIPS:            4402.78
Hypervisor vendor:   KVM
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            1024K
L3 cache:            39424K
NUMA node0 CPU(s):   0-23,48-71
NUMA node1 CPU(s):   24-47,72-95
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat avx512_vnni md_clear arch_capabilities

Versions of relevant libraries:
[pip3] flake8==6.0.0
[pip3] msgpack-numpy==0.4.8
[pip3] mypy==1.2.0
[pip3] mypy-extensions==1.0.0
[pip3] mypy-protobuf==3.2.0
[pip3] numpy==1.23.2
[pip3] numpyro==0.10.1
[pip3] torch==1.13.1+cu117
[conda] Could not collect
```

cc @ptrblck