-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add aten mkldnn view operator #19209
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
db58627
V6: Initial commit
bddppq 8f21b79
V7: Merge with parent diff changes
bddppq 9179134
V8: Merge with parent diff changes
bddppq 09f9994
V9: Merge with parent diff changes
bddppq 770599c
V10: Merge with parent diff changes
bddppq 6bfc41d
V11: Merge with parent diff changes
bddppq 2929a24
V12: Merge with parent diff changes
bddppq f43c0a4
V14: Merge with parent diff changes
bddppq e93e527
V15: Merge with parent diff changes
bddppq c882909
V16: Merge with parent diff changes
bddppq 01fbab5
V17: Merge with parent diff changes
bddppq 6c8161e
V19: Merge with parent diff changes
bddppq 1c6f83a
V20: Merge with parent diff changes
bddppq 0f8da65
V21: Merge with parent diff changes
bddppq 23c8fbe
V22: Merge with parent diff changes
bddppq bd255b4
V24: Merge with parent diff changes
bddppq 39f5b1d
V25: Merge with parent diff changes
bddppq 78104ef
V26: Merge with parent diff changes
bddppq 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #include <ATen/ATen.h> | ||
| #include <ATen/Config.h> | ||
| #include <ATen/InferSize.h> | ||
| #include <ATen/NativeFunctions.h> | ||
|
|
||
| #if !AT_MKLDNN_ENABLED() | ||
|
|
||
| namespace at { | ||
| namespace native { | ||
|
|
||
| Tensor mkldnn_view(const Tensor& self, IntArrayRef size) { | ||
| AT_ERROR("mkldnn_reshape: ATen not compiled with MKLDNN support"); | ||
| } | ||
|
|
||
| Tensor mkldnn_reshape(const Tensor& self, IntArrayRef size) { | ||
| AT_ERROR("mkldnn_reshape: ATen not compiled with MKLDNN support"); | ||
| } | ||
|
|
||
| } // namespace native | ||
| } // namespace at | ||
|
|
||
| #else // AT_MKLDNN_EBABLED | ||
|
|
||
| #include <ATen/native/mkldnn/MKLDNNCommon.h> | ||
|
|
||
| namespace at { | ||
| namespace native { | ||
|
|
||
| Tensor mkldnn_view(const Tensor& self, IntArrayRef size) { | ||
| AT_ERROR( | ||
| "Currently Mkldnn tensor does not support view. Change to use reshape instead"); | ||
| } | ||
|
|
||
| Tensor mkldnn_reshape(const Tensor& self, IntArrayRef size) { | ||
| auto inferred_size = at::infer_size(size, self.numel()); | ||
| const ideep::tensor& x = itensor_from_mkldnn(self); | ||
| ideep::tensor y; | ||
| ideep::direct_copy::compute<AllocForMKLDNN>(x, y); | ||
| y.reshape({inferred_size.cbegin(), inferred_size.cend()}); | ||
| return new_with_itensor_mkldnn(std::move(y), self.options()); | ||
| } | ||
|
|
||
| } // namespace native | ||
| } // namespace at | ||
|
|
||
| #endif // AT_MKLDNN_EBABLED | ||
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #pragma once | ||
|
|
||
| #include <ATen/ATen.h> | ||
|
|
||
| namespace at { | ||
| namespace native { | ||
|
|
||
| Tensor mkldnn_view(const Tensor& self, IntArrayRef size); | ||
|
|
||
| } // namespace native | ||
| } // namespace at |
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 |
|---|---|---|
|
|
@@ -1522,6 +1522,12 @@ | |
| variants: function, method | ||
| device_guard: False | ||
|
|
||
| - func: mkldnn_reshape(Tensor self, int[] shape) -> Tensor | ||
| device_guard: False | ||
| requires_tensor: True | ||
|
Collaborator
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. you don't need
Contributor
Author
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. yep I know this, just for documentation purpose :-) |
||
| dispatch: | ||
| MkldnnCPU: mkldnn_reshape | ||
|
|
||
| - func: reshape_as(Tensor self, Tensor other) -> Tensor | ||
| variants: method | ||
| device_guard: False | ||
|
|
||
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
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.
nit: I guess you can move it out of the #ifdef as the error is regardless of whether mkldnn is compiled in
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.
The error messages are different though so I would prefer to keep two these two places.