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
Integrate MKLDNN Conv1d and support 3d layout #13530
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
06901b8
add 3d layout support for MKLDNN Conv and Activation
xinyu-intel 49296fc
fix lint
xinyu-intel cc6ebf3
resolve conflict
xinyu-intel 2da1e2a
code refactor
xinyu-intel 8f70c99
Merge remote-tracking branch 'upstream/master' into conv1d
xinyu-intel 869ad9d
add testcase for group1 conv and skip quantization for conv1d
xinyu-intel 5e1a5f3
Merge remote-tracking branch 'upstream/master' into conv1d
xinyu-intel a3f843b
fix lint
xinyu-intel 25a0e4f
avoid conv1d quantization
xinyu-intel e20807f
Merge remote-tracking branch 'upstream/master' into conv1d
xinyu-intel b627592
Merge remote-tracking branch 'upstream/master' into conv1d
xinyu-intel 4d51c8f
code refactor and add activation ut
xinyu-intel 95bef09
del todo
xinyu-intel a13d87a
Merge remote-tracking branch 'upstream/master' into conv1d
xinyu-intel 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,10 +175,11 @@ struct ConvolutionParam; | |
struct DeconvolutionParam; | ||
struct SoftmaxParam; | ||
bool SupportMKLDNNAct(const ActivationParam& param); | ||
bool SupportMKLDNNAct(const ActivationParam& param, const NDArray &input); | ||
bool SupportMKLDNNConv(const ConvolutionParam& params, const NDArray &input); | ||
bool SupportMKLDNNDeconv(const DeconvolutionParam& params, const NDArray &input); | ||
bool SupportMKLDNNSoftmax(const SoftmaxParam& param); | ||
} | ||
} // namespace op | ||
|
||
static int GetTypeSize(int dtype) { | ||
int size = -1; | ||
|
@@ -253,14 +254,23 @@ inline static mkldnn::memory::desc GetWeightDesc(const NDArray &arr, | |
if (num_groups == 1) { | ||
return GetMemDesc(arr); | ||
} else { | ||
CHECK_EQ(arr.shape().ndim(), 4U); | ||
mkldnn::memory::dims tz = mkldnn::memory::dims{ num_groups, | ||
static_cast<int>(arr.shape()[0] / num_groups), | ||
static_cast<int>(arr.shape()[1]), | ||
static_cast<int>(arr.shape()[2]), | ||
static_cast<int>(arr.shape()[3])}; | ||
return mkldnn::memory::desc{tz, get_mkldnn_type(arr.dtype()), | ||
mkldnn::memory::format::any}; | ||
CHECK((arr.shape().ndim() == 3) || (arr.shape().ndim() == 4)) | ||
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. Use a variable to save the value of |
||
<< "MKL-DNN weight currectly supports 3d and 4d layout"; | ||
const int N = 0, H = 2, W = 3, C = 1; | ||
if (arr.shape().ndim() == 3) { | ||
mkldnn::memory::dims tz = mkldnn::memory::dims{ | ||
num_groups, static_cast<int>(arr.shape()[N] / num_groups), | ||
static_cast<int>(arr.shape()[C]), static_cast<int>(arr.shape()[H])}; | ||
return mkldnn::memory::desc{tz, get_mkldnn_type(arr.dtype()), | ||
mkldnn::memory::format::any}; | ||
} else { | ||
mkldnn::memory::dims tz = mkldnn::memory::dims{ | ||
num_groups, static_cast<int>(arr.shape()[N] / num_groups), | ||
static_cast<int>(arr.shape()[C]), static_cast<int>(arr.shape()[H]), | ||
static_cast<int>(arr.shape()[W])}; | ||
return mkldnn::memory::desc{tz, get_mkldnn_type(arr.dtype()), | ||
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. This line is the common part of dim3 and dim4, right? |
||
mkldnn::memory::format::any}; | ||
} | ||
} | ||
} | ||
|
||
|
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.
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.
Is there a performance difference between 3D and 4D implementation?