-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Relay][Layout] Add FInferCorrectLayout for L2 norm layout transform. #12497
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
Contributor
Author
masahi
approved these changes
Aug 19, 2022
3614f98 to
d995ec7
Compare
Contributor
Author
|
@tvm-bot rerun CI / Windows (pull_request) |
d995ec7 to
0d39fb3
Compare
Member
|
@tvm-bot rerun |
This comment was marked as resolved.
This comment was marked as resolved.
76f716e to
61f499b
Compare
Contributor
Author
|
@tvm-bot merge |
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 25, 2022
…apache#12497) * [Relay][Layout] FInferCorrectLayout for L2 norm layout change. * [Relay][Layout] Test for L2 norm layout transform. * [Relay][Layout] Re-edit test to add multi-dimensional axis list. * Fix cpplint errors * Use clang-format-10 rules. * replace uint with size_t.
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.
The
FInferCorrectLayoutwas set toElemwiseArbitraryLayoutwhich is for layout agnostic operators. While L2norm is a lightly-layout sensitive operator withattrs-axis. Refered to Convert Layout Pass.tvm/src/relay/op/nn/nn.cc
Line 672 in 72b0f5e
When running model, I met a situation:
%0 = layout_transform(%x, src_layout="NHWC", dst_layout="NCHW") /* ty=Tensor[(1, 64, 56, 56), float32] */;%1 = layout_transform(%weight, src_layout="HWIO", dst_layout="OIHW") /* ty=Tensor[(64, 64, 3, 3), float32] */;%2 = nn.conv2d(%0, %1, padding=[1, 1, 1, 1], channels=64, kernel_size=[3, 3]) /* ty=Tensor[(1, 64, 56, 56), float32] */;%3 = nn.l2_normalize(%2, eps=0.001f, axis=[3]) /* ty=Tensor[(1, 64, 56, 56), float32] */;The nn.l2_normalize 's axis didn't change during
InferCorrectLayout. So i write aL2NormalizeInferCorrectLayoutfor it.Also, add some tests.
BTW! I'm still new to cpp, please advise if there is anything inappropriate in code. Thanks!
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.