pytorch/torch/export
angelayi 6a1b820255 [export] Enable symint inputs for AdditionalInputs and ShapesCollection (#151842)
With `AdditionalInputs`, the behavior is the same as with tensors:
```python
class M(torch.nn.Module):
    def forward(self, x, y):
        return x + y

additional_inputs = torch.export.AdditionalInputs()
additional_inputs.add((5, 5))
additional_inputs.add((3, 5))
additional_inputs.add((5, 4))
ep = torch.export.export(
    M(), (6, 7), dynamic_shapes=additional_inputs, strict=False
)
```

With `ShapesCollection`, we now need to wrap integer inputs as `_IntWrapper` so that we can have a unique identifier for each integer input.
```python
class M(torch.nn.Module):
    def forward(self, x, y):
        return x + y

from torch.export.dynamic_shapes import _IntWrapper

args = (_IntWrapper(5), _IntWrapper(5))
# Or we can do `args = pytree.tree_map_only(int, lambda a: _IntWrapper(a), orig_args)`
shapes_collection = torch.export.ShapesCollection()
shapes_collection[args[0]] = Dim.DYNAMIC
shapes_collection[args[1]] = Dim.DYNAMIC
ep = torch.export.export(
    M(), args, dynamic_shapes=shapes_collection, strict=False
)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151842
Approved by: https://github.com/pianpwk
2025-04-22 22:29:18 +00:00
..
experimental PEP585 update - torch/export (#145165) 2025-01-19 20:56:55 +00:00
passes PEP585: More UP006 fixes (#146392) 2025-02-20 06:18:13 +00:00
__init__.py [doc fix] fix torch export docs for preserve_module_call_signature (#151140) 2025-04-18 02:55:35 +00:00
_draft_export.py Rename register_fake_profile to unsafe_generate_fake_kernels (#151797) 2025-04-21 23:08:15 +00:00
_remove_auto_functionalized_pass.py remove allow-untyped-defs from torch/export/_remove_auto_functionalized_pass.py (#144230) 2025-01-06 22:23:19 +00:00
_remove_effect_tokens_pass.py Fakify torchbind objects in compile_fx and add tests for SigridTransformsInstanceTorchBind (#149529) 2025-03-21 18:58:28 +00:00
_safeguard.py
_swap.py PEP585 update - torch/export (#145165) 2025-01-19 20:56:55 +00:00
_trace.py Infra for handling builtin ops (min, max, math.pow) (#151348) 2025-04-22 17:20:09 +00:00
_tree_utils.py PEP585 update - torch/export (#145165) 2025-01-19 20:56:55 +00:00
_unlift.py Suppress more warnings (#149833) 2025-04-01 05:33:04 +00:00
_wrapper_utils.py [reland] Make export._trace._WrapperModule work in strict mode (#146919) (#151264) 2025-04-15 18:35:34 +00:00
custom_obj.py
custom_ops.py Fix subclass access custom op bug (#149698) 2025-03-21 19:42:56 +00:00
decomp_utils.py Re-land exclude upsample_bilinear2d.vec and nearest2d.vec from default export decomposition table (#147153) 2025-02-19 23:03:29 +00:00
dynamic_shapes.py [export] Enable symint inputs for AdditionalInputs and ShapesCollection (#151842) 2025-04-22 22:29:18 +00:00
exported_program.py Fix implicit state dict modification (#151436) 2025-04-18 00:58:55 +00:00
graph_signature.py pretty print graph signature (#149710) 2025-03-21 21:31:58 +00:00
unflatten.py [dynamo] add dynamo disable reasons to codebase (#150440) 2025-04-02 04:26:48 +00:00