2 // Copyright (c) 2018 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.
19 #include "common_kernel_base.h"
20 #include "kernel_selector_params.h"
22 namespace kernel_selector
24 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 struct lstm_gemm_params : public base_params
29 lstm_gemm_params() : base_params(KernelType::LSTM_GEMM) {}
36 bool hasHidden = false;
37 uint32_t direction = 0;
38 uint32_t input_direction = 0; // for bidirectional node fusion in stacked LSTMs
39 uint32_t hidden_direction = 0;
41 void SetBias(const DataTensor& v) {
46 void SetHidden(const DataTensor& v) {
51 virtual ParamsKey GetParamsKey() const override
53 ParamsKey k = base_params::GetParamsKey();
57 k.EnableLSTMGEMMBias();
62 k.EnableLSTMGEMMHidden();
69 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
70 // lstm_gemm_optional_params
71 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72 struct lstm_gemm_optional_params : optional_params
74 lstm_gemm_optional_params() : optional_params(KernelType::LSTM_GEMM) {}
77 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
79 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80 class LSTMGemmKernelBase : public common_kernel_base
83 using common_kernel_base::common_kernel_base;
84 virtual ~LSTMGemmKernelBase() {}
86 struct DispatchData : public CommonDispatchData
90 virtual JitConstants GetJitConstants(const lstm_gemm_params& params) const;
91 KernelsData GetCommonKernelsData(const Params& params, const optional_params& optParams) const;
93 bool Validate(const Params& p, const optional_params&) const override
95 if (p.GetType() != KernelType::LSTM_GEMM)