a47fdf41c52f82a2677fcfec027e55283b6a99ec
[platform/upstream/dldt.git] / inference-engine / src / mkldnn_plugin / nodes / mkldnn_rnn.h
1 // Copyright (C) 2018 Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5
6 #pragma once
7
8 #include <ie_common.h>
9 #include <mkldnn_node.h>
10 #include <string>
11 #include <memory>
12 #include <vector>
13
14 namespace MKLDNNPlugin {
15
16 class MKLDNNRNN : public MKLDNNNode {
17 public:
18     MKLDNNRNN(const InferenceEngine::CNNLayerPtr& layer, const mkldnn::engine& eng);
19     ~MKLDNNRNN() override = default;
20
21     void getSupportedDescriptors() override;
22     void createPrimitive() override;
23     bool created() const override;
24
25     void createDescriptor(const std::vector<InferenceEngine::TensorDesc>& inputDesc,
26                           const std::vector<InferenceEngine::TensorDesc>& outputDesc) override;
27
28     void execute(mkldnn::stream strm) override;
29
30 private:
31     static Register<MKLDNNRNN> reg;
32
33     InferenceEngine::CellType cellr_type = InferenceEngine::CellType::LSTM;
34     /** Native order if [batch, seq, data], other case is [seq, batch, data] */
35     bool nativeOrder = true;
36     bool swap_state = false;
37
38     int batch = 0;
39     int seq = 0;
40     int data_len = 0;
41     int state_len = 0;
42     const size_t num_gates = 4;
43
44     MKLDNNMemoryDesc in_data_d;
45     MKLDNNMemoryDesc out_data_d;
46
47     MKLDNNMemoryDesc in_state_d;
48     MKLDNNMemoryDesc out_state_d;
49
50     MKLDNNMemoryDesc w_data_d;
51     MKLDNNMemoryDesc w_state_d;
52     MKLDNNMemoryDesc w_bias_d;
53
54     std::vector<mkldnn::reorder> exec_before;
55     std::vector<mkldnn::reorder> exec_after;
56 };
57
58 }  // namespace MKLDNNPlugin
59