blob: 96c776141a1aadf7d510a3851436741e1e9484ec [file] [log] [blame]
Michalis Spyrouba27e442019-05-28 10:04:57 +01001/*
2 * Copyright (c) 2019 ARM Limited.
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 */
24#include "arm_compute/runtime/NEON/functions/NELSTMLayerQuantized.h"
25
26#include "arm_compute/core/Utils.h"
27#include "arm_compute/core/Validate.h"
28#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
29
30#include <cmath>
31#include <memory>
32#include <tuple>
33
34namespace arm_compute
35{
36namespace
37{
38// Quantization info structures used in the LSTMQuantize layer
39const QuantizationInfo qasymm(1.f / 128.f, 128);
40const QuantizationInfo qsymm_3(8.f / 32768.f, 0); // qsymm16 with 3 integer bit
41const QuantizationInfo qsymm_4(16.f / 32768.f, 0); // qsymm16 with 4 integer bit
42const QuantizationInfo qsymm_0(1.f / 32768.f, 0); // qsymm16 with 0 integer bit
43} // namespace
44
45NELSTMLayerQuantized::NELSTMLayerQuantized(std::shared_ptr<IMemoryManager> memory_manager)
46 : _memory_group(std::move(memory_manager)), _gemmlowp(), _output_stage(), _transpose_weights(), _concat_input_weights(), _concat_recurrent_weights(), _concat_weights(), _concat_inputs(),
47 _concat_bias(), _sigmoid_forget_gate(), _sigmoid_input_gate(), _sigmoid_output_gate(), _tanh_modulation_gate(), _tanh_output_state(), _add1(), _add2(), _mul1(), _mul2(), _mul3(),
48 _slice_input_tensor(), _slice_forget_tensor(), _slice_cell_tensor(), _slice_output_tensor(), _dequantize(), _quantize(), _input_to_input_weights(nullptr), _input_to_forget_weights(nullptr),
49 _input_to_cell_weights(nullptr), _input_to_output_weights(nullptr), _recurrent_to_input_weights(nullptr), _recurrent_to_forget_weights(nullptr), _recurrent_to_cell_weights(nullptr),
50 _recurrent_to_output_weights(nullptr), _input_gate_bias(nullptr), _forget_gate_bias(nullptr), _cell_bias(nullptr), _output_gate_bias(nullptr), _recurrent_weights(), _input_weights(), _weights(),
51 _input(), _weights_transposed(), _output_highp(), _output_lowp(), _bias(), _forget_gate_input(), _input_gate_input(), _output_gate_input(), _input_modulation_gate_input(), _forget_gate_output(),
52 _input_gate_output(), _output_gate_output(), _input_modulation_gate_output(), _cell_state1(), _cell_state2(), _output_state_tmp(), _output_state_out_symm(), _output_state_out_f32(),
53 _is_prepared(false)
54{
55}
56
57void NELSTMLayerQuantized::configure(const ITensor *input,
58 const ITensor *input_to_input_weights, const ITensor *input_to_forget_weights, const ITensor *input_to_cell_weights, const ITensor *input_to_output_weights,
59 const ITensor *recurrent_to_input_weights, const ITensor *recurrent_to_forget_weights, const ITensor *recurrent_to_cell_weights, const ITensor *recurrent_to_output_weights,
60 const ITensor *input_gate_bias, const ITensor *forget_gate_bias, const ITensor *cell_bias, const ITensor *output_gate_bias,
61 ITensor *cell_state_in, const ITensor *output_state_in,
62 ITensor *cell_state_out, ITensor *output_state_out)
63{
64 ARM_COMPUTE_ERROR_ON_NULLPTR(input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights,
65 recurrent_to_input_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights,
66 input_gate_bias, forget_gate_bias, cell_bias, output_gate_bias, cell_state_in, output_state_in, cell_state_out, output_state_out);
67
68 ARM_COMPUTE_ERROR_THROW_ON(NELSTMLayerQuantized::validate(input->info(), input_to_input_weights->info(), input_to_forget_weights->info(), input_to_cell_weights->info(),
69 input_to_output_weights->info(),
70 recurrent_to_input_weights->info(), recurrent_to_forget_weights->info(), recurrent_to_cell_weights->info(), recurrent_to_output_weights->info(),
71 input_gate_bias->info(), forget_gate_bias->info(), cell_bias->info(), output_gate_bias->info(), cell_state_in->info(), output_state_in->info(), cell_state_out->info(), output_state_out->info()));
72
73 const int input_size = input->info()->dimension(0);
74 const int batch_size = input->info()->dimension(1);
75 const int output_size = input_to_input_weights->info()->dimension(1);
76
77 const QuantizationInfo qweights = input_to_input_weights->info()->quantization_info(); // Weights quantization
78
79 auto_init_if_empty(*cell_state_out->info(), TensorInfo(TensorShape(batch_size, output_size), 1, DataType::QSYMM16, qsymm_4));
80 auto_init_if_empty(*output_state_out->info(), TensorInfo(TensorShape(batch_size, output_size), 1, DataType::QASYMM8, qasymm));
81
82 _input_to_input_weights = input_to_input_weights;
83 _input_to_forget_weights = input_to_forget_weights;
84 _input_to_cell_weights = input_to_cell_weights;
85 _input_to_output_weights = input_to_output_weights;
86 _recurrent_to_input_weights = recurrent_to_input_weights;
87 _recurrent_to_forget_weights = recurrent_to_forget_weights;
88 _recurrent_to_cell_weights = recurrent_to_cell_weights;
89 _recurrent_to_output_weights = recurrent_to_output_weights;
90 _input_gate_bias = input_gate_bias;
91 _forget_gate_bias = forget_gate_bias;
92 _cell_bias = cell_bias;
93 _output_gate_bias = output_gate_bias;
94
95 // Weights concatenation
96 std::vector<const ITensor *> inputs_weights_vector{ input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights };
97 std::vector<const ITensor *> recurrent_weights_vector{ recurrent_to_input_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights };
98
99 _input_weights.allocator()->init(TensorInfo(TensorShape(input_size, 4 * output_size), 1, DataType::QASYMM8, qweights));
100 _concat_input_weights.configure(inputs_weights_vector, &_input_weights, Window::DimY);
101
102 _recurrent_weights.allocator()->init(TensorInfo(TensorShape(output_size, 4 * output_size), 1, DataType::QASYMM8, qweights));
103 _concat_recurrent_weights.configure(recurrent_weights_vector, &_recurrent_weights, Window::DimY);
104
105 std::vector<const ITensor *> weights_vector{ &_recurrent_weights, &_input_weights };
106 _weights.allocator()->init(TensorInfo(TensorShape(output_size + input_size, 4 * output_size), 1, DataType::QASYMM8, qweights));
107 _concat_weights.configure(weights_vector, &_weights, Window::DimX);
108 _transpose_weights.configure(&_weights, &_weights_transposed);
109
110 // Input concatenation
111 std::vector<const ITensor *> input_vector{ input, output_state_in };
112 _memory_group.manage(&_input);
113 _input.allocator()->init(TensorInfo(TensorShape(output_size + input_size, batch_size), 1, DataType::QASYMM8, qasymm));
114 _concat_inputs.configure(input_vector, &_input, Window::DimX);
115
116 // Bias concatenation
117 std::vector<const ITensor *> bias_vector{ input_gate_bias, forget_gate_bias, cell_bias, output_gate_bias };
118 _bias.allocator()->init(TensorInfo(TensorShape(4 * output_size), 1, DataType::S32));
119 _concat_bias.configure(bias_vector, &_bias, Window::DimX);
120
121 // Invert the offset for gemmlowp
122 _input.info()->set_quantization_info(QuantizationInfo(qasymm.uniform().scale, -qasymm.uniform().offset));
123 _weights_transposed.info()->set_quantization_info(QuantizationInfo(qweights.uniform().scale, -qweights.uniform().offset));
124
125 // Run gemmlowp
126 _memory_group.manage(&_output_highp);
127 _output_highp.allocator()->init(TensorInfo(TensorShape(4 * output_size, batch_size), 1, DataType::S32));
128 _gemmlowp.configure(&_input, &_weights_transposed, nullptr, &_output_highp);
129 _input.allocator()->allocate();
130
131 // Set the offset back
132 _input.info()->set_quantization_info(QuantizationInfo(qasymm.uniform().scale, qasymm.uniform().offset));
133 _weights_transposed.info()->set_quantization_info(QuantizationInfo(qweights.uniform().scale, qweights.uniform().offset));
134
135 // multiplier = (input_scale * weights_scale) / output_scale (2 ^ (-12))
136 _output_lowp.allocator()->init(TensorInfo(_output_highp.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_3));
137
138 const float multiplier = 4096.f * qasymm.uniform().scale * qweights.uniform().scale;
139 int output_multiplier = 0;
140 int output_shift = 0;
141
142 quantization::calculate_quantized_multiplier_less_than_one(multiplier, &output_multiplier, &output_shift);
143
144 _memory_group.manage(&_output_lowp);
145 _output_stage.configure(&_output_highp, &_bias, &_output_lowp, output_multiplier, output_shift);
146 _output_highp.allocator()->allocate();
147 _bias.allocator()->allocate();
148
149 // Get the gate tensors
150 _memory_group.manage(&_input_gate_input);
151 _slice_input_tensor.configure(&_output_lowp, &_input_gate_input, { 0, 0 }, { output_size, batch_size });
152 _memory_group.manage(&_forget_gate_input);
153 _slice_forget_tensor.configure(&_output_lowp, &_forget_gate_input, { output_size, 0 }, { 2 * output_size, batch_size });
154 _memory_group.manage(&_input_modulation_gate_input);
155 _slice_cell_tensor.configure(&_output_lowp, &_input_modulation_gate_input, { 2 * output_size, 0 }, { 3 * output_size, batch_size });
156 _memory_group.manage(&_output_gate_input);
157 _slice_output_tensor.configure(&_output_lowp, &_output_gate_input, { 3 * output_size, 0 }, { 4 * output_size, batch_size });
158 _output_lowp.allocator()->allocate();
159
160 // Forget gate
161 _memory_group.manage(&_forget_gate_output);
162 _forget_gate_output.allocator()->init(TensorInfo(_forget_gate_input.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
163 _sigmoid_forget_gate.configure(&_forget_gate_input, &_forget_gate_output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
164 _forget_gate_input.allocator()->allocate();
165
166 // Input gate
167 _memory_group.manage(&_input_gate_output);
168 _input_gate_output.allocator()->init(TensorInfo(_input_gate_input.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
169 _sigmoid_input_gate.configure(&_input_gate_input, &_input_gate_output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
170 _input_gate_input.allocator()->allocate();
171
172 // Input modulation gate equation
173 _memory_group.manage(&_input_modulation_gate_output);
174 _input_modulation_gate_output.allocator()->init(TensorInfo(_input_modulation_gate_input.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
175 _tanh_modulation_gate.configure(&_input_modulation_gate_input, &_input_modulation_gate_output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH, 1.0f, 1.0f));
176 _input_modulation_gate_input.allocator()->allocate();
177
178 // Output gate
179 _memory_group.manage(&_output_gate_output);
180 _output_gate_output.allocator()->init(TensorInfo(_output_gate_input.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
181 _sigmoid_output_gate.configure(&_output_gate_input, &_output_gate_output, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC));
182 _output_gate_input.allocator()->allocate();
183
184 // Long term memory
185 _memory_group.manage(&_cell_state1);
186 _cell_state1.allocator()->init(TensorInfo(_forget_gate_output.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_4));
187 _mul1.configure(&_forget_gate_output, cell_state_in, &_cell_state1, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_ZERO);
188 _forget_gate_output.allocator()->allocate();
189
190 _memory_group.manage(&_cell_state2);
191 _cell_state2.allocator()->init(TensorInfo(_input_gate_output.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_4));
192 _mul2.configure(&_input_gate_output, &_input_modulation_gate_output, &_cell_state2, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_ZERO);
193 _input_modulation_gate_output.allocator()->allocate();
194 _input_gate_output.allocator()->allocate();
195
196 _add1.configure(&_cell_state1, &_cell_state2, cell_state_out, ConvertPolicy::SATURATE);
197 _cell_state1.allocator()->allocate();
198 _cell_state2.allocator()->allocate();
199
200 // Short term memory
201 _memory_group.manage(&_output_state_tmp);
202 _output_state_tmp.allocator()->init(TensorInfo(cell_state_out->info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
203 _tanh_output_state.configure(cell_state_out, &_output_state_tmp, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH, 1.0f, 1.0f));
204
205 _memory_group.manage(&_output_state_out_symm);
206 _output_state_out_symm.allocator()->init(TensorInfo(_output_gate_output.info()->tensor_shape(), 1, DataType::QSYMM16, qsymm_0));
207 _mul3.configure(&_output_state_tmp, &_output_gate_output, &_output_state_out_symm, 1, ConvertPolicy::SATURATE, RoundingPolicy::TO_ZERO);
208 _output_gate_output.allocator()->allocate();
209 _output_state_tmp.allocator()->allocate();
210
211 // Requantize the output state from QSYMM16 to QASYMM8
212 _memory_group.manage(&_output_state_out_f32);
213 _output_state_out_f32.allocator()->init(TensorInfo(_output_state_out_symm.info()->tensor_shape(), 1, DataType::F32));
214 _dequantize.configure(&_output_state_out_symm, &_output_state_out_f32);
215 _output_state_out_symm.allocator()->allocate();
216
217 _quantize.configure(&_output_state_out_f32, output_state_out);
218 _output_state_out_f32.allocator()->allocate();
219}
220
221Status NELSTMLayerQuantized::validate(const ITensorInfo *input,
222 const ITensorInfo *input_to_input_weights, const ITensorInfo *input_to_forget_weights, const ITensorInfo *input_to_cell_weights, const ITensorInfo *input_to_output_weights,
223 const ITensorInfo *recurrent_to_input_weights, const ITensorInfo *recurrent_to_forget_weights, const ITensorInfo *recurrent_to_cell_weights, const ITensorInfo *recurrent_to_output_weights,
224 const ITensorInfo *input_gate_bias, const ITensorInfo *forget_gate_bias, const ITensorInfo *cell_bias, const ITensorInfo *output_gate_bias,
225 const ITensorInfo *cell_state_in, const ITensorInfo *output_state_in,
226 const ITensorInfo *cell_state_out, const ITensorInfo *output_state_out)
227{
228 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_input_weights,
229 recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, input_gate_bias, forget_gate_bias, cell_bias, output_gate_bias, cell_state_in,
230 output_state_in, cell_state_out, output_state_out);
231
232 const int input_size = input->dimension(0);
233 const int batch_size = input->dimension(1);
234 const int output_size = input_to_input_weights->dimension(1);
235
236 // Dimensionality checks
237 ARM_COMPUTE_RETURN_ERROR_ON(input->num_dimensions() > 2);
238 ARM_COMPUTE_RETURN_ERROR_ON(input_to_input_weights->num_dimensions() > 2);
239 ARM_COMPUTE_RETURN_ERROR_ON(input_gate_bias->num_dimensions() > 1);
240 ARM_COMPUTE_RETURN_ERROR_ON(output_state_in->num_dimensions() > 2);
241
242 TensorInfo input_weights_info(input_to_input_weights->clone()->set_tensor_shape(TensorShape(input_size, output_size)).set_data_type(DataType::QASYMM8));
Manuel Bottini10c53f12019-07-17 16:11:53 +0100243 TensorInfo recurrent_weights_info(input_to_input_weights->clone()->set_tensor_shape(TensorShape(output_size, output_size)).set_data_type(DataType::QASYMM8));
Michalis Spyrouba27e442019-05-28 10:04:57 +0100244 TensorInfo bias_info(input_gate_bias->clone()->set_tensor_shape(TensorShape(output_size)).set_data_type(DataType::S32));
245 TensorInfo output_state_info(cell_state_in->clone()->set_tensor_shape(TensorShape(output_size, batch_size)).set_data_type(DataType::QASYMM8).set_quantization_info(qasymm));
246 TensorInfo cell_state_info(cell_state_in->clone()->set_tensor_shape(TensorShape(output_size, batch_size)).set_data_type(DataType::QSYMM16).set_quantization_info(qsymm_4));
247
248 // Shape checks
249 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&input_weights_info, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights);
250 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&recurrent_weights_info, recurrent_to_input_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights);
251 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&bias_info, input_gate_bias, forget_gate_bias, cell_bias, output_gate_bias);
252 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&cell_state_info, cell_state_in);
253 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&output_state_info, output_state_in);
254
255 // Data type checks
256 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&input_weights_info, input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights);
Manuel Bottini10c53f12019-07-17 16:11:53 +0100257 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(recurrent_to_input_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights);
Michalis Spyrouba27e442019-05-28 10:04:57 +0100258 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&bias_info, input_gate_bias, forget_gate_bias, cell_bias, output_gate_bias);
259 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&cell_state_info, cell_state_in);
260 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&output_state_info, output_state_in);
261
262 // Quantization checks
Manuel Bottini10c53f12019-07-17 16:11:53 +0100263 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(&input_weights_info, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights);
264 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(recurrent_to_input_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights);
Michalis Spyrouba27e442019-05-28 10:04:57 +0100265 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(&cell_state_info, cell_state_in);
266 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(&output_state_info, output_state_in);
267
268 if(cell_state_out->total_size() != 0)
269 {
270 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&cell_state_info, cell_state_out);
271 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&cell_state_info, cell_state_out);
272 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(&cell_state_info, cell_state_out);
273 }
274
275 if(output_state_out->total_size() != 0)
276 {
277 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&output_state_info, output_state_out);
278 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&output_state_info, output_state_out);
279 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(&output_state_info, output_state_out);
280 }
281
282 return Status{};
283}
284
285void NELSTMLayerQuantized::run()
286{
287 prepare();
288
289 // Acquire all the temporaries
290 MemoryGroupResourceScope scope_mg(_memory_group);
291
292 // Concat and transpose the input
293 _concat_inputs.run();
294
295 // Run gemmlowp
296 _gemmlowp.run();
297 _output_stage.run();
298
299 // Slice the results
300 _slice_input_tensor.run();
301 _slice_forget_tensor.run();
302 _slice_cell_tensor.run();
303 _slice_output_tensor.run();
304
305 // Gates
306 // Forget gate
307 _sigmoid_forget_gate.run();
308
309 // Input gate
310 _sigmoid_input_gate.run();
311
312 // Input modulation gate
313 _tanh_modulation_gate.run();
314
315 // Output gate
316 _sigmoid_output_gate.run();
317
318 // Cell state (long term memory)
319 _mul1.run();
320 _mul2.run();
321 _add1.run();
322
323 // Output state (short term memory)
324 _tanh_output_state.run();
325 _mul3.run();
326
Michele Di Giorgio35ea9a72019-08-23 12:02:06 +0100327 // Requantize output state from QSYMM16 to QASYMM8
Michalis Spyrouba27e442019-05-28 10:04:57 +0100328 _dequantize.run();
329 _quantize.run();
330}
331
332void NELSTMLayerQuantized::prepare()
333{
334 if(!_is_prepared)
335 {
336 _input_weights.allocator()->allocate();
337 _concat_input_weights.run();
338
339 _input_to_input_weights->mark_as_unused();
340 _input_to_forget_weights->mark_as_unused();
341 _input_to_cell_weights->mark_as_unused();
342 _input_to_output_weights->mark_as_unused();
343
344 _recurrent_weights.allocator()->allocate();
345 _concat_recurrent_weights.run();
346 _recurrent_to_input_weights->mark_as_unused();
347 _recurrent_to_forget_weights->mark_as_unused();
348 _recurrent_to_cell_weights->mark_as_unused();
349 _recurrent_to_output_weights->mark_as_unused();
350
351 _weights.allocator()->allocate();
352 _concat_weights.run();
353
354 _input_weights.mark_as_unused();
355 _input_weights.allocator()->free();
356 _recurrent_weights.mark_as_unused();
357 _recurrent_weights.allocator()->free();
358
359 _weights_transposed.allocator()->allocate();
360 _transpose_weights.run();
361
362 _weights.mark_as_unused();
363 _weights.allocator()->free();
364
365 _bias.allocator()->allocate();
366 _concat_bias.run();
367 _input_gate_bias->mark_as_unused();
368 _forget_gate_bias->mark_as_unused();
369 _cell_bias->mark_as_unused();
370 _output_gate_bias->mark_as_unused();
371
372 _is_prepared = true;
373 }
374}
375
376} // namespace arm_compute