inductor: fix _dynamic_reshape_indexer issue when tail index is sym (#97502)
For TIMM **swin_base_patch4_window7_224** dynamic shape case, there has an error for ```view``` op:
```
File "/home/xiaobing/pytorch-offical/torch/_inductor/lowering.py", line 229, in wrapped
out = decomp_fn(*args, **kwargs)
File "/home/xiaobing/pytorch-offical/torch/_inductor/lowering.py", line 665, in view
return TensorBox(View.create(x.data, sizes))
File "/home/xiaobing/pytorch-offical/torch/_inductor/ir.py", line 1325, in create
reindex = cls.dynamic_reshape_indexer(old_size, new_size)
File "/home/xiaobing/pytorch-offical/torch/_inductor/ir.py", line 1351, in dynamic_reshape_indexer
reindex2 = cls._dynamic_reshape_indexer(flat, new_size)
File "/home/xiaobing/pytorch-offical/torch/_inductor/ir.py", line 1406, in _dynamic_reshape_indexer
assert size_new == 1
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
LoweringException: AssertionError:
target: aten.view.default
args[0]: TensorBox(StorageBox(
Pointwise(
'cpu',
torch.float32,
def inner_fn(index):
i0, i1, i2, i3 = index
tmp0 = ops.load(buf37, i3 + 49 * i2 + 2401 * i1 + 9604 * i0)
tmp1 = ops.load(arg35_1, i3 + 49 * i2)
tmp2 = ops.load(arg1_1, i1 + 4 * (tmp1))
tmp3 = tmp0 + tmp2
return tmp3
,
ranges=[64, 4, 49, 49],
origins={add_12}
)
))
args[1]: [64//s3, s3, 4, 49, 49]
```
the target shaps of ```view``` is ```[64//s3, s3, 4, 49, 49]```, and ```Sym(s3)``` is 64, see
```
sym_size_16: Sym(s3) = torch.ops.aten.sym_size(arg34_1, 0)
floordiv_3: Sym(64//s3) = sym_size_13 // sym_size_16
view_33: f32[64//s3, 64//(64//s3), 4, 49, 49] = torch.ops.aten.view.default(add_12, [floordiv_3, sym_size_16, 4, sym_size_14, sym_size_14]); add_12 = floordiv_3 = sym_size_16 = None
```
For the tail index of the new size is ```Sym(64//s3)```, it is not a number, we shouldn't directly compare it with ```1```.
Currently, I didn't find a simple test case to reproduce it, I just test it for the real model.
```
python -m torch.backends.xeon.run_cpu --core_list 0 --ncores_per_instance 1 benchmarks/dynamo/timm_models.py --performance --float32 -dcpu -n50 --inductor --only swin_base_patch4_window7_224 --batch_size 1 --threads 1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97502
Approved by: https://github.com/jgong5, https://github.com/ezyang