[Relay] Flexible shape dispatch transformation#11199
Merged
Merged
Conversation
jroesch
reviewed
May 3, 2022
jroesch
reviewed
May 3, 2022
jroesch
reviewed
May 3, 2022
jroesch
reviewed
May 3, 2022
jroesch
reviewed
May 3, 2022
Member
|
cc @mbs-octoml |
Contributor
Author
|
@jroesch I think the documentation should now be substantially improved based on your input. Let me know what you think. |
mbs-octoml
approved these changes
May 3, 2022
mbs-octoml
left a comment
Contributor
There was a problem hiding this comment.
LGTM, some optional nits:
- consider asserting dim is Any in override_shape to avoid surprises
- rename dim -> axis, value -> dim
- should we force a TypeInfer afterwards to be sure the Any->dim subst is sound?
Contributor
Author
|
All feedback has been addressed and tests are green. @jroesch do you want to give this one more pass? |
shtinsa
pushed a commit
to Deelvin/tvm
that referenced
this pull request
May 17, 2022
* Added pass that creates a semi-dynamic dispatcher around a relay module. * Added automatic padding feature. * Output slicing working. * Multiple input support working i think. * Added test file. * Improve comments. * Fix lint. * Allow default values. * Fix docstring. * Improved documentation based on feedback. * Add extra check for record loading. * Improve variable names. * Add type inference to make sure things worked. * Added support for multiple outputs.
SebastianBoblest
pushed a commit
to SebastianBoblest/tvm
that referenced
this pull request
May 27, 2022
* Added pass that creates a semi-dynamic dispatcher around a relay module. * Added automatic padding feature. * Output slicing working. * Multiple input support working i think. * Added test file. * Improve comments. * Fix lint. * Allow default values. * Fix docstring. * Improved documentation based on feedback. * Add extra check for record loading. * Improve variable names. * Add type inference to make sure things worked. * Added support for multiple outputs.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new pass to
relay.transformthat creates a dispatcher around an input module to handle multiple input shapes. For example consider a case where I'd like to optimize my model to handle bothbatch_size=1andbatch_size=4. I can now do so elegantly as follows:As seen above
FlexibleShapeDispatchis a simple halfway point between fully static and fully dynamic graphs that allows us to leverage TVM tuning. If an input shape is not provided inbuckets, it will either run fully dynamically usingrelay.Any, or if theauto_padargument is set forFlexibleShapeDispatch, padding will be applied to match the closest bucket.There are a few special cases that this pass handles. Multiple dynamic inputs (like those you might see in BERT) can be handled by setting
input_indicesto indicate which inputs have a dynamic axis.affects_outputcan be set toFalsefor cases where the output shape is not dependent on input dynamism which could occur in dynamic resolution cases or something.To make applying tuning logs more convenient, I also added the ability to load and merge multiple files to both autotvm and autoscheduler.
Thanks @jroesch for providing the backbone of this implementation.