This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Fix softmax behavior to not cast up the accumulator if no output dtype is specified #14759
Closed
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
…values based on AType
…large tensor takes a long time and shows no change between this change and previous change
@@ -310,9 +311,9 @@ struct SoftmaxParam : public dmlc::Parameter<SoftmaxParam> { | |||
} | |||
}; | |||
|
|||
static inline bool softmax_has_dtype_override(const nnvm::NodeAttrs& attrs) { | |||
static inline int sofmtax_dtype_param(const nnvm::NodeAttrs &attrs) { |
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.
typo? softmax
shape.get<3>(), axis, static_cast<DType>(temperature)); | ||
} | ||
}); | ||
int out_idx = sofmtax_dtype_param(attrs) != -1 ? 2 : 1; |
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.
I'd suggest we have an env var to trigger stable reduction instead of relying on dtype argument, including other ops like norm
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.
@nswamy Please address comments |
@mxnet-label-bot add[pr-awaiting-response] |
marcoabreu
added
the
pr-awaiting-response
PR is reviewed and waiting for contributor to respond
label
May 20, 2019
@mxnet-label-bot remove[pr-awaiting-review] |
Fixed in #15037 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
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.
Description
Softmax operator was recently changed to cast the accumulator type to higher precision data type(in #14098) than the input type regardless of the whether the
dtype
of the output is passed to the operator or not. This not only breaks backward compatibility but also the increases loss when training a rnn language model with float32 input data type. Details are #14722.This PR changes the accumulator type only if the
dtype
has been passed and uses thedtype
passed for accumulation.@eric-haibin-lin
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments