-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Improve log_softmax op performance by using DNNL support #18320
Conversation
Hey @bgawrych , Thanks for submitting the PR
CI supported jobs: [clang, windows-gpu, miscellaneous, unix-gpu, website, unix-cpu, centos-gpu, edge, windows-cpu, sanity, centos-cpu] Note: |
@mxnet-bot run ci [centos-cpu, unix-cpu] |
Jenkins CI successfully triggered : [unix-cpu, centos-cpu] |
@TaoLv @pengzhao-intel Can you look at this and ping interested people also? |
src/operator/nn/log_softmax.cc
Outdated
} | ||
|
||
inline static bool LogSoftmaxStorageType(const nnvm::NodeAttrs& attrs, | ||
const int dev_mask, |
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.
Please fix indent.
src/operator/nn/log_softmax.cc
Outdated
} | ||
|
||
inline static bool LogSoftmaxGradStorageType(const nnvm::NodeAttrs& attrs, | ||
const int dev_mask, |
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.
Ditto.
src/operator/nn/log_softmax.cc
Outdated
.set_attr<nnvm::FGradient>("FGradient", SoftmaxFGradient{"_backward_log_softmax"}) | ||
.set_attr<nnvm::FInferType>("FInferType", SoftmaxOpType) | ||
.set_num_inputs(1) | ||
.set_num_outputs(1) | ||
.set_attr<mxnet::FInferShape>("FInferShape", ElemwiseShape<1, 1>) | ||
.set_attr<mxnet::FInferShape>("FInferShape", SoftmaxOpShape) |
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.
Could you please elaborate?
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.
Residue after use_length support
const OpReqType &req, | ||
const NDArray &out_data) { | ||
if (req == kNullOp) return; | ||
// same as the FCompute path, softmax only supports kWriteTo and kWriteInplace for now. |
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.
Fix the comment - should it be log_softmax?
const NDArray &data, | ||
const NDArray &output) { | ||
// MKLDNN does not support temperature argument in their softmax function | ||
// now. Need update this once they start to support it. |
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.
Duplicated comments. Also change softmax to log_softmax.
@mxnet-bot run ci [miscellaneous] |
Jenkins CI successfully triggered : [miscellaneous] |
Thanks, @bgawrych thanks for the contribution :) You can cc Tao and me when you filed a PR so that we can notice reviewing your code in time and please cherry-pick the change to 1.x after the code merge. |
Please add the new op into our list |
I have tested accuracy of Tree LSTM model to make sure MKLDNN log_softmax Tree LSTM model accuracy with MKLDNN log_softmax
Tree LSTM model accuracy with native log_softmax
There are some slightly differences (bolded), but overall it looks like floating point precision issue.
Is this message to me or someone from amazon? Because I can't find any file responsible for this page |
@xinyu-intel could you help point out where to change the doc? |
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.
LGTM, thanks for your contribution.
@pengzhao-intel @TaoLv |
Thanks for the contribution. Merging now. |
…upport (apache#18320) * Improve log_softmax performance by OneDNN library * Adapt tests for MKLDNN log_softmax * Fix lint errors * Fix indent and comments
* Improve log_softmax performance by OneDNN library * Adapt tests for MKLDNN log_softmax * Fix lint errors * Fix indent and comments
* Improve log_softmax performance by OneDNN library * Adapt tests for MKLDNN log_softmax * Fix lint errors * Fix indent and comments
* Improve log_softmax performance by OneDNN library * Adapt tests for MKLDNN log_softmax * Fix lint errors * Fix indent and comments
…upport (apache#18320) (apache#18469) * Improve log_softmax performance by OneDNN library * Adapt tests for MKLDNN log_softmax * Fix lint errors * Fix indent and comments
Description
Improve log_softmax op performance by using DNNL support
Native implementation:
MKLDNN implementation:
Checklist
Essentials
Comments