Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CLLSTMLAYER_H |
| 25 | #define ARM_COMPUTE_CLLSTMLAYER_H |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 29 | #include "arm_compute/core/CL/kernels/CLCopyKernel.h" |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/CL/kernels/CLMemsetKernel.h" |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 31 | #include "arm_compute/core/Types.h" |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 32 | #include "arm_compute/runtime/CL/CLTensor.h" |
Georgios Pinitas | ab23dd0 | 2020-07-06 14:57:36 +0100 | [diff] [blame] | 33 | #include "arm_compute/runtime/CL/functions/CLActivationLayer.h" |
Georgios Pinitas | 09f2497 | 2019-05-17 18:14:40 +0100 | [diff] [blame] | 34 | #include "arm_compute/runtime/CL/functions/CLConcatenateLayer.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 35 | #include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 36 | #include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" |
| 37 | #include "arm_compute/runtime/CL/functions/CLGEMM.h" |
Michele Di Giorgio | 39438b4 | 2019-06-04 12:41:45 +0100 | [diff] [blame] | 38 | #include "arm_compute/runtime/CL/functions/CLMeanStdDevNormalizationLayer.h" |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 39 | #include "arm_compute/runtime/CL/functions/CLPixelWiseMultiplication.h" |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 40 | #include "arm_compute/runtime/IMemoryManager.h" |
Georgios Pinitas | 26014cf | 2019-09-09 19:00:57 +0100 | [diff] [blame] | 41 | #include "arm_compute/runtime/MemoryGroup.h" |
Michalis Spyrou | 25f45a4 | 2018-08-08 12:53:05 +0100 | [diff] [blame] | 42 | #include "arm_compute/runtime/common/LSTMParams.h" |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 43 | |
| 44 | #include <memory> |
| 45 | |
| 46 | namespace arm_compute |
| 47 | { |
| 48 | class ICLTensor; |
| 49 | |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 50 | /** This function performs a single time step in a Long Short-Term Memory (LSTM) layer. |
| 51 | * |
| 52 | */ |
| 53 | class CLLSTMLayer : public IFunction |
| 54 | { |
| 55 | public: |
| 56 | /** Default constructor */ |
| 57 | CLLSTMLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr); |
| 58 | /** Initialize function's tensors. |
| 59 | * |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 60 | * @param[in] input Source tensor. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: F16/F32. |
| 61 | * @param[in] input_to_forget_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 62 | * @param[in] input_to_cell_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 63 | * @param[in] input_to_output_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 64 | * @param[in] recurrent_to_forget_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 65 | * @param[in] recurrent_to_cell_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 66 | * @param[in] recurrent_to_output_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 67 | * @param[in] forget_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 68 | * @param[in] cell_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 69 | * @param[in] output_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 70 | * @param[in] output_state_in 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 71 | * @param[in] cell_state_in 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 72 | * @param[out] scratch_buffer 2D tensor with dimensions [num_units * 4, batch_size] with CIFG or [num_units * 3, batch_size] without CIGF. Data type supported: Same as @p input. |
| 73 | * @param[out] output_state_out 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 74 | * @param[out] cell_state_out 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 75 | * @param[out] output Destination tensor. Output is a 2D tensor with dimensions [output_size, batch_size]. |
| 76 | * Data types supported: Same as @p input. |
Michele Di Giorgio | 25d9775 | 2020-03-04 18:08:47 +0000 | [diff] [blame] | 77 | * @param[in] lstm_params Weights tensors used in peephole optimization: |
| 78 | * input_to_input_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 79 | * recurrent_to_input_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 80 | * cell_to_input_weights 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: Same as @p input. |
| 81 | * cell_to_forget_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 82 | * cell_to_output_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 83 | * input_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input |
| 84 | * projection_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 85 | * projection_bias 1D weights tensor with dimensions [output_size]. Data type supported: Same as @p input. |
| 86 | * input_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 87 | * forget_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 88 | * cell_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 89 | * output_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 90 | * @param[in] activation_info Contains activation information described in @ref ActivationLayerInfo. |
Michele Di Giorgio | 25d9775 | 2020-03-04 18:08:47 +0000 | [diff] [blame] | 91 | * @param[in] cell_threshold (Optional) The clipping threshold for the cell state, such that values are bound within [-cell_clip, cell_clip]. |
| 92 | * If set to 0.0f then clipping is disabled. |
| 93 | * @param[in] projection_threshold (Optional) The clipping threshold for the output from the projection layer, such that values are bound within [-proj_clip, proj_clip]. |
Michele Di Giorgio | 39438b4 | 2019-06-04 12:41:45 +0100 | [diff] [blame] | 94 | * If set to 0.0f then clipping is disabled. |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 95 | */ |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 96 | void configure(const ICLTensor *input, |
| 97 | const ICLTensor *input_to_forget_weights, const ICLTensor *input_to_cell_weights, const ICLTensor *input_to_output_weights, |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 98 | const ICLTensor *recurrent_to_forget_weights, const ICLTensor *recurrent_to_cell_weights, const ICLTensor *recurrent_to_output_weights, |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 99 | const ICLTensor *forget_gate_bias, const ICLTensor *cell_bias, const ICLTensor *output_gate_bias, |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 100 | const ICLTensor *output_state_in, ICLTensor *cell_state_in, |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 101 | ICLTensor *scratch_buffer, ICLTensor *output_state_out, ICLTensor *cell_state_out, ICLTensor *output, |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 102 | const LSTMParams<ICLTensor> &lstm_params, const ActivationLayerInfo &activation_info, float cell_threshold = 0.f, float projection_threshold = 0.f); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 103 | /** Initialize function's tensors. |
| 104 | * |
| 105 | * @param[in] compile_context The compile context to be used. |
| 106 | * @param[in] input Source tensor. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: F16/F32. |
| 107 | * @param[in] input_to_forget_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 108 | * @param[in] input_to_cell_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 109 | * @param[in] input_to_output_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 110 | * @param[in] recurrent_to_forget_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 111 | * @param[in] recurrent_to_cell_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 112 | * @param[in] recurrent_to_output_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 113 | * @param[in] forget_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 114 | * @param[in] cell_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 115 | * @param[in] output_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 116 | * @param[in] output_state_in 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 117 | * @param[in] cell_state_in 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 118 | * @param[out] scratch_buffer 2D tensor with dimensions [num_units * 4, batch_size] with CIFG or [num_units * 3, batch_size] without CIGF. Data type supported: Same as @p input. |
| 119 | * @param[out] output_state_out 2D weights tensor with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 120 | * @param[out] cell_state_out 2D tensor with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 121 | * @param[out] output Destination tensor. Output is a 2D tensor with dimensions [output_size, batch_size]. |
| 122 | * Data types supported: Same as @p input. |
| 123 | * @param[in] lstm_params Weights tensors used in peephole optimization: |
| 124 | * input_to_input_weights 2D weights tensor with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 125 | * recurrent_to_input_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 126 | * cell_to_input_weights 1D weights tensor with dimensions [num_units]. Can be nullptr. Data type supported: Same as @p input. |
| 127 | * cell_to_forget_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 128 | * cell_to_output_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 129 | * input_gate_bias 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input |
| 130 | * projection_weights 2D weights tensor with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 131 | * projection_bias 1D weights tensor with dimensions [output_size]. Data type supported: Same as @p input. |
| 132 | * input_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 133 | * forget_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 134 | * cell_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 135 | * output_layer_norm_weights 1D weights tensor with dimensions [num_units]. Data type supported: Same as @p input. |
| 136 | * @param[in] activation_info Contains activation information described in @ref ActivationLayerInfo. |
| 137 | * @param[in] cell_threshold (Optional) The clipping threshold for the cell state, such that values are bound within [-cell_clip, cell_clip]. |
| 138 | * If set to 0.0f then clipping is disabled. |
| 139 | * @param[in] projection_threshold (Optional) The clipping threshold for the output from the projection layer, such that values are bound within [-proj_clip, proj_clip]. |
| 140 | * If set to 0.0f then clipping is disabled. |
| 141 | */ |
| 142 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, |
| 143 | const ICLTensor *input_to_forget_weights, const ICLTensor *input_to_cell_weights, const ICLTensor *input_to_output_weights, |
| 144 | const ICLTensor *recurrent_to_forget_weights, const ICLTensor *recurrent_to_cell_weights, const ICLTensor *recurrent_to_output_weights, |
| 145 | const ICLTensor *forget_gate_bias, const ICLTensor *cell_bias, const ICLTensor *output_gate_bias, |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 146 | const ICLTensor *output_state_in, ICLTensor *cell_state_in, |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 147 | ICLTensor *scratch_buffer, ICLTensor *output_state_out, ICLTensor *cell_state_out, ICLTensor *output, |
| 148 | const LSTMParams<ICLTensor> &lstm_params, const ActivationLayerInfo &activation_info, float cell_threshold = 0.f, float projection_threshold = 0.f); |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 149 | |
| 150 | /** Static function to check if given info will lead to a valid configuration of @ref CLLSTMLayer |
| 151 | * |
Michele Di Giorgio | 39438b4 | 2019-06-04 12:41:45 +0100 | [diff] [blame] | 152 | * @param[in] input Source tensor info. Input is a 2D tensor with dimensions [input_size, batch_size]. Data types supported: F16/F32. |
| 153 | * @param[in] input_to_forget_weights 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 154 | * @param[in] input_to_cell_weights 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 155 | * @param[in] input_to_output_weights 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 156 | * @param[in] recurrent_to_forget_weights 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 157 | * @param[in] recurrent_to_cell_weights 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 158 | * @param[in] recurrent_to_output_weights 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 159 | * @param[in] forget_gate_bias 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 160 | * @param[in] cell_bias 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 161 | * @param[in] output_gate_bias 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 162 | * @param[in] output_state_in 2D weights tensor info with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 163 | * @param[in] cell_state_in 2D tensor info with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 164 | * @param[in] scratch_buffer 2D tensor info with dimensions [num_units * 4, batch_size] with CIFG or [num_units * 3, batch_size] without CIGF. |
| 165 | * Data type supported: Same as @p input. |
| 166 | * @param[in] output_state_out 2D weights tensor info with dimensions [output_size, batch_size]. Data type supported: Same as @p input. |
| 167 | * @param[in] cell_state_out 2D tensor info with dimensions [num_units, batch_size]. Data type supported: Same as @p input. |
| 168 | * @param[in] output Destination tensor info. Output is a 2D tensor with dimensions [output_size, batch_size]. Data types supported: Same as @p input. |
Michele Di Giorgio | 25d9775 | 2020-03-04 18:08:47 +0000 | [diff] [blame] | 169 | * @param[in] lstm_params Weights tensors info used in peephole optimization: |
| 170 | * input_to_input_weights 2D weights tensor info with dimensions [input_size, num_units]. Data type supported: Same as @p input. |
| 171 | * recurrent_to_input_weights 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 172 | * cell_to_input_weights 1D weights tensor info with dimensions [num_units]. Can be nullptr. Data type supported: Same as @p input. |
| 173 | * cell_to_forget_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 174 | * cell_to_output_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 175 | * input_gate_bias 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input |
| 176 | * projection_weights 2D weights tensor info with dimensions [output_size, num_units]. Data type supported: Same as @p input. |
| 177 | * projection_bias 1D weights tensor info with dimensions [output_size]. Data type supported: Same as @p input. |
| 178 | * input_layer_norm_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 179 | * forget_layer_norm_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 180 | * cell_layer_norm_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
| 181 | * output_layer_norm_weights 1D weights tensor info with dimensions [num_units]. Data type supported: Same as @p input. |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 182 | * @param[in] activation_info Contains activation information described in @ref ActivationLayerInfo. |
Michele Di Giorgio | 25d9775 | 2020-03-04 18:08:47 +0000 | [diff] [blame] | 183 | * @param[in] cell_threshold (Optional) The clipping threshold for the cell state, such that values are bound within [-cell_clip, cell_clip]. |
| 184 | * If set to 0.0f then clipping is disabled. |
| 185 | * @param[in] projection_threshold (Optional) The clipping threshold for the output from the projection layer, such that values are bound within [-proj_clip, proj_clip]. |
Michele Di Giorgio | 39438b4 | 2019-06-04 12:41:45 +0100 | [diff] [blame] | 186 | * If set to 0.0f then clipping is disabled. |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 187 | * |
| 188 | * @return a status |
| 189 | */ |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 190 | static Status validate(const ITensorInfo *input, |
| 191 | const ITensorInfo *input_to_forget_weights, const ITensorInfo *input_to_cell_weights, const ITensorInfo *input_to_output_weights, |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 192 | const ITensorInfo *recurrent_to_forget_weights, const ITensorInfo *recurrent_to_cell_weights, const ITensorInfo *recurrent_to_output_weights, |
| 193 | const ITensorInfo *forget_gate_bias, const ITensorInfo *cell_bias, const ITensorInfo *output_gate_bias, |
Georgios Pinitas | 8bc745d | 2018-07-18 19:51:24 +0100 | [diff] [blame] | 194 | const ITensorInfo *output_state_in, const ITensorInfo *cell_state_in, |
| 195 | const ITensorInfo *scratch_buffer, const ITensorInfo *output_state_out, const ITensorInfo *cell_state_out, const ITensorInfo *output, |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 196 | const LSTMParams<ITensorInfo> &lstm_params, const ActivationLayerInfo &activation_info, float cell_threshold = 0.f, float projection_threshold = 0.f); |
| 197 | |
| 198 | // Inherited methods overridden: |
| 199 | void run() override; |
John Kesapides | cafec8f | 2019-02-19 15:53:59 +0000 | [diff] [blame] | 200 | void prepare() override; |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 201 | |
| 202 | private: |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 203 | MemoryGroup _memory_group; |
| 204 | CLFullyConnectedLayer _fully_connected_input_gate; |
| 205 | CLArithmeticAddition _accum_input_gate1; |
| 206 | CLArithmeticSubtraction _subtract_input_gate; |
| 207 | CLPixelWiseMultiplication _pixelwise_mul_input_gate; |
| 208 | CLActivationLayer _activation_input_gate; |
| 209 | CLFullyConnectedLayer _fully_connected_forget_gate; |
| 210 | CLArithmeticAddition _accum_forget_gate1; |
| 211 | CLPixelWiseMultiplication _pixelwise_mul_forget_gate; |
| 212 | CLActivationLayer _activation_forget_gate; |
| 213 | CLFullyConnectedLayer _fully_connected_cell_state; |
| 214 | CLGEMM _gemm_cell_state1; |
| 215 | CLTransposeKernel _transpose_cell_state; |
| 216 | CLArithmeticAddition _accum_cell_state1; |
| 217 | CLArithmeticAddition _accum_cell_state2; |
| 218 | CLPixelWiseMultiplication _pixelwise_mul_cell_state1; |
| 219 | CLActivationLayer _activation_cell_state; |
| 220 | CLActivationLayer _cell_clip; |
| 221 | CLPixelWiseMultiplication _pixelwise_mul_cell_state2; |
| 222 | CLFullyConnectedLayer _fully_connected_output; |
| 223 | CLPixelWiseMultiplication _pixelwise_mul_output_state1; |
| 224 | CLArithmeticAddition _accum_output1; |
| 225 | CLActivationLayer _activation_output; |
| 226 | CLActivationLayer _activation_output_state; |
| 227 | CLPixelWiseMultiplication _pixelwise_mul_output_state2; |
| 228 | CLFullyConnectedLayer _fully_connected_output_state; |
| 229 | CLActivationLayer _projection_clip; |
| 230 | CLCopyKernel _copy_cell_state; |
| 231 | CLCopyKernel _copy_output; |
| 232 | CLConcatenateLayer _concat_scratch_buffer; |
| 233 | CLConcatenateLayer _concat_inputs_forget_gate; |
| 234 | CLConcatenateLayer _concat_weights_forget_gate; |
| 235 | CLConcatenateLayer _concat_weights_input_gate; |
| 236 | CLConcatenateLayer _concat_weights_output; |
| 237 | CLMemsetKernel _ones_memset_kernel; |
| 238 | CLMeanStdDevNormalizationLayer _mean_std_norm_input_gate; |
| 239 | CLPixelWiseMultiplication _pixelwise_mul_input_gate_coeff; |
| 240 | CLArithmeticAddition _accum_input_gate_bias; |
| 241 | CLMeanStdDevNormalizationLayer _mean_std_norm_forget_gate; |
| 242 | CLPixelWiseMultiplication _pixelwise_mul_forget_gate_coeff; |
| 243 | CLArithmeticAddition _accum_forget_gate_bias; |
| 244 | CLMeanStdDevNormalizationLayer _mean_std_norm_cell_gate; |
| 245 | CLPixelWiseMultiplication _pixelwise_mul_cell_gate_coeff; |
| 246 | CLArithmeticAddition _accum_cell_gate_bias; |
| 247 | CLMeanStdDevNormalizationLayer _mean_std_norm_output_gate; |
| 248 | CLPixelWiseMultiplication _pixelwise_mul_output_gate_coeff; |
| 249 | CLArithmeticAddition _accum_output_gate_bias; |
| 250 | CLTensor _input_gate_out1; |
| 251 | CLTensor _input_gate_out2; |
| 252 | CLTensor _input_gate_out3; |
| 253 | CLTensor _input_gate_out4; |
| 254 | CLTensor _forget_gate_out1; |
| 255 | CLTensor _forget_gate_out2; |
| 256 | CLTensor _forget_gate_out3; |
| 257 | CLTensor _forget_gate_out4; |
| 258 | CLTensor _forget_gate_out5; |
| 259 | CLTensor _forget_gate_out6; |
| 260 | CLTensor _cell_state_out1; |
| 261 | CLTensor _cell_state_out2; |
| 262 | CLTensor _cell_state_out3; |
| 263 | CLTensor _cell_state_out4; |
| 264 | CLTensor _cell_state_out5; |
| 265 | CLTensor _output1; |
| 266 | CLTensor _output2; |
| 267 | CLTensor _output3; |
| 268 | CLTensor _output4; |
| 269 | CLTensor _cell_state_activation; |
| 270 | CLTensor _output_state1; |
| 271 | CLTensor _ones; |
| 272 | CLTensor _input_layer_norm_out1; |
| 273 | CLTensor _input_layer_norm_out2; |
| 274 | CLTensor _forget_layer_norm_out1; |
| 275 | CLTensor _forget_layer_norm_out2; |
| 276 | CLTensor _cell_layer_norm_out1; |
| 277 | CLTensor _cell_layer_norm_out2; |
| 278 | CLTensor _output_layer_norm_out1; |
| 279 | CLTensor _output_layer_norm_out2; |
| 280 | bool _run_peephole_opt; |
| 281 | bool _run_cifg_opt; |
| 282 | bool _perform_cell_clipping; |
| 283 | bool _has_projection_weights; |
| 284 | bool _perform_projection_clipping; |
| 285 | bool _is_prepared; |
| 286 | bool _is_layer_norm_lstm; |
Michalis Spyrou | bcedf51 | 2018-03-22 14:55:08 +0000 | [diff] [blame] | 287 | }; |
John Kesapides | cafec8f | 2019-02-19 15:53:59 +0000 | [diff] [blame] | 288 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 289 | #endif /* ARM_COMPUTE_CLLSTMLAYER_H */ |