aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/QLstmLayer.cpp
blob: e98deb6a88a0c9c455c1c16b34ce10ca90f4a6a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
//
// Copyright © 2020-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "QLstmLayer.hpp"

#include "LayerCloneBase.hpp"

#include <armnn/LstmParams.hpp>
#include <armnn/TypesUtils.hpp>
#include <armnn/backends/TensorHandle.hpp>
#include <armnn/backends/WorkloadFactory.hpp>

namespace armnn
{

QLstmLayer::QLstmLayer(const QLstmDescriptor& param, const char* name)
        : LayerWithParameters(3, 3, LayerType::QLstm, param, name)
{
}

std::unique_ptr<IWorkload> QLstmLayer::CreateWorkload(const IWorkloadFactory& factory) const
{
    QLstmQueueDescriptor descriptor;

    // Basic parameters
    descriptor.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights.get();
    descriptor.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights.get();
    descriptor.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights.get();
    descriptor.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights.get();
    descriptor.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights.get();
    descriptor.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights.get();
    descriptor.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias.get();
    descriptor.m_CellBias = m_BasicParameters.m_CellBias.get();
    descriptor.m_OutputGateBias = m_BasicParameters.m_OutputGateBias.get();

    // CIFG parameters
    if (!m_Param.m_CifgEnabled)
    {
        descriptor.m_InputToInputWeights     = m_CifgParameters.m_InputToInputWeights.get();
        descriptor.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights.get();
        descriptor.m_InputGateBias           = m_CifgParameters.m_InputGateBias.get();
    }

    // Projection parameters
    if (m_Param.m_ProjectionEnabled)
    {
        descriptor.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights.get();
        descriptor.m_ProjectionBias    = m_ProjectionParameters.m_ProjectionBias.get();
    }

    // Peephole parameters
    if (m_Param.m_PeepholeEnabled)
    {
        if (!m_Param.m_CifgEnabled)
        {
            descriptor.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights.get();
        }

        descriptor.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights.get();
        descriptor.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights.get();
    }

    // Layer normalisation parameters
    if(m_Param.m_LayerNormEnabled)
    {
        if (!m_Param.m_CifgEnabled)
        {
            descriptor.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights.get();
        }
        descriptor.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights.get();
        descriptor.m_CellLayerNormWeights   = m_LayerNormParameters.m_CellLayerNormWeights.get();
        descriptor.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights.get();
    }

    SetAdditionalInfo(descriptor);

    return factory.CreateWorkload(LayerType::QLstm, descriptor, PrepInfoAndDesc(descriptor));
}

QLstmLayer* QLstmLayer::Clone(Graph& graph) const
{
    auto layer = CloneBase<QLstmLayer>(graph, m_Param, GetName());

    layer->m_BasicParameters.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights ?
            m_BasicParameters.m_InputToForgetWeights : nullptr;
    layer->m_BasicParameters.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights ?
            m_BasicParameters.m_InputToCellWeights : nullptr;
    layer->m_BasicParameters.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights ?
            m_BasicParameters.m_InputToOutputWeights : nullptr;
    layer->m_BasicParameters.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights ?
            m_BasicParameters.m_RecurrentToForgetWeights : nullptr;
    layer->m_BasicParameters.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights ?
            m_BasicParameters.m_RecurrentToCellWeights : nullptr;
    layer->m_BasicParameters.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights ?
            m_BasicParameters.m_RecurrentToOutputWeights : nullptr;
    layer->m_BasicParameters.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias ?
            m_BasicParameters.m_ForgetGateBias : nullptr;
    layer->m_BasicParameters.m_CellBias = m_BasicParameters.m_CellBias ?
            m_BasicParameters.m_CellBias : nullptr;
    layer->m_BasicParameters.m_OutputGateBias = m_BasicParameters.m_OutputGateBias ?
            m_BasicParameters.m_OutputGateBias : nullptr;

    if (!m_Param.m_CifgEnabled)
    {
        layer->m_CifgParameters.m_InputToInputWeights = m_CifgParameters.m_InputToInputWeights ?
                m_CifgParameters.m_InputToInputWeights : nullptr;
        layer->m_CifgParameters.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights ?
                m_CifgParameters.m_RecurrentToInputWeights : nullptr;
        layer->m_CifgParameters.m_InputGateBias = m_CifgParameters.m_InputGateBias ?
                m_CifgParameters.m_InputGateBias : nullptr;
    }

    if (m_Param.m_ProjectionEnabled)
    {
        layer->m_ProjectionParameters.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights ?
                m_ProjectionParameters.m_ProjectionWeights : nullptr;
        layer->m_ProjectionParameters.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias ?
                m_ProjectionParameters.m_ProjectionBias : nullptr;
    }

    if (m_Param.m_PeepholeEnabled)
    {
        if (!m_Param.m_CifgEnabled) {
            layer->m_PeepholeParameters.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights ?
                    m_PeepholeParameters.m_CellToInputWeights : nullptr;
        }

        layer->m_PeepholeParameters.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights ?
                m_PeepholeParameters.m_CellToForgetWeights : nullptr;
        layer->m_PeepholeParameters.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights ?
                m_PeepholeParameters.m_CellToOutputWeights : nullptr;
    }

    if (m_Param.m_LayerNormEnabled)
    {
        if (!m_Param.m_CifgEnabled) {
            layer->m_LayerNormParameters.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights ?
                    m_LayerNormParameters.m_InputLayerNormWeights : nullptr;
        }

        layer->m_LayerNormParameters.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights ?
                m_LayerNormParameters.m_ForgetLayerNormWeights : nullptr;
        layer->m_LayerNormParameters.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights ?
                m_LayerNormParameters.m_CellLayerNormWeights : nullptr;
        layer->m_LayerNormParameters.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights ?
                m_LayerNormParameters.m_OutputLayerNormWeights : nullptr;
    }

    return std::move(layer);
}

std::vector<TensorShape> QLstmLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
{
    if (inputShapes.size() != 3)
    {
        throw armnn::Exception("inputShapes' size is \"" + std::to_string(inputShapes.size()) +
                               "\" - should be \"3\".");
    }

    // Get input values for validation
    unsigned int batchSize = inputShapes[0][0];
    unsigned int outputSize = inputShapes[1][1];
    unsigned int numUnits = inputShapes[2][1];

    std::vector<TensorShape> outShapes;
    outShapes.push_back(TensorShape({ batchSize, outputSize })); // outputStateOut
    outShapes.push_back(TensorShape({ batchSize, numUnits })); // cellStateOut
    outShapes.push_back(TensorShape({ batchSize, outputSize })); // output

    return outShapes;
}

void QLstmLayer::ValidateTensorShapesFromInputs()
{
    VerifyLayerConnections(3, CHECK_LOCATION());

    const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();

    VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);

    auto inferredShapes = InferOutputShapes(
    {
        GetInputSlot(0).GetTensorInfo().GetShape(), // input
        GetInputSlot(1).GetTensorInfo().GetShape(), // previousOutputIn
        GetInputSlot(2).GetTensorInfo().GetShape()  // previousCellStateIn
    });

    if (inferredShapes.size() != 3)
    {
        throw armnn::LayerValidationException("inferredShapes has "
                                              + std::to_string(inferredShapes.size()) +
                                              " element(s) - should only have 3.");
    }

    // Check if the weights are nullptr for basic params
    if (!m_BasicParameters.m_InputToForgetWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_InputToForgetWeights should not be null.");
    }

    if (!m_BasicParameters.m_InputToCellWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_InputToCellWeights should not be null.");
    }

    if (!m_BasicParameters.m_InputToOutputWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_InputToOutputWeights should not be null.");
    }

    if (!m_BasicParameters.m_RecurrentToForgetWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
    }

    if (!m_BasicParameters.m_RecurrentToCellWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_RecurrentToCellWeights should not be null.");
    }

    if (!m_BasicParameters.m_RecurrentToOutputWeights)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
    }

    if (!m_BasicParameters.m_ForgetGateBias)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_ForgetGateBias should not be null.");
    }

    if (!m_BasicParameters.m_CellBias)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_CellBias should not be null.");
    }

    if (!m_BasicParameters.m_OutputGateBias)
    {
        throw armnn::LayerValidationException("QLstmLayer: "
                                              "m_BasicParameters.m_OutputGateBias should not be null.");
    }

    if (!m_Param.m_CifgEnabled)
    {
        if (!m_CifgParameters.m_InputToInputWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_CifgParameters.m_InputToInputWeights should not be null.");
        }

        if (!m_CifgParameters.m_RecurrentToInputWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_CifgParameters.m_RecurrentToInputWeights should not be null.");
        }

        if (!m_CifgParameters.m_InputGateBias)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_CifgParameters.m_InputGateBias should not be null.");
        }

        ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
    }
    else
    {
        if (m_CifgParameters.m_InputToInputWeights)
        {
                throw armnn::LayerValidationException("QLstmLayer: "
                                                      "m_CifgParameters.m_InputToInputWeights "
                                                      "should not have a value when CIFG is enabled.");
        }

        if (m_CifgParameters.m_RecurrentToInputWeights)
        {
                throw armnn::LayerValidationException("QLstmLayer: "
                                                      "m_CifgParameters.m_RecurrentToInputWeights "
                                                      "should not have a value when CIFG is enabled.");
        }

        if (m_CifgParameters.m_InputGateBias)
        {
                throw armnn::LayerValidationException("QLstmLayer: "
                                                      "m_CifgParameters.m_InputGateBias "
                                                      "should not have a value when CIFG is enabled.");
        }

        ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
    }

    if (m_Param.m_ProjectionEnabled)
    {
        if (!m_ProjectionParameters.m_ProjectionWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_ProjectionParameters.m_ProjectionWeights should not be null.");
        }
    }

    if (m_Param.m_PeepholeEnabled)
    {
        if (!m_Param.m_CifgEnabled) {
            if (!m_PeepholeParameters.m_CellToInputWeights)
            {
                throw armnn::LayerValidationException("QLstmLayer: "
                                                      "m_PeepholeParameters.m_CellToInputWeights should not be null "
                                                      "when Peephole is enabled and CIFG is disabled.");
            }
        }

        if (!m_PeepholeParameters.m_CellToForgetWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_PeepholeParameters.m_CellToForgetWeights should not be null.");
        }

        if (!m_PeepholeParameters.m_CellToOutputWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_PeepholeParameters.m_CellToOutputWeights should not be null.");
        }
    }

    ValidateAndCopyShape(
            GetOutputSlot(1).GetTensorInfo().GetShape(), inferredShapes[1], m_ShapeInferenceMethod, "QLstmLayer", 1);
    ValidateAndCopyShape(
            GetOutputSlot(2).GetTensorInfo().GetShape(), inferredShapes[2], m_ShapeInferenceMethod, "QLstmLayer", 2);

    if (m_Param.m_LayerNormEnabled)
    {
        if (!m_Param.m_CifgEnabled)
        {
            if (!m_LayerNormParameters.m_InputLayerNormWeights)
            {
                throw armnn::LayerValidationException("QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights "
                                                      "should not be null.");
            }
        }

        if (!m_LayerNormParameters.m_ForgetLayerNormWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
        }

        if (!m_LayerNormParameters.m_CellLayerNormWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
        }

        if (!m_LayerNormParameters.m_OutputLayerNormWeights)
        {
            throw armnn::LayerValidationException("QLstmLayer: "
                                                  "m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
        }
    }
}

Layer::ImmutableConstantTensors QLstmLayer::GetConstantTensorsByRef() const
{
    // For API stability DO NOT ALTER order and add new members to the end of vector
    return {m_BasicParameters.m_InputToForgetWeights,
            m_BasicParameters.m_InputToCellWeights,
            m_BasicParameters.m_InputToOutputWeights,
            m_BasicParameters.m_RecurrentToForgetWeights,
            m_BasicParameters.m_RecurrentToCellWeights,
            m_BasicParameters.m_RecurrentToOutputWeights,
            m_BasicParameters.m_ForgetGateBias,
            m_BasicParameters.m_CellBias,
            m_BasicParameters.m_OutputGateBias,

            // Cifg parameters
            m_CifgParameters.m_InputToInputWeights,
            m_CifgParameters.m_RecurrentToInputWeights,
            m_CifgParameters.m_InputGateBias,

            // Projection parameters
            m_ProjectionParameters.m_ProjectionWeights,
            m_ProjectionParameters.m_ProjectionBias,

            // Peephole parameters
            m_PeepholeParameters.m_CellToInputWeights,
            m_PeepholeParameters.m_CellToForgetWeights,
            m_PeepholeParameters.m_CellToOutputWeights,

            // Layer normalisation parameters
            m_LayerNormParameters.m_InputLayerNormWeights,
            m_LayerNormParameters.m_ForgetLayerNormWeights,
            m_LayerNormParameters.m_CellLayerNormWeights,
            m_LayerNormParameters.m_OutputLayerNormWeights};
}


void QLstmLayer::ExecuteStrategy(IStrategy& strategy) const
{
    std::vector<ConstTensor> constTensors;
    ManagedConstTensorHandle managedInputToForgetWeights(m_BasicParameters.m_InputToForgetWeights);
    ManagedConstTensorHandle managedInputToCellWeights(m_BasicParameters.m_InputToCellWeights);
    ManagedConstTensorHandle managedInputToOutputWeights(m_BasicParameters.m_InputToOutputWeights);
    ManagedConstTensorHandle managedRecurrentToForgetWeights(m_BasicParameters.m_RecurrentToForgetWeights);
    ManagedConstTensorHandle managedRecurrentToCellWeights(m_BasicParameters.m_RecurrentToCellWeights);
    ManagedConstTensorHandle managedRecurrentToOutputWeights(m_BasicParameters.m_RecurrentToOutputWeights);
    ManagedConstTensorHandle managedForgetGateBias(m_BasicParameters.m_ForgetGateBias);
    ManagedConstTensorHandle managedCellBias(m_BasicParameters.m_CellBias);
    ManagedConstTensorHandle managedOutputGateBias(m_BasicParameters.m_OutputGateBias);

    // Cifg parameters
    ManagedConstTensorHandle managedInputToInputWeights(m_CifgParameters.m_InputToInputWeights);
    ManagedConstTensorHandle managedRecurrentToInputWeights(m_CifgParameters.m_RecurrentToInputWeights);
    ManagedConstTensorHandle managedInputGateBias(m_CifgParameters.m_InputGateBias);

    // Projection parameters
    ManagedConstTensorHandle managedProjectionWeights(m_ProjectionParameters.m_ProjectionWeights);
    ManagedConstTensorHandle managedProjectionBias(m_ProjectionParameters.m_ProjectionBias);

    // Peephole parameters
    ManagedConstTensorHandle managedCellToInputWeights(m_PeepholeParameters.m_CellToInputWeights);
    ManagedConstTensorHandle managedCellToForgetWeights(m_PeepholeParameters.m_CellToForgetWeights);
    ManagedConstTensorHandle managedCellToOutputWeights(m_PeepholeParameters.m_CellToOutputWeights);

    // Layer normalisation parameters
    ManagedConstTensorHandle managedInputLayerNormWeights(m_LayerNormParameters.m_InputLayerNormWeights);
    ManagedConstTensorHandle managedForgetLayerNormWeights(m_LayerNormParameters.m_ForgetLayerNormWeights);
    ManagedConstTensorHandle managedCellLayerNormWeights(m_LayerNormParameters.m_CellLayerNormWeights);
    ManagedConstTensorHandle managedOutputLayerNormWeights(m_LayerNormParameters.m_OutputLayerNormWeights);

    // First add mandatory/basic parameters
    if (m_BasicParameters.m_InputToForgetWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputToForgetWeights.GetTensorInfo(),
                                              managedInputToForgetWeights.Map()));
    }
    if (m_BasicParameters.m_InputToCellWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputToCellWeights.GetTensorInfo(),
                                              managedInputToCellWeights.Map()));
    }
    if (m_BasicParameters.m_InputToOutputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputToOutputWeights.GetTensorInfo(),
                                              managedInputToOutputWeights.Map()));
    }
    if (m_BasicParameters.m_RecurrentToForgetWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(
                managedRecurrentToForgetWeights.GetTensorInfo(),
                managedRecurrentToForgetWeights.Map()));
    }
    if (m_BasicParameters.m_RecurrentToCellWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(
                managedRecurrentToCellWeights.GetTensorInfo(),
                managedRecurrentToCellWeights.Map()));
    }
    if (m_BasicParameters.m_RecurrentToOutputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(
                managedRecurrentToOutputWeights.GetTensorInfo(),
                managedRecurrentToOutputWeights.Map()));
    }
    if (m_BasicParameters.m_ForgetGateBias != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedForgetGateBias.GetTensorInfo(),
                                              managedForgetGateBias.Map()));
    }
    if (m_BasicParameters.m_CellBias != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedCellBias.GetTensorInfo(),
                                              managedCellBias.Map()));
    }
    if (m_BasicParameters.m_OutputGateBias != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedOutputGateBias.GetTensorInfo(),
                                              managedOutputGateBias.Map()));
    }

    // Add cifig parameters
    if (m_CifgParameters.m_InputToInputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputToInputWeights.GetTensorInfo(),
                                              managedInputToInputWeights.Map()));
    }
    if (m_CifgParameters.m_RecurrentToInputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(
                managedRecurrentToInputWeights.GetTensorInfo(),
                managedRecurrentToInputWeights.Map()));
    }
    if (m_CifgParameters.m_InputGateBias != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputGateBias.GetTensorInfo(),
                                              managedInputGateBias.Map()));
    }

    // Add peephole parameters
    if (m_PeepholeParameters.m_CellToInputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedCellToInputWeights.GetTensorInfo(),
                                              managedCellToInputWeights.Map()));
    }
    if (m_PeepholeParameters.m_CellToForgetWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedCellToForgetWeights.GetTensorInfo(),
                                              managedCellToForgetWeights.Map()));
    }
    if (m_PeepholeParameters.m_CellToOutputWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedCellToOutputWeights.GetTensorInfo(),
                                              managedCellToOutputWeights.Map()));
    }

    // Add projection parameters
    if (m_ProjectionParameters.m_ProjectionWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedProjectionWeights.GetTensorInfo(),
                                              managedProjectionWeights.Map()));
    }
    if (m_ProjectionParameters.m_ProjectionBias != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedProjectionBias.GetTensorInfo(),
                                              managedProjectionBias.Map()));
    }

    // Add norm parameters
    if (m_LayerNormParameters.m_InputLayerNormWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedInputLayerNormWeights.GetTensorInfo(),
                                              managedInputLayerNormWeights.Map()));
    }
    if (m_LayerNormParameters.m_ForgetLayerNormWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedForgetLayerNormWeights.GetTensorInfo(),
                                              managedForgetLayerNormWeights.Map()));
    }
    if (m_LayerNormParameters.m_CellLayerNormWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedCellLayerNormWeights.GetTensorInfo(),
                                              managedCellLayerNormWeights.Map()));
    }
    if (m_LayerNormParameters.m_OutputLayerNormWeights != nullptr)
    {
        constTensors.emplace_back(ConstTensor(managedOutputLayerNormWeights.GetTensorInfo(),
                                              managedOutputLayerNormWeights.Map()));
    }
    strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
}

} // namespace armnn