Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / mkldnn_plugin / nodes / mkldnn_permute_node.h
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <ie_common.h>
8 #include <mkldnn_node.h>
9 #include <string>
10 #include <vector>
11 #include <utility>
12 #include <map>
13
14 namespace MKLDNNPlugin {
15
16 class MKLDNNPermuteNode : public MKLDNNNode {
17 public:
18     MKLDNNPermuteNode(const InferenceEngine::CNNLayerPtr& layer, const mkldnn::engine& eng);
19     ~MKLDNNPermuteNode() override = default;
20
21     void getSupportedDescriptors() override;
22     void initSupportedPrimitiveDescriptors() override;
23     void createPrimitive() override;
24     void execute(mkldnn::stream strm) override;
25     bool created() const override;
26     bool canBeInPlace() const override {
27         return false;
28     }
29
30 private:
31     static Register<MKLDNNPermuteNode> reg;
32     InferenceEngine::SizeVector order;
33
34     typedef std::function<void(int MB, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr)> permuteImpl;
35     typedef std::function<bool(MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr)> isApplicable;
36     struct PermuteImpl {
37         PermuteImpl(permuteImpl f0, isApplicable f1): execute(std::move(f0)), isValidParams(std::move(f1)) {}
38
39         permuteImpl execute;
40         isApplicable isValidParams;
41     };
42
43     static std::multimap<InferenceEngine::SizeVector, PermuteImpl> OptimizedCases;
44 };
45
46 }  // namespace MKLDNNPlugin
47