forked from facebookincubator/AITemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support dim != 1 for softmax w/o using permute (facebookincubator#845)
Summary: Pull Request resolved: facebookincubator#845 This is a port of PyTorch's softmax implementation. Notable differences: * We use fast_exp & fast_max instead of std::max and std::exp * We don't use higher-precision types for accumulator values (doesn't look like the dim=-1 softmax code does this either) * We propagate the reduction dim size & inner size as constants We seem to be very marginally slower than PT for small batch sizes and very marginally faster for large ones. I have named this new softmax implementation "softmaxGeneral" since it is able to handle arbitrary reduction dimensions, even though we are only using it for the `dim > 1` case. Differential Revision: D47732875 fbshipit-source-id: 5118fed5cf6457bd9d27f553245c3b9985403f78
- Loading branch information
1 parent
48ac31a
commit 87b9340
Showing
4 changed files
with
254 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
Oops, something went wrong.