[TOPI] Add layer norm operator#12864
Merged
vinx13 merged 4 commits intoapache:mainfrom Sep 22, 2022
Merged
Conversation
ad090f4 to
bdeace4
Compare
bdeace4 to
b2d0735
Compare
b0ef965 to
d2219a7
Compare
MasterJH5574
approved these changes
Sep 22, 2022
Contributor
MasterJH5574
left a comment
There was a problem hiding this comment.
LGTM! Thanks @vinx13 for implementing layer-norm! I just have two tiny nits.
| from .bnn import * | ||
| from .qnn import * | ||
| from .upsampling import * | ||
| from .layer_norm import layer_norm |
Contributor
There was a problem hiding this comment.
What about importing * 👀? Since I see all other imports import *.
Suggested change
| from .layer_norm import layer_norm | |
| from .layer_norm import * |
Member
There was a problem hiding this comment.
Wildcard importing is actually not a good idea though lol
Member
Author
There was a problem hiding this comment.
agreed, so I avoid using wildcard here. perhaps we should clean up this file in the future
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 25, 2022
* [TOPI] Add one-pass layer norm using tuple reduction * Add reducer pattern for LowerCrossThreadReduction * lint * update docs
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 added a tuple-sum based implementation of layer norm. It performs one-pass reduction to compute mean and variance at the same time.
Reducer pattern is also added to allow
LowerCrossThreadReductionto handle this case.On CUDA, it will generate two kernels: one for reduction and one for elemwise operations. Because of some limitation of
compute_atcurrently we are not able to fuse them into one kernel.cc @MasterJH5574 @junrushao @AndrewZhaoLuo