Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / include / lstm_gemm_inst.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #pragma once
19 #include "api/CPP/lstm.hpp"
20 #include "primitive_inst.h"
21
22 namespace cldnn
23 {
24 template <>
25 struct typed_program_node<lstm_gemm> : public typed_program_node_base<lstm_gemm>
26 {
27     using parent = typed_program_node_base<lstm_gemm>;
28
29 public:
30     using parent::parent;
31
32     decltype(auto) input() const { return get_dependency(0); }
33     decltype(auto) weights() const { return get_dependency(1); }
34     decltype(auto) recurrent() const { return get_dependency(2); }
35     decltype(auto) bias() const { return get_dependency(3); }
36     decltype(auto) hidden() const {
37         return bias_term() ? get_dependency(4) : get_dependency(3);
38     }
39     bool bias_term() const { return !get_primitive()->bias.empty(); }
40     bool hidden_term() const { return !get_primitive()->hidden.empty(); }
41 };
42
43 using lstm_gemm_node = typed_program_node<lstm_gemm>;
44
45 template <>
46 class typed_primitive_inst<lstm_gemm> : public typed_primitive_inst_base<lstm_gemm>
47 {
48     using parent = typed_primitive_inst_base<lstm_gemm>;
49
50 public:
51     static layout calc_output_layout(lstm_gemm_node const& node);
52     static std::string to_string(lstm_gemm_node const& node);
53
54 public:
55     typed_primitive_inst(network_impl& network, lstm_gemm_node const& node);
56
57     decltype(auto) weights_memory() const { return dep_memory(1); }
58     decltype(auto) recurrent_memory() const { return dep_memory(2); }
59     decltype(auto) bias_memory() const { return dep_memory(3); }
60     decltype(auto) hidden_memory() const {
61         return bias_term() ? dep_memory(4) : dep_memory(3);
62     }
63     bool bias_term() const { return !argument.bias.empty(); }
64     bool hidden_term() const { return !argument.hidden.empty(); }
65 };
66
67 using lstm_gemm_inst = typed_primitive_inst<lstm_gemm>;
68
69 }