-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Relay, TOPI] Make Softmax op fusible with elemwise ops #8909
Merged
Conversation
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
masahi
requested review from
anijain2305,
areusch,
comaniac,
Huyuwei,
jcf94,
jroesch,
junrushao,
jwfromm,
kevinthesun,
Laurawly,
MarisaKirisame,
mbrookhart,
merrymercy,
slyubomirsky,
tqchen,
vinx13,
wweic,
yzhliu,
zhiics and
ZihengJiang
as code owners
September 2, 2021 09:12
masahi
commented
Sep 2, 2021
comaniac
approved these changes
Sep 2, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM.
masahi
force-pushed
the
softmax-fuse
branch
4 times, most recently
from
September 3, 2021 08:35
ecb05db
to
c4dd35b
Compare
|
masahi
force-pushed
the
softmax-fuse
branch
2 times, most recently
from
September 3, 2021 10:53
6afd482
to
89c947b
Compare
…y storage_rewrite
…reused by storage_rewrite" This reverts commit 8aa340e.
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Sep 29, 2021
* Change softmax op pattern to OUT_ELEMWISE_FUSABLE * Softmax is fused but x86 schedule is suboptimal * fusion properly done * Updating GPU schedule for fusion * update softmax warp shuffle schedule * fix compute_at * Bug fix in lower_thread_all_reduce when reduction storage is reused by storage_rewrite * Temp disable softmax warp reduction schedule when softmax is fused * Revert "Bug fix in lower_thread_all_reduce when reduction storage is reused by storage_rewrite" This reverts commit 8aa340e. * lint fix * try make diff smaller * fix tests * fixed another broken test * Fix flaky uTVM templating test * fix equality check on output op Co-authored-by: masa <masa@pop-os.localdomain> Co-authored-by: Gavin Uberti <gavin.uberti@gmail.com>
ylc
pushed a commit
to ylc/tvm
that referenced
this pull request
Jan 13, 2022
* Change softmax op pattern to OUT_ELEMWISE_FUSABLE * Softmax is fused but x86 schedule is suboptimal * fusion properly done * Updating GPU schedule for fusion * update softmax warp shuffle schedule * fix compute_at * Bug fix in lower_thread_all_reduce when reduction storage is reused by storage_rewrite * Temp disable softmax warp reduction schedule when softmax is fused * Revert "Bug fix in lower_thread_all_reduce when reduction storage is reused by storage_rewrite" This reverts commit 8aa340e. * lint fix * try make diff smaller * fix tests * fixed another broken test * Fix flaky uTVM templating test * fix equality check on output op Co-authored-by: masa <masa@pop-os.localdomain> Co-authored-by: Gavin Uberti <gavin.uberti@gmail.com>
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.
Currently, op fusion is not enabled for
softmax
op. This has been fine for imagenet models wheresoftmax
is only used at the end. But transformer models use a lot of softmax in the middle.When the FP16 conversion is applied,
softmax
is always left fp32, so there are always a lot ofcast(softmax_output, dtype="float16")
after the conversion. Sincesoftmax
andcast
cannot be fused, we end up a lot of inefficient "cast only" kernels: https://gist.github.com/masahi/0d7d96ae88722b616a906cec2054559e#file-transformer-txt-L37-L43This PR changes
softmax
op's fuse pattern, so that it can be fused with following elemwise / injective ops, just like conv2d etc. Topi schedules have also been updated to take fused ops into account.cc @yzhliu @comaniac @AndrewZhaoLuo @mbrookhart