2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 #include "api/CPP/lstm.hpp"
20 #include "primitive_inst.h"
25 struct typed_program_node<lstm_gemm> : public typed_program_node_base<lstm_gemm>
27 using parent = typed_program_node_base<lstm_gemm>;
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);
39 bool bias_term() const { return !get_primitive()->bias.empty(); }
40 bool hidden_term() const { return !get_primitive()->hidden.empty(); }
43 using lstm_gemm_node = typed_program_node<lstm_gemm>;
46 class typed_primitive_inst<lstm_gemm> : public typed_primitive_inst_base<lstm_gemm>
48 using parent = typed_primitive_inst_base<lstm_gemm>;
51 static layout calc_output_layout(lstm_gemm_node const& node);
52 static std::string to_string(lstm_gemm_node const& node);
55 typed_primitive_inst(network_impl& network, lstm_gemm_node const& node);
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);
63 bool bias_term() const { return !argument.bias.empty(); }
64 bool hidden_term() const { return !argument.hidden.empty(); }
67 using lstm_gemm_inst = typed_primitive_inst<lstm_gemm>;