-
Notifications
You must be signed in to change notification settings - Fork 2
Pooling Layer OneDNN #263
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
Merged
Pooling Layer OneDNN #263
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5257b21
pooling onednn
Semyon1104 3c344d0
files
Semyon1104 6cf1ca2
tests
Semyon1104 1023508
del
Semyon1104 9ba34b2
tests
Semyon1104 eec016d
unused
Semyon1104 dddcff9
Merge branch 'main' into Semyon1104/PoolingOneDNN
Semyon1104 3c8eed4
Merge remote-tracking branch 'origin/main' into Semyon1104/PoolingOneDNN
Semyon1104 ce76ff5
fix setup test
Semyon1104 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #pragma once | ||
|
|
||
| #include <dnnl.hpp> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "layers/Layer.hpp" | ||
|
|
||
| namespace it_lab_ai { | ||
|
|
||
| class PoolingLayerOneDnn : public Layer { | ||
| public: | ||
| explicit PoolingLayerOneDnn(const Shape& pooling_shape, | ||
| const Shape& strides = {2, 2}, | ||
| const Shape& pads = {0, 0, 0, 0}, | ||
| const Shape& dilations = {1, 1}, | ||
| bool ceil_mode = false, | ||
| std::string pooling_type = "average") | ||
| : Layer(kPooling), | ||
| poolingShape_(pooling_shape), | ||
| strides_(strides), | ||
| pads_(pads), | ||
| dilations_(dilations), | ||
| ceil_mode_(ceil_mode), | ||
| poolingType_(std::move(pooling_type)), | ||
| engine_(std::make_unique<dnnl::engine>(dnnl::engine::kind::cpu, 0)), | ||
| stream_(std::make_unique<dnnl::stream>(*engine_)) {} | ||
|
|
||
| void run(const std::vector<Tensor>& input, | ||
| std::vector<Tensor>& output) override; | ||
|
|
||
| void setStrides(size_t h, size_t w) { | ||
| strides_ = {h, w}; | ||
| initialized_ = false; | ||
| } | ||
|
|
||
| void setPads(size_t top, size_t bottom, size_t left, size_t right) { | ||
| pads_ = {top, bottom, left, right}; | ||
| initialized_ = false; | ||
| } | ||
|
|
||
| void setDilations(size_t h, size_t w) { | ||
| dilations_ = {h, w}; | ||
| initialized_ = false; | ||
| } | ||
|
|
||
| void setCeilMode(bool ceil_mode) { | ||
| ceil_mode_ = ceil_mode; | ||
| initialized_ = false; | ||
| } | ||
|
|
||
| #ifdef ENABLE_STATISTIC_WEIGHTS | ||
| Tensor get_weights() override { | ||
| std::vector<int> v = {0}; | ||
| Tensor a = make_tensor(v); | ||
| return a; | ||
| } | ||
| #endif | ||
|
|
||
| private: | ||
| void initialize_onednn(const Shape& shape, Type data_type); | ||
| [[nodiscard]] dnnl::algorithm get_PoolType() const; | ||
| static void validate_input(const std::vector<Tensor>& input); | ||
| [[nodiscard]] static dnnl::memory::data_type get_dnnl_data_type(Type type); | ||
| [[nodiscard]] Shape calculate_output_shape(const Shape& input_shape) const; | ||
|
|
||
| Shape poolingShape_; | ||
| Shape strides_; | ||
| Shape pads_; | ||
| Shape dilations_; | ||
| bool ceil_mode_; | ||
| std::string poolingType_; | ||
|
|
||
| bool initialized_ = false; | ||
| Shape last_shape_; | ||
| Type last_type_; | ||
|
|
||
| std::unique_ptr<dnnl::engine> engine_; | ||
| std::unique_ptr<dnnl::stream> stream_; | ||
| std::unique_ptr<dnnl::pooling_forward> pool_prim_; | ||
| dnnl::memory::desc src_memory_desc_; | ||
| dnnl::memory::desc dst_memory_desc_; | ||
| Shape output_shape_; | ||
| }; | ||
|
|
||
| } // namespace it_lab_ai |
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.
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.
please remove unused changes
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.
there was an error in the layer and it needed to be corrected
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.
What I meant was that you added an extra line that does nothing.