pytorch/docs
Avik Chaudhuri b70d105c77 infer dynamic shapes through additional inputs (#150144)
Summary:
Instead of explicitly specifying dynamic shapes, it is possible to infer them from additional example inputs. Together with the example inputs provided to export, we can basically make any varying dim dynamic and keep any fixed dim static. This should be useful for prod scenarios that have access to tests and/or profiling data, yet are somewhat removed from the model authoring process.

However this alone is not satisfactory: the exported program by design has only one graph, representing one path through the model, and we cannot necessarily guarantee that this graph works for the additional example inputs because different guards might have been created if we had exported with them instead (corresponding to different traced paths). However, checking that the additional example inputs satisfy the guards created by the original export should be sufficient for generalization.

Now, while we don't preserve all guards in the exported program, we do check a subset of them as part of input matching. So we add a verification step at the end of export when such additional example inputs are provided. This should be enough for now.

Test Plan: added test (positive and negative cases)

Differential Revision: D72001771

Pull Request resolved: https://github.com/pytorch/pytorch/pull/150144
Approved by: https://github.com/bobrenjc93
2025-04-01 21:13:39 +00:00
..
cpp Removing doc references to PRE_CXX11_ABI. (#149756) 2025-03-25 16:01:59 +00:00
source infer dynamic shapes through additional inputs (#150144) 2025-04-01 21:13:39 +00:00
.gitignore
libtorch.rst Add ROCm documentation to libtorch (C++) reST. (#136378) 2024-09-25 02:30:56 +00:00
make.bat Sphinx parallel build (#38785) 2020-05-21 13:03:55 -07:00
Makefile [ONNX] Update images and APIs to onnx_dynamo.rst (#144358) 2025-01-08 21:44:43 +00:00
README.md Add docs/README.md to make existing doc build info more discoverable (#49286) 2020-12-16 11:55:45 -08:00
requirements.txt Revert "Fix deprecated pytorch_sphinx_theme editable installation (#145347)" 2025-01-23 20:06:07 +00:00

Please see the Writing documentation section of CONTRIBUTING.md for details on both writing and building the docs.