• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "DriverTestHelpers.hpp"
9 
10 #include <armnn/utility/IgnoreUnused.hpp>
11 
12 #include <array>
13 
14 using ArmnnDriver   = armnn_driver::ArmnnDriver;
15 using DriverOptions = armnn_driver::DriverOptions;
16 using RequestArgument = V1_0::RequestArgument;
17 
18 #ifdef ARMNN_ANDROID_S
19 #include <nnapi/Types.h>
20 #endif
21 
22 using namespace driverTestHelpers;
23 using namespace android::hardware;
24 
25 namespace
26 {
27 
28 template<typename T>
CreateRequestArgument(const std::vector<T> & value,unsigned int poolIndex)29 RequestArgument CreateRequestArgument(const std::vector<T>& value, unsigned int poolIndex)
30 {
31     V1_0::DataLocation inputInloc = {};
32     inputInloc.poolIndex = poolIndex;
33     inputInloc.offset = 0;
34     inputInloc.length = value.size() * sizeof(T);
35     RequestArgument inputRequestArgument = {};
36     inputRequestArgument.location = inputInloc;
37     inputRequestArgument.dimensions = hidl_vec<uint32_t>{};
38     return inputRequestArgument;
39 }
40 
41 // Helper function to create an OperandLifeTime::NO_VALUE for testing.
42 // To be used on optional input operands that have no values - these are valid and should be tested.
CreateNoValueLifeTime(const hidl_vec<uint32_t> & dimensions)43 V1_0::OperandLifeTime CreateNoValueLifeTime(const hidl_vec<uint32_t>& dimensions)
44 {
45     // Only create a NO_VALUE for optional operands that have no elements
46     if (dimensions.size() == 0 || dimensions[0] == 0)
47     {
48         return V1_0::OperandLifeTime::NO_VALUE;
49     }
50     return V1_0::OperandLifeTime::CONSTANT_COPY;
51 }
52 
53 template<typename HalModel>
ExecuteModel(const HalModel & model,armnn_driver::ArmnnDriver & driver,const V1_0::Request & request)54 void ExecuteModel(const HalModel& model, armnn_driver::ArmnnDriver& driver, const V1_0::Request& request)
55 {
56     android::sp<V1_0::IPreparedModel> preparedModel = PrepareModel(model, driver);
57     if (preparedModel.get() != nullptr)
58     {
59         Execute(preparedModel, request);
60     }
61 }
62 
63 #if defined(ARMNN_ANDROID_NN_V1_2) || defined(ARMNN_ANDROID_NN_V1_3)
64 
65 template<>
ExecuteModel(const armnn_driver::hal_1_2::HalPolicy::Model & model,armnn_driver::ArmnnDriver & driver,const V1_0::Request & request)66 void ExecuteModel<armnn_driver::hal_1_2::HalPolicy::Model>(const armnn_driver::hal_1_2::HalPolicy::Model& model,
67                                                            armnn_driver::ArmnnDriver& driver,
68                                                            const V1_0::Request& request)
69 {
70     android::sp<V1_2::IPreparedModel> preparedModel = PrepareModel_1_2(model, driver);
71     if (preparedModel.get() != nullptr)
72     {
73         Execute(preparedModel, request);
74     }
75 }
76 
77 #endif
78 
79 } // anonymous namespace
80 
81 // Add our own tests here since we fail the unidirectional sequence lstm
82 // tests which Google supplies (because of non-const weights)
83 template <typename HalPolicy>
UnidirectionalSequenceLstmTestImpl(const hidl_vec<uint32_t> & inputDimensions,const std::vector<float> & inputValue,const hidl_vec<uint32_t> & inputToInputWeightsDimensions,const std::vector<float> & inputToInputWeightsValue,const hidl_vec<uint32_t> & inputToForgetWeightsDimensions,const std::vector<float> & inputToForgetWeightsValue,const hidl_vec<uint32_t> & inputToCellWeightsDimensions,const std::vector<float> & inputToCellWeightsValue,const hidl_vec<uint32_t> & inputToOutputWeightsDimensions,const std::vector<float> & inputToOutputWeightsValue,const hidl_vec<uint32_t> & recurrentToInputWeightsDimensions,const std::vector<float> & recurrentToInputWeightsValue,const hidl_vec<uint32_t> & recurrentToForgetWeightsDimensions,const std::vector<float> & recurrentToForgetWeightsValue,const hidl_vec<uint32_t> & recurrentToCellWeightsDimensions,const std::vector<float> & recurrentToCellWeightsValue,const hidl_vec<uint32_t> & recurrentToOutputWeightsDimensions,const std::vector<float> & recurrentToOutputWeightsValue,const hidl_vec<uint32_t> & cellToInputWeightsDimensions,const std::vector<float> & cellToInputWeightsValue,const hidl_vec<uint32_t> & cellToForgetWeightsDimensions,const std::vector<float> & cellToForgetWeightsValue,const hidl_vec<uint32_t> & cellToOutputWeightsDimensions,const std::vector<float> & cellToOutputWeightsValue,const hidl_vec<uint32_t> & inputGateBiasDimensions,const std::vector<float> & inputGateBiasValue,const hidl_vec<uint32_t> & forgetGateBiasDimensions,const std::vector<float> & forgetGateBiasValue,const hidl_vec<uint32_t> & cellBiasDimensions,const std::vector<float> & cellBiasValue,const hidl_vec<uint32_t> & outputGateBiasDimensions,const std::vector<float> & outputGateBiasValue,const hidl_vec<uint32_t> & projectionWeightsDimensions,const std::vector<float> & projectionWeightsValue,const hidl_vec<uint32_t> & projectionBiasDimensions,const std::vector<float> & projectionBiasValue,const hidl_vec<uint32_t> & outputStateInDimensions,const std::vector<float> & outputStateInValue,const hidl_vec<uint32_t> & cellStateInDimensions,const std::vector<float> & cellStateInValue,const hidl_vec<uint32_t> & activationFunctionDimensions,const std::vector<int32_t> & activationFunctionValue,const hidl_vec<uint32_t> & cellClippingThresholdDimensions,const std::vector<float> & cellClippingThresholdValue,const hidl_vec<uint32_t> & projectionClippingThresholdDimensions,const std::vector<float> & projectionClippingThresholdValue,const bool & timeMajorValue,const hidl_vec<uint32_t> & inputLayerNormWeightsDimensions,const std::vector<float> & inputLayerNormWeightsValue,const hidl_vec<uint32_t> & forgetLayerNormWeightsDimensions,const std::vector<float> & forgetLayerNormWeightsValue,const hidl_vec<uint32_t> & cellLayerNormWeightsDimensions,const std::vector<float> & cellLayerNormWeightsValue,const hidl_vec<uint32_t> & outputLayerNormWeightsDimensions,const std::vector<float> & outputLayerNormWeightsValue,const hidl_vec<uint32_t> & outputDimensions,const std::vector<float> & outputValue,const hidl_vec<uint32_t> &,const std::vector<float> &,const hidl_vec<uint32_t> &,const std::vector<float> &,armnn::Compute compute,float epsilonValue=0)84 void UnidirectionalSequenceLstmTestImpl(const hidl_vec<uint32_t>& inputDimensions,
85                                         const std::vector<float>& inputValue,
86                                         const hidl_vec<uint32_t>& inputToInputWeightsDimensions,
87                                         const std::vector<float>& inputToInputWeightsValue,
88                                         const hidl_vec<uint32_t>& inputToForgetWeightsDimensions,
89                                         const std::vector<float>& inputToForgetWeightsValue,
90                                         const hidl_vec<uint32_t>& inputToCellWeightsDimensions,
91                                         const std::vector<float>& inputToCellWeightsValue,
92                                         const hidl_vec<uint32_t>& inputToOutputWeightsDimensions,
93                                         const std::vector<float>& inputToOutputWeightsValue,
94                                         const hidl_vec<uint32_t>& recurrentToInputWeightsDimensions,
95                                         const std::vector<float>& recurrentToInputWeightsValue,
96                                         const hidl_vec<uint32_t>& recurrentToForgetWeightsDimensions,
97                                         const std::vector<float>& recurrentToForgetWeightsValue,
98                                         const hidl_vec<uint32_t>& recurrentToCellWeightsDimensions,
99                                         const std::vector<float>& recurrentToCellWeightsValue,
100                                         const hidl_vec<uint32_t>& recurrentToOutputWeightsDimensions,
101                                         const std::vector<float>& recurrentToOutputWeightsValue,
102                                         const hidl_vec<uint32_t>& cellToInputWeightsDimensions,
103                                         const std::vector<float>& cellToInputWeightsValue,
104                                         const hidl_vec<uint32_t>& cellToForgetWeightsDimensions,
105                                         const std::vector<float>& cellToForgetWeightsValue,
106                                         const hidl_vec<uint32_t>& cellToOutputWeightsDimensions,
107                                         const std::vector<float>& cellToOutputWeightsValue,
108                                         const hidl_vec<uint32_t>& inputGateBiasDimensions,
109                                         const std::vector<float>& inputGateBiasValue,
110                                         const hidl_vec<uint32_t>& forgetGateBiasDimensions,
111                                         const std::vector<float>& forgetGateBiasValue,
112                                         const hidl_vec<uint32_t>& cellBiasDimensions,
113                                         const std::vector<float>& cellBiasValue,
114                                         const hidl_vec<uint32_t>& outputGateBiasDimensions,
115                                         const std::vector<float>& outputGateBiasValue,
116                                         const hidl_vec<uint32_t>& projectionWeightsDimensions,
117                                         const std::vector<float>& projectionWeightsValue,
118                                         const hidl_vec<uint32_t>& projectionBiasDimensions,
119                                         const std::vector<float>& projectionBiasValue,
120                                         const hidl_vec<uint32_t>& outputStateInDimensions,
121                                         const std::vector<float>& outputStateInValue,
122                                         const hidl_vec<uint32_t>& cellStateInDimensions,
123                                         const std::vector<float>& cellStateInValue,
124                                         const hidl_vec<uint32_t>& activationFunctionDimensions,
125                                         const std::vector<int32_t>& activationFunctionValue,
126                                         const hidl_vec<uint32_t>& cellClippingThresholdDimensions,
127                                         const std::vector<float>& cellClippingThresholdValue,
128                                         const hidl_vec<uint32_t>& projectionClippingThresholdDimensions,
129                                         const std::vector<float>& projectionClippingThresholdValue,
130                                         const bool& timeMajorValue,
131                                         const hidl_vec<uint32_t>& inputLayerNormWeightsDimensions,
132                                         const std::vector<float>& inputLayerNormWeightsValue,
133                                         const hidl_vec<uint32_t>& forgetLayerNormWeightsDimensions,
134                                         const std::vector<float>& forgetLayerNormWeightsValue,
135                                         const hidl_vec<uint32_t>& cellLayerNormWeightsDimensions,
136                                         const std::vector<float>& cellLayerNormWeightsValue,
137                                         const hidl_vec<uint32_t>& outputLayerNormWeightsDimensions,
138                                         const std::vector<float>& outputLayerNormWeightsValue,
139                                         const hidl_vec<uint32_t>& outputDimensions,
140                                         const std::vector<float>& outputValue,
141                                         const hidl_vec<uint32_t>&, // outputStateOutDimensions,
142                                         const std::vector<float>&, // outputStateOutValue,
143                                         const hidl_vec<uint32_t>&, // cellStateOutDimensions,
144                                         const std::vector<float>&, // cellStateOutValue,
145                                         armnn::Compute compute,
146                                         float epsilonValue = 0)
147 {
148     auto driver = std::make_unique<ArmnnDriver>(DriverOptions(compute));
149     using Model = typename HalPolicy::Model;
150     Model model = {};
151 
152     // Inputs:
153     // 00: The input: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, input_size], where
154     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
155     AddInputOperand<HalPolicy>(model, inputDimensions);
156 
157     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
158     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
159     AddTensorOperand<HalPolicy>(model,
160                                 inputToInputWeightsDimensions,
161                                 inputToInputWeightsValue,
162                                 HalPolicy::OperandType::TENSOR_FLOAT32,
163                                 CreateNoValueLifeTime(inputToInputWeightsDimensions));
164     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
165     //     [num_units, input_size].
166     AddTensorOperand<HalPolicy>(model, inputToForgetWeightsDimensions, inputToForgetWeightsValue);
167     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
168     // [num_units, input_size].
169     AddTensorOperand<HalPolicy>(model, inputToCellWeightsDimensions, inputToCellWeightsValue);
170     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
171     //     [num_units, input_size].
172     AddTensorOperand<HalPolicy>(model, inputToOutputWeightsDimensions, inputToOutputWeightsValue);
173     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
174     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
175     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
176     AddTensorOperand<HalPolicy>(model,
177                                 recurrentToInputWeightsDimensions,
178                                 recurrentToInputWeightsValue,
179                                 HalPolicy::OperandType::TENSOR_FLOAT32,
180                                 CreateNoValueLifeTime(recurrentToInputWeightsDimensions));
181     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
182     //     [num_units, output_size].
183     AddTensorOperand<HalPolicy>(model, recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue);
184     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
185     //     [num_units, output_size].
186     AddTensorOperand<HalPolicy>(model, recurrentToCellWeightsDimensions, recurrentToCellWeightsValue);
187     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
188     //     [num_units, output_size].
189     AddTensorOperand<HalPolicy>(model, recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue);
190     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
191     AddTensorOperand<HalPolicy>(model,
192                                 cellToInputWeightsDimensions,
193                                 cellToInputWeightsValue,
194                                 HalPolicy::OperandType::TENSOR_FLOAT32,
195                                 CreateNoValueLifeTime(cellToInputWeightsDimensions));
196     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
197     AddTensorOperand<HalPolicy>(model,
198                                 cellToForgetWeightsDimensions,
199                                 cellToForgetWeightsValue,
200                                 HalPolicy::OperandType::TENSOR_FLOAT32,
201                                 CreateNoValueLifeTime(cellToForgetWeightsDimensions));
202     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
203     AddTensorOperand<HalPolicy>(model,
204                                 cellToOutputWeightsDimensions,
205                                 cellToOutputWeightsValue,
206                                 HalPolicy::OperandType::TENSOR_FLOAT32,
207                                 CreateNoValueLifeTime(cellToOutputWeightsDimensions));
208     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
209     AddTensorOperand<HalPolicy>(model,
210                                 inputGateBiasDimensions,
211                                 inputGateBiasValue,
212                                 HalPolicy::OperandType::TENSOR_FLOAT32,
213                                 CreateNoValueLifeTime(inputGateBiasDimensions));
214     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
215     AddTensorOperand<HalPolicy>(model, forgetGateBiasDimensions, forgetGateBiasValue);
216     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
217     AddTensorOperand<HalPolicy>(model, cellBiasDimensions, cellBiasValue);
218     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
219     AddTensorOperand<HalPolicy>(model, outputGateBiasDimensions, outputGateBiasValue);
220     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
221     //     [output_size, num_units].
222     AddTensorOperand<HalPolicy>(model,
223                                 projectionWeightsDimensions,
224                                 projectionWeightsValue,
225                                 HalPolicy::OperandType::TENSOR_FLOAT32,
226                                 CreateNoValueLifeTime(projectionWeightsDimensions));
227     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
228     AddTensorOperand<HalPolicy>(model,
229                                 projectionBiasDimensions,
230                                 projectionBiasValue,
231                                 HalPolicy::OperandType::TENSOR_FLOAT32,
232                                 CreateNoValueLifeTime(projectionBiasDimensions));
233 
234     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
235     AddInputOperand<HalPolicy>(model, outputStateInDimensions);
236     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
237     AddInputOperand<HalPolicy>(model, cellStateInDimensions);
238 
239     // Constant scalar values (the VTS test adds these as tensors of dim {})
240     // 20: The activation function: A value indicating the activation function:
241     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
242     AddTensorOperand<HalPolicy>(model,
243                                 activationFunctionDimensions,
244                                 activationFunctionValue,
245                                 HalPolicy::OperandType::INT32);
246     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
247     //     If set to 0.0 then clipping is disabled.
248     AddTensorOperand<HalPolicy>(model,
249                                 cellClippingThresholdDimensions,
250                                 cellClippingThresholdValue,
251                                 HalPolicy::OperandType::FLOAT32);
252     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
253     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
254     AddTensorOperand<HalPolicy>(model,
255                                 projectionClippingThresholdDimensions,
256                                 projectionClippingThresholdValue,
257                                 HalPolicy::OperandType::FLOAT32);
258 
259     // 23: Time-major if true, batch-major if false.
260     AddBoolOperand<HalPolicy>(model, timeMajorValue);
261 
262     // Normalization:
263     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
264     //    Used to rescale normalized inputs to activation at input gate.
265     AddTensorOperand<HalPolicy>(model,
266                                 inputLayerNormWeightsDimensions,
267                                 inputLayerNormWeightsValue,
268                                 HalPolicy::OperandType::TENSOR_FLOAT32,
269                                 CreateNoValueLifeTime(inputLayerNormWeightsDimensions));
270     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
271     //    Used to rescale normalized inputs to activation at forget gate.
272     AddTensorOperand<HalPolicy>(model,
273                                 forgetLayerNormWeightsDimensions,
274                                 forgetLayerNormWeightsValue,
275                                 HalPolicy::OperandType::TENSOR_FLOAT32,
276                                 CreateNoValueLifeTime(forgetLayerNormWeightsDimensions));
277     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
278     //    Used to rescale normalized inputs to activation at cell gate.
279     AddTensorOperand<HalPolicy>(model,
280                                 cellLayerNormWeightsDimensions,
281                                 cellLayerNormWeightsValue,
282                                 HalPolicy::OperandType::TENSOR_FLOAT32,
283                                 CreateNoValueLifeTime(cellLayerNormWeightsDimensions));
284     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
285     //    Used to rescale normalized inputs to activation at output gate.
286     AddTensorOperand<HalPolicy>(model,
287                                 outputLayerNormWeightsDimensions,
288                                 outputLayerNormWeightsValue,
289                                 HalPolicy::OperandType::TENSOR_FLOAT32,
290                                 CreateNoValueLifeTime(outputLayerNormWeightsDimensions));
291 
292     // Outputs:
293     // 00: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
294     // [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
295     AddOutputOperand<HalPolicy>(model, outputDimensions);
296     // 01: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
297     // [batch_size, output_size]. This output is optional and can be omitted. If this output
298     // is present then output #2 must be present as well.
299     //AddOutputOperand<HalPolicy>(model, hiddenStateOutDimensions);
300     // 02: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
301     // [batch_size, num_units]. This output is optional and can be omitted.
302     //AddOutputOperand<HalPolicy>(model, cellStateOutDimensions);
303 
304     // make the lstm operation
305     model.operations.resize(1);
306     model.operations[0].type = HalPolicy::OperationType::UNIDIRECTIONAL_SEQUENCE_LSTM;
307 
308     model.operations[0].inputs = hidl_vec<uint32_t> {0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13,
309                                                      14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
310     model.operations[0].outputs = hidl_vec<uint32_t> {28};
311 
312     // define the input values
313     hidl_vec<RequestArgument> inputArguments;
314     inputArguments.resize(3);
315 
316     inputArguments[0] = CreateRequestArgument<float>(inputValue, 0);
317     inputArguments[1] = CreateRequestArgument<float>(outputStateInValue, 1);
318     inputArguments[2] = CreateRequestArgument<float>(cellStateInValue, 2);
319 
320     // define the expected output values
321     hidl_vec<RequestArgument> outputArguments;
322     outputArguments.resize(1);
323 
324     outputArguments[0] = CreateRequestArgument<float>(outputValue, 3);
325 
326     V1_0::Request request = {};
327     request.inputs  = inputArguments;
328     request.outputs = outputArguments;
329 
330     // set the input data
331     AddPoolAndSetData(inputValue.size(), request, inputValue.data());
332     AddPoolAndSetData(outputStateInValue.size(), request, outputStateInValue.data());
333     AddPoolAndSetData(cellStateInValue.size(), request, cellStateInValue.data());
334 
335     // add memory for the outputs
336     android::sp<IMemory> outputMemory = AddPoolAndGetData<float>(outputValue.size(), request);
337     float* outputData = static_cast<float*>(static_cast<void*>(outputMemory->getPointer()));
338 
339     // make the prepared model and run the execution
340     ExecuteModel(model, *driver, request);
341 
342     // check the results
343     if (epsilonValue != 0)
344     {
345         for (size_t i = 0; i < outputValue.size(); ++i)
346         {
347             DOCTEST_CHECK_MESSAGE(outputValue[i] == doctest::Approx(outputData[i]).epsilon(epsilonValue),
348                                   "outputValue[" << i << "]: " << outputValue[i] << " != " << outputData[i]);
349         }
350     }
351     else
352     {
353         for (size_t i = 0; i < outputValue.size(); ++i)
354         {
355             DOCTEST_CHECK_MESSAGE(outputValue[i] == doctest::Approx(outputData[i]),
356                                   "outputValue[" << i << "]: " << outputValue[i] << " != " << outputData[i]);
357         }
358     }
359 }
360 
361 template<typename HalPolicy>
UnidirectionalSequenceLstmLayerFloat32TestImpl(armnn::Compute compute)362 void UnidirectionalSequenceLstmLayerFloat32TestImpl(armnn::Compute compute)
363 {
364     uint32_t batchSize  = 3;
365     uint32_t timeSize   = 2;
366     uint32_t inputSize  = 3;
367     uint32_t outputSize = 4;
368     uint32_t numUnits   = outputSize;
369 
370     // Inputs:
371     // 00: The input: A 3-D tensor of shape: If time-major: [max_time, batch_size, input_size] If batch-major:
372     //     [batch_size, max_time, input_size] where “max_time” is the number of timesteps (sequence length),
373     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
374     hidl_vec<uint32_t> inputDimensions{batchSize, timeSize, inputSize};
375     std::vector<float> inputValue{1., 2., 3., 4., 5., 4.,
376                                   3., 2., 1., 2., 3., 4.,
377                                   5., 4., 3., 2., 1., 2.};
378 
379     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
380     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
381     hidl_vec<uint32_t> inputToInputWeightsDimensions{numUnits, inputSize};
382     std::vector<float> inputToInputWeightsValue{-0.49536117f, -0.0556083915f, -0.102400711f,
383                                                 -0.117484632f, 0.3298470976f, -0.1179017122f,
384                                                 0.214305695f, 0.42135173085f, 0.003878414626f,
385                                                 -0.348303917f, -0.1881275477f, 0.0343011027f};
386     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
387     //     [num_units, input_size].
388     hidl_vec<uint32_t> inputToForgetWeightsDimensions{numUnits, inputSize};
389     std::vector<float> inputToForgetWeightsValue{0.2415594226f, 0.15400093799f, 0.4566498398f,
390                                                  -0.3810434485f, 0.268383264f, -0.009807467424f,
391                                                  -0.3522925403f, -0.24275735512f, -0.28344226125f,
392                                                  0.13512269116f, -0.4932442977f, -0.10039821991f};
393     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units, input_size].
394     hidl_vec<uint32_t> inputToCellWeightsDimensions{numUnits, inputSize};
395     std::vector<float> inputToCellWeightsValue{-0.2504855627f, 0.184490025045f, -0.2480507493f,
396                                                0.386399507f, -0.259465157985f, -0.16545993089f,
397                                                -0.4230232555f, 0.341664791103f, -0.18127849691f,
398                                                -0.2277662414f, -0.55275535589f, 0.34184026718f};
399     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
400     //     [num_units, input_size].
401     hidl_vec<uint32_t> inputToOutputWeightsDimensions{numUnits, inputSize};
402     std::vector<float> inputToOutputWeightsValue{0.2303854227f, 0.5218806862f, -0.4865379333f,
403                                                  0.53969591851f, 0.23393625035f, -0.27140527306f,
404                                                  0.50009280443f, 0.07511717046f, 0.3998299249f,
405                                                  -0.51717478049f, 0.1889653282f, -0.367323637f};
406     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
407     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
408     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
409     hidl_vec<uint32_t> recurrentToInputWeightsDimensions{numUnits, outputSize};
410     std::vector<float> recurrentToInputWeightsValue{-0.128009796112f, 0.1995525098f, -0.07745539397f, 0.1558421701f,
411                                                     -0.265254765766f, -0.38837709614f, -0.05636804124f, 0.4259087456f,
412                                                     0.17628988623f, 0.3877420127f, 0.53300309181f, -0.0959980934f,
413                                                     0.00302857416f, 0.3266998827f, -0.142509296562f, -0.04433270756f};
414     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
415     //     [num_units, output_size].
416     hidl_vec<uint32_t> recurrentToForgetWeightsDimensions{numUnits, outputSize};
417     std::vector<float> recurrentToForgetWeightsValue{-0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
418                                                      -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
419                                                      -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
420                                                      -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f};
421     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
422     //     [num_units, output_size].
423     hidl_vec<uint32_t> recurrentToCellWeightsDimensions{numUnits, outputSize};
424     std::vector<float> recurrentToCellWeightsValue{-0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
425                                                    -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
426                                                    0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
427                                                    0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f};
428     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
429     //     [num_units, output_size].
430     hidl_vec<uint32_t> recurrentToOutputWeightsDimensions{numUnits, outputSize};
431     std::vector<float> recurrentToOutputWeightsValue{-0.32921677827f, 0.32624614238f, -0.1388191282f,
432                                                      -0.17879831790f, -0.15185534954f, -0.16918526583f,
433                                                      -0.10087361183f, -0.5436913968f, 0.016758225858f,
434                                                      0.30454617738f, -0.41493862867f, -0.005565764375f,
435                                                      -0.12584099173f, -0.12319286912f, 0.2407919466f,
436                                                      -0.08879069983f};
437     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
438     hidl_vec<uint32_t> cellToInputWeightsDimensions{0};
439     std::vector<float> cellToInputWeightsValue;
440     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
441     hidl_vec<uint32_t> cellToForgetWeightsDimensions{0};
442     std::vector<float> cellToForgetWeightsValue;
443     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
444     hidl_vec<uint32_t> cellToOutputWeightsDimensions{0};
445     std::vector<float> cellToOutputWeightsValue;
446     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
447     hidl_vec<uint32_t> inputGateBiasDimensions{numUnits};
448     std::vector<float> inputGateBiasValue(numUnits, 0.0f);
449     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
450     hidl_vec<uint32_t> forgetGateBiasDimensions{numUnits};
451     std::vector<float> forgetGateBiasValue(numUnits, 1.0f);
452     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
453     hidl_vec<uint32_t> cellBiasDimensions{numUnits};
454     std::vector<float> cellBiasValue(numUnits, 0.0f);
455     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
456     hidl_vec<uint32_t> outputGateBiasDimensions{numUnits};
457     std::vector<float> outputGateBiasValue(numUnits, 0.0f);
458     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
459     //     [output_size, num_units].
460     hidl_vec<uint32_t> projectionWeightsDimensions{0};
461     std::vector<float> projectionWeightsValue;
462     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
463     hidl_vec<uint32_t> projectionBiasDimensions{0};
464     std::vector<float> projectionBiasValue;
465 
466     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
467     hidl_vec<uint32_t> outputStateInDimensions{batchSize, outputSize};
468     std::vector<float> outputStateInValue(batchSize * outputSize, 0.0f);
469     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
470     hidl_vec<uint32_t> cellStateInDimensions{batchSize, numUnits};
471     std::vector<float> cellStateInValue(batchSize * numUnits, 0.0f);
472 
473     // Constant scalar values (the VTS test adds these as tensors of dim {})
474     // 20: The activation function: A value indicating the activation function:
475     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
476     hidl_vec<uint32_t>   activationFunctionDimensions{};
477     std::vector<int32_t> activationFunctionValue{4};
478     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
479     //     If set to 0.0 then clipping is disabled.
480     hidl_vec<uint32_t>   cellClippingThresholdDimensions{};
481     std::vector<float>   cellClippingThresholdValue{10.0f};
482     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
483     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
484     hidl_vec<uint32_t>   projectionClippingThresholdDimensions{};
485     std::vector<float>   projectionClippingThresholdValue{0.f};
486 
487     // 23: Time-major if true, batch-major if false.
488     bool timeMajorValue = false;
489 
490     // Normalization:
491     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
492     //    Used to rescale normalized inputs to activation at input gate.
493     hidl_vec<uint32_t> inputLayerNormWeightsDimensions{0};
494     std::vector<float> inputLayerNormWeightsValue;
495     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
496     //    Used to rescale normalized inputs to activation at forget gate.
497     hidl_vec<uint32_t> forgetLayerNormWeightsDimensions{0};
498     std::vector<float> forgetLayerNormWeightsValue;
499     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
500     //    Used to rescale normalized inputs to activation at cell gate.
501     hidl_vec<uint32_t> cellLayerNormWeightsDimensions{0};
502     std::vector<float> cellLayerNormWeightsValue;
503     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
504     //    Used to rescale normalized inputs to activation at output gate.
505     hidl_vec<uint32_t> outputLayerNormWeightsDimensions{0};
506     std::vector<float> outputLayerNormWeightsValue;
507 
508     // Outputs:
509     // 0: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
510     //    [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
511     hidl_vec<uint32_t> outputDimensions{batchSize, timeSize, outputSize};
512     std::vector<float> outputValue{-0.07149004f, -0.1621171f, -0.17516759f, -0.0232934225f,
513                                    -0.16810727f, -0.41412935f, -0.5498753f, -0.00803578f,
514                                    -0.06687349f, 0.204077631f, -0.4276504f, -0.03123213f,
515                                    -0.12000261f, -0.0941918f, -0.45639035f, -0.02870186f,
516                                    -0.03429216f, 0.20824050f, -0.6569892f, -0.004152651f,
517                                    -0.10493034f, 0.14210969f, -0.58347696f, -0.03297536f};
518 
519     // 1: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
520     //    [batch_size, output_size]. This output is optional and can be omitted. If this output
521     //    is present then output #2 must be present as well.
522     hidl_vec<uint32_t> hiddenStateOutDimensions{batchSize, outputSize};
523     std::vector<float> hiddenStateOutValue(batchSize * outputSize, 0.f);
524     // 2: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
525     //    [batch_size, num_units]. This output is optional and can be omitted.
526     hidl_vec<uint32_t> cellStateOutDimensions{batchSize, numUnits};
527     std::vector<float> cellStateOutValue(batchSize * numUnits, 0.f);
528 
529     UnidirectionalSequenceLstmTestImpl<HalPolicy>(inputDimensions, inputValue,
530                                                   inputToInputWeightsDimensions, inputToInputWeightsValue,
531                                                   inputToForgetWeightsDimensions, inputToForgetWeightsValue,
532                                                   inputToCellWeightsDimensions, inputToCellWeightsValue,
533                                                   inputToOutputWeightsDimensions, inputToOutputWeightsValue,
534                                                   recurrentToInputWeightsDimensions, recurrentToInputWeightsValue,
535                                                   recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue,
536                                                   recurrentToCellWeightsDimensions, recurrentToCellWeightsValue,
537                                                   recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue,
538                                                   cellToInputWeightsDimensions, cellToInputWeightsValue,
539                                                   cellToForgetWeightsDimensions, cellToForgetWeightsValue,
540                                                   cellToOutputWeightsDimensions, cellToOutputWeightsValue,
541                                                   inputGateBiasDimensions, inputGateBiasValue,
542                                                   forgetGateBiasDimensions, forgetGateBiasValue,
543                                                   cellBiasDimensions, cellBiasValue,
544                                                   outputGateBiasDimensions, outputGateBiasValue,
545                                                   projectionWeightsDimensions, projectionWeightsValue,
546                                                   projectionBiasDimensions, projectionBiasValue,
547                                                   outputStateInDimensions, outputStateInValue,
548                                                   cellStateInDimensions, cellStateInValue,
549                                                   activationFunctionDimensions, activationFunctionValue,
550                                                   cellClippingThresholdDimensions, cellClippingThresholdValue,
551                                                   projectionClippingThresholdDimensions,
552                                                   projectionClippingThresholdValue,
553                                                   timeMajorValue,
554                                                   inputLayerNormWeightsDimensions, inputLayerNormWeightsValue,
555                                                   forgetLayerNormWeightsDimensions, forgetLayerNormWeightsValue,
556                                                   cellLayerNormWeightsDimensions, cellLayerNormWeightsValue,
557                                                   outputLayerNormWeightsDimensions, outputLayerNormWeightsValue,
558                                                   outputDimensions, outputValue,
559                                                   hiddenStateOutDimensions, hiddenStateOutValue,
560                                                   cellStateOutDimensions, cellStateOutValue,
561                                                   compute);
562 }
563 
564 template<typename HalPolicy>
UnidirectionalSequenceLstmLayerFloat32TimeMajorTestImpl(armnn::Compute compute)565 void UnidirectionalSequenceLstmLayerFloat32TimeMajorTestImpl(armnn::Compute compute)
566 {
567     uint32_t batchSize  = 3;
568     uint32_t timeSize   = 2;
569     uint32_t inputSize  = 3;
570     uint32_t outputSize = 4;
571     uint32_t numUnits   = outputSize;
572 
573     // Inputs:
574     // 00: The input: A 3-D tensor of shape: If time-major: [max_time, batch_size, input_size] If batch-major:
575     //     [batch_size, max_time, input_size] where “max_time” is the number of timesteps (sequence length),
576     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
577     hidl_vec<uint32_t> inputDimensions{timeSize, batchSize, inputSize};
578     std::vector<float> inputValue{1., 2., 3., 4., 5., 4.,
579                                   3., 2., 1., 2., 3., 4.,
580                                   5., 4., 3., 2., 1., 2.};
581 
582     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
583     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
584     hidl_vec<uint32_t> inputToInputWeightsDimensions{numUnits, inputSize};
585     std::vector<float> inputToInputWeightsValue{0.27277296781539917f, 0.3813590407371521f, -0.394489049911499f,
586                                                 0.2782636880874634f, -0.3793870210647583f, -0.018918335437774658f,
587                                                 0.2724653482437134f, -0.19314253330230713f, -0.2947450876235962f,
588                                                 -0.30253493785858154f, 0.4241350293159485f, -0.22560018301010132f};
589     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
590     //     [num_units, input_size].
591     hidl_vec<uint32_t> inputToForgetWeightsDimensions{numUnits, inputSize};
592     std::vector<float> inputToForgetWeightsValue{-0.2667974531650543f, -0.05505800247192383f, -0.20932340621948242f,
593                                                  -0.14345619082450867f, 0.09666192531585693f, -0.2604355812072754f,
594                                                  -0.2681812047958374f, -0.3314584493637085f, 0.4485899806022644f,
595                                                  -0.23467743396759033f, 0.5072842240333557f, -0.4192768931388855f};
596     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units, input_size].
597     hidl_vec<uint32_t> inputToCellWeightsDimensions{numUnits, inputSize};
598     std::vector<float> inputToCellWeightsValue{-0.15782442688941956f, -0.027530014514923096f, 0.4789854884147644f,
599                                                0.23227906227111816f, 0.28259342908859253f, -0.030095696449279785f,
600                                                0.10071521997451782f, -0.08535495400428772f, 0.18563997745513916f,
601                                                -0.3049069046974182f, -0.478048175573349f, 0.025234103202819824f};
602     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
603     //     [num_units, input_size].
604     hidl_vec<uint32_t> inputToOutputWeightsDimensions{numUnits, inputSize};
605     std::vector<float> inputToOutputWeightsValue{-0.04584759473800659f, -0.2716066539287567f, 0.012970447540283203f,
606                                                  -0.4729190170764923f, -0.37422770261764526f, 0.49352723360061646f,
607                                                  0.3163864016532898f, -0.436781644821167f, -0.33074596524238586f,
608                                                  -0.32885751128196716f, -0.40959352254867554f, -0.2124689817428589f};
609     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
610     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
611     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
612     hidl_vec<uint32_t> recurrentToInputWeightsDimensions{numUnits, outputSize};
613     std::vector<float> recurrentToInputWeightsValue{0.23788475990f, -0.24948765337f, 0.50044941902f,
614                                                     0.14431896805f, -0.115940228137f, -0.717082679f,
615                                                     -0.17208620906f, 0.17850610617f, -0.16702319684f,
616                                                     -0.11384502053f, -0.309785276245f, -0.3316611672f,
617                                                     0.52380162477f, -0.06839632987f, -0.391478359627f,
618                                                     -0.10756178963f};
619     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
620     //     [num_units, output_size].
621     hidl_vec<uint32_t> recurrentToForgetWeightsDimensions{numUnits, outputSize};
622     std::vector<float> recurrentToForgetWeightsValue{0.11383482068f, 0.1676601767f, -0.08550968004f, 0.03399394089f,
623                                                      0.08042152225f, -0.2133381964f, 0.05182432704f, 0.38161808255f,
624                                                      -0.5018365979f, -0.08043262364f, 0.07894329014f, -0.07547105155f,
625                                                      0.12047368288f, 0.2986997961f, 0.0485043078f, -0.13372567296f};
626     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
627     //     [num_units, output_size].
628     hidl_vec<uint32_t> recurrentToCellWeightsDimensions{numUnits, outputSize};
629     std::vector<float> recurrentToCellWeightsValue{0.0433832928545f, 0.07587072294f, -0.120520234107f, 0.604576051f,
630                                                    -0.434353142986f, 0.009314475068f, 0.005085289478f, 0.08488202038f,
631                                                    -0.00025437487886f, 0.15245915082f, -0.1936587542f, 0.004754020f,
632                                                    -0.1582719236f, 0.3307867646f, 0.0236605107784f, 0.307716339826f};
633     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
634     //     [num_units, output_size].
635     hidl_vec<uint32_t> recurrentToOutputWeightsDimensions{numUnits, outputSize};
636     std::vector<float> recurrentToOutputWeightsValue{-0.079031050201f, 0.041414566286f, -0.583727357285f,
637                                                      0.1025384515f, -0.172372072937f, 0.09214124082f,
638                                                      0.178184121827f, -0.2439443916f, 0.104485116899f,
639                                                      0.2600405514f, 0.064414866268f, 0.24141204357f,
640                                                      0.281875759363f, -0.14234502664f, 0.15126448862f,
641                                                      -0.24421440064f};
642     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
643     hidl_vec<uint32_t> cellToInputWeightsDimensions{0};
644     std::vector<float> cellToInputWeightsValue;
645     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
646     hidl_vec<uint32_t> cellToForgetWeightsDimensions{0};
647     std::vector<float> cellToForgetWeightsValue;
648     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
649     hidl_vec<uint32_t> cellToOutputWeightsDimensions{0};
650     std::vector<float> cellToOutputWeightsValue;
651     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
652     hidl_vec<uint32_t> inputGateBiasDimensions{numUnits};
653     std::vector<float> inputGateBiasValue(numUnits, 0.0f);
654     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
655     hidl_vec<uint32_t> forgetGateBiasDimensions{numUnits};
656     std::vector<float> forgetGateBiasValue(numUnits, 1.0f);
657     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
658     hidl_vec<uint32_t> cellBiasDimensions{numUnits};
659     std::vector<float> cellBiasValue(numUnits, 0.0f);
660     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
661     hidl_vec<uint32_t> outputGateBiasDimensions{numUnits};
662     std::vector<float> outputGateBiasValue(numUnits, 0.0f);
663     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
664     //     [output_size, num_units].
665     hidl_vec<uint32_t> projectionWeightsDimensions{0};
666     std::vector<float> projectionWeightsValue;
667     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
668     hidl_vec<uint32_t> projectionBiasDimensions{0};
669     std::vector<float> projectionBiasValue;
670 
671     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
672     hidl_vec<uint32_t> outputStateInDimensions{batchSize, outputSize};
673     std::vector<float> outputStateInValue(batchSize * outputSize, 0.0f);
674     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
675     hidl_vec<uint32_t> cellStateInDimensions{batchSize, numUnits};
676     std::vector<float> cellStateInValue(batchSize * numUnits, 0.0f);
677 
678     // Constant scalar values (the VTS test adds these as tensors of dim {})
679     // 20: The activation function: A value indicating the activation function:
680     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
681     hidl_vec<uint32_t>   activationFunctionDimensions{};
682     std::vector<int32_t> activationFunctionValue{4};
683     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
684     //     If set to 0.0 then clipping is disabled.
685     hidl_vec<uint32_t>   cellClippingThresholdDimensions{};
686     std::vector<float>   cellClippingThresholdValue{10.0f};
687     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
688     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
689     hidl_vec<uint32_t>   projectionClippingThresholdDimensions{};
690     std::vector<float>   projectionClippingThresholdValue{0.f};
691 
692     // 23: Time-major if true, batch-major if false.
693     bool timeMajorValue = true;
694 
695     // Normalization:
696     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
697     //    Used to rescale normalized inputs to activation at input gate.
698     hidl_vec<uint32_t> inputLayerNormWeightsDimensions{0};
699     std::vector<float> inputLayerNormWeightsValue;
700     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
701     //    Used to rescale normalized inputs to activation at forget gate.
702     hidl_vec<uint32_t> forgetLayerNormWeightsDimensions{0};
703     std::vector<float> forgetLayerNormWeightsValue;
704     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
705     //    Used to rescale normalized inputs to activation at cell gate.
706     hidl_vec<uint32_t> cellLayerNormWeightsDimensions{0};
707     std::vector<float> cellLayerNormWeightsValue;
708     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
709     //    Used to rescale normalized inputs to activation at output gate.
710     hidl_vec<uint32_t> outputLayerNormWeightsDimensions{0};
711     std::vector<float> outputLayerNormWeightsValue;
712 
713     // Outputs:
714     // 0: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
715     //    [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
716     hidl_vec<uint32_t> outputDimensions{timeSize, batchSize, outputSize};
717     std::vector<float> outputValue{0.135657698f, 0.124672532f, 0.0212090332f, -0.0530203655f,
718                                    0.106138252f, 0.0404792242f, 0.0151643595f, -0.00675163185f,
719                                    -0.0128514022f, 0.0644884035f, 0.0709072053f, -0.0454045124f,
720                                    0.16288602f,  0.16649379f,  0.02770456f, -0.03698075f,
721                                    0.11171641f,  0.043119f  ,  0.0762981f , -0.01228541f,
722                                    0.10439701f,  0.21439962f,  0.11919238f, -0.08390583f};
723 
724     // 1: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
725     //    [batch_size, output_size]. This output is optional and can be omitted. If this output
726     //    is present then output #2 must be present as well.
727     hidl_vec<uint32_t> hiddenStateOutDimensions{batchSize, outputSize};
728     std::vector<float> hiddenStateOutValue(batchSize * outputSize, 0.f);
729     // 2: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
730     //    [batch_size, num_units]. This output is optional and can be omitted.
731     hidl_vec<uint32_t> cellStateOutDimensions{batchSize, numUnits};
732     std::vector<float> cellStateOutValue(batchSize * numUnits, 0.f);
733 
734     UnidirectionalSequenceLstmTestImpl<HalPolicy>(inputDimensions, inputValue,
735                                                   inputToInputWeightsDimensions, inputToInputWeightsValue,
736                                                   inputToForgetWeightsDimensions, inputToForgetWeightsValue,
737                                                   inputToCellWeightsDimensions, inputToCellWeightsValue,
738                                                   inputToOutputWeightsDimensions, inputToOutputWeightsValue,
739                                                   recurrentToInputWeightsDimensions, recurrentToInputWeightsValue,
740                                                   recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue,
741                                                   recurrentToCellWeightsDimensions, recurrentToCellWeightsValue,
742                                                   recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue,
743                                                   cellToInputWeightsDimensions, cellToInputWeightsValue,
744                                                   cellToForgetWeightsDimensions, cellToForgetWeightsValue,
745                                                   cellToOutputWeightsDimensions, cellToOutputWeightsValue,
746                                                   inputGateBiasDimensions, inputGateBiasValue,
747                                                   forgetGateBiasDimensions, forgetGateBiasValue,
748                                                   cellBiasDimensions, cellBiasValue,
749                                                   outputGateBiasDimensions, outputGateBiasValue,
750                                                   projectionWeightsDimensions, projectionWeightsValue,
751                                                   projectionBiasDimensions, projectionBiasValue,
752                                                   outputStateInDimensions, outputStateInValue,
753                                                   cellStateInDimensions, cellStateInValue,
754                                                   activationFunctionDimensions, activationFunctionValue,
755                                                   cellClippingThresholdDimensions, cellClippingThresholdValue,
756                                                   projectionClippingThresholdDimensions,
757                                                   projectionClippingThresholdValue,
758                                                   timeMajorValue,
759                                                   inputLayerNormWeightsDimensions, inputLayerNormWeightsValue,
760                                                   forgetLayerNormWeightsDimensions, forgetLayerNormWeightsValue,
761                                                   cellLayerNormWeightsDimensions, cellLayerNormWeightsValue,
762                                                   outputLayerNormWeightsDimensions, outputLayerNormWeightsValue,
763                                                   outputDimensions, outputValue,
764                                                   hiddenStateOutDimensions, hiddenStateOutValue,
765                                                   cellStateOutDimensions, cellStateOutValue,
766                                                   compute);
767 }
768 
769 template<typename HalPolicy>
UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionTestImpl(armnn::Compute compute)770 void UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionTestImpl(armnn::Compute compute)
771 {
772     uint32_t batchSize  = 2;
773     uint32_t timeSize   = 3;
774     uint32_t inputSize  = 4;
775     uint32_t outputSize = 5;
776     uint32_t numUnits   = 6;
777 
778     // Inputs:
779     // 00: The input: A 3-D tensor of shape: If time-major: [max_time, batch_size, input_size] If batch-major:
780     //     [batch_size, max_time, input_size] where “max_time” is the number of timesteps (sequence length),
781     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
782     hidl_vec<uint32_t> inputDimensions{batchSize, timeSize, inputSize};
783     std::vector<float> inputValue{1., 2., 3., 4., 5., 4.,
784                                   3., 2., 1., 2., 3., 4.,
785                                   5., 4., 3., 2., 1., 2.,
786                                   1., 2., 3., 4., 5., 4.};
787 
788     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
789     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
790     hidl_vec<uint32_t> inputToInputWeightsDimensions{numUnits, inputSize};
791     std::vector<float> inputToInputWeightsValue{0.021393683f, 0.06124551f, 0.046905167f, -0.014657677f,
792                                                 -0.03149463f, 0.09171803f, 0.14647801f, 0.10797193f,
793                                                 -0.0057968358f, 0.0019193048f, -0.2726754f, 0.10154029f,
794                                                 -0.018539885f, 0.080349885f, -0.10262385f, -0.022599787f,
795                                                 -0.09121155f, -0.008675967f, -0.045206103f, -0.0821282f,
796                                                 -0.008045952f, 0.015478081f, 0.055217247f, 0.038719587f};
797     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
798     //     [num_units, input_size].
799     hidl_vec<uint32_t> inputToForgetWeightsDimensions{numUnits, inputSize};
800     std::vector<float> inputToForgetWeightsValue{-0.0018401089f, -0.004852237f, 0.03698424f, 0.014181704f,
801                                                  0.028273236f, -0.016726194f, -0.05249759f, -0.10204261f,
802                                                  0.00861066f, -0.040979505f, -0.009899187f, 0.01923892f,
803                                                  -0.028177269f, -0.08535103f, -0.14585495f, 0.10662567f,
804                                                  -0.01909731f, -0.017883534f, -0.0047269356f, -0.045103323f,
805                                                  0.0030784295f, 0.076784775f, 0.07463696f, 0.094531395f};
806     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units, input_size].
807     hidl_vec<uint32_t> inputToCellWeightsDimensions{numUnits, inputSize};
808     std::vector<float> inputToCellWeightsValue{-0.04580283f, -0.09549462f, -0.032418985f, -0.06454633f,
809                                                -0.043528453f, 0.043018587f, -0.049152344f, -0.12418144f,
810                                                -0.078985475f, -0.07596889f, 0.019484362f, -0.11434962f,
811                                                -0.0074034138f, -0.06314844f, -0.092981495f, 0.0062155537f,
812                                                -0.025034338f, -0.0028890965f, 0.048929527f, 0.06235075f,
813                                                0.10665918f, -0.032036792f, -0.08505916f, -0.10843358f};
814     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
815     //     [num_units, input_size].
816     hidl_vec<uint32_t> inputToOutputWeightsDimensions{numUnits, inputSize};
817     std::vector<float> inputToOutputWeightsValue{-0.0998932f, -0.07201956f, -0.052803773f, -0.15629593f,
818                                                  -0.15001918f, -0.07650751f, 0.02359855f, -0.075155355f,
819                                                  -0.08037709f, -0.15093534f, 0.029517552f, -0.04751393f,
820                                                  0.010350531f, -0.02664851f, -0.016839722f, -0.023121163f,
821                                                  0.0077019283f, 0.012851257f, -0.05040649f, -0.0129761f,
822                                                  -0.021737747f, -0.038305793f, -0.06870586f, -0.01481247f};
823     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
824     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
825     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
826     hidl_vec<uint32_t> recurrentToInputWeightsDimensions{numUnits, outputSize};
827     std::vector<float> recurrentToInputWeightsValue{-0.001374326f, -0.078856036f, 0.10672688f, 0.029162422f,
828                                                     -0.11585556f, 0.02557986f, -0.13446963f, -0.035785314f,
829                                                     -0.01244275f, 0.025961924f, -0.02337298f, -0.044228926f,
830                                                     -0.055839065f, -0.046598054f, -0.010546039f, -0.06900766f,
831                                                     0.027239809f, 0.022582639f, -0.013296484f, -0.05459212f,
832                                                     0.08981f, -0.045407712f, 0.08682226f, -0.06867011f,
833                                                     -0.14390695f, -0.02916037f, 0.000996957f, 0.091420636f,
834                                                     0.14283475f, -0.07390571f};
835     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
836     //     [num_units, output_size].
837     hidl_vec<uint32_t> recurrentToForgetWeightsDimensions{numUnits, outputSize};
838     std::vector<float> recurrentToForgetWeightsValue{-0.057784554f, -0.026057621f, -0.068447545f, -0.022581743f,
839                                                      0.14811787f, 0.10826372f, 0.09471067f, 0.03987225f,
840                                                      -0.0039523416f, 0.00030638507f, 0.053185795f, 0.10572994f,
841                                                      0.08414449f, -0.022036452f, -0.00066928595f, -0.09203576f,
842                                                      0.032950465f, -0.10985798f, -0.023809856f, 0.0021431844f,
843                                                      -0.02196096f, -0.00326074f, 0.00058621005f, -0.074678116f,
844                                                      -0.06193199f, 0.055729095f, 0.03736828f, 0.020123724f,
845                                                      0.061878487f, -0.04729229f};
846     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
847     //     [num_units, output_size].
848     hidl_vec<uint32_t> recurrentToCellWeightsDimensions{numUnits, outputSize};
849     std::vector<float> recurrentToCellWeightsValue{-0.037322544f, 0.018592842f, 0.0056175636f, -0.06253426f,
850                                                    0.055647098f, -0.05713207f, -0.05626563f, 0.005559383f,
851                                                    0.03375411f, -0.025757805f, -0.088049285f, 0.06017052f,
852                                                    -0.06570978f, 0.007384076f, 0.035123326f, -0.07920549f,
853                                                    0.053676967f, 0.044480428f, -0.07663568f, 0.0071805613f,
854                                                    0.08089997f, 0.05143358f, 0.038261272f, 0.03339287f,
855                                                    -0.027673481f, 0.044746667f, 0.028349208f, 0.020090483f,
856                                                    -0.019443132f, -0.030755889f};
857     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
858     //     [num_units, output_size].
859     hidl_vec<uint32_t> recurrentToOutputWeightsDimensions{numUnits, outputSize};
860     std::vector<float> recurrentToOutputWeightsValue{0.025825322f, -0.05813119f, 0.09495884f,
861                                                      -0.045984812f,-0.01255415f, -0.0026479573f,
862                                                      -0.08196161f, -0.054914974f, -0.0046604523f,
863                                                      -0.029587349f, -0.044576716f, -0.07480124f,
864                                                      -0.082868785f, 0.023254942f, 0.027502948f,
865                                                      -0.0039728214f, -0.08683098f, -0.08116779f,
866                                                      -0.014675607f, -0.037924774f, -0.023314456f,
867                                                      -0.007401714f, -0.09255757f, 0.029460307f,
868                                                      -0.08829125f, -0.005139627f, -0.08989442f,
869                                                      -0.0555066f, 0.13596267f, 0.025062224f};
870     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
871     hidl_vec<uint32_t> cellToInputWeightsDimensions{numUnits};
872     std::vector<float> cellToInputWeightsValue{0.040369894f, 0.030746894f, 0.24704495f,
873                                                0.018586371f, -0.037586458f, -0.15312155f};
874     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
875     hidl_vec<uint32_t> cellToForgetWeightsDimensions{numUnits};
876     std::vector<float> cellToForgetWeightsValue{-0.01998659f, -0.15568835f, -0.24248174f,
877                                                 -0.012770197f, 0.041331276f, -0.072311886f};
878     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
879     hidl_vec<uint32_t> cellToOutputWeightsDimensions{numUnits};
880     std::vector<float> cellToOutputWeightsValue{0.08286371f, -0.08261836f, -0.51210177f,
881                                                 0.002913762f, 0.17764764f, -0.5495371f};
882     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
883     hidl_vec<uint32_t> inputGateBiasDimensions{numUnits};
884     std::vector<float> inputGateBiasValue{0.02234832f, 0.14757581f, 0.18176508f,
885                                           0.10380666f, 0.053110216f, -0.06928846f};
886     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
887     hidl_vec<uint32_t> forgetGateBiasDimensions{numUnits};
888     std::vector<float> forgetGateBiasValue{0.035185695f, -0.042891346f, -0.03032477f,
889                                            0.23027696f, 0.11098921f, 0.08989442f};
890     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
891     hidl_vec<uint32_t> cellBiasDimensions{numUnits};
892     std::vector<float> cellBiasValue{-0.024379363f, 0.0055531194f, 0.23377132f,
893                                      0.033463873f, -0.1483596f, 0.029460307f};
894     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
895     hidl_vec<uint32_t> outputGateBiasDimensions{numUnits};
896     std::vector<float> outputGateBiasValue{0.046159424f, -0.0012809046f, 0.03563469f,
897                                            0.12648113f, 0.027195795f, 0.35373217f};
898     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
899     //     [output_size, num_units].
900     hidl_vec<uint32_t> projectionWeightsDimensions{numUnits, outputSize};
901     std::vector<float> projectionWeightsValue{-0.009802181f, 0.09401916f, 0.0717386f, -0.13895074f, 0.09641832f,
902                                               0.060420845f, 0.08539281f, 0.054285463f, 0.061395317f, 0.034448683f,
903                                               -0.042991187f, 0.019801661f, -0.16840284f, -0.015726732f, -0.23041931f,
904                                               -0.024478018f, -0.10959692f, -0.013875541f, 0.18600968f, -0.061274476f,
905                                               0.0138165f, -0.08160894f, -0.07661644f, 0.032372914f, 0.16169067f,
906                                               0.22465782f, -0.03993472f, -0.004017731f, 0.08633481f, -0.28869787f};
907     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
908     hidl_vec<uint32_t> projectionBiasDimensions{outputSize};
909     std::vector<float> projectionBiasValue(outputSize, 0.f);
910 
911     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
912     hidl_vec<uint32_t> outputStateInDimensions{batchSize, outputSize};
913     std::vector<float> outputStateInValue(batchSize * outputSize, 0.f);
914     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
915     hidl_vec<uint32_t> cellStateInDimensions{batchSize, numUnits};
916     std::vector<float> cellStateInValue(batchSize * numUnits, 0.f);
917 
918     // Constant scalar values (the VTS test adds these as tensors of dim {})
919     // 20: The activation function: A value indicating the activation function:
920     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
921     hidl_vec<uint32_t>   activationFunctionDimensions{};
922     std::vector<int32_t> activationFunctionValue{4};
923     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
924     //     If set to 0.0 then clipping is disabled.
925     hidl_vec<uint32_t>   cellClippingThresholdDimensions{};
926     std::vector<float>   cellClippingThresholdValue{10.0f};
927     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
928     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
929     hidl_vec<uint32_t>   projectionClippingThresholdDimensions{};
930     std::vector<float>   projectionClippingThresholdValue{0.f};
931 
932     // 23: Time-major if true, batch-major if false.
933     bool timeMajorValue = false;
934 
935     // Normalization:
936     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
937     //    Used to rescale normalized inputs to activation at input gate.
938     hidl_vec<uint32_t> inputLayerNormWeightsDimensions{0};
939     std::vector<float> inputLayerNormWeightsValue;
940     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
941     //    Used to rescale normalized inputs to activation at forget gate.
942     hidl_vec<uint32_t> forgetLayerNormWeightsDimensions{0};
943     std::vector<float> forgetLayerNormWeightsValue;
944     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
945     //    Used to rescale normalized inputs to activation at cell gate.
946     hidl_vec<uint32_t> cellLayerNormWeightsDimensions{0};
947     std::vector<float> cellLayerNormWeightsValue;
948     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
949     //    Used to rescale normalized inputs to activation at output gate.
950     hidl_vec<uint32_t> outputLayerNormWeightsDimensions{0};
951     std::vector<float> outputLayerNormWeightsValue;
952 
953     // Outputs:
954     // 0: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
955     //    [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
956     hidl_vec<uint32_t> outputDimensions{batchSize, timeSize, outputSize};
957     std::vector<float> outputValue{-0.0135612f, -0.0263441f, 0.0314008f, -0.00883455f, 0.00763052f,
958                                    -0.00126877f, -0.0292959f, 0.0449957f, -0.00976195f, -0.00492338f,
959                                    -0.0175702f, -0.0431753f, 0.0597117f, -0.0169154f, 0.0142087f,
960                                    0.00472515f, -0.0196355f, 0.0342524f, -0.00407936f, -0.0253189f,
961                                    -0.00512944f, -0.0293754f, 0.0512771f, -0.0151874f, -0.0246433f,
962                                    -0.00744986f, -0.0345103f, 0.0450666f, -0.00944991f, 0.0127171f};
963 
964     // 1: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
965     //    [batch_size, output_size]. This output is optional and can be omitted. If this output
966     //    is present then output #2 must be present as well.
967     hidl_vec<uint32_t> hiddenStateOutDimensions{batchSize, outputSize};
968     std::vector<float> hiddenStateOutValue(batchSize * outputSize, 0.f);
969     // 2: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
970     //    [batch_size, num_units]. This output is optional and can be omitted.
971     hidl_vec<uint32_t> cellStateOutDimensions{batchSize, numUnits};
972     std::vector<float> cellStateOutValue(batchSize * numUnits, 0.f);
973 
974     UnidirectionalSequenceLstmTestImpl<HalPolicy>(inputDimensions, inputValue,
975                                                   inputToInputWeightsDimensions, inputToInputWeightsValue,
976                                                   inputToForgetWeightsDimensions, inputToForgetWeightsValue,
977                                                   inputToCellWeightsDimensions, inputToCellWeightsValue,
978                                                   inputToOutputWeightsDimensions, inputToOutputWeightsValue,
979                                                   recurrentToInputWeightsDimensions, recurrentToInputWeightsValue,
980                                                   recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue,
981                                                   recurrentToCellWeightsDimensions, recurrentToCellWeightsValue,
982                                                   recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue,
983                                                   cellToInputWeightsDimensions, cellToInputWeightsValue,
984                                                   cellToForgetWeightsDimensions, cellToForgetWeightsValue,
985                                                   cellToOutputWeightsDimensions, cellToOutputWeightsValue,
986                                                   inputGateBiasDimensions, inputGateBiasValue,
987                                                   forgetGateBiasDimensions, forgetGateBiasValue,
988                                                   cellBiasDimensions, cellBiasValue,
989                                                   outputGateBiasDimensions, outputGateBiasValue,
990                                                   projectionWeightsDimensions, projectionWeightsValue,
991                                                   projectionBiasDimensions, projectionBiasValue,
992                                                   outputStateInDimensions, outputStateInValue,
993                                                   cellStateInDimensions, cellStateInValue,
994                                                   activationFunctionDimensions, activationFunctionValue,
995                                                   cellClippingThresholdDimensions, cellClippingThresholdValue,
996                                                   projectionClippingThresholdDimensions,
997                                                   projectionClippingThresholdValue,
998                                                   timeMajorValue,
999                                                   inputLayerNormWeightsDimensions, inputLayerNormWeightsValue,
1000                                                   forgetLayerNormWeightsDimensions, forgetLayerNormWeightsValue,
1001                                                   cellLayerNormWeightsDimensions, cellLayerNormWeightsValue,
1002                                                   outputLayerNormWeightsDimensions, outputLayerNormWeightsValue,
1003                                                   outputDimensions, outputValue,
1004                                                   hiddenStateOutDimensions, hiddenStateOutValue,
1005                                                   cellStateOutDimensions, cellStateOutValue,
1006                                                   compute, 0.0031454);
1007 }
1008 
1009 template<typename HalPolicy>
UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionWithLayerNormTestImpl(armnn::Compute compute)1010 void UnidirectionalSequenceLstmLayerNoCifgWithPeepholeWithProjectionWithLayerNormTestImpl(armnn::Compute compute)
1011 {
1012     uint32_t batchSize  = 3;
1013     uint32_t timeSize   = 2;
1014     uint32_t inputSize  = 3;
1015     uint32_t outputSize = 4;
1016     uint32_t numUnits   = 5;
1017 
1018     // Inputs:
1019     // 00: The input: A 3-D tensor of shape: If time-major: [max_time, batch_size, input_size] If batch-major:
1020     //     [batch_size, max_time, input_size] where “max_time” is the number of timesteps (sequence length),
1021     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
1022     hidl_vec<uint32_t> inputDimensions{batchSize, timeSize, inputSize};
1023     std::vector<float> inputValue{1., 2., 3., 4., 5., 4.,
1024                                   3., 2., 1., 2., 3., 4.,
1025                                   5., 4., 3., 2., 1., 2.};
1026 
1027     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1028     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
1029     hidl_vec<uint32_t> inputToInputWeightsDimensions{numUnits, inputSize};
1030     std::vector<float> inputToInputWeightsValue{-0.49536117f, -0.0556083915f, -0.102400711f,
1031                                                 -0.117484632f, 0.3298470976f, -0.1179017122f,
1032                                                 0.214305695f, 0.42135173085f, 0.003878414626f,
1033                                                 -0.348303917f, -0.1881275477f, 0.0343011027f,
1034                                                 -0.38837709614f, -0.05636804124f, 0.4259087456f};
1035     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1036     //     [num_units, input_size].
1037     hidl_vec<uint32_t> inputToForgetWeightsDimensions{numUnits, inputSize};
1038     std::vector<float> inputToForgetWeightsValue{0.2415594226f, 0.15400093799f, 0.4566498398f,
1039                                                  -0.3810434485f, 0.268383264f, -0.009807467424f,
1040                                                  -0.3522925403f, -0.24275735512f, -0.28344226125f,
1041                                                  0.13512269116f, -0.4932442977f, -0.10039821991f,
1042                                                  0.2726137042f, 0.09216640889f, -0.06551410215f};
1043     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units, input_size].
1044     hidl_vec<uint32_t> inputToCellWeightsDimensions{numUnits, inputSize};
1045     std::vector<float> inputToCellWeightsValue{-0.2504855627f, 0.184490025045f, -0.2480507493f,
1046                                                0.386399507f, -0.259465157985f, -0.16545993089f,
1047                                                -0.4230232555f, 0.341664791103f, -0.18127849691f,
1048                                                -0.2277662414f, -0.55275535589f, 0.34184026718f,
1049                                                0.3954237699f, -0.19407111404f, 0.30412107706f};
1050     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1051     //     [num_units, input_size].
1052     hidl_vec<uint32_t> inputToOutputWeightsDimensions{numUnits, inputSize};
1053     std::vector<float> inputToOutputWeightsValue{0.2303854227f, 0.5218806862f, -0.4865379333f,
1054                                                  0.53969591851f, 0.23393625035f, -0.27140527306f,
1055                                                  0.50009280443f, 0.07511717046f, 0.3998299249f,
1056                                                  -0.51717478049f, 0.1889653282f, -0.367323637f,
1057                                                  -0.12584099173f, -0.12319286912f, 0.2407919466f};
1058     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1059     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
1060     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
1061     hidl_vec<uint32_t> recurrentToInputWeightsDimensions{numUnits, outputSize};
1062     std::vector<float> recurrentToInputWeightsValue{-0.128009796112f, 0.1995525098f, -0.07745539397f, 0.1558421701f,
1063                                                     -0.265254765766f, -0.38837709614f, -0.05636804124f, 0.4259087456f,
1064                                                     0.17628988623f, 0.3877420127f, 0.53300309181f, -0.0959980934f,
1065                                                     0.00302857416f, 0.3266998827f, -0.142509296562f, -0.04433270756f,
1066                                                     0.54066205f, -0.32668582f, -0.43562764f, -0.56094903f};
1067     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1068     //     [num_units, output_size].
1069     hidl_vec<uint32_t> recurrentToForgetWeightsDimensions{numUnits, outputSize};
1070     std::vector<float> recurrentToForgetWeightsValue{-0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
1071                                                      -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
1072                                                      -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
1073                                                      -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f,
1074                                                      0.01841056f, -0.32764608f, -0.33027974f, -0.10826075f};
1075     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1076     //     [num_units, output_size].
1077     hidl_vec<uint32_t> recurrentToCellWeightsDimensions{numUnits, outputSize};
1078     std::vector<float> recurrentToCellWeightsValue{-0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
1079                                                    -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
1080                                                    0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
1081                                                    0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f,
1082                                                    0.19069612f, -0.03026325f, -0.54532051f, 0.33003211f};
1083     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1084     //     [num_units, output_size].
1085     hidl_vec<uint32_t> recurrentToOutputWeightsDimensions{numUnits, outputSize};
1086     std::vector<float> recurrentToOutputWeightsValue{-0.32921677827f, 0.32624614238f, -0.1388191282f,
1087                                                      -0.17879831790f,-0.15185534954f, -0.16918526583f,
1088                                                      -0.10087361183f, -0.5436913968f, 0.016758225858f,
1089                                                      0.30454617738f, -0.41493862867f, -0.005565764375f,
1090                                                      -0.12584099173f, -0.12319286912f, 0.2407919466f,
1091                                                      -0.08879069983f, 0.11178309f, 0.09481031f,
1092                                                      -0.26424935f, 0.46261835f};
1093     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1094     hidl_vec<uint32_t> cellToInputWeightsDimensions{numUnits};
1095     std::vector<float> cellToInputWeightsValue{0.05f, 0.1f, 0.25f, 0.15f, -0.02f};
1096     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1097     hidl_vec<uint32_t> cellToForgetWeightsDimensions{numUnits};
1098     std::vector<float> cellToForgetWeightsValue{-0.02f, -0.15f, -0.25f, -0.03f, 0.15f};
1099     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1100     hidl_vec<uint32_t> cellToOutputWeightsDimensions{numUnits};
1101     std::vector<float> cellToOutputWeightsValue{0.1f, -0.1f, -0.5f, 0.05f, 0.01f};
1102     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1103     hidl_vec<uint32_t> inputGateBiasDimensions{numUnits};
1104     std::vector<float> inputGateBiasValue{0.03f, 0.15f, 0.22f, 0.38f, 0.05f};
1105     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1106     hidl_vec<uint32_t> forgetGateBiasDimensions{numUnits};
1107     std::vector<float> forgetGateBiasValue{0.1f, -0.3f, -0.2f, 0.1f, 0.4f};
1108     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1109     hidl_vec<uint32_t> cellBiasDimensions{numUnits};
1110     std::vector<float> cellBiasValue{-0.05f, 0.72f, 0.25f, 0.08f, 0.1f};
1111     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1112     hidl_vec<uint32_t> outputGateBiasDimensions{numUnits};
1113     std::vector<float> outputGateBiasValue{0.05f, -0.01f, 0.2f, 0.1f, -0.2f};
1114     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1115     //     [output_size, num_units].
1116     hidl_vec<uint32_t> projectionWeightsDimensions{numUnits, outputSize};
1117     std::vector<float> projectionWeightsValue{-0.1f, 0.2f, 0.01f, -0.2f,
1118                                               0.1f, 0.5f,  0.3f, 0.08f,
1119                                               0.07f, 0.2f, -0.4f,  0.2f,
1120                                               0.5f, -0.4f, 0.3f, -0.2f,
1121                                               0.3f, 0.08f, -0.07f, 0.2f};
1122     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
1123     hidl_vec<uint32_t> projectionBiasDimensions{outputSize};
1124     std::vector<float> projectionBiasValue(outputSize, 0.f);
1125 
1126     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
1127     hidl_vec<uint32_t> outputStateInDimensions{batchSize, outputSize};
1128     std::vector<float> outputStateInValue(batchSize * outputSize, 0.f);
1129     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
1130     hidl_vec<uint32_t> cellStateInDimensions{batchSize, numUnits};
1131     std::vector<float> cellStateInValue(batchSize * numUnits, 0.f);
1132 
1133     // Constant scalar values (the VTS test adds these as tensors of dim {})
1134     // 20: The activation function: A value indicating the activation function:
1135     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
1136     hidl_vec<uint32_t>   activationFunctionDimensions{};
1137     std::vector<int32_t> activationFunctionValue{4};
1138     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
1139     //     If set to 0.0 then clipping is disabled.
1140     hidl_vec<uint32_t>   cellClippingThresholdDimensions{};
1141     std::vector<float>   cellClippingThresholdValue{10.0f};
1142     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
1143     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
1144     hidl_vec<uint32_t>   projectionClippingThresholdDimensions{};
1145     std::vector<float>   projectionClippingThresholdValue{0.f};
1146 
1147     // 23: Time-major if true, batch-major if false.
1148     bool timeMajorValue = false;
1149 
1150     // Normalization:
1151     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
1152     //    Used to rescale normalized inputs to activation at input gate.
1153     hidl_vec<uint32_t> inputLayerNormWeightsDimensions{numUnits};
1154     std::vector<float> inputLayerNormWeightsValue{0.1f, 0.2f, 0.3f, 0.5f, 0.8f};
1155     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
1156     //    Used to rescale normalized inputs to activation at forget gate.
1157     hidl_vec<uint32_t> forgetLayerNormWeightsDimensions{numUnits};
1158     std::vector<float> forgetLayerNormWeightsValue{0.1f, 0.2f, 0.3f, 0.5f, 0.2f};
1159     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
1160     //    Used to rescale normalized inputs to activation at cell gate.
1161     hidl_vec<uint32_t> cellLayerNormWeightsDimensions{numUnits};
1162     std::vector<float> cellLayerNormWeightsValue{0.7f, 0.2f, 0.3f, 0.8f, 0.5f};
1163     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
1164     //    Used to rescale normalized inputs to activation at output gate.
1165     hidl_vec<uint32_t> outputLayerNormWeightsDimensions{numUnits};
1166     std::vector<float> outputLayerNormWeightsValue{0.6f, 0.2f, 0.2f, 0.5f, 0.1f};
1167 
1168     // Outputs:
1169     // 0: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
1170     //    [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
1171     hidl_vec<uint32_t> outputDimensions{batchSize, timeSize, outputSize};
1172     std::vector<float> outputValue{0.0642256f, 0.0343966f, 0.184122f, 0.114717f,
1173                                    0.11458f, 0.0407109f, 0.300327f, 0.174301f,
1174                                    0.0864761f, 0.0362912f, 0.178635f, 0.115689f,
1175                                    0.108008f, 0.0386623f, 0.273471f, 0.167115f,
1176                                    0.0859545f, 0.0331481f, 0.186051f, 0.11888f,
1177                                    0.106649f, 0.0276847f, 0.229863f, 0.166958f};
1178 
1179     // 1: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
1180     //    [batch_size, output_size]. This output is optional and can be omitted. If this output
1181     //    is present then output #2 must be present as well.
1182     hidl_vec<uint32_t> hiddenStateOutDimensions{batchSize, outputSize};
1183     std::vector<float> hiddenStateOutValue(batchSize * outputSize, 0.f);
1184     // 2: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
1185     //    [batch_size, num_units]. This output is optional and can be omitted.
1186     hidl_vec<uint32_t> cellStateOutDimensions{batchSize, numUnits};
1187     std::vector<float> cellStateOutValue(batchSize * numUnits, 0.f);
1188 
1189     UnidirectionalSequenceLstmTestImpl<HalPolicy>(inputDimensions, inputValue,
1190                                                   inputToInputWeightsDimensions, inputToInputWeightsValue,
1191                                                   inputToForgetWeightsDimensions, inputToForgetWeightsValue,
1192                                                   inputToCellWeightsDimensions, inputToCellWeightsValue,
1193                                                   inputToOutputWeightsDimensions, inputToOutputWeightsValue,
1194                                                   recurrentToInputWeightsDimensions, recurrentToInputWeightsValue,
1195                                                   recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue,
1196                                                   recurrentToCellWeightsDimensions, recurrentToCellWeightsValue,
1197                                                   recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue,
1198                                                   cellToInputWeightsDimensions, cellToInputWeightsValue,
1199                                                   cellToForgetWeightsDimensions, cellToForgetWeightsValue,
1200                                                   cellToOutputWeightsDimensions, cellToOutputWeightsValue,
1201                                                   inputGateBiasDimensions, inputGateBiasValue,
1202                                                   forgetGateBiasDimensions, forgetGateBiasValue,
1203                                                   cellBiasDimensions, cellBiasValue,
1204                                                   outputGateBiasDimensions, outputGateBiasValue,
1205                                                   projectionWeightsDimensions, projectionWeightsValue,
1206                                                   projectionBiasDimensions, projectionBiasValue,
1207                                                   outputStateInDimensions, outputStateInValue,
1208                                                   cellStateInDimensions, cellStateInValue,
1209                                                   activationFunctionDimensions, activationFunctionValue,
1210                                                   cellClippingThresholdDimensions, cellClippingThresholdValue,
1211                                                   projectionClippingThresholdDimensions,
1212                                                   projectionClippingThresholdValue,
1213                                                   timeMajorValue,
1214                                                   inputLayerNormWeightsDimensions, inputLayerNormWeightsValue,
1215                                                   forgetLayerNormWeightsDimensions, forgetLayerNormWeightsValue,
1216                                                   cellLayerNormWeightsDimensions, cellLayerNormWeightsValue,
1217                                                   outputLayerNormWeightsDimensions, outputLayerNormWeightsValue,
1218                                                   outputDimensions, outputValue,
1219                                                   hiddenStateOutDimensions, hiddenStateOutValue,
1220                                                   cellStateOutDimensions, cellStateOutValue,
1221                                                   compute);
1222 }
1223 
1224 template<typename HalPolicy>
UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTestImpl(armnn::Compute compute)1225 void UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTestImpl(armnn::Compute compute)
1226 {
1227     uint32_t batchSize  = 3;
1228     uint32_t timeSize   = 2;
1229     uint32_t inputSize  = 3;
1230     uint32_t outputSize = 4;
1231     uint32_t numUnits   = outputSize;
1232 
1233     // Inputs:
1234     // 00: The input: A 3-D tensor of shape: If time-major: [max_time, batch_size, input_size] If batch-major:
1235     //     [batch_size, max_time, input_size] where “max_time” is the number of timesteps (sequence length),
1236     //     “batch_size” corresponds to the batching dimension, and “input_size” is the size of the input.
1237     hidl_vec<uint32_t> inputDimensions{batchSize, timeSize, inputSize};
1238     std::vector<float> inputValue{1., 2., 3., 4., 5., 4.,
1239                                   3., 2., 1., 2., 3., 4.,
1240                                   5., 4., 3., 2., 1., 2.};
1241 
1242     // 01: The input-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1243     //     [num_units, input_size], where “num_units” corresponds to the number of cell units.
1244     hidl_vec<uint32_t> inputToInputWeightsDimensions{0};
1245     std::vector<float> inputToInputWeightsValue;
1246     // 02: The input-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1247     //     [num_units, input_size].
1248     hidl_vec<uint32_t> inputToForgetWeightsDimensions{numUnits, inputSize};
1249     std::vector<float> inputToForgetWeightsValue{0.2415594226f, 0.15400093799f, 0.4566498398f,
1250                                                  -0.3810434485f, 0.268383264f, -0.009807467424f,
1251                                                  -0.3522925403f, -0.24275735512f, -0.28344226125f,
1252                                                  0.13512269116f, -0.4932442977f, -0.10039821991f};
1253     // 03: The input-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units, input_size].
1254     hidl_vec<uint32_t> inputToCellWeightsDimensions{numUnits, inputSize};
1255     std::vector<float> inputToCellWeightsValue{-0.2504855627f, 0.184490025045f, -0.2480507493f,
1256                                                0.386399507f, -0.259465157985f, -0.16545993089f,
1257                                                -0.4230232555f, 0.341664791103f, -0.18127849691f,
1258                                                -0.2277662414f, -0.55275535589f, 0.34184026718f};
1259     // 04: The input-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1260     //     [num_units, input_size].
1261     hidl_vec<uint32_t> inputToOutputWeightsDimensions{numUnits, inputSize};
1262     std::vector<float> inputToOutputWeightsValue{0.2303854227f, 0.5218806862f, -0.4865379333f,
1263                                                  0.53969591851f, 0.23393625035f, -0.27140527306f,
1264                                                  0.50009280443f, 0.07511717046f, 0.3998299249f,
1265                                                  -0.51717478049f, 0.1889653282f, -0.367323637f};
1266     // 05: The recurrent-to-input weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1267     //     [num_units, output_size], where “output_size” corresponds to either the number of cell units (i.e.,
1268     //     “num_units”), or the second dimension of the “projection_weights”, if defined.
1269     hidl_vec<uint32_t> recurrentToInputWeightsDimensions{0};
1270     std::vector<float> recurrentToInputWeightsValue;
1271     // 06: The recurrent-to-forget weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1272     //     [num_units, output_size].
1273     hidl_vec<uint32_t> recurrentToForgetWeightsDimensions{numUnits, outputSize};
1274     std::vector<float> recurrentToForgetWeightsValue{-0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
1275                                                      -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
1276                                                      -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
1277                                                      -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f};
1278     // 07: The recurrent-to-cell weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1279     //     [num_units, output_size].
1280     hidl_vec<uint32_t> recurrentToCellWeightsDimensions{numUnits, outputSize};
1281     std::vector<float> recurrentToCellWeightsValue{-0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
1282                                                    -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
1283                                                    0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
1284                                                    0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f};
1285     // 08: The recurrent-to-output weights: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1286     //     [num_units, output_size].
1287     hidl_vec<uint32_t> recurrentToOutputWeightsDimensions{numUnits, outputSize};
1288     std::vector<float> recurrentToOutputWeightsValue{-0.32921677827f, 0.32624614238f, -0.1388191282f,
1289                                                      -0.17879831790f, -0.15185534954f, -0.16918526583f,
1290                                                      -0.10087361183f, -0.5436913968f, 0.016758225858f,
1291                                                      0.30454617738f, -0.41493862867f, -0.005565764375f,
1292                                                      -0.12584099173f, -0.12319286912f, 0.2407919466f,
1293                                                      -0.08879069983f};
1294     // 09: The cell-to-input weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1295     hidl_vec<uint32_t> cellToInputWeightsDimensions{0};
1296     std::vector<float> cellToInputWeightsValue;
1297     // 10: The cell-to-forget weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1298     hidl_vec<uint32_t> cellToForgetWeightsDimensions{numUnits};
1299     std::vector<float> cellToForgetWeightsValue{0.47485286f, -0.51955009f, -0.24458408f, 0.31544167f};
1300     // 11: The cell-to-output weights: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1301     hidl_vec<uint32_t> cellToOutputWeightsDimensions{numUnits};
1302     std::vector<float> cellToOutputWeightsValue{-0.17135078f, 0.82760304f, 0.85573703f, -0.77109635f};
1303     // 12: The input gate bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1304     hidl_vec<uint32_t> inputGateBiasDimensions{0};
1305     std::vector<float> inputGateBiasValue;
1306     // 13: The forget gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1307     hidl_vec<uint32_t> forgetGateBiasDimensions{numUnits};
1308     std::vector<float> forgetGateBiasValue{1., 1., 1., 1.};
1309     // 14: The cell bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1310     hidl_vec<uint32_t> cellBiasDimensions{numUnits};
1311     std::vector<float> cellBiasValue{0., 0., 0., 0.};
1312     // 15: The output gate bias: A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [num_units].
1313     hidl_vec<uint32_t> outputGateBiasDimensions{numUnits};
1314     std::vector<float> outputGateBiasValue{0., 0., 0., 0.};
1315     // 16: The projection weights: Optional. A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape
1316     //     [output_size, num_units].
1317     hidl_vec<uint32_t> projectionWeightsDimensions{0};
1318     std::vector<float> projectionWeightsValue;
1319     // 17: The projection bias: Optional. A 1-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [output_size].
1320     hidl_vec<uint32_t> projectionBiasDimensions{0};
1321     std::vector<float> projectionBiasValue;
1322 
1323     // 18: The output state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, output_size].
1324     hidl_vec<uint32_t> outputStateInDimensions{batchSize, outputSize};
1325     std::vector<float> outputStateInValue(batchSize * outputSize, 0.f);
1326     // 19: The cell state: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32, of shape [batch_size, num_units].
1327     hidl_vec<uint32_t> cellStateInDimensions{batchSize, numUnits};
1328     std::vector<float> cellStateInValue(batchSize * numUnits, 0.f);
1329 
1330     // Constant scalar values (the VTS test adds these as tensors of dim {})
1331     // 20: The activation function: A value indicating the activation function:
1332     //     0: None; 1: Relu; 3: Relu6; 4: Tanh; 6: Sigmoid.
1333     hidl_vec<uint32_t>   activationFunctionDimensions{};
1334     std::vector<int32_t> activationFunctionValue{4};
1335     // 21: The clipping threshold: for the cell state, such that values are bound within [-cell_clip, cell_clip].
1336     //     If set to 0.0 then clipping is disabled.
1337     hidl_vec<uint32_t>   cellClippingThresholdDimensions{};
1338     std::vector<float>   cellClippingThresholdValue{10.0f};
1339     // 22: The clipping threshold: for the output from the projection layer, such that values are bound within
1340     //     [-proj_clip, proj_clip]. If set to 0.0 then clipping is disabled.
1341     hidl_vec<uint32_t>   projectionClippingThresholdDimensions{};
1342     std::vector<float>   projectionClippingThresholdValue{0.f};
1343 
1344     // 23: Time-major if true, batch-major if false.
1345     bool timeMajorValue = false;
1346 
1347     // Normalization:
1348     // 24:The input layer normalization weights. A 1-D tensor of shape [num_units].
1349     //    Used to rescale normalized inputs to activation at input gate.
1350     hidl_vec<uint32_t> inputLayerNormWeightsDimensions{0};
1351     std::vector<float> inputLayerNormWeightsValue;
1352     // 25:The forget layer normalization weights. A 1-D tensor of shape [num_units].
1353     //    Used to rescale normalized inputs to activation at forget gate.
1354     hidl_vec<uint32_t> forgetLayerNormWeightsDimensions{0};
1355     std::vector<float> forgetLayerNormWeightsValue;
1356     // 26:The cell layer normalization weights. A 1-D tensor of shape [num_units].
1357     //    Used to rescale normalized inputs to activation at cell gate.
1358     hidl_vec<uint32_t> cellLayerNormWeightsDimensions{0};
1359     std::vector<float> cellLayerNormWeightsValue;
1360     // 27:The output layer normalization weights. A 1-D tensor of shape [num_units].
1361     //    Used to rescale normalized inputs to activation at output gate.
1362     hidl_vec<uint32_t> outputLayerNormWeightsDimensions{0};
1363     std::vector<float> outputLayerNormWeightsValue;
1364 
1365     // Outputs:
1366     // 0: The output: A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16. Shape:  if time-major:
1367     //    [max_time, batch_size, output_size] If batch-major: [batch_size, max_time, output_size]
1368     hidl_vec<uint32_t> outputDimensions{batchSize, timeSize, outputSize};
1369     std::vector<float> outputValue{-0.0129257f, -0.070531f, -0.153508f, -0.0392391f,
1370                                    -0.0300169f, -0.195717f, -0.528679f, -0.0818106f,
1371                                    -0.0332748f, 0.155429f, -0.353966f, -0.0801505f,
1372                                    -0.032312f, -0.0407911f, -0.435053f, -0.0932317f,
1373                                    -0.0108233f, 0.165584f, -0.640424f, -0.0447535f,
1374                                    -0.031675f, 0.125987f, -0.526695f, -0.110093f};
1375 
1376     // 1: The hidden state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
1377     //    [batch_size, output_size]. This output is optional and can be omitted. If this output
1378     //    is present then output #2 must be present as well.
1379     hidl_vec<uint32_t> hiddenStateOutDimensions{batchSize, outputSize};
1380     std::vector<float> hiddenStateOutValue(batchSize * outputSize, 0.f);
1381     // 2: The cell state (out): A 2-D tensor of ANEURALNETWORKS_TENSOR_FLOAT32/16, of shape
1382     //    [batch_size, num_units]. This output is optional and can be omitted.
1383     hidl_vec<uint32_t> cellStateOutDimensions{batchSize, numUnits};
1384     std::vector<float> cellStateOutValue(batchSize * numUnits, 0.f);
1385 
1386     UnidirectionalSequenceLstmTestImpl<HalPolicy>(inputDimensions, inputValue,
1387                                                   inputToInputWeightsDimensions, inputToInputWeightsValue,
1388                                                   inputToForgetWeightsDimensions, inputToForgetWeightsValue,
1389                                                   inputToCellWeightsDimensions, inputToCellWeightsValue,
1390                                                   inputToOutputWeightsDimensions, inputToOutputWeightsValue,
1391                                                   recurrentToInputWeightsDimensions, recurrentToInputWeightsValue,
1392                                                   recurrentToForgetWeightsDimensions, recurrentToForgetWeightsValue,
1393                                                   recurrentToCellWeightsDimensions, recurrentToCellWeightsValue,
1394                                                   recurrentToOutputWeightsDimensions, recurrentToOutputWeightsValue,
1395                                                   cellToInputWeightsDimensions, cellToInputWeightsValue,
1396                                                   cellToForgetWeightsDimensions, cellToForgetWeightsValue,
1397                                                   cellToOutputWeightsDimensions, cellToOutputWeightsValue,
1398                                                   inputGateBiasDimensions, inputGateBiasValue,
1399                                                   forgetGateBiasDimensions, forgetGateBiasValue,
1400                                                   cellBiasDimensions, cellBiasValue,
1401                                                   outputGateBiasDimensions, outputGateBiasValue,
1402                                                   projectionWeightsDimensions, projectionWeightsValue,
1403                                                   projectionBiasDimensions, projectionBiasValue,
1404                                                   outputStateInDimensions, outputStateInValue,
1405                                                   cellStateInDimensions, cellStateInValue,
1406                                                   activationFunctionDimensions, activationFunctionValue,
1407                                                   cellClippingThresholdDimensions, cellClippingThresholdValue,
1408                                                   projectionClippingThresholdDimensions,
1409                                                   projectionClippingThresholdValue,
1410                                                   timeMajorValue,
1411                                                   inputLayerNormWeightsDimensions, inputLayerNormWeightsValue,
1412                                                   forgetLayerNormWeightsDimensions, forgetLayerNormWeightsValue,
1413                                                   cellLayerNormWeightsDimensions, cellLayerNormWeightsValue,
1414                                                   outputLayerNormWeightsDimensions, outputLayerNormWeightsValue,
1415                                                   outputDimensions, outputValue,
1416                                                   hiddenStateOutDimensions, hiddenStateOutValue,
1417                                                   cellStateOutDimensions, cellStateOutValue,
1418                                                   compute);
1419 }