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
update support MKLDNN BN conditions #15870
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac58ff4
update support MKLDNN BN conditions
ElaineBao 008e07e
add bn test case for channel size = 8
ElaineBao a833967
fix bn gradient with use_global_stats
ElaineBao 3086347
rm useless comments
ElaineBao 201d869
fix mkldnn bn output when use_global_stats
ElaineBao f0a5a7f
fix lint
ElaineBao 2c27914
retrigger ci
ElaineBao 1307f62
retrigger ci again
ElaineBao d894d3e
retrigger ci again 2
ElaineBao 8d69ee4
retrigger ci again 3
ElaineBao 8487041
retrigger ci again 4
ElaineBao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,7 +384,6 @@ static inline bool SupportMKLDNNBN(const NDArray &input, const BatchNormParam &p | |
mxnet::TShape shape = input.shape(); | ||
return SupportMKLDNN(input) && shape.ndim() == 4 | ||
&& param.axis == mxnet::op::batchnorm::DEFAULT_AXIS | ||
&& shape[param.axis] % 8 == 0 | ||
&& !mxnet::op::batchnorm::disable_mkl; | ||
} | ||
|
||
|
@@ -395,8 +394,8 @@ void BatchNormComputeExCPU(const nnvm::NodeAttrs &attrs, | |
const std::vector<NDArray> &outputs) { | ||
CHECK_EQ(inputs.size(), 5U); | ||
const BatchNormParam ¶m = nnvm::get<BatchNormParam>(attrs.parsed); | ||
// MKLDNN batchnorm only works well on the special MKLDNN layout. | ||
if (SupportMKLDNNBN(inputs[0], param) && inputs[0].IsMKLDNNData()) { | ||
|
||
if (SupportMKLDNNBN(inputs[0], param)) { | ||
std::vector<NDArray> in_data(inputs.begin(), inputs.begin() + batchnorm::kInMovingMean); | ||
std::vector<NDArray> aux_states(inputs.begin() + batchnorm::kInMovingMean, inputs.end()); | ||
|
||
|
@@ -419,9 +418,8 @@ void BatchNormGradComputeExCPU(const nnvm::NodeAttrs &attrs, | |
const BatchNormParam ¶m = nnvm::get<BatchNormParam>(attrs.parsed); | ||
|
||
mxnet::TShape shape = inputs[0].shape(); | ||
// MKLDNN batchnorm only works well on the special MKLDNN layout. | ||
if (SupportMKLDNNBN(inputs[0], param) | ||
&& (inputs[3].IsMKLDNNData() || inputs[0].IsMKLDNNData())) { | ||
|
||
if (SupportMKLDNNBN(inputs[0], param)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we don't need to check these two conditions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same reason as line 399, as described in Performance part, when a model has fp32 bn along with other int8 ops, it triggers the IsMKLDNNData() check and cannot run int MKLDNN, which cause a slower speed. |
||
std::vector<NDArray> out_grad(1); | ||
std::vector<NDArray> out_data(3); | ||
std::vector<NDArray> in_data(3); | ||
|
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
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.
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 remove the comments in L397