pytorch/test/export
Pian Pawakapan 51045e6251 make DimHints compatible with Dims (#138490)
Previously we'd been raising UserErrors when `Dim()` and DimHints (`Dim.AUTO/Dim.DYNAMIC`) were both specified in `dynamic_shapes`, this PR stops that, and uses `Dim()` objects to guide DimHints.

The key to this was making the `EqualityConstraint` class happy when it checks that inferred equivalence relations were specified in the original `dynamic_shapes` spec, and this introduces a `RelaxedConstraint` object to mark the hinted dimensions, so equality checks between `RelaxedConstraints` and other constraints are treated as valid.

Current behavior is that:
```
class Foo(torch.nn.Module):
    def forward(self, x, y):
        return x - y

inputs = (torch.randn(4, 4), torch.randn(4, 4))
shapes = {
    "x": (Dim.AUTO, Dim("d1", min=3)),
    "y": (Dim("d0", max=8), Dim.DYNAMIC),
}
ep = export(Foo(), inputs, dynamic_shapes=shapes)
```

The dimensions marked `AUTO` and `DYNAMIC` will have max & min ranges of 8 & 3 respectively. Note that inferred equality between `Dim()` objects & `Dim.STATIC` will still raise errors - `Dim()` suggests not specializing to a constant.

Differential Revision: D64636101

Pull Request resolved: https://github.com/pytorch/pytorch/pull/138490
Approved by: https://github.com/avikchaudhuri
2024-10-22 07:43:48 +00:00
..
__init__.py
opinfo_schema.py
test_converter.py [ts_converter] Fix prim::If buffer names (#136648) 2024-10-02 00:07:47 +00:00
test_db.py Move test_db to training IR (#138251) 2024-10-18 07:42:13 +00:00
test_experimental.py Move test_experimental.py to training IR (#138140) 2024-10-17 17:30:10 +00:00
test_export.py make DimHints compatible with Dims (#138490) 2024-10-22 07:43:48 +00:00
test_export_nonstrict.py
test_export_training_ir_to_run_decomp.py
test_functionalized_assertions.py
test_hop.py
test_lift_unlift.py
test_pass_infra.py
test_passes.py
test_retraceability.py
test_schema.py
test_serdes.py
test_serialize.py Training IR should preserve custom metadata (#138266) 2024-10-22 01:09:56 +00:00
test_sparse.py
test_swap.py [export] Move swap to a different file (#137134) 2024-10-06 04:28:18 +00:00
test_tools.py
test_torchbind.py Update torchbind expecttest from landrace (#137453) 2024-10-08 06:01:29 +00:00
test_tree_utils.py
test_unflatten.py
test_unflatten_training_ir.py Lift restriction on training IR for unflatten (#137470) 2024-10-08 22:30:24 +00:00
test_verifier.py Move test_verifier to training IR (#138249) 2024-10-18 07:36:29 +00:00
testing.py