-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Softmax MKLDNN FLUID operator #9214
Softmax MKLDNN FLUID operator #9214
Conversation
083b8bd
to
29b68ef
Compare
LGTM. @tensor-tang Could you help review the |
using mkldnn::stream; | ||
|
||
template <typename T> | ||
class SoftmaxMkldnnKernel : public paddle::framework::OpKernel<T> { |
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.
SoftmaxMkldnnKernel
==> SoftmaxMKLDNNKernel
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.
Ok
@@ -81,6 +81,7 @@ def fc(input, | |||
num_flatten_dims=1, | |||
param_attr=None, | |||
bias_attr=None, | |||
use_mkldnn=False, |
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.
Why softmax PR would change fc?
attrs={ | ||
"x_num_col_dims": num_flatten_dims, | ||
"y_num_col_dims": 1, | ||
'use_mkldnn': use_mkldnn |
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.
Save as above, this should be added in FC PR, right?
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.
@tensor-tang You are correct, but without those changes to FC Softmax MKLDNN would remain unused code. Till FC of MKLDNN is not ready (it is under development) then there is no other option for users to take advantage of softmax mkldnn operator as it is usually used as activation of FC layer. Do you suggest to remove use_mkldnn attribute/param from FC ?
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.
@tensor-tang, @luotao1 Should I remove use_mkldnn attrbute from FC , in this PR?
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 think there should be some other ways to use mkldnn softmax without change fc. But since we will implement MKLDNN FC soon, I think it's fine, you do not need revert back now.
9df2a09
to
228e0dc
Compare
removed diagnostic - Added Unit tests for Softmax MKLDNN Forward Added fix for div by 0 to happen in cross_entropy backward Conflicts: paddle/fluid/operators/CMakeLists.txt - Cosmetic fixes to SoftMax MKLDNN fluid operator Added misssing softmax fluid operator file Disabled MKLDNN softmax operator by default Fix to softmax op unittest merge clang_formater fixes clang_formatter fixes - Name changing of softmax mkldnn operator to maintin consistency across codebase - updated comment fix to comment
228e0dc
to
3b95b55
Compare
attrs={ | ||
"x_num_col_dims": num_flatten_dims, | ||
"y_num_col_dims": 1, | ||
'use_mkldnn': use_mkldnn |
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 think there should be some other ways to use mkldnn softmax without change fc. But since we will implement MKLDNN FC soon, I think it's fine, you do not need revert back now.
This PR provides MKLDNN based Softmax op implementation.
Performance and testing:
On tested models softmax MKLDNN op is roughly ~10x faster than Plain CPU version.
RNN Search (https://github.com/dzhwinter/benchmark/blob/master/fluid/machine_translation.py)
executes training in ~90% of Plain CPU time. RNN search does converge with Softmax MKLDNN op used.
Notes