-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
conversion_dtype
in ONNXConversion pass and `dynamic_shapes…
…` on torch.onnx.export(..., dynamo=True) (#1511) ## Describe your changes (1) Introduce `dynamic_shapes`, which is a crucial parameter to torch.onnx.export(..., dynamo=True). (2) Enable `dynamic` boolean control in the config (3) Actually apply `torch_dtype` to model inputs. NOTE: 1. Some automation is intentionally not supported by the dynamic_shapes field due to the complexity of generatirng `dynamic_shapes`, and torch.onnx.export(dynamo=True) actually supports converting `dynamic_axes` to `dynamic_shapes` (limited). 2. To follow JSON rules, `dynamic_shapes` requires users to provide a list of [dim_name(str), min(int), max(int)]. These information will later be used to compose `torch.export.Dim(dim_name, min=min, max=max)` ([detail](https://pytorch.org/docs/stable/export.html#expressing-dynamism)). 3. `dynamic_shapes` follows the tree structure of the model inputs. For example, if the model input is nested tuple, then the `dynamic_shapes` should be a nested tuple, instead of a dictionary. 4. The `kv_cache` support of `dynamic_shapes` is limited in terms of the variation of model signatures, implementations, and inputs. Users are encouraged to provide full kv cache. ## Checklist before requesting a review - [x] Add unit tests for this change. - [x] Make sure all tests can pass. - [x] Update documents if necessary. - [x] Lint and apply fixes to your code by running `lintrunner -a` - [x] Is this a user-facing change? If yes, give a description of this change to be included in the release notes. - [ ] Is this PR including examples changes? If yes, please remember to update [example documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md) in a follow-up PR. ## (Optional) Issue link
- Loading branch information
1 parent
86f742d
commit f372b89
Showing
11 changed files
with
302 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.