blob: 7af2f271d7782110231fbb642b31e1677035f314 [file] [log] [blame]
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001//
Colm Donelan7bcae3c2024-01-22 10:07:14 +00002// Copyright © 2021, 2023-2024 Arm Ltd and Contributors. All rights reserved.
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "UnidirectionalSequenceLstmTestHelper.hpp"
7
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01008#include <doctest/doctest.h>
9
10namespace armnnDelegate
11{
12
Colm Donelan7bcae3c2024-01-22 10:07:14 +000013void UnidirectionalSequenceLstmTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat7684b182021-08-12 14:48:15 +010014{
15 int32_t batchSize = 3;
16 int32_t timeSize = 2;
17 int32_t inputSize = 3;
18 int32_t outputSize = 4;
19 // cellSize and outputSize have the same size when there is no projection.
20 int32_t numUnits = outputSize;
21
22 //tensorInfo12,
23 bool hasInputToInputWeights = true;
24 std::vector<float> inputToInputWeights = { -0.49536117f, -0.0556083915f, -0.102400711f,
25 -0.117484632f, 0.3298470976f, -0.1179017122f,
26 0.214305695f, 0.42135173085f, 0.003878414626f,
27 -0.348303917f, -0.1881275477f, 0.0343011027f };
28
29 std::vector<float> inputToForgetWeights = { 0.2415594226f, 0.15400093799f, 0.4566498398f,
30 -0.3810434485f, 0.268383264f, -0.009807467424f,
31 -0.3522925403f, -0.24275735512f, -0.28344226125f,
32 0.13512269116f, -0.4932442977f, -0.10039821991f };
33
34 std::vector<float> inputToCellWeights = { -0.2504855627f, 0.184490025045f, -0.2480507493f,
35 0.386399507f, -0.259465157985f, -0.16545993089f,
36 -0.4230232555f, 0.341664791103f, -0.18127849691f,
37 -0.2277662414f, -0.55275535589f, 0.34184026718f };
38
39 std::vector<float> inputToOutputWeights = { 0.2303854227f, 0.5218806862f, -0.4865379333f,
40 0.53969591851f, 0.23393625035f, -0.27140527306f,
41 0.50009280443f, 0.07511717046f, 0.3998299249f,
42 -0.51717478049f, 0.1889653282f, -0.367323637f };
43
44 //tensorInfo16,
45 bool hasRecurrentToInputWeights = true;
46 std::vector<float> recurrentToInputWeights = { -0.128009796112f, 0.1995525098f, -0.07745539397f, 0.1558421701f,
47 -0.265254765766f, -0.38837709614f, -0.05636804124f, 0.4259087456f,
48 0.17628988623f, 0.3877420127f, 0.53300309181f, -0.0959980934f,
49 0.00302857416f, 0.3266998827f, -0.142509296562f, -0.04433270756f };
50
51 std::vector<float> recurrentToForgetWeights = { -0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
52 -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
53 -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
54 -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f };
55
56 std::vector<float> recurrentToCellWeights = { -0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
57 -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
58 0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
59 0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f };
60
61 std::vector<float> recurrentToOutputWeights = { -0.32921677827f, 0.32624614238f, -0.1388191282f, -0.17879831790f,
62 -0.15185534954f, -0.16918526583f, -0.10087361183f, -0.5436913968f,
63 0.016758225858f, 0.30454617738f, -0.41493862867f, -0.005565764375f,
64 -0.12584099173f, -0.12319286912f, 0.2407919466f, -0.08879069983f };
65 // tensorInfo4
66 bool hasCellToInputWeights = false;
67 std::vector<float> cellToInputWeights;
68 bool hasCellToForgetWeights = false;
69 std::vector<float> cellToForgetWeights;
70 bool hasCellToOutputWeights = false;
71 std::vector<float> cellToOutputWeights;
72
73 bool hasInputGateBias = true;
74 std::vector<float> inputGateBias = {0., 0., 0., 0.};
75 std::vector<float> forgetGateBias = {1., 1., 1., 1.};
76 std::vector<float> cellBias = {0., 0., 0., 0.};
77 std::vector<float> outputGateBias = {0., 0., 0., 0.};
78
79 bool hasProjectionWeights = false;
80 std::vector<float> projectionWeights;
81 bool hasProjectionBias = false;
82 std::vector<float> projectionBias;
83
84 bool hasInputLayerNormWeights = false;
85 std::vector<float> inputLayerNormWeights;
86 bool hasForgetLayerNormWeights = false;
87 std::vector<float> forgetLayerNormWeights;
88 bool hasCellLayerNormWeights = false;
89 std::vector<float> cellLayerNormWeights;
90 bool hasOutputLayerNormWeights = false;
91 std::vector<float> outputLayerNormWeights;
92
93 std::vector<float> inputValues = { 1., 2., 3., 4., 5., 4.,
94 3., 2., 1., 2., 3., 4.,
95 5., 4., 3., 2., 1., 2. };
96 std::vector<float> expectedOutputValues = { -0.0714901f, -0.162117f, -0.175168f, -0.0232934f,
97 -0.168107f, -0.414129f, -0.549875f, -0.00803579f,
98 -0.0668735f, 0.204078f, -0.42765f, -0.0312321f,
99 -0.120003f, -0.0941918f, -0.456391f, -0.0287019f,
100 -0.0342921f, 0.20824f, -0.656989f, -0.00415265f,
101 -0.10493f, 0.14211f, -0.583478f, -0.0329754f };
102
103 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
104 float clippingThresCell = 10.f;
105 float clippingThresProj = 0.f;
106 bool isTimeMajor = false;
107
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000108 UnidirectionalSequenceLstmTestImpl<float>(::tflite::TensorType_FLOAT32,
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100109 batchSize,
110 timeSize,
111 inputSize,
112 outputSize,
113 numUnits,
114 hasInputToInputWeights,
115 inputToInputWeights,
116 inputToForgetWeights,
117 inputToCellWeights,
118 inputToOutputWeights,
119 hasRecurrentToInputWeights,
120 recurrentToInputWeights,
121 recurrentToForgetWeights,
122 recurrentToCellWeights,
123 recurrentToOutputWeights,
124 hasCellToInputWeights,
125 cellToInputWeights,
126 hasCellToForgetWeights,
127 cellToForgetWeights,
128 hasCellToOutputWeights,
129 cellToOutputWeights,
130 hasInputGateBias,
131 inputGateBias,
132 forgetGateBias,
133 cellBias,
134 outputGateBias,
135 hasProjectionWeights,
136 projectionWeights,
137 hasProjectionBias,
138 projectionBias,
139 hasInputLayerNormWeights,
140 inputLayerNormWeights,
141 hasForgetLayerNormWeights,
142 forgetLayerNormWeights,
143 hasCellLayerNormWeights,
144 cellLayerNormWeights,
145 hasOutputLayerNormWeights,
146 outputLayerNormWeights,
147 inputValues,
148 expectedOutputValues,
149 activationFunction,
150 clippingThresCell,
151 clippingThresProj,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000152 isTimeMajor,
153 backends);
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100154}
155
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000156void UnidirectionalSequenceLstmTimeMajorTestImpl(int32_t timeSize,
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100157 std::vector<float>& inputValues,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000158 std::vector<float>& expectedOutputValues,
159 const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100160{
161 int32_t batchSize = 3;
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100162 int32_t inputSize = 3;
163 int32_t outputSize = 4;
164 // cellSize and outputSize have the same size when there is no projection.
165 int32_t numUnits = outputSize;
166
167 std::vector<int32_t> inputShape = {timeSize, batchSize, inputSize};
168 std::vector<int32_t> cellStateInTensorInfo = {batchSize, numUnits};
169 std::vector<int32_t> outputStateInTensorInfo = {batchSize, outputSize};
170
171 std::vector<int32_t> outputTensorInfo = {timeSize, batchSize, outputSize};
172
173 //tensorInfo12
174 bool hasInputToInputWeights = true;
175 std::vector<float> inputToInputWeights = { 0.27277296781539917f, 0.3813590407371521f, -0.394489049911499f,
176 0.2782636880874634f, -0.3793870210647583f, -0.018918335437774658f,
177 0.2724653482437134f, -0.19314253330230713f, -0.2947450876235962f,
178 -0.30253493785858154f, 0.4241350293159485f, -0.22560018301010132f };
179
180 std::vector<float> inputToForgetWeights = { -0.2667974531650543f, -0.05505800247192383f, -0.20932340621948242f,
181 -0.14345619082450867f, 0.09666192531585693f, -0.2604355812072754f,
182 -0.2681812047958374f, -0.3314584493637085f, 0.4485899806022644f,
183 -0.23467743396759033f, 0.5072842240333557f, -0.4192768931388855f };
184
185 std::vector<float> inputToCellWeights = { -0.15782442688941956f, -0.027530014514923096f, 0.4789854884147644f,
186 0.23227906227111816f, 0.28259342908859253f, -0.030095696449279785f,
187 0.10071521997451782f, -0.08535495400428772f, 0.18563997745513916f,
188 -0.3049069046974182f, -0.478048175573349f, 0.025234103202819824f };
189
190 std::vector<float> inputToOutputWeights = { -0.04584759473800659f, -0.2716066539287567f, 0.012970447540283203f,
191 -0.4729190170764923f, -0.37422770261764526f, 0.49352723360061646f,
192 0.3163864016532898f, -0.436781644821167f, -0.33074596524238586f,
193 -0.32885751128196716f, -0.40959352254867554f, -0.2124689817428589f };
194
195 //tensorInfo16
196 bool hasRecurrentToInputWeights = true;
197 std::vector<float> recurrentToInputWeights = { 0.23788475990f, -0.24948765337f, 0.50044941902f, 0.14431896805f,
198 -0.115940228137f, -0.717082679f, -0.17208620906f, 0.17850610617f,
199 -0.16702319684f, -0.11384502053f, -0.309785276245f, -0.3316611672f,
200 0.52380162477f, -0.06839632987f, -0.391478359627f, -0.10756178963f };
201
202 std::vector<float> recurrentToForgetWeights = { 0.11383482068f, 0.1676601767f, -0.08550968004f, 0.03399394089f,
203 0.08042152225f, -0.2133381964f, 0.05182432704f, 0.38161808255f,
204 -0.5018365979f, -0.08043262364f, 0.07894329014f, -0.07547105155f,
205 0.12047368288f, 0.2986997961f, 0.0485043078f, -0.13372567296f };
206
207 std::vector<float> recurrentToCellWeights = { 0.0433832928545f, 0.07587072294f, -0.120520234107f, 0.604576051f,
208 -0.434353142986f, 0.009314475068f, 0.005085289478f, 0.08488202038f,
209 -0.00025437487886f, 0.15245915082f, -0.1936587542f, 0.004754020f,
210 -0.1582719236f, 0.3307867646f, 0.0236605107784f, 0.307716339826f };
211
212 std::vector<float> recurrentToOutputWeights = { -0.079031050201f, 0.041414566286f, -0.583727357285f, 0.1025384515f,
213 -0.172372072937f, 0.09214124082f, 0.178184121827f, -0.2439443916f,
214 0.104485116899f, 0.2600405514f, 0.064414866268f, 0.24141204357f,
215 0.281875759363f, -0.14234502664f, 0.15126448862f, -0.24421440064f };
216 // tensorInfo4
217 bool hasCellToInputWeights = false;
218 std::vector<float> cellToInputWeights;
219 bool hasCellToForgetWeights = false;
220 std::vector<float> cellToForgetWeights;
221 bool hasCellToOutputWeights = false;
222 std::vector<float> cellToOutputWeights;
223
224 bool hasInputGateBias = true;
225 std::vector<float> inputGateBias = {0., 0., 0., 0.};
226 std::vector<float> forgetGateBias = {1., 1., 1., 1.};
227 std::vector<float> cellBias = {0., 0., 0., 0.};
228 std::vector<float> outputGateBias = {0., 0., 0., 0.};
229
230 bool hasProjectionWeights = false;
231 std::vector<float> projectionWeights;
232 bool hasProjectionBias = false;
233 std::vector<float> projectionBias;
234
235 bool hasInputLayerNormWeights = false;
236 std::vector<float> inputLayerNormWeights;
237 bool hasForgetLayerNormWeights = false;
238 std::vector<float> forgetLayerNormWeights;
239 bool hasCellLayerNormWeights = false;
240 std::vector<float> cellLayerNormWeights;
241 bool hasOutputLayerNormWeights = false;
242 std::vector<float> outputLayerNormWeights;
243
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100244 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
245 float clippingThresCell = 10.f;
246 float clippingThresProj = 0.f;
247 bool isTimeMajor = true;
248
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000249 UnidirectionalSequenceLstmTestImpl<float>(::tflite::TensorType_FLOAT32,
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100250 batchSize,
251 timeSize,
252 inputSize,
253 outputSize,
254 numUnits,
255 hasInputToInputWeights,
256 inputToInputWeights,
257 inputToForgetWeights,
258 inputToCellWeights,
259 inputToOutputWeights,
260 hasRecurrentToInputWeights,
261 recurrentToInputWeights,
262 recurrentToForgetWeights,
263 recurrentToCellWeights,
264 recurrentToOutputWeights,
265 hasCellToInputWeights,
266 cellToInputWeights,
267 hasCellToForgetWeights,
268 cellToForgetWeights,
269 hasCellToOutputWeights,
270 cellToOutputWeights,
271 hasInputGateBias,
272 inputGateBias,
273 forgetGateBias,
274 cellBias,
275 outputGateBias,
276 hasProjectionWeights,
277 projectionWeights,
278 hasProjectionBias,
279 projectionBias,
280 hasInputLayerNormWeights,
281 inputLayerNormWeights,
282 hasForgetLayerNormWeights,
283 forgetLayerNormWeights,
284 hasCellLayerNormWeights,
285 cellLayerNormWeights,
286 hasOutputLayerNormWeights,
287 outputLayerNormWeights,
288 inputValues,
289 expectedOutputValues,
290 activationFunction,
291 clippingThresCell,
292 clippingThresProj,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000293 isTimeMajor,
294 backends);}
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100295
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000296void UnidirectionalSequenceLstmTimeMajorTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100297{
298 int32_t timeSize = 2;
299
300 std::vector<float> inputValues = { 1., 2., 3., 4., 5., 4.,
301 3., 2., 1., 2., 3., 4.,
302 5., 4., 3., 2., 1., 2. };
303
304 std::vector<float> expectedOutputValues = { 0.135658f, 0.124673f, 0.021209f, -0.0530204f,
305 0.106138f, 0.0404792f, 0.0151644f, -0.00675166f,
306 -0.0128514f, 0.0644884f, 0.0709072f, -0.0454045f,
307 0.162886f, 0.166494f, 0.0277046f, -0.0369807f,
308 0.111716f, 0.043119f, 0.0762981f, -0.0122854f,
309 0.104397f, 0.2144f, 0.119192f, -0.0839058f };
310
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000311 UnidirectionalSequenceLstmTimeMajorTestImpl(timeSize,
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100312 inputValues,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000313 expectedOutputValues,
314 backends);
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100315}
316
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000317void UnidirectionalSequenceLstmTimeMajorSingleTimeTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100318{
319 int32_t timeSize = 1;
320
321 std::vector<float> inputValues = { 1., 2., 3.,
322 4., 5., 6.,
323 7., 8., 9. };
324
325 std::vector<float> expectedOutputValues = { 0.13565768f, 0.12467254f, 0.02120903f, -0.05302038f,
326 0.1053334f, 0.08508634f, 0.00667238f, -0.00356043f,
327 0.05638668f, 0.02924093f, 0.00119751f, -0.00017249f };
328
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000329 UnidirectionalSequenceLstmTimeMajorTestImpl(timeSize,
Narumol Prangnawarat5f941242023-08-11 16:09:26 +0100330 inputValues,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000331 expectedOutputValues,
332 backends);
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100333}
334
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000335void UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100336{
337 int32_t batchSize = 2;
338 int32_t timeSize = 3;
339 int32_t inputSize = 4;
340 int32_t outputSize = 5;
341 int32_t numUnits = 6;
342
343 std::vector<int32_t> inputShape = {batchSize, timeSize, inputSize};
344 std::vector<int32_t> cellStateInTensorInfo = {batchSize, numUnits};
345 std::vector<int32_t> outputStateInTensorInfo = {batchSize, outputSize};
346
347 std::vector<int32_t> outputTensorInfo = {batchSize, timeSize, outputSize};
348
349 //tensorInfoInputSize,
350 bool hasInputToInputWeights = true;
351 std::vector<float> inputToInputWeights = { 0.021393683f, 0.06124551f, 0.046905167f, -0.014657677f,
352 -0.03149463f, 0.09171803f, 0.14647801f, 0.10797193f,
353 -0.0057968358f, 0.0019193048f, -0.2726754f, 0.10154029f,
354 -0.018539885f, 0.080349885f, -0.10262385f, -0.022599787f,
355 -0.09121155f, -0.008675967f, -0.045206103f, -0.0821282f,
356 -0.008045952f, 0.015478081f, 0.055217247f, 0.038719587f };
357
358 std::vector<float> inputToForgetWeights = { -0.0018401089f, -0.004852237f, 0.03698424f, 0.014181704f,
359 0.028273236f, -0.016726194f, -0.05249759f, -0.10204261f,
360 0.00861066f, -0.040979505f, -0.009899187f, 0.01923892f,
361 -0.028177269f, -0.08535103f, -0.14585495f, 0.10662567f,
362 -0.01909731f, -0.017883534f, -0.0047269356f, -0.045103323f,
363 0.0030784295f, 0.076784775f, 0.07463696f, 0.094531395f};
364
365 std::vector<float> inputToCellWeights = { -0.04580283f, -0.09549462f, -0.032418985f, -0.06454633f,
366 -0.043528453f, 0.043018587f, -0.049152344f, -0.12418144f,
367 -0.078985475f, -0.07596889f, 0.019484362f, -0.11434962f,
368 -0.0074034138f, -0.06314844f, -0.092981495f, 0.0062155537f,
369 -0.025034338f, -0.0028890965f, 0.048929527f, 0.06235075f,
370 0.10665918f, -0.032036792f, -0.08505916f, -0.10843358f };
371
372 std::vector<float> inputToOutputWeights = { -0.0998932f, -0.07201956f, -0.052803773f, -0.15629593f,
373 -0.15001918f, -0.07650751f, 0.02359855f, -0.075155355f,
374 -0.08037709f, -0.15093534f, 0.029517552f, -0.04751393f,
375 0.010350531f, -0.02664851f, -0.016839722f, -0.023121163f,
376 0.0077019283f, 0.012851257f, -0.05040649f, -0.0129761f,
377 -0.021737747f, -0.038305793f, -0.06870586f, -0.01481247f };
378
379 //tensorInfoOutputSize,
380 bool hasRecurrentToInputWeights = true;
381 std::vector<float> recurrentToInputWeights = { -0.001374326f, -0.078856036f, 0.10672688f, 0.029162422f,
382 -0.11585556f, 0.02557986f, -0.13446963f, -0.035785314f,
383 -0.01244275f, 0.025961924f, -0.02337298f, -0.044228926f,
384 -0.055839065f, -0.046598054f, -0.010546039f, -0.06900766f,
385 0.027239809f, 0.022582639f, -0.013296484f, -0.05459212f,
386 0.08981f, -0.045407712f, 0.08682226f, -0.06867011f,
387 -0.14390695f, -0.02916037f, 0.000996957f, 0.091420636f,
388 0.14283475f, -0.07390571f };
389
390 std::vector<float> recurrentToForgetWeights = { -0.057784554f, -0.026057621f, -0.068447545f, -0.022581743f,
391 0.14811787f, 0.10826372f, 0.09471067f, 0.03987225f,
392 -0.0039523416f, 0.00030638507f, 0.053185795f, 0.10572994f,
393 0.08414449f, -0.022036452f, -0.00066928595f, -0.09203576f,
394 0.032950465f, -0.10985798f, -0.023809856f, 0.0021431844f,
395 -0.02196096f, -0.00326074f, 0.00058621005f, -0.074678116f,
396 -0.06193199f, 0.055729095f, 0.03736828f, 0.020123724f,
397 0.061878487f, -0.04729229f };
398
399 std::vector<float> recurrentToCellWeights = { -0.037322544f, 0.018592842f, 0.0056175636f, -0.06253426f,
400 0.055647098f, -0.05713207f, -0.05626563f, 0.005559383f,
401 0.03375411f, -0.025757805f, -0.088049285f, 0.06017052f,
402 -0.06570978f, 0.007384076f, 0.035123326f, -0.07920549f,
403 0.053676967f, 0.044480428f, -0.07663568f, 0.0071805613f,
404 0.08089997f, 0.05143358f, 0.038261272f, 0.03339287f,
405 -0.027673481f, 0.044746667f, 0.028349208f, 0.020090483f,
406 -0.019443132f, -0.030755889f };
407
408 std::vector<float> recurrentToOutputWeights = { 0.025825322f, -0.05813119f, 0.09495884f,
409 -0.045984812f,-0.01255415f, -0.0026479573f,
410 -0.08196161f, -0.054914974f, -0.0046604523f,
411 -0.029587349f, -0.044576716f, -0.07480124f,
412 -0.082868785f, 0.023254942f, 0.027502948f,
413 -0.0039728214f, -0.08683098f, -0.08116779f,
414 -0.014675607f, -0.037924774f, -0.023314456f,
415 -0.007401714f, -0.09255757f, 0.029460307f,
416 -0.08829125f, -0.005139627f, -0.08989442f,
417 -0.0555066f, 0.13596267f, 0.025062224f };
418 // tensorInfoNumUnits
419 bool hasCellToInputWeights = true;
420 std::vector<float> cellToInputWeights = { 0.040369894f, 0.030746894f, 0.24704495f,
421 0.018586371f, -0.037586458f, -0.15312155f };
422 bool hasCellToForgetWeights = true;
423 std::vector<float> cellToForgetWeights = { -0.01998659f, -0.15568835f, -0.24248174f,
424 -0.012770197f, 0.041331276f, -0.072311886f };
425 bool hasCellToOutputWeights = true;
426 std::vector<float> cellToOutputWeights = { 0.08286371f, -0.08261836f, -0.51210177f,
427 0.002913762f, 0.17764764f, -0.5495371f };
428
429 bool hasInputGateBias = true;
430 std::vector<float> inputGateBias = { 0.02234832f, 0.14757581f, 0.18176508f,
431 0.10380666f, 0.053110216f, -0.06928846f };
432 std::vector<float> forgetGateBias = { 0.035185695f, -0.042891346f, -0.03032477f,
433 0.23027696f, 0.11098921f, 0.08989442f };
434 std::vector<float> cellBias = { -0.024379363f, 0.0055531194f, 0.23377132f,
435 0.033463873f, -0.1483596f, 0.029460307f };
436 std::vector<float> outputGateBias = { 0.046159424f, -0.0012809046f, 0.03563469f,
437 0.12648113f, 0.027195795f, 0.35373217f };
438
439 bool hasProjectionWeights = true;
440 std::vector<float> projectionWeights = { -0.009802181f, 0.09401916f, 0.0717386f, -0.13895074f, 0.09641832f,
441 0.060420845f, 0.08539281f, 0.054285463f, 0.061395317f, 0.034448683f,
442 -0.042991187f, 0.019801661f, -0.16840284f, -0.015726732f, -0.23041931f,
443 -0.024478018f, -0.10959692f, -0.013875541f, 0.18600968f, -0.061274476f,
444 0.0138165f, -0.08160894f, -0.07661644f, 0.032372914f, 0.16169067f,
445 0.22465782f, -0.03993472f, -0.004017731f, 0.08633481f, -0.28869787f };
446
447 bool hasProjectionBias = true;
448 std::vector<float> projectionBias(outputSize, 0.f);
449
450 bool hasInputLayerNormWeights = false;
451 std::vector<float> inputLayerNormWeights;
452 bool hasForgetLayerNormWeights = false;
453 std::vector<float> forgetLayerNormWeights;
454 bool hasCellLayerNormWeights = false;
455 std::vector<float> cellLayerNormWeights;
456 bool hasOutputLayerNormWeights = false;
457 std::vector<float> outputLayerNormWeights;
458
459 std::vector<float> inputValues = { 1., 2., 3., 4., 5., 4.,
460 3., 2., 1., 2., 3., 4.,
461 5., 4., 3., 2., 1., 2.,
462 1., 2., 3., 4., 5., 4.};
463 std::vector<float> expectedOutputValues = { -0.0135612f, -0.0263441f, 0.0314008f, -0.00883455f, 0.00763052f,
464 -0.00126877f, -0.0292959f, 0.0449957f, -0.00976195f, -0.00492338f,
465 -0.0175702f, -0.0431753f, 0.0597117f, -0.0169154f, 0.0142087f,
466 0.00472515f, -0.0196355f, 0.0342524f, -0.00407936f, -0.0253189f,
467 -0.00512944f, -0.0293754f, 0.0512771f, -0.0151874f, -0.0246433f,
468 -0.00744986f, -0.0345103f, 0.0450666f, -0.00944991f, 0.0126895f };
469
470 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
471 float clippingThresCell = 10.f;
472 float clippingThresProj = 0.f;
473 bool isTimeMajor = false;
474
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000475 UnidirectionalSequenceLstmTestImpl<float>(::tflite::TensorType_FLOAT32,
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100476 batchSize,
477 timeSize,
478 inputSize,
479 outputSize,
480 numUnits,
481 hasInputToInputWeights,
482 inputToInputWeights,
483 inputToForgetWeights,
484 inputToCellWeights,
485 inputToOutputWeights,
486 hasRecurrentToInputWeights,
487 recurrentToInputWeights,
488 recurrentToForgetWeights,
489 recurrentToCellWeights,
490 recurrentToOutputWeights,
491 hasCellToInputWeights,
492 cellToInputWeights,
493 hasCellToForgetWeights,
494 cellToForgetWeights,
495 hasCellToOutputWeights,
496 cellToOutputWeights,
497 hasInputGateBias,
498 inputGateBias,
499 forgetGateBias,
500 cellBias,
501 outputGateBias,
502 hasProjectionWeights,
503 projectionWeights,
504 hasProjectionBias,
505 projectionBias,
506 hasInputLayerNormWeights,
507 inputLayerNormWeights,
508 hasForgetLayerNormWeights,
509 forgetLayerNormWeights,
510 hasCellLayerNormWeights,
511 cellLayerNormWeights,
512 hasOutputLayerNormWeights,
513 outputLayerNormWeights,
514 inputValues,
515 expectedOutputValues,
516 activationFunction,
517 clippingThresCell,
518 clippingThresProj,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000519 isTimeMajor,
520 backends);
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100521}
522
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000523void UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100524{
525 int32_t batchSize = 3;
526 int32_t timeSize = 2;
527 int32_t inputSize = 3;
528 int32_t outputSize = 4;
529 // cellSize and outputSize have the same size when there is no projection.
530 int32_t numUnits = outputSize;
531
532 //tensorInfo12
533 bool hasInputToInputWeights = false;
534 std::vector<float> inputToInputWeights{};
535
536 std::vector<float> inputToForgetWeights = { 0.2415594226f, 0.15400093799f, 0.4566498398f,
537 -0.3810434485f, 0.268383264f, -0.009807467424f,
538 -0.3522925403f, -0.24275735512f, -0.28344226125f,
539 0.13512269116f, -0.4932442977f, -0.10039821991f };
540
541 std::vector<float> inputToCellWeights = { -0.2504855627f, 0.184490025045f, -0.2480507493f,
542 0.386399507f, -0.259465157985f, -0.16545993089f,
543 -0.4230232555f, 0.341664791103f, -0.18127849691f,
544 -0.2277662414f, -0.55275535589f, 0.34184026718f };
545
546 std::vector<float> inputToOutputWeights = { 0.2303854227f, 0.5218806862f, -0.4865379333f,
547 0.53969591851f, 0.23393625035f, -0.27140527306f,
548 0.50009280443f, 0.07511717046f, 0.3998299249f,
549 -0.51717478049f, 0.1889653282f, -0.367323637f };
550
551 //tensorInfo16
552 bool hasRecurrentToInputWeights = false;
553 std::vector<float> recurrentToInputWeights{};
554
555 std::vector<float> recurrentToForgetWeights = { -0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
556 -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
557 -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
558 -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f };
559
560 std::vector<float> recurrentToCellWeights = { -0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
561 -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
562 0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
563 0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f };
564
565 std::vector<float> recurrentToOutputWeights = { -0.32921677827f, 0.32624614238f, -0.1388191282f, -0.17879831790f,
566 -0.15185534954f, -0.16918526583f, -0.10087361183f, -0.5436913968f,
567 0.016758225858f, 0.30454617738f, -0.41493862867f, -0.005565764375f,
568 -0.12584099173f, -0.12319286912f, 0.2407919466f, -0.08879069983f };
569 // tensorInfo4
570 bool hasCellToInputWeights = false;
571 std::vector<float> cellToInputWeights;
572 bool hasCellToForgetWeights = true;
573 std::vector<float> cellToForgetWeights = {0.47485286f, -0.51955009f, -0.24458408f, 0.31544167f};
574 bool hasCellToOutputWeights = true;
575 std::vector<float> cellToOutputWeights = {-0.17135078f, 0.82760304f, 0.85573703f, -0.77109635f};
576
577 bool hasInputGateBias = false;
578 std::vector<float> inputGateBias;
579 std::vector<float> forgetGateBias = {1., 1., 1., 1.};
580 std::vector<float> cellBias = {0., 0., 0., 0.};
581 std::vector<float> outputGateBias = {0., 0., 0., 0.};
582
583 bool hasProjectionWeights = false;
584 std::vector<float> projectionWeights;
585 bool hasProjectionBias = false;
586 std::vector<float> projectionBias;
587
588 bool hasInputLayerNormWeights = false;
589 std::vector<float> inputLayerNormWeights;
590 bool hasForgetLayerNormWeights = false;
591 std::vector<float> forgetLayerNormWeights;
592 bool hasCellLayerNormWeights = false;
593 std::vector<float> cellLayerNormWeights;
594 bool hasOutputLayerNormWeights = false;
595 std::vector<float> outputLayerNormWeights;
596
597 std::vector<float> inputValues = { 1., 2., 3., 4., 5., 4.,
598 3., 2., 1., 2., 3., 4.,
599 5., 4., 3., 2., 1., 2. };
600 std::vector<float> expectedOutputValues = { -0.0129257f, -0.070531f, -0.153508f, -0.0392391f,
601 -0.0300169f, -0.195717f, -0.528679f, -0.0818106f,
602 -0.0332748f, 0.155429f, -0.353966f, -0.0801505f,
603 -0.032312f, -0.0407911f, -0.435053f, -0.0932317f,
604 -0.0108233f, 0.165584f, -0.640424f, -0.0447535f,
605 -0.031675f, 0.125987f, -0.526695f, -0.110093f };
606
607 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
608 float clippingThresCell = 10.f;
609 float clippingThresProj = 0.f;
610 bool isTimeMajor = false;
611
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000612 UnidirectionalSequenceLstmTestImpl<float>(::tflite::TensorType_FLOAT32,
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100613 batchSize,
614 timeSize,
615 inputSize,
616 outputSize,
617 numUnits,
618 hasInputToInputWeights,
619 inputToInputWeights,
620 inputToForgetWeights,
621 inputToCellWeights,
622 inputToOutputWeights,
623 hasRecurrentToInputWeights,
624 recurrentToInputWeights,
625 recurrentToForgetWeights,
626 recurrentToCellWeights,
627 recurrentToOutputWeights,
628 hasCellToInputWeights,
629 cellToInputWeights,
630 hasCellToForgetWeights,
631 cellToForgetWeights,
632 hasCellToOutputWeights,
633 cellToOutputWeights,
634 hasInputGateBias,
635 inputGateBias,
636 forgetGateBias,
637 cellBias,
638 outputGateBias,
639 hasProjectionWeights,
640 projectionWeights,
641 hasProjectionBias,
642 projectionBias,
643 hasInputLayerNormWeights,
644 inputLayerNormWeights,
645 hasForgetLayerNormWeights,
646 forgetLayerNormWeights,
647 hasCellLayerNormWeights,
648 cellLayerNormWeights,
649 hasOutputLayerNormWeights,
650 outputLayerNormWeights,
651 inputValues,
652 expectedOutputValues,
653 activationFunction,
654 clippingThresCell,
655 clippingThresProj,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000656 isTimeMajor,
657 backends);
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100658}
659
660void UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionWithLayerNormTest(
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000661 const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100662{
663 int32_t batchSize = 3;
664 int32_t timeSize = 2;
665 int32_t inputSize = 3;
666 int32_t outputSize = 4;
667 int32_t numUnits = 5;
668
669 //tensorInfo15
670 bool hasInputToInputWeights = true;
671 std::vector<float> inputToInputWeights = { -0.49536117f, -0.0556083915f, -0.102400711f,
672 -0.117484632f, 0.3298470976f, -0.1179017122f,
673 0.214305695f, 0.42135173085f, 0.003878414626f,
674 -0.348303917f, -0.1881275477f, 0.0343011027f,
675 -0.38837709614f, -0.05636804124f, 0.4259087456f};
676
677 std::vector<float> inputToForgetWeights = { 0.2415594226f, 0.15400093799f, 0.4566498398f,
678 -0.3810434485f, 0.268383264f, -0.009807467424f,
679 -0.3522925403f, -0.24275735512f, -0.28344226125f,
680 0.13512269116f, -0.4932442977f, -0.10039821991f,
681 0.2726137042f, 0.09216640889f, -0.06551410215f};
682
683 std::vector<float> inputToCellWeights = { -0.2504855627f, 0.184490025045f, -0.2480507493f,
684 0.386399507f, -0.259465157985f, -0.16545993089f,
685 -0.4230232555f, 0.341664791103f, -0.18127849691f,
686 -0.2277662414f, -0.55275535589f, 0.34184026718f,
687 0.3954237699f, -0.19407111404f, 0.30412107706f};
688
689 std::vector<float> inputToOutputWeights = { 0.2303854227f, 0.5218806862f, -0.4865379333f,
690 0.53969591851f, 0.23393625035f, -0.27140527306f,
691 0.50009280443f, 0.07511717046f, 0.3998299249f,
692 -0.51717478049f, 0.1889653282f, -0.367323637f,
693 -0.12584099173f, -0.12319286912f, 0.2407919466f};
694
695 //tensorInfo20
696 bool hasRecurrentToInputWeights = true;
697 std::vector<float> recurrentToInputWeights = { -0.128009796112f, 0.1995525098f, -0.07745539397f, 0.1558421701f,
698 -0.265254765766f, -0.38837709614f, -0.05636804124f, 0.4259087456f,
699 0.17628988623f, 0.3877420127f, 0.53300309181f, -0.0959980934f,
700 0.00302857416f, 0.3266998827f, -0.142509296562f, -0.04433270756f,
701 0.54066205f, -0.32668582f, -0.43562764f, -0.56094903f };
702
703 std::vector<float> recurrentToForgetWeights = { -0.09499983487f, -0.08814888417f, -0.04834804721f, 0.1516668247f,
704 -0.3967529535f, -0.06463699788f, 0.4952811002f, 0.003274492938f,
705 -0.0968840941f, 0.17928104102f, 0.0031281141592f, -0.3387276584f,
706 -0.3587934076f, 0.06705895066f, 0.22463923692f, 0.1961955726f,
707 0.01841056f, -0.32764608f, -0.33027974f, -0.10826075f };
708
709 std::vector<float> recurrentToCellWeights = { -0.21938985582f, -0.3023648226f, -0.1170005202f, -0.3509177422f,
710 -0.4286288613f, 0.2726137042f, 0.09216640889f, -0.06551410215f,
711 0.20453298098f, 0.2393476665f, 0.11846517771f, 0.2630801796f,
712 0.3954237699f, -0.19407111404f, 0.30412107706f, -0.27342408554f,
713 0.19069612f, -0.03026325f, -0.54532051f, 0.33003211f };
714
715 std::vector<float> recurrentToOutputWeights = { -0.32921677827f, 0.32624614238f, -0.1388191282f, -0.17879831790f,
716 -0.15185534954f, -0.16918526583f, -0.10087361183f, -0.5436913968f,
717 0.016758225858f, 0.30454617738f, -0.41493862867f, -0.005565764375f,
718 -0.12584099173f, -0.12319286912f, 0.2407919466f, -0.08879069983f,
719 0.11178309f, 0.09481031f, -0.26424935f, 0.46261835f };
720 // tensorInfo5
721 bool hasCellToInputWeights = true;
722 std::vector<float> cellToInputWeights = { 0.05f, 0.1f, 0.25f, 0.15f, -0.02f };
723 bool hasCellToForgetWeights = true;
724 std::vector<float> cellToForgetWeights = { -0.02f, -0.15f, -0.25f, -0.03f, 0.15f };
725 bool hasCellToOutputWeights = true;
726 std::vector<float> cellToOutputWeights = { 0.1f, -0.1f, -0.5f, 0.05f, 0.01f };
727
728 bool hasInputGateBias = true;
729 std::vector<float> inputGateBias = { 0.03f, 0.15f, 0.22f, 0.38f, 0.05f };
730 std::vector<float> forgetGateBias = { 0.1f, -0.3f, -0.2f, 0.1f, 0.4f };
731 std::vector<float> cellBias = { -0.05f, 0.72f, 0.25f, 0.08f, 0.1f };
732 std::vector<float> outputGateBias = { 0.05f, -0.01f, 0.2f, 0.1f, -0.2f };
733
734 bool hasProjectionWeights = true;
735 std::vector<float> projectionWeights = { -0.1f, 0.2f, 0.01f, -0.2f,
736 0.1f, 0.5f, 0.3f, 0.08f,
737 0.07f, 0.2f, -0.4f, 0.2f,
738 0.5f, -0.4f, 0.3f, -0.2f,
739 0.3f, 0.08f, -0.07f, 0.2f}; //{outputSize, numUnits}
740 bool hasProjectionBias = true;
741 std::vector<float> projectionBias(outputSize, 0.f);;
742
743 bool hasInputLayerNormWeights = true;
744 std::vector<float> inputLayerNormWeights = { 0.1f, 0.2f, 0.3f, 0.5f, 0.8f };
745 bool hasForgetLayerNormWeights = true;
746 std::vector<float> forgetLayerNormWeights = { 0.1f, 0.2f, 0.3f, 0.5f, 0.2f };
747 bool hasCellLayerNormWeights = true;
748 std::vector<float> cellLayerNormWeights = { 0.7f, 0.2f, 0.3f, 0.8f, 0.5f };
749 bool hasOutputLayerNormWeights = true;
750 std::vector<float> outputLayerNormWeights = { 0.6f, 0.2f, 0.2f, 0.5f, 0.1f };
751
752 std::vector<float> inputValues = { 1., 2., 3., 4., 5., 4.,
753 3., 2., 1., 2., 3., 4.,
754 5., 4., 3., 2., 1., 2. };
755 std::vector<float> expectedOutputValues = { 0.0642256f, 0.0343966f, 0.184122f, 0.114717f,
756 0.11458f, 0.0407109f, 0.300327f, 0.174301f,
757 0.0864761f, 0.0362912f, 0.178635f, 0.115689f,
758 0.108008f, 0.0386623f, 0.273471f, 0.167115f,
759 0.0859545f, 0.0331481f, 0.186051f, 0.11888f,
760 0.106649f, 0.0276847f, 0.229863f, 0.166958f };
761
762 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
763 float clippingThresCell = 10.f;
764 float clippingThresProj = 0.f;
765 bool isTimeMajor = false;
766
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000767 UnidirectionalSequenceLstmTestImpl<float>(::tflite::TensorType_FLOAT32,
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100768 batchSize,
769 timeSize,
770 inputSize,
771 outputSize,
772 numUnits,
773 hasInputToInputWeights,
774 inputToInputWeights,
775 inputToForgetWeights,
776 inputToCellWeights,
777 inputToOutputWeights,
778 hasRecurrentToInputWeights,
779 recurrentToInputWeights,
780 recurrentToForgetWeights,
781 recurrentToCellWeights,
782 recurrentToOutputWeights,
783 hasCellToInputWeights,
784 cellToInputWeights,
785 hasCellToForgetWeights,
786 cellToForgetWeights,
787 hasCellToOutputWeights,
788 cellToOutputWeights,
789 hasInputGateBias,
790 inputGateBias,
791 forgetGateBias,
792 cellBias,
793 outputGateBias,
794 hasProjectionWeights,
795 projectionWeights,
796 hasProjectionBias,
797 projectionBias,
798 hasInputLayerNormWeights,
799 inputLayerNormWeights,
800 hasForgetLayerNormWeights,
801 forgetLayerNormWeights,
802 hasCellLayerNormWeights,
803 cellLayerNormWeights,
804 hasOutputLayerNormWeights,
805 outputLayerNormWeights,
806 inputValues,
807 expectedOutputValues,
808 activationFunction,
809 clippingThresCell,
810 clippingThresProj,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000811 isTimeMajor,
812 backends);
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100813}
814
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000815void UnidirectionalSequenceLstmInt8Test(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +0100816{
817 int32_t batchSize = 3;
818 int32_t timeSize = 2;
819 int32_t inputSize = 3;
820 int32_t outputSize = 4;
821 // cellSize and outputSize have the same size when there is no projection.
822 int32_t numUnits = outputSize;
Narumol Prangnawarat7684b182021-08-12 14:48:15 +0100823
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +0100824 //tensorInfo12
825 bool hasInputToInputWeights = true;
826 std::vector<int8_t> inputToInputWeights = { -4, -1, -1, -2, 3, -2, 2, 4, 1, -4, -2, 3 };
827
828 std::vector<int8_t> inputToForgetWeights = { 2, 1, 4, -4, 3, -1, -3, -2, -3, 1, -4, -1 };
829
830 std::vector<int8_t> inputToCellWeights = { -2, 1, -2, 4, -3, -2, -4, 3, -2, -2, -6, 3 };
831
832 std::vector<int8_t> inputToOutputWeights = { 2, 5, -4, 5, 2, -3, 5, 7, 3, -5, 1, -4 };
833
834 //tensorInfo16
835 bool hasRecurrentToInputWeights = true;
836 std::vector<int8_t> recurrentToInputWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -1, -1 };
837
838 std::vector<int8_t> recurrentToForgetWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -2, -1 };
839
840 std::vector<int8_t> recurrentToCellWeights = { -2, -3, -1, -3, -4, 2, 1, -1, 2, 2, 1, 2, 3, -2, 3, -3 };
841
842 std::vector<int8_t> recurrentToOutputWeights = { -3, 3, -1, -2, -2, -2, -1, -5, 1, 3, -4, -1, -1, -1, 2, -1 };
843
844 // tensorInfo4
845 bool hasCellToInputWeights = false;
846 std::vector<int8_t> cellToInputWeights;
847 bool hasCellToForgetWeights = false;
848 std::vector<int8_t> cellToForgetWeights;
849 bool hasCellToOutputWeights = false;
850 std::vector<int8_t> cellToOutputWeights;
851
852 bool hasInputGateBias = true;
853 std::vector<float> inputGateBias = { 0., 0., 0., 0. };
854 std::vector<float> forgetGateBias = { 1., 1., 1., 1. };
855 std::vector<float> cellBias = { 0., 0., 0., 0. };
856 std::vector<float> outputGateBias = { 0., 0., 0., 0. };
857
858 bool hasProjectionWeights = false;
859 std::vector<int8_t> projectionWeights;
860 bool hasProjectionBias = false;
861 std::vector<float> projectionBias;
862
863 bool hasInputLayerNormWeights = false;
864 std::vector<float> inputLayerNormWeights;
865 bool hasForgetLayerNormWeights = false;
866 std::vector<float> forgetLayerNormWeights;
867 bool hasCellLayerNormWeights = false;
868 std::vector<float> cellLayerNormWeights;
869 bool hasOutputLayerNormWeights = false;
870 std::vector<float> outputLayerNormWeights;
871
872 std::vector<float> inputValues = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.4f,
873 0.3f, 0.2f, 0.1f, 0.2f, 0.3f, 0.4f,
874 0.5f, 0.4f, 0.3f, 0.2f, 0.1f, 0.2f };
875
876 std::vector<float> expectedOutputValues = { -0.0142517f, -0.0198845f, -0.0120569f, -0.0116868f,
877 -0.0350714f, -0.0343202f, -0.047504f, -0.0569789f,
878 -0.0146346f, 0.0106663f, -0.0247238f, -0.0319502f,
879 -0.0294759f, -0.0129935f, -0.0444175f, -0.0444354f,
880 -0.0280855f, 0.00545101f, -0.051422f, -0.0463838f,
881 -0.0310702f, 0.00915739f, -0.0625207f, -0.0482648f };
882
883 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
884 float clippingThresCell = 10.f;
885 float clippingThresProj = 0.f;
886 bool isTimeMajor = false;
887
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000888 UnidirectionalSequenceLstmTestImpl<int8_t>(::tflite::TensorType_INT8,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +0100889 batchSize,
890 timeSize,
891 inputSize,
892 outputSize,
893 numUnits,
894 hasInputToInputWeights,
895 inputToInputWeights,
896 inputToForgetWeights,
897 inputToCellWeights,
898 inputToOutputWeights,
899 hasRecurrentToInputWeights,
900 recurrentToInputWeights,
901 recurrentToForgetWeights,
902 recurrentToCellWeights,
903 recurrentToOutputWeights,
904 hasCellToInputWeights,
905 cellToInputWeights,
906 hasCellToForgetWeights,
907 cellToForgetWeights,
908 hasCellToOutputWeights,
909 cellToOutputWeights,
910 hasInputGateBias,
911 inputGateBias,
912 forgetGateBias,
913 cellBias,
914 outputGateBias,
915 hasProjectionWeights,
916 projectionWeights,
917 hasProjectionBias,
918 projectionBias,
919 hasInputLayerNormWeights,
920 inputLayerNormWeights,
921 hasForgetLayerNormWeights,
922 forgetLayerNormWeights,
923 hasCellLayerNormWeights,
924 cellLayerNormWeights,
925 hasOutputLayerNormWeights,
926 outputLayerNormWeights,
927 inputValues,
928 expectedOutputValues,
929 activationFunction,
930 clippingThresCell,
931 clippingThresProj,
932 isTimeMajor,
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000933 backends,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +0100934 0.1f);
935}
936
Colm Donelan7bcae3c2024-01-22 10:07:14 +0000937void UnidirectionalSequenceLstmInt8TimeMajorTest(const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +0100938{
939 int32_t batchSize = 3;
940 int32_t timeSize = 2;
941 int32_t inputSize = 3;
942 int32_t outputSize = 4;
943 // cellSize and outputSize have the same size when there is no projection.
944 int32_t numUnits = outputSize;
945
946 //tensorInfo12
947 bool hasInputToInputWeights = true;
948 std::vector<int8_t> inputToInputWeights = { -4, -1, -1, -2, 3, -2, 2, 4, 1, -4, -2, 3 };
949
950 std::vector<int8_t> inputToForgetWeights = { 2, 1, 4, -4, 3, -1, -3, -2, -3, 1, -4, -1 };
951
952 std::vector<int8_t> inputToCellWeights = { -2, 1, -2, 4, -3, -2, -4, 3, -2, -2, -6, 3 };
953
954 std::vector<int8_t> inputToOutputWeights = { 2, 5, -4, 5, 2, -3, 5, 7, 3, -5, 1, -4 };
955
956 //tensorInfo16
957 bool hasRecurrentToInputWeights = true;
958 std::vector<int8_t> recurrentToInputWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -1, -1 };
959
960 std::vector<int8_t> recurrentToForgetWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -2, -1 };
961
962 std::vector<int8_t> recurrentToCellWeights = { -2, -3, -1, -3, -4, 2, 1, -1, 2, 2, 1, 2, 3, -2, 3, -3 };
963
964 std::vector<int8_t> recurrentToOutputWeights = { -3, 3, -1, -2, -2, -2, -1, -5, 1, 3, -4, -1, -1, -1, 2, -1 };
965
966 // tensorInfo4
967 bool hasCellToInputWeights = false;
968 std::vector<int8_t> cellToInputWeights;
969 bool hasCellToForgetWeights = false;
970 std::vector<int8_t> cellToForgetWeights;
971 bool hasCellToOutputWeights = false;
972 std::vector<int8_t> cellToOutputWeights;
973
974 bool hasInputGateBias = true;
975 std::vector<float> inputGateBias = { 0., 0., 0., 0. };
976 std::vector<float> forgetGateBias = { 1., 1., 1., 1. };
977 std::vector<float> cellBias = { 0., 0., 0., 0. };
978 std::vector<float> outputGateBias = { 0., 0., 0., 0. };
979
980 bool hasProjectionWeights = false;
981 std::vector<int8_t> projectionWeights;
982 bool hasProjectionBias = false;
983 std::vector<float> projectionBias;
984
985 bool hasInputLayerNormWeights = false;
986 std::vector<float> inputLayerNormWeights;
987 bool hasForgetLayerNormWeights = false;
988 std::vector<float> forgetLayerNormWeights;
989 bool hasCellLayerNormWeights = false;
990 std::vector<float> cellLayerNormWeights;
991 bool hasOutputLayerNormWeights = false;
992 std::vector<float> outputLayerNormWeights;
993
994 std::vector<float> inputValues = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.4f,
995 0.3f, 0.2f, 0.1f, 0.2f, 0.3f, 0.4f,
996 0.5f, 0.4f, 0.3f, 0.2f, 0.1f, 0.2f };
997
998 std::vector<float> expectedOutputValues = { -0.0142517f, -0.0198845f, -0.0120122f, -0.0116868f,
999 -0.0261295f, -0.0188487f, -0.0345463f, -0.049733f,
1000 -0.0146346f, 0.0106663f, -0.0247238f, -0.0319502f,
1001 -0.0291863f, -0.0369402f, -0.0354071f, -0.0296529f,
1002 -0.0419539f, -0.00617731f, -0.0814796f, -0.0804005f,
1003 -0.0244737f, 0.0119905f, -0.0457527f, -0.0331862f };
1004
1005 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
1006 float clippingThresCell = 10.f;
1007 float clippingThresProj = 0.f;
1008 bool isTimeMajor = true;
1009
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001010 UnidirectionalSequenceLstmTestImpl<int8_t>(::tflite::TensorType_INT8,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001011 batchSize,
1012 timeSize,
1013 inputSize,
1014 outputSize,
1015 numUnits,
1016 hasInputToInputWeights,
1017 inputToInputWeights,
1018 inputToForgetWeights,
1019 inputToCellWeights,
1020 inputToOutputWeights,
1021 hasRecurrentToInputWeights,
1022 recurrentToInputWeights,
1023 recurrentToForgetWeights,
1024 recurrentToCellWeights,
1025 recurrentToOutputWeights,
1026 hasCellToInputWeights,
1027 cellToInputWeights,
1028 hasCellToForgetWeights,
1029 cellToForgetWeights,
1030 hasCellToOutputWeights,
1031 cellToOutputWeights,
1032 hasInputGateBias,
1033 inputGateBias,
1034 forgetGateBias,
1035 cellBias,
1036 outputGateBias,
1037 hasProjectionWeights,
1038 projectionWeights,
1039 hasProjectionBias,
1040 projectionBias,
1041 hasInputLayerNormWeights,
1042 inputLayerNormWeights,
1043 hasForgetLayerNormWeights,
1044 forgetLayerNormWeights,
1045 hasCellLayerNormWeights,
1046 cellLayerNormWeights,
1047 hasOutputLayerNormWeights,
1048 outputLayerNormWeights,
1049 inputValues,
1050 expectedOutputValues,
1051 activationFunction,
1052 clippingThresCell,
1053 clippingThresProj,
1054 isTimeMajor,
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001055 backends,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001056 0.1);
1057}
1058
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001059void UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionTest(
1060 const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001061{
1062 int32_t batchSize = 3;
1063 int32_t timeSize = 2;
1064 int32_t inputSize = 3;
1065 int32_t outputSize = 4;
1066 int32_t numUnits = 4;
1067
1068 bool hasInputToInputWeights = true;
1069 std::vector<int8_t> inputToInputWeights = { -4, -1, -1, -2, 3, -2, 2, 4, 1, -4, -2, 3 };
1070
1071 std::vector<int8_t> inputToForgetWeights = { 2, 1, 4, -4, 3, -1, -3, -2, -3, 1, -4, -1 };
1072
1073 std::vector<int8_t> inputToCellWeights = { -2, 1, -2, 4, -3, -2, -4, 3, -2, -2, -6, 3 };
1074
1075 std::vector<int8_t> inputToOutputWeights = { 2, 5, -4, 5, 2, -3, 5, 7, 3, -5, 1, -4 };
1076
1077 //tensorInfo16
1078 bool hasRecurrentToInputWeights = true;
1079 std::vector<int8_t> recurrentToInputWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -1, -1 };
1080
1081 std::vector<int8_t> recurrentToForgetWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -2, -1 };
1082
1083 std::vector<int8_t> recurrentToCellWeights = { -2, -3, -1, -3, -4, 2, 1, -1, 2, 2, 1, 2, 3, -2, 3, -3 };
1084
1085 std::vector<int8_t> recurrentToOutputWeights = { -3, 3, -1, -2, -2, -2, -1, -5, 1, 3, -4, -1, -1, -1, 2, -1 };
1086
1087 // tensorInfo4
1088 bool hasCellToInputWeights = true;
1089 std::vector<int8_t> cellToInputWeights = { 5, 10, 25, 15 };
1090 bool hasCellToForgetWeights = true;
1091 std::vector<int8_t> cellToForgetWeights = { -5, 15, 25, 3 };
1092 bool hasCellToOutputWeights = true;
1093 std::vector<int8_t> cellToOutputWeights = { 10, -10, -5, 50 };
1094
1095 bool hasInputGateBias = true;
1096 std::vector<float> inputGateBias = { 0.02234832f, 0.14757581f, 0.18176508f, 0.10380666f};
1097 std::vector<float> forgetGateBias = { 0.035185695f, -0.042891346f, -0.3032477f, 0.23027696f};
1098 std::vector<float> cellBias = { -0.124379363f, 0.55531194f, 0.23377132f, 0.033463873f };
1099 std::vector<float> outputGateBias = { 0.046159424f, -0.12809046f, 0.03563469f, 0.12648113f };
1100
1101 bool hasProjectionWeights = true;
1102 std::vector<int8_t> projectionWeights = { -25, 51, 3, -5, 25, 127, 77, 20, 18, 51, -10, 51, -25, 88, 77, -13 };
1103 bool hasProjectionBias = true;
1104 std::vector<float> projectionBias(outputSize, 0.f);
1105
1106 bool hasInputLayerNormWeights = false;
1107 std::vector<float> inputLayerNormWeights;
1108 bool hasForgetLayerNormWeights = false;
1109 std::vector<float> forgetLayerNormWeights;
1110 bool hasCellLayerNormWeights = false;
1111 std::vector<float> cellLayerNormWeights;
1112 bool hasOutputLayerNormWeights = false;
1113 std::vector<float> outputLayerNormWeights;
1114
1115 std::vector<float> inputValues = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.4f,
1116 0.3f, 0.2f, 0.1f, 0.2f, 0.3f, 0.4f,
1117 0.5f, 0.4f, 0.3f, 0.2f, 0.1f, 0.2f };
1118
1119 std::vector<float> expectedOutputValues = { 0.612103f, 1.56788f, 0.31966f, 1.42956f,
1120 0.909718f, 3.07916f, -0.560586f, 3.8907f,
1121 0.753671f, 1.77485f, 0.365122f, 1.60077f,
1122 0.812644f, 2.79092f, -0.605396f, 3.61742f,
1123 0.791857f, 1.64353f, 0.316588f, 1.55192f,
1124 0.807265f, 2.47012f, -0.539598f, 3.25654f };
1125
1126 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
1127 float clippingThresCell = 10.f;
1128 float clippingThresProj = 0.f;
1129 bool isTimeMajor = false;
1130
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001131 UnidirectionalSequenceLstmTestImpl<int8_t>(::tflite::TensorType_INT8,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001132 batchSize,
1133 timeSize,
1134 inputSize,
1135 outputSize,
1136 numUnits,
1137 hasInputToInputWeights,
1138 inputToInputWeights,
1139 inputToForgetWeights,
1140 inputToCellWeights,
1141 inputToOutputWeights,
1142 hasRecurrentToInputWeights,
1143 recurrentToInputWeights,
1144 recurrentToForgetWeights,
1145 recurrentToCellWeights,
1146 recurrentToOutputWeights,
1147 hasCellToInputWeights,
1148 cellToInputWeights,
1149 hasCellToForgetWeights,
1150 cellToForgetWeights,
1151 hasCellToOutputWeights,
1152 cellToOutputWeights,
1153 hasInputGateBias,
1154 inputGateBias,
1155 forgetGateBias,
1156 cellBias,
1157 outputGateBias,
1158 hasProjectionWeights,
1159 projectionWeights,
1160 hasProjectionBias,
1161 projectionBias,
1162 hasInputLayerNormWeights,
1163 inputLayerNormWeights,
1164 hasForgetLayerNormWeights,
1165 forgetLayerNormWeights,
1166 hasCellLayerNormWeights,
1167 cellLayerNormWeights,
1168 hasOutputLayerNormWeights,
1169 outputLayerNormWeights,
1170 inputValues,
1171 expectedOutputValues,
1172 activationFunction,
1173 clippingThresCell,
1174 clippingThresProj,
1175 isTimeMajor,
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001176 backends,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001177 0.1f);
1178}
1179
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001180void UnidirectionalSequenceLstmInt8WithCifgWithPeepholeNoProjectionTest(
1181 const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001182{
1183 int32_t batchSize = 3;
1184 int32_t timeSize = 2;
1185 int32_t inputSize = 3;
1186 int32_t outputSize = 4;
1187 // cellSize and outputSize have the same size when there is no projection.
1188 int32_t numUnits = outputSize;
1189
1190 //tensorInfo12,
1191 bool hasInputToInputWeights = false;
1192 std::vector<int8_t> inputToInputWeights;
1193
1194 std::vector<int8_t> inputToForgetWeights = { 2, 1, 4, -4, 3, -1, -3, -2, -3, 1, -4, -1 };
1195
1196 std::vector<int8_t> inputToCellWeights = { -2, 1, -2, 4, -3, -2, -4, 3, -2, -2, -6, 3 };
1197
1198 std::vector<int8_t> inputToOutputWeights = { 2, 5, -4, 5, 2, -3, 5, 7, 3, -5, 1, -4 };
1199
1200 //tensorInfo16,
1201 bool hasRecurrentToInputWeights = false;
1202 std::vector<int8_t> recurrentToInputWeights;
1203 std::vector<int8_t> recurrentToForgetWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3, 5, -1, 1, 3, -2, -1 };
1204
1205 std::vector<int8_t> recurrentToCellWeights = { -2, -3, -1, -3, -4, 2, 1, -1, 2, 2, 1, 2, 3, -2, 3, -3 };
1206
1207 std::vector<int8_t> recurrentToOutputWeights = { -3, 3, -1, -2, -2, -2, -1, -5, 1, 3, -4, -1, -1, -1, 2, -1 };
1208
1209 // tensorInfo4
1210 bool hasCellToInputWeights = false;
1211 std::vector<int8_t> cellToInputWeights;
1212 bool hasCellToForgetWeights = true;
1213 std::vector<int8_t> cellToForgetWeights = { 47, -52, -24, 31 };
1214 bool hasCellToOutputWeights = true;
1215 std::vector<int8_t> cellToOutputWeights = { -17, 82, 85, -77 };
1216
1217 bool hasInputGateBias = false;
1218 std::vector<float> inputGateBias;
1219 std::vector<float> forgetGateBias = { 1., 1., 1., 1. };
1220 std::vector<float> cellBias = { 0., 0., 0., 0. };
1221 std::vector<float> outputGateBias = { 0., 0., 0., 0. };
1222
1223 bool hasProjectionWeights = false;
1224 std::vector<int8_t> projectionWeights;
1225 bool hasProjectionBias = false;
1226 std::vector<float> projectionBias;
1227
1228 bool hasInputLayerNormWeights = false;
1229 std::vector<float> inputLayerNormWeights;
1230 bool hasForgetLayerNormWeights = false;
1231 std::vector<float> forgetLayerNormWeights;
1232 bool hasCellLayerNormWeights = false;
1233 std::vector<float> cellLayerNormWeights;
1234 bool hasOutputLayerNormWeights = false;
1235 std::vector<float> outputLayerNormWeights;
1236
1237 std::vector<float> inputValues = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.4f,
1238 0.3f, 0.2f, 0.1f, 0.2f, 0.3f, 0.4f,
1239 0.5f, 0.4f, 0.3f, 0.2f, 0.1f, 0.2f };
1240
1241 std::vector<float> expectedOutputValues = { -0.0072104f, -0.00991171f, -0.00650478f, -0.00713055f,
1242 -0.0191782f, -0.0161269f, -0.0233683f, -0.054299f,
1243 -0.00783725f, 0.00635271f, -0.0126718f, -0.022613f,
1244 -0.0161351f, -0.00775868f, -0.021054f, -0.0339778f,
1245 -0.0146392f, 0.00330261f, -0.0258733f, -0.0407797f,
1246 -0.0174297f, 0.0050105f, -0.0266275f, -0.0362564f };
1247
1248 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
1249 float clippingThresCell = 10.f;
1250 float clippingThresProj = 0.f;
1251 bool isTimeMajor = false;
1252
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001253 UnidirectionalSequenceLstmTestImpl<int8_t>(::tflite::TensorType_INT8,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001254 batchSize,
1255 timeSize,
1256 inputSize,
1257 outputSize,
1258 numUnits,
1259 hasInputToInputWeights,
1260 inputToInputWeights,
1261 inputToForgetWeights,
1262 inputToCellWeights,
1263 inputToOutputWeights,
1264 hasRecurrentToInputWeights,
1265 recurrentToInputWeights,
1266 recurrentToForgetWeights,
1267 recurrentToCellWeights,
1268 recurrentToOutputWeights,
1269 hasCellToInputWeights,
1270 cellToInputWeights,
1271 hasCellToForgetWeights,
1272 cellToForgetWeights,
1273 hasCellToOutputWeights,
1274 cellToOutputWeights,
1275 hasInputGateBias,
1276 inputGateBias,
1277 forgetGateBias,
1278 cellBias,
1279 outputGateBias,
1280 hasProjectionWeights,
1281 projectionWeights,
1282 hasProjectionBias,
1283 projectionBias,
1284 hasInputLayerNormWeights,
1285 inputLayerNormWeights,
1286 hasForgetLayerNormWeights,
1287 forgetLayerNormWeights,
1288 hasCellLayerNormWeights,
1289 cellLayerNormWeights,
1290 hasOutputLayerNormWeights,
1291 outputLayerNormWeights,
1292 inputValues,
1293 expectedOutputValues,
1294 activationFunction,
1295 clippingThresCell,
1296 clippingThresProj,
1297 isTimeMajor,
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001298 backends,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001299 0.1);
1300}
1301
1302void UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionWithLayerNormTest(
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001303 const std::vector<armnn::BackendId>& backends = {})
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001304{
1305 int32_t batchSize = 3;
1306 int32_t timeSize = 2;
1307 int32_t inputSize = 3;
1308 int32_t outputSize = 4;
1309 int32_t numUnits = 5;
1310
1311 bool hasInputToInputWeights = true;
1312 std::vector<int8_t> inputToInputWeights = { -4, -1, -1, -2, 3, -2, 2, 4, 1, -4, -2, 3, 2, 2, -4 };
1313
1314 std::vector<int8_t> inputToForgetWeights = { 2, 1, 4, -4, 3, -1, -3, -2, -3, 1, -4, -1, -3, -2, -4 };
1315
1316 std::vector<int8_t> inputToCellWeights = { -2, 1, -2, 4, -3, -2, -4, 3, -2, -2, -6, 3, 2, 5, -4 };
1317
1318 std::vector<int8_t> inputToOutputWeights = { 2, 5, -4, 5, 2, -3, 5, 7, 3, -5, 1, -4, -4, -1, -1 };
1319
1320 bool hasRecurrentToInputWeights = true;
1321 std::vector<int8_t> recurrentToInputWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3,
1322 5, -1, 1, 3, -1, -1, -1, 4, 2, 3 };
1323
1324 std::vector<int8_t> recurrentToForgetWeights = { -1, 1, -1, 1, -3, -4, -1, 4, 2, 3,
1325 5, -1, 1, 3, -2, -1, -1, 2, 2, 1 };
1326
1327 std::vector<int8_t> recurrentToCellWeights = { -2, -3, -1, -3, -4, 2, 1, -1, 2, 2,
1328 1, 2, 3, -2, 3, -3, -1, -5, 1, 3 };
1329
1330 std::vector<int8_t> recurrentToOutputWeights = { -3, 3, -1, -2, -2, -2, -1, -5, 1, 3,
1331 -4, -1, -1, -1, 2, -1, 5, 1, -3, -4 };
1332
1333 // tensorInfo5
1334 bool hasCellToInputWeights = true;
1335 std::vector<int8_t> cellToInputWeights = { 5, 3, 8, -5, 2 };
1336 bool hasCellToForgetWeights = true;
1337 std::vector<int8_t> cellToForgetWeights = { -2, -7, 5, -3, 4 };
1338 bool hasCellToOutputWeights = true;
1339 std::vector<int8_t> cellToOutputWeights = { 9, -10 , -5, 5, 1 };
1340
1341 bool hasInputGateBias = true;
1342 std::vector<float> inputGateBias = { 0.03f, 0.15f, 0.22f, 0.38f, 0.05f };
1343 std::vector<float> forgetGateBias = { 0.1f, -0.3f, -0.2f, 0.1f, 0.4f };
1344 std::vector<float> cellBias = { -0.05f, 0.72f, 0.25f, 0.08f, 0.1f };
1345 std::vector<float> outputGateBias = { 0.05f, -0.01f, 0.2f, 0.1f, -0.2f };
1346
1347 bool hasProjectionWeights = true;
1348 std::vector<int8_t> projectionWeights = { -1, 2, 1, -2, 1, 5, 3, 8, 7, 2,
1349 -4, 2, 5, -4, 3, -2, 3, 8, -7, 2 };
1350 bool hasProjectionBias = true;
1351 std::vector<float> projectionBias(outputSize, 0.f);
1352
1353 bool hasInputLayerNormWeights = true;
1354 std::vector<float> inputLayerNormWeights = { 0.1f, 0.2f, -0.3f, -0.1f, 0.5f };
1355 bool hasForgetLayerNormWeights = true;
1356 std::vector<float> forgetLayerNormWeights = { -0.1f, 0.2f, 0.3f, 0.5f, 0.2f };
1357 bool hasCellLayerNormWeights = true;
1358 std::vector<float> cellLayerNormWeights = { 0.5f, 0.2f, 0.3f, 0.4f, -0.5f };
1359 bool hasOutputLayerNormWeights = true;
1360 std::vector<float> outputLayerNormWeights = { 0.6f, -0.2f, -0.2f, 0.5f, 0.1f };
1361
1362 std::vector<float> inputValues = { 1., 8., 3., 4., 5., 4.,
1363 3., 2., 1., 2., 3., 4.,
1364 5., 4., 3., 2., 1., 2. };
1365
1366 std::vector<float> expectedOutputValues = { 0.0471276f, 0.0168155f, 0.0789885f, 0.16550f,
1367 0.0643133f, -0.0400722f, 0.100593f, 0.197722f,
1368 0.0465562f, -0.0600682f, 0.0622087f, 0.115053f,
1369 0.056287f, -0.0566218f, 0.0856832f, 0.148484f,
1370 0.0457859f, -0.0588112f, 0.0623636f, 0.114333f,
1371 0.0509271f, -0.0754262f, 0.058600f, 0.0801288f };
1372
1373 tflite::ActivationFunctionType activationFunction = tflite::ActivationFunctionType_TANH;
1374 float clippingThresCell = 10.f;
1375 float clippingThresProj = 0.f;
1376 bool isTimeMajor = false;
1377
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001378 UnidirectionalSequenceLstmTestImpl<int8_t>(::tflite::TensorType_INT8,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001379 batchSize,
1380 timeSize,
1381 inputSize,
1382 outputSize,
1383 numUnits,
1384 hasInputToInputWeights,
1385 inputToInputWeights,
1386 inputToForgetWeights,
1387 inputToCellWeights,
1388 inputToOutputWeights,
1389 hasRecurrentToInputWeights,
1390 recurrentToInputWeights,
1391 recurrentToForgetWeights,
1392 recurrentToCellWeights,
1393 recurrentToOutputWeights,
1394 hasCellToInputWeights,
1395 cellToInputWeights,
1396 hasCellToForgetWeights,
1397 cellToForgetWeights,
1398 hasCellToOutputWeights,
1399 cellToOutputWeights,
1400 hasInputGateBias,
1401 inputGateBias,
1402 forgetGateBias,
1403 cellBias,
1404 outputGateBias,
1405 hasProjectionWeights,
1406 projectionWeights,
1407 hasProjectionBias,
1408 projectionBias,
1409 hasInputLayerNormWeights,
1410 inputLayerNormWeights,
1411 hasForgetLayerNormWeights,
1412 forgetLayerNormWeights,
1413 hasCellLayerNormWeights,
1414 cellLayerNormWeights,
1415 hasOutputLayerNormWeights,
1416 outputLayerNormWeights,
1417 inputValues,
1418 expectedOutputValues,
1419 activationFunction,
1420 clippingThresCell,
1421 clippingThresProj,
1422 isTimeMajor,
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001423 backends,
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001424 0.1);
1425}
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001426
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001427TEST_SUITE("UnidirectionalSequenceLstmTestTests")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001428{
1429
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001430TEST_CASE ("UnidirectionalSequenceLstmTest_Test")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001431{
1432 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1433 UnidirectionalSequenceLstmTest(backends);
1434}
1435
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001436TEST_CASE ("UnidirectionalSequenceLstmTimeMajorTest_Test")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001437{
1438 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1439 UnidirectionalSequenceLstmTimeMajorTest(backends);
1440}
1441
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001442TEST_CASE ("UnidirectionalSequenceLstmTimeMajorSingleTimeTest_Test")
Narumol Prangnawarat5f941242023-08-11 16:09:26 +01001443{
1444 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1445 UnidirectionalSequenceLstmTimeMajorSingleTimeTest(backends);
1446}
1447
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001448TEST_CASE ("UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionTest_Test")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001449{
1450 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1451 UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionTest(backends);
1452}
1453
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001454TEST_CASE ("UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTest_Test")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001455{
1456 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1457 UnidirectionalSequenceLstmWithCifgWithPeepholeNoProjectionTest(backends);
1458}
1459
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001460TEST_CASE ("UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionWithLayerNormTest_Test")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001461{
1462 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1463 UnidirectionalSequenceLstmNoCifgWithPeepholeWithProjectionWithLayerNormTest(backends);
1464}
1465
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001466TEST_CASE ("UnidirectionalSequenceLstmInt8Test_Test")
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001467{
1468 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1469 UnidirectionalSequenceLstmInt8Test(backends);
1470}
1471
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001472TEST_CASE ("UnidirectionalSequenceLstmTimeInt8TimeMajorTest_Test")
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001473{
1474 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1475 UnidirectionalSequenceLstmInt8TimeMajorTest(backends);
1476}
1477
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001478TEST_CASE ("UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionTest_Test")
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001479{
1480 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1481 UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionTest(backends);
1482}
1483
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001484TEST_CASE ("UnidirectionalSequenceLstmInt8WithCifgWithPeepholeNoProjectionTest_Test")
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001485{
1486 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1487 UnidirectionalSequenceLstmInt8WithCifgWithPeepholeNoProjectionTest(backends);
1488}
1489
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001490TEST_CASE ("UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionWithLayerNormTest_Test")
Narumol Prangnawaratbd575b22021-08-31 16:53:54 +01001491{
1492 std::vector <armnn::BackendId> backends = {armnn::Compute::CpuRef};
1493 UnidirectionalSequenceLstmInt8NoCifgWithPeepholeWithProjectionWithLayerNormTest(backends);
1494}
1495
Colm Donelan7bcae3c2024-01-22 10:07:14 +00001496} //End of TEST_SUITE("UnidirectionalSequenceLstmTest")
Narumol Prangnawarat7684b182021-08-12 14:48:15 +01001497
1498} // namespace armnnDelegate