-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Relay] Support dynamic indices size in gather_nd and scatter_nd #8105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Member
Author
|
pinging for reviews. |
jwfromm
reviewed
May 27, 2021
jwfromm
approved these changes
May 28, 2021
55a4430 to
53d9700
Compare
b745d31 to
06ac205
Compare
mehrdadh
pushed a commit
to mehrdadh/tvm
that referenced
this pull request
Jun 3, 2021
…che#8105) * add gather_nd shape func * refactor gather_nd ref funcs * add dynamic gather_nd test * gather_dim -> num_indices_per_tuple * support dynamic scatter nd * minor fix * fix pylint * rename to index_rank and make it Optional * pylint, do not use -1 for default value
trevor-m
pushed a commit
to trevor-m/tvm
that referenced
this pull request
Jun 17, 2021
…che#8105) * add gather_nd shape func * refactor gather_nd ref funcs * add dynamic gather_nd test * gather_dim -> num_indices_per_tuple * support dynamic scatter nd * minor fix * fix pylint * rename to index_rank and make it Optional * pylint, do not use -1 for default value
trevor-m
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Jun 17, 2021
…che#8105) * add gather_nd shape func * refactor gather_nd ref funcs * add dynamic gather_nd test * gather_dim -> num_indices_per_tuple * support dynamic scatter nd * minor fix * fix pylint * rename to index_rank and make it Optional * pylint, do not use -1 for default value
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.
Added shape func for
gather_ndop to support dynamic indices size.scatter_ndalso works with dynamic indices after dropping some assertions check on shapes.please review @mbrookhart @jwfromm @comaniac @kevinthesun
One difficulty with
gather_ndshape func was that the rank of the output tensor depends on the runtime shape ofindicestensor.At the line
tvm/python/tvm/relay/op/_transform.py
Line 1089 in 55a4430
if instead I have something like
different errors are raised depending on the context. For example, an error occurs in the shape func for
squeezethat followsgather_dim, attvm/python/tvm/relay/op/_transform.py
Line 772 in 55a4430
inputs[0].shape[0].value, to be a compile time fixed integer. But if the rank of thegather_dimoutput tensor is calculated like above, the rank would not be a compile time integer (because it depends on the runtime value of shape).My workaround for this problem is based on the fact that the first axis of
indicestensor, whose runtime size is required to compute the output rank, is actually a compile time constant as asserted attvm/src/relay/op/tensor/transform.cc
Lines 3347 to 3348 in 55a4430
gather_dim, which is a bit ad hoc but necessary.