Repository: pytorch
Issue: [torch.compile] Conv1d failed: AssertionError: expected size 33==33, stride 1==50 at dim=1
Labels: oncall: pt2,oncall: cpu inductor

### 🐛 Describe the bug

The following testcase can reproduce this issue:
```
import torch
import torch.nn as nn

class Conv1d(nn.Module):
    def __init__(self):
        super(Conv1d, self).__init__()
        self.conv = nn.Conv1d(16, 33, 1)
    def forward(self, x):
        x = self.conv(x)
        return x
    
x = torch.randn(20, 16, 50)
model = Conv1d().eval()

#conv1d weight stride: 16, 1, 1 -> 16, 1, 16
print(model.conv.weight.data.size(), model.conv.weight.data.stride())
t = model.conv.weight.data
t = t.view(t.size(0), t.size(1), 1, t.size(2))
t = t.to(memory_format=torch.channels_last)
t = t.view(t.size(0), t.size(1), t.size(3))
model.conv.weight.data = t
print(model.conv.weight.data.size(), model.conv.weight.data.stride())

compiled_model = torch.compile(model)

with torch.no_grad():
    for _ in range(3):
        out = compiled_model(x)
```

The error message:
Traceback (most recent call last):
  File "/home/jiayisun/pytorch/2.py", line 28, in <module>
    out = compiled_model(x)
  File "/home/jiayisun/pytorch/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/nn/modules/module.py", line 1541, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/_dynamo/eval_frame.py", line 387, in _fn
    return fn(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/nn/modules/module.py", line 1541, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/jiayisun/pytorch/2.py", line 8, in forward
    def forward(self, x):
  File "/home/jiayisun/pytorch/torch/_dynamo/eval_frame.py", line 387, in _fn
    return fn(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/_dynamo/external_utils.py", line 36, in inner
    return fn(*args, **kwargs)
  File "/home/jiayisun/pytorch/torch/_functorch/aot_autograd.py", line 991, in forward
    return compiled_fn(full_args)
  File "/home/jiayisun/pytorch/torch/_functorch/_aot_autograd/runtime_wrappers.py", line 130, in runtime_wrapper
    all_outs = call_func_at_runtime_with_args(
  File "/home/jiayisun/pytorch/torch/_functorch/_aot_autograd/utils.py", line 116, in call_func_at_runtime_with_args
    out = normalize_as_list(f(args))
  File "/home/jiayisun/pytorch/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 181, in rng_functionalization_wrapper
    return compiled_fw(args)
  File "/home/jiayisun/pytorch/torch/_inductor/compile_fx.py", line 1156, in wrapper
    return optimized_function(args_new)
  File "/home/jiayisun/pytorch/torch/_inductor/codecache.py", line 956, in __call__
    return self.current_callable(inputs)
  File "/tmp/torchinductor_jiayisun/k2/ck23ppqce3ytpw7ximiwvn5qrgmkw2pzv2itjeewmxvwbk7soolf.py", line 41, in call
    assert_size_stride(buf0, (20, 33, 50), (1650, 50, 1))
AssertionError: expected size 33==33, stride 1==50 at dim=1


### Versions

PyTorch version: 2.4.0a0+git19f5033
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 11.1.0-1ubuntu1~20.04) 11.1.0
Clang version: 9.0.1-12
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.9.15 (main, Nov 11 2022, 13:58:57)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-102-generic-x86_64-with-glibc2.35
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:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Byte Order:                         Little Endian
Address sizes:                      52 bits physical, 57 bits virtual
CPU(s):                             128
On-line CPU(s) list:                0-127
Thread(s) per core:                 2
Core(s) per socket:                 32
Socket(s):                          2
NUMA node(s):                       2
Vendor ID:                          GenuineIntel
CPU family:                         6
Model:                              106
Model name:                         Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz
Stepping:                           6
CPU MHz:                            2600.000
CPU max MHz:                        3400.0000
CPU min MHz:                        800.0000
BogoMIPS:                           5200.00
L1d cache:                          3 MiB
L1i cache:                          2 MiB
L2 cache:                           80 MiB
L3 cache:                           96 MiB
NUMA node0 CPU(s):                  0-31,64-95
NUMA node1 CPU(s):                  32-63,96-127
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] clip-anytorch==2.5.2
[pip3] CoCa-pytorch==0.0.7
[pip3] dalle2-pytorch==1.14.2
[pip3] ema-pytorch==0.2.3
[pip3] flake8==6.0.0
[pip3] flake8-bugbear==23.3.23
[pip3] flake8-comprehensions==3.12.0
[pip3] flake8-executable==2.1.3
[pip3] flake8-logging-format==0.9.0
[pip3] flake8-pyi==23.3.1
[pip3] flake8-simplify==0.19.3
[pip3] intel-extension-for-pytorch==2.3.0+gitaf812a6
[pip3] mypy==1.7.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.3
[pip3] open-clip-torch==2.20.0
[pip3] optree==0.9.1
[pip3] pytorch-warmup==0.1.1
[pip3] rotary-embedding-torch==0.2.7
[pip3] torch==2.4.0a0+git1fd9e32
[pip3] torch-fidelity==0.3.0
[pip3] torch_geometric==2.4.0
[pip3] torchaudio==2.1.0a0+5ee254e
[pip3] torchmetrics==1.1.1
[pip3] torchvision==0.16.0a0+6472a5c
[pip3] vector-quantize-pytorch==1.7.0
[conda] clip-anytorch             2.5.2                    pypi_0    pypi
[conda] coca-pytorch              0.0.7                    pypi_0    pypi
[conda] dalle2-pytorch            1.14.2                   pypi_0    pypi
[conda] ema-pytorch               0.2.3                    pypi_0    pypi
[conda] intel-extension-for-pytorch 2.3.0+gitaf812a6           dev_0    <develop>
[conda] mkl                       2023.0.0            intel_25398    intel
[conda] mkl-include               2023.1.0                 pypi_0    pypi
[conda] mkl-static                2023.1.0                 pypi_0    pypi
[conda] numpy                     1.26.3                   pypi_0    pypi
[conda] open-clip-torch           2.20.0                   pypi_0    pypi
[conda] optree                    0.9.1                    pypi_0    pypi
[conda] pytorch-warmup            0.1.1                    pypi_0    pypi
[conda] rotary-embedding-torch    0.2.7                    pypi_0    pypi
[conda] torch                     2.4.0a0+git1fd9e32           dev_0    <develop>
[conda] torch-fidelity            0.3.0                    pypi_0    pypi
[conda] torch-geometric           2.4.0                    pypi_0    pypi
[conda] torchaudio                2.1.0a0+5ee254e          pypi_0    pypi
[conda] torchmetrics              1.1.1                    pypi_0    pypi
[conda] torchvision               0.16.0a0+6472a5c          pypi_0    pypi
[conda] vector-quantize-pytorch   1.7.0                    pypi_0    pypi


cc @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang