-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Mkldnn layout #11040
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
Merged
luotao1
merged 9 commits into
PaddlePaddle:develop
from
mozga-intel:mozga-intel/mkldnn-layout
Jun 7, 2018
Merged
Mkldnn layout #11040
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b6c8610
Add MKLDNN layout support in Paddle
liujianhang-design a1a86a5
Add MKLDNN layout support in activation OP
liujianhang-design a9a1fe6
Don't populate layout from input to output when kMKLDNN in
liujianhang-design 04339d5
Refine pool mkldnn op kernel
liujianhang-design b0b8db6
MKLDNN layout
mozga-intel c387fa9
Remove the inferitance from tensor file
mozga-intel 3abe446
MKLDNN layout: refactoring
mozga-intel dfc6566
Remove additional #define to register new operator
mozga-intel 568aff0
Prepare mkldnn tests to work with layout
mozga-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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -34,6 +34,28 @@ namespace framework { | |
| class LoDTensor; | ||
|
|
||
| class Tensor { | ||
| #ifdef PADDLE_WITH_MKLDNN | ||
|
|
||
| public: | ||
| inline mkldnn::memory::format format() const { return format_; } | ||
|
|
||
| inline void set_format(const mkldnn::memory::format format) { | ||
| format_ = format; | ||
| } | ||
|
|
||
| protected: | ||
| /** | ||
| * @brief the detail format of memory block which have layout as kMKLDNN | ||
| * | ||
| * @note MKLDNN lib support various memory format like nchw, nhwc, nChw8C, | ||
| * nChw16c, etc. For a MKLDNN memory block, layout will be set as | ||
| * DataLayout::kMKLDNN meanwhile detail memory format will be kept in | ||
| * this field. | ||
| */ | ||
|
|
||
| mkldnn::memory::format format_ = mkldnn::memory::format::format_undef; | ||
| #endif | ||
|
|
||
| public: | ||
| template <typename T, size_t D, int MajorType, typename IndexType> | ||
| friend struct EigenTensor; | ||
|
|
@@ -195,8 +217,10 @@ class Tensor { | |
| * N,C,H,W for respectively the batch size, the number of | ||
| * feature maps, the height. | ||
| */ | ||
|
|
||
| DataLayout layout_ = DataLayout::kNHWC; | ||
| // Fix me: here just change the default layout to kNCHW | ||
| // it doesn't fix the real issue, i.e. feeder should set up tensor layout | ||
| // according to actual input data | ||
| DataLayout layout_ = DataLayout::kNCHW; | ||
|
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. Is this acceptable? @luotao1 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. @mozga-intel @tensor-tang |
||
|
|
||
| /** | ||
| * @brief A PlaceHolder may be shared by more than one tensor. | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Any better solution?
It seems have some duplicated logic with