torch._dynamo.export does not support symbolic int inputs
Labels: triaged, oncall: pt2, module: dynamic shapes, module: export

### 🐛 Describe the bug

```
import torch

def f(x, i):
    return x.view(i) + 2

r = torch._dynamo.export(f, torch.randn(3, 3), 9)
```

prints

```
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] Summary of dimension constraints:
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] The following dimensions have been specialized and CANNOT be dynamic.
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] ```
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] def specializations(x, i):
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO]     # x:
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO]     assert x.size()[0] == 3
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO]     assert x.size()[1] == 3
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] ```
[2023-07-26 07:44:09,382] torch._dynamo.eval_frame: [INFO] 
```

There isn't really any reason why the input 9 couldn't be treated symbolically though.

You can sort of fake it with this patch

```
diff --git a/fbcode/caffe2/torch/_dynamo/eval_frame.py b/fbcode/caffe2/torch/_dynamo/eval_frame.py
--- a/fbcode/caffe2/torch/_dynamo/eval_frame.py
+++ b/fbcode/caffe2/torch/_dynamo/eval_frame.py
@@ -966,7 +966,7 @@
         assume_static_by_default = True
     with patch(f"{__name__}.most_recent_backend", None), config.patch(
         summarize_dim_constraints=True,
-        specialize_int=True,
+        specialize_int=False,
         assume_static_by_default=assume_static_by_default,
         automatic_dynamic_shapes=False,
         capture_dynamic_output_shape_ops=True,
diff --git a/fbcode/caffe2/torch/_dynamo/variables/builder.py b/fbcode/caffe2/torch/_dynamo/variables/builder.py
--- a/fbcode/caffe2/torch/_dynamo/variables/builder.py
+++ b/fbcode/caffe2/torch/_dynamo/variables/builder.py
@@ -1082,12 +1082,6 @@
             )
             self.tx.output.unspec_variable_map[self.name] = unspec_var
             if not is_constant_source(self.get_source()):
-                if self.tx.export and not isinstance(self.get_source(), LocalSource):
-                    raise AssertionError(
-                        "Dynamo attempts to add additional input during export: value={}, source={}".format(
-                            wrapped_value, self.get_source()
-                        )
-                    )
                 fake_tensor_value = None
                 if isinstance(unspec_var, ConstantVariable):
                     example_value = unspec_var.value
diff --git a/fbcode/caffe2/torch/fx/experimental/symbolic_shapes.py b/fbcode/caffe2/torch/fx/experimental/symbolic_shapes.py
--- a/fbcode/caffe2/torch/fx/experimental/symbolic_shapes.py
+++ b/fbcode/caffe2/torch/fx/experimental/symbolic_shapes.py
@@ -1480,7 +1480,11 @@
         self.symbol_to_source = symbol_to_source
 
     def print_source(self, source) -> str:
-        return f"dynamic_dim({source.base.name()}, {source.idx})"
+        from torch._dynamo.source import TensorPropertySource
+        if isinstance(source, TensorPropertySource):
+            return f"dynamic_dim({source.base.name()}, {source.idx})"
+        else:
+            return "TODO"
 
     def _print_Symbol(self, expr) -> str:
         assert isinstance(expr, sympy.Symbol), str(type(expr))
```

but there are still some gaps (see TODO; also argument matching doesn't work

```
eval_frame.py", line 924, in produce_matching                                                                                                         
    id(arg) in dict_of_source_args                                            
AssertionError: Dynamo input and output is a strict subset of traced input/output   
```

cc @msaroufim @wconstab @bdhirsh @anijain2305 @tugsbayasgalan @voznesenskym 

### Versions

main