blob: ddf0d0b587cbf7fc625f8d154f5dd81b97081132 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#include "LayerTests.hpp"
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006#include "WorkloadTestUtils.hpp"
Nina Drozdd41b2592018-11-19 13:03:36 +00007#include "TensorUtils.hpp"
telsoa014fcda012018-03-09 14:13:49 +00008
9#include "test/TensorHelpers.hpp"
10#include "TensorCopyUtils.hpp"
surmeh013537c2c2018-05-18 16:31:43 +010011#include "Permute.hpp"
telsoa014fcda012018-03-09 14:13:49 +000012
13#include <boost/test/unit_test.hpp>
surmeh013537c2c2018-05-18 16:31:43 +010014#include <boost/assert.hpp>
telsoa014fcda012018-03-09 14:13:49 +000015
David Beck711fa312018-09-24 10:46:38 +010016#include <armnn/LayerSupport.hpp>
telsoa014fcda012018-03-09 14:13:49 +000017
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000018#include <backendsCommon/CpuTensorHandle.hpp>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +000019#include <backendsCommon/IBackendInternal.hpp>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000020#include <backendsCommon/WorkloadFactory.hpp>
telsoa014fcda012018-03-09 14:13:49 +000021
Éanna Ó Catháinde705582018-12-03 13:04:22 +000022#include <reference/workloads/RefWorkloads.hpp>
23
telsoa014fcda012018-03-09 14:13:49 +000024#include <algorithm>
25#include <boost/cast.hpp>
26
27#include "WorkloadTestUtils.hpp"
28#include "Conv2dTestImpl.hpp"
29#include "BatchNormTestImpl.hpp"
30#include "ActivationTestImpl.hpp"
31#include "Pooling2dTestImpl.hpp"
32#include "ReshapeTestImpl.hpp"
33#include "FullyConnectedTestImpl.hpp"
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +000034#include "SpaceToBatchNdTestImpl.hpp"
telsoa014fcda012018-03-09 14:13:49 +000035#include "SplitterTestImpl.hpp"
36#include "SoftmaxTestImpl.hpp"
Nattapat Chaimanowong1216b582018-11-23 15:33:41 +000037#include "StridedSliceTestImpl.hpp"
telsoa014fcda012018-03-09 14:13:49 +000038#include "NormTestImpl.hpp"
39#include "PermuteTestImpl.hpp"
telsoa01c577f2c2018-08-31 09:22:23 +010040#include "LstmTestImpl.hpp"
41#include "ConvertFp16ToFp32TestImpl.hpp"
42#include "ConvertFp32ToFp16TestImpl.hpp"
Nattapat Chaimanowongcfdcadf2018-12-06 11:54:33 +000043#include "DebugTestImpl.hpp"
telsoa014fcda012018-03-09 14:13:49 +000044
telsoa01c577f2c2018-08-31 09:22:23 +010045// 3-channel 16x8 image used as common input data for a number of Conv2d tests.
telsoa014fcda012018-03-09 14:13:49 +000046static std::vector<float> ConvInput3x8x16({
47 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
48 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
49 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
50 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
51 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
52 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
53 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
54 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f,
55 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
65 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
66 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
67 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
68 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
69 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
70 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
71});
72
telsoa01c577f2c2018-08-31 09:22:23 +010073// 2-channel bias used by a number of Conv2d tests.
telsoa014fcda012018-03-09 14:13:49 +000074static std::vector<float> Bias2({0, 2});
75
telsoa01c577f2c2018-08-31 09:22:23 +010076// Helper function that returns either Bias2 or an empty vector depending on whether bias is enabled.
telsoa014fcda012018-03-09 14:13:49 +000077template<typename T>
78boost::multi_array<T, 1> GetBias2(bool biasEnabled, float qScale, int32_t qOffset)
79{
80 if(biasEnabled)
81 {
82 armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias2.size())}, armnn::GetDataType<T>());
83 boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(qScale, qOffset, Bias2));
84 return bias;
85 }
86 else
87 {
88 return boost::multi_array<T, 1>();
89 }
90}
91
92template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +000093LayerTestResult<T, 4> SimpleConvolution2d3x5TestCommon(
94 armnn::IWorkloadFactory& workloadFactory,
95 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
96 float qScale,
97 int32_t qOffset,
98 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +000099 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000100{
telsoa01c577f2c2018-08-31 09:22:23 +0100101 // Use common single-batch 3-channel 16x8 image.
telsoa014fcda012018-03-09 14:13:49 +0000102 armnn::TensorInfo inputDesc({1, 3, 8, 16}, armnn::GetDataType<T>());
103 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16));
104
telsoa01c577f2c2018-08-31 09:22:23 +0100105 // Use a 2-element batch with 3-channel 3x5 kernels.
telsoa014fcda012018-03-09 14:13:49 +0000106 armnn::TensorInfo kernelDesc({2, 3, 5, 3}, armnn::GetDataType<T>());
107 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>(
108 QuantizedVector<T>(qScale, qOffset, {
109 1, 1, 1,
110 1, -1, 1,
111 1, 1, 1,
112 1, 1, 1,
113 1, 1, 1,
114
115 0, 0, 0,
116 0, 0, 0,
117 0, 0, 0,
118 0, 0, 0,
119 0, 0, 0,
120
121 2, 2, 2,
122 2, 2, 2,
123 2, 2, 2,
124 2, 2, 2,
125 2, 2, 2,
126
127
128 0, 0, 0,
129 0, 0, 0,
130 0, 0, 0,
131 0, 0, 0,
132 0, 0, 0,
133
134 1, 1, 1,
135 1, 1, 1,
136 1, 1, 1,
137 1, 1, 1,
138 1, 1, 1,
139
140 0, 0, 0,
141 0, 0, 0,
142 0, 0, 0,
143 0, 0, 0,
144 0, 0, 0
145 })));
146
telsoa01c577f2c2018-08-31 09:22:23 +0100147 // Expected output is 2 batch elements of a 1-channel 14x4 image.
telsoa014fcda012018-03-09 14:13:49 +0000148 armnn::TensorInfo outputDesc({1, 2, 4, 14}, armnn::GetDataType<T>());
149 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>(
150 QuantizedVector<T>(qScale, qOffset, {
151 -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
152 -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
153 -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f,
154 -23.5f, -23.5f, -23.5f,
155 -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f,
156 -23.5f, -23.5f, -23.5f,
157
158 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
159 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
162 })));
163
164 return SimpleConvolution2dTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000165 memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000166 input,
167 kernel,
168 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset),
169 expectedOutput,
170 qScale,
jimfly010a088a62018-10-25 17:05:05 +0100171 qOffset,
172 layout);
telsoa014fcda012018-03-09 14:13:49 +0000173}
174
175template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000176LayerTestResult<T, 4> SimpleConvolution2d3x3TestCommon(
177 armnn::IWorkloadFactory& workloadFactory,
178 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
179 float qScale,
180 int32_t qOffset,
181 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000182 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000183{
telsoa01c577f2c2018-08-31 09:22:23 +0100184 // Use a 3x3 kernel, which exercises ArmCompute's direct convolution path.
telsoa014fcda012018-03-09 14:13:49 +0000185
telsoa01c577f2c2018-08-31 09:22:23 +0100186 // Use common single-batch 3-channel 16x8 image.
telsoa014fcda012018-03-09 14:13:49 +0000187 armnn::TensorInfo inputDesc({1, 3, 8, 16}, armnn::GetDataType<T>());
188 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16));
189
telsoa01c577f2c2018-08-31 09:22:23 +0100190 // Use a 2-element batch of 3-channel 3x3 kernels.
telsoa014fcda012018-03-09 14:13:49 +0000191 armnn::TensorInfo kernelDesc({2, 3, 3, 3}, armnn::GetDataType<T>());
192 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>(
193 QuantizedVector<T>(qScale, qOffset, {
194 1, 1, 1,
195 1, -1, 1,
196 1, 1, 1,
197
198 0, 0, 0,
199 0, 0, 0,
200 0, 0, 0,
201
202 2, 2, 2,
203 2, 2, 2,
204 2, 2, 2,
205
206
207 0, 0, 0,
208 0, 0, 0,
209 0, 0, 0,
210
211 1, 1, 1,
212 1, 1, 1,
213 1, 1, 1,
214
215 0, 0, 0,
216 0, 0, 0,
217 0, 0, 0
218 })));
219
telsoa01c577f2c2018-08-31 09:22:23 +0100220 // Expected output is 1 batch of a 2-channel 14x6 image.
telsoa014fcda012018-03-09 14:13:49 +0000221 armnn::TensorInfo outputDesc({1, 2, 6, 14}, armnn::GetDataType<T>());
222 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>(
223 QuantizedVector<T>(qScale, qOffset, {
224 -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15,
225 -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
226 -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,
227 -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,
228 -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,
229 -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,
230
231 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
232 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
233 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
235 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
237 })));
238
239 return SimpleConvolution2dTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000240 memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000241 input,
242 kernel,
243 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset),
244 expectedOutput,
245 qScale,
narpra015f703182018-10-26 16:24:58 +0100246 qOffset,
247 layout);
telsoa014fcda012018-03-09 14:13:49 +0000248}
249
Francis Murtaghd59116e2018-10-04 16:03:07 +0100250template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000251LayerTestResult<T, 4> SimpleConvolution2d3x3NhwcTestCommon(
252 armnn::IWorkloadFactory& workloadFactory,
253 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
254 float qScale,
255 int32_t qOffset,
256 bool biasEnabled,
257 armnn::DataLayout dataLayout)
Francis Murtaghd59116e2018-10-04 16:03:07 +0100258{
259 // Use common single-batch 5x5 image.
260
261 armnn::TensorInfo inputDesc({1, 3, 4, 1}, armnn::GetDataType<T>());
262 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc,
263 {
264 1, 5, 2, 3,
265 8, 7, 3, 6,
266 3, 3, 9, 1
267 });
268
269
270 // Use a 2-element batch of 3-channel 3x3 kernels.
271 armnn::TensorInfo kernelDesc({1, 3, 3, 1}, armnn::GetDataType<T>());
272 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, {
273 4, 5, 6,
274 0, 0, 0,
275 3, 2, 1
276 });
277
278 // Expected output is 1 batch of a 5x5 image.
279 armnn::TensorInfo outputDesc({1, 3, 4, 1}, armnn::GetDataType<T>());
280
281 const std::vector<float> outputData =
282 {
283 23, 41, 33, 21,
284 44, 65, 76, 52,
285 82, 85, 79, 42
286 };
287
288 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData);
289
290 return SimpleConvolution2dNhwcTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000291 memoryManager,
Francis Murtaghd59116e2018-10-04 16:03:07 +0100292 input,
293 kernel,
294 boost::multi_array<T, 1>(),
295 expectedOutput,
296 dataLayout,
297 qScale,
298 qOffset);
299}
300
Mike Kelly7332ed82018-12-20 17:03:06 +0000301template<typename T>
302LayerTestResult<T, 4> SimpleConvolution2d3x3Stride2x2TestCommon(
303 armnn::IWorkloadFactory& workloadFactory,
304 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
305 float qScale,
306 int32_t qOffset,
307 bool biasEnabled,
308 const armnn::DataLayout& dataLayout)
309{
310 // Input is a single-batch, 1 channel, 5x5 image.
311 armnn::TensorInfo inputDesc({1, 5, 5, 1}, armnn::GetDataType<T>());
312 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc,
313 {
314 1, 5, 2, 3, 5,
315 8, 7, 3, 6, 3,
316 3, 3, 9, 1, 9,
317 4, 1, 8, 1, 3,
318 6, 8, 1, 9, 2
319 });
320
321 // Use a 3x3 kernel.
322 armnn::TensorInfo kernelDesc({1, 3, 3, 1}, armnn::GetDataType<T>());
323 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc,
324 {
325 4, 5, 6,
326 0, 0, 0,
327 3, 2, 1
328 });
329
330 // Expected output is a single-batch, 1 channel, 3x3 image.
331 armnn::TensorInfo outputDesc({1, 3, 3, 1}, armnn::GetDataType<T>());
332
333 const std::vector<T> outputData =
334 {
335 23, 33, 24,
336 91, 99, 48,
337 26, 50, 19
338 };
339
340 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData);
341
342 uint32_t padLeft = 1;
343 uint32_t padTop = 1;
344 uint32_t padRight = 1;
345 uint32_t padBottom = 1;
346 uint32_t strideX = 2;
347 uint32_t strideY = 2;
348
349 return SimpleConvolution2dNhwcTestImpl<T>(workloadFactory,
350 memoryManager,
351 input,
352 kernel,
353 boost::multi_array<T, 1>(),
354 expectedOutput,
355 dataLayout,
356 qScale,
357 qOffset,
358 padLeft,
359 padTop,
360 padRight,
361 padBottom,
362 strideX,
363 strideY);
364}
365
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000366LayerTestResult<float, 4> SimpleConvolution2d3x5Test(
367 armnn::IWorkloadFactory& workloadFactory,
368 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
369 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000370 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000371{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000372 return SimpleConvolution2d3x5TestCommon<float>(workloadFactory, memoryManager, 0.f, 0, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000373}
374
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000375LayerTestResult<uint8_t, 4> SimpleConvolution2d3x5Uint8Test(
376 armnn::IWorkloadFactory& workloadFactory,
377 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
378 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000379 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000380{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000381 return SimpleConvolution2d3x5TestCommon<uint8_t>(workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000382}
383
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000384LayerTestResult<float, 4> SimpleConvolution2d3x3Test(
385 armnn::IWorkloadFactory& workloadFactory,
386 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
387 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000388 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000389{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000390 return SimpleConvolution2d3x3TestCommon<float>(workloadFactory, memoryManager, 0.f, 0, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000391}
392
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000393LayerTestResult<float, 4> SimpleConvolution2d3x3NhwcTest(
394 armnn::IWorkloadFactory& workloadFactory,
395 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
396 bool biasEnabled)
Francis Murtaghd59116e2018-10-04 16:03:07 +0100397{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000398 return SimpleConvolution2d3x3NhwcTestCommon<float>(workloadFactory,
399 memoryManager,
400 0.f,
401 0,
402 biasEnabled,
403 armnn::DataLayout::NHWC);
Francis Murtaghd59116e2018-10-04 16:03:07 +0100404}
405
Mike Kelly7332ed82018-12-20 17:03:06 +0000406LayerTestResult<float, 4> SimpleConvolution2d3x3Stride2x2Test(
407 armnn::IWorkloadFactory& workloadFactory,
408 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
409 bool biasEnabled,
410 const armnn::DataLayout layout)
411{
412 return SimpleConvolution2d3x3Stride2x2TestCommon<float>(workloadFactory,
413 memoryManager,
414 0.f,
415 0,
416 biasEnabled,
417 layout);
418}
419
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000420LayerTestResult<uint8_t, 4> SimpleConvolution2d3x3Uint8Test(
421 armnn::IWorkloadFactory& workloadFactory,
422 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
423 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000424 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000425{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000426 return SimpleConvolution2d3x3TestCommon<uint8_t>(workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000427}
428
429template<typename T>
430LayerTestResult<T, 4> Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon(
431 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000432 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +0000433 const armnn::DataLayout layout,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000434 float qScale,
435 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +0000436{
telsoa01c577f2c2018-08-31 09:22:23 +0100437 // Use a single-batch 1-channel 3x3 image as input.
telsoa014fcda012018-03-09 14:13:49 +0000438 armnn::TensorInfo inputDesc({1, 1, 3, 3}, armnn::GetDataType<T>());
439 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>(
440 QuantizedVector<T>(qScale, qOffset, {
441 11,21,31,
442 12,22,32,
443 13,23,33
444 })));
445
telsoa01c577f2c2018-08-31 09:22:23 +0100446 // Use 1 batch of a 1-channel 2x2 kernel.
telsoa014fcda012018-03-09 14:13:49 +0000447 armnn::TensorInfo kernelDesc({1, 1, 2, 2}, armnn::GetDataType<T>());
448 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>(
449 QuantizedVector<T>(qScale, qOffset, {
450 -11,-21,
451 -12,-22,
452 })));
453
telsoa01c577f2c2018-08-31 09:22:23 +0100454// Expected output is 1 batch of a 1-channel 6x8 image.
telsoa014fcda012018-03-09 14:13:49 +0000455// Manually calculated like this:
456//[-11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ..]
457//[-11*0 -21*0 -12*0 -22*11 ; -11*0 -21*0 -12*11 -22*21 ; -11*0 -21*0 -12*21 -22*31 ; -11*0 -21*0 -12*31 -22*0 ..]
458//[-11*0 -21*11 -12*0 -22*12 ; -11*11 -21*21 -12*12 -22*22 ; -11*21 -21*31 -12*22 -22*32 ; -11*31 -21*0 -12*32 -22*0 ..]
459//[-11*0 -21*12 -12*0 -22*13 ; -11*12 -21*22 -12*13 -22*23 ; -11*22 -21*32 -12*23 -22*33 ; -11*32 -21*0 -12*33 -22*0 ..]
460//[-11*0 -21*13 -12*0 -22*0 ; -11*13 -21*23 -12*0 -22*0 ; -11*23 -21*33 -12*0 -22*0 ; -11*33 -21*0 -12*0 -22*0 ..]
461//[-11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ..]
462//[..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ..]
463 armnn::TensorInfo outputDesc({1, 1, 8, 6}, armnn::GetDataType<T>());
464 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>(
465 QuantizedVector<T>(qScale, qOffset, {
466 0, 0, 0, 0, 0, 0,
467 -242, -594, -934, -372, 0, 0,
468 -495, -1190, -1850, -725, 0, 0,
469 -538, -1256, -1916, -748, 0, 0,
470 -273, -626, -946, -363, 0, 0,
471 0, 0, 0, 0, 0, 0,
472 0, 0, 0, 0, 0, 0,
473 0, 0, 0, 0, 0, 0
474 })));
475
476 return SimpleConvolution2dTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000477 memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000478 input,
479 kernel,
480 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(false, qScale, qOffset),
481 expectedOutput,
482 qScale,
483 qOffset,
narpra015f703182018-10-26 16:24:58 +0100484 layout,
telsoa01c577f2c2018-08-31 09:22:23 +0100485 1, // Padding left.
486 2, // Padding top.
487 3, // Padding right.
488 4); // Padding bottom.
telsoa014fcda012018-03-09 14:13:49 +0000489}
490
491template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000492LayerTestResult<T, 4> SimpleConvolution2dAsymmetricPaddingTestCommon(
493 armnn::IWorkloadFactory& workloadFactory,
494 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +0000495 const armnn::DataLayout layout,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000496 float qScale,
497 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +0000498{
telsoa01c577f2c2018-08-31 09:22:23 +0100499 // Use a single-batch 1-channel 5x5 image as input.
telsoa014fcda012018-03-09 14:13:49 +0000500 armnn::TensorInfo inputDesc({ 1, 1, 5, 5 }, armnn::GetDataType<T>());
501 boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>(
502 QuantizedVector<T>(qScale, qOffset, {
503 11,21,31,41,51,
504 12,22,32,42,52,
505 13,23,33,43,53,
506 14,24,34,44,54,
507 15,25,35,45,55,
508 })));
509
telsoa01c577f2c2018-08-31 09:22:23 +0100510 // Use 1 batch of a 1-channel 4x4 kernel.
telsoa014fcda012018-03-09 14:13:49 +0000511 armnn::TensorInfo kernelDesc({ 1, 1, 4, 4 }, armnn::GetDataType<T>());
512 boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>(
513 QuantizedVector<T>(qScale, qOffset, {
514 -11,-21,-31,-41,
515 -12,-22,-32,-42,
516 -13,-23,-33,-43,
517 -14,-24,-34,-44,
518 })));
519
telsoa01c577f2c2018-08-31 09:22:23 +0100520 // Expected output is 1 batch of a 1-channel 5x5 image.
telsoa014fcda012018-03-09 14:13:49 +0000521 armnn::TensorInfo outputDesc({ 1, 1, 5, 5 }, armnn::GetDataType<T>());
522 std::vector<T> myVec(outputDesc.GetNumElements(), 0);
523 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>(
524 QuantizedVector<T>(qScale, qOffset, {
telsoa014fcda012018-03-09 14:13:49 +0000525 -7140, -10580, -13940, -9300, -5230,
526 -9590, -14120, -18520, -12290, -6860,
527 -9980, -14560, -18960, -12560, -7000,
528 -7518, -10904, -14144, -9318, -5152,
surmeh013537c2c2018-05-18 16:31:43 +0100529 -5032, -7256, -9376, -6142, -3368,
telsoa014fcda012018-03-09 14:13:49 +0000530 })));
531
532 return SimpleConvolution2dTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000533 memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000534 input,
535 kernel,
536 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(false, qScale, qOffset),
537 expectedOutput,
538 qScale,
539 qOffset,
narpra015f703182018-10-26 16:24:58 +0100540 layout,
telsoa01c577f2c2018-08-31 09:22:23 +0100541 1, // Padding left.
542 1, // Padding top.
543 2, // Padding right.
544 2); // Padding bottom.
surmeh013537c2c2018-05-18 16:31:43 +0100545}
546
547template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000548LayerTestResult<T, 4> DepthwiseConvolution2dAsymmetricTestCommon(
549 armnn::IWorkloadFactory& workloadFactory,
550 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
551 float qScale,
552 int32_t qOffset,
553 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000554 const armnn::DataLayout layout)
surmeh013537c2c2018-05-18 16:31:43 +0100555{
telsoa01c577f2c2018-08-31 09:22:23 +0100556 // Use a single-batch 2-channel 5x5 image as input.
surmeh013537c2c2018-05-18 16:31:43 +0100557 armnn::TensorInfo inputTensorInfo({ 1, 2, 5, 5 }, armnn::GetDataType<T>());
558 auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(
559 QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), {
560 0, 1, 2, 3, 4,
561 5, 6, 7, 8, 9,
562 10, 11, 12, 13, 14,
563 15, 16, 17, 18, 19,
564 20, 21, 22, 23, 24,
565
566 25, 26, 27, 28, 29,
567 30, 31, 32, 33, 34,
568 35, 36, 37, 38, 39,
569 40, 41, 42, 43, 44,
570 45, 46, 47, 48, 49
571 })));
572
telsoa01c577f2c2018-08-31 09:22:23 +0100573 // Use a depth multiplier of 1 on a 2-channel 4x4 kernel.
surmeh013537c2c2018-05-18 16:31:43 +0100574 armnn::TensorInfo kernelTensorInfo({ 1, 2, 4, 4 }, armnn::GetDataType<T>());
575 auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>(
576 QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), {
577 32, 31, 30, 29,
578 28, 27, 26, 25,
579 24, 23, 22, 21,
580 20, 19, 18, 17,
581
582 16, 15, 14, 13,
583 12, 11, 10, 9,
584 8, 7, 6, 5,
585 4, 3, 2, 1
586 })));
587
telsoa01c577f2c2018-08-31 09:22:23 +0100588 // Expected output is 1 batch of a 2-channel 5x5 image.
589 // Calculated using the python tensorflow library with strideX=1, strideY=1.
surmeh013537c2c2018-05-18 16:31:43 +0100590 armnn::TensorInfo outputTensorInfo({ 1, 2, 5, 5 }, armnn::GetDataType<T>());
591 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(
592 QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), {
593 1062, 1580, 1850, 1530, 1117,
594 2140, 3108, 3500, 2842, 2042,
595 3580, 5068, 5460, 4342, 3062,
596 3618, 5072, 5390, 4248, 2971,
597 3074, 4282, 4510, 3533, 2457,
598 1550, 2284, 2362, 1955, 1428,
599 2910, 4206, 4342, 3528, 2536,
600 3390, 4886, 5022, 4068, 2916,
601 3566, 5056, 5182, 4133, 2922,
602 3100, 4352, 4452, 3517, 2465
603 })));
604
605 return DepthwiseConvolution2dAsymmetricTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000606 memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +0100607 input,
608 kernel,
609 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset),
610 expectedOutput,
611 qScale,
612 qOffset,
jimfly01382a91d2018-10-26 15:55:50 +0100613 layout,
telsoa01c577f2c2018-08-31 09:22:23 +0100614 1, // Padding left.
615 1, // Padding top.
616 2, // Padding right.
617 2, // Padding bottom.
surmeh013537c2c2018-05-18 16:31:43 +0100618 1, // strideX
619 1); // strideY
telsoa014fcda012018-03-09 14:13:49 +0000620}
621
Nikhil Rajcec6b652018-10-12 13:51:57 +0100622template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000623LayerTestResult<T, 4> DepthwiseConvolution2dNhwcTestCommon(
624 armnn::IWorkloadFactory& workloadFactory,
625 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
626 float qScale,
627 int32_t qOffset,
628 bool biasEnabled)
Nikhil Rajcec6b652018-10-12 13:51:57 +0100629{
630 armnn::TensorInfo inputTensorInfo({ 1, 5, 5, 2}, armnn::GetDataType<T>());
631 auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(
632 QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), {
633 0, 25,
634 1, 26,
635 2, 27,
636 3, 28,
637 4, 29,
638
639 5, 30,
640 6, 31,
641 7, 32,
642 8, 33,
643 9, 34,
644
645 10, 35,
646 11, 36,
647 12, 37,
648 13, 38,
649 14, 39,
650
651 15, 40,
652 16, 41,
653 17, 42,
654 18, 43,
655 19, 44,
656
657 20, 45,
658 21, 46,
659 22, 47,
660 23, 48,
661 24, 49
662 })));
663
664 armnn::TensorInfo kernelTensorInfo({ 1, 4, 4, 2}, armnn::GetDataType<T>());
665 auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>(
666 QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), {
667 32, 16,
668 31, 15,
669 30, 14,
670 29, 13,
671
672 28, 12,
673 27, 11,
674 26, 10,
675 25, 9,
676
677 24, 8,
678 23, 7,
679 22, 6,
680 21, 5,
681
682 20, 4,
683 19, 3,
684 18, 2,
685 17, 1
686 })));
687
688 armnn::TensorInfo outputTensorInfo({ 1, 5, 5, 2}, armnn::GetDataType<T>());
689 boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(
690 QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), {
691 1062, 1550,
692 1580, 2284,
693 1850, 2362,
694 1530, 1955,
695 1117, 1428,
696
697 2140, 2910,
698 3108, 4206,
699 3500, 4342,
700 2842, 3528,
701 2042, 2536,
702
703 3580, 3390,
704 5068, 4886,
705 5460, 5022,
706 4342, 4068,
707 3062, 2916,
708
709 3618, 3566,
710 5072, 5056,
711 5390, 5182,
712 4248, 4133,
713 2971, 2922,
714
715 3074, 3100,
716 4282, 4352,
717 4510, 4452,
718 3533, 3517,
719 2457, 2465
720 })));
721
722 return DepthwiseConvolution2dNhwcTestImpl<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000723 memoryManager,
Nikhil Rajcec6b652018-10-12 13:51:57 +0100724 input,
725 kernel,
726 GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset),
727 expectedOutput,
728 qScale,
729 qOffset,
730 1, // Padding left.
731 1, // Padding top.
732 2, // Padding right.
733 2, // Padding bottom.
734 1, // strideX
735 1); // strideY
736}
737
telsoa014fcda012018-03-09 14:13:49 +0000738LayerTestResult<float, 4>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000739Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTest(
740 armnn::IWorkloadFactory& workloadFactory,
741 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +0000742 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000743{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000744 return Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon<float>(
745 workloadFactory, memoryManager, layout, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +0000746}
747
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000748LayerTestResult<float, 4> Convolution2dAsymmetricPaddingTest(
749 armnn::IWorkloadFactory& workloadFactory,
750 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +0000751 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000752{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000753 return SimpleConvolution2dAsymmetricPaddingTestCommon<float>(
754 workloadFactory, memoryManager, layout, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +0000755}
756
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000757LayerTestResult<float, 4> DepthwiseConvolution2dTest(
758 armnn::IWorkloadFactory& workloadFactory,
759 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
760 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000761 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000762{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000763 return DepthwiseConvolution2dTestImpl<float, float>(
764 workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000765}
766
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000767LayerTestResult<float, 4> DepthwiseConvolution2dDepthNhwcTest(
768 armnn::IWorkloadFactory& workloadFactory,
769 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
770 bool biasEnabled)
Nikhil Rajcec6b652018-10-12 13:51:57 +0100771{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000772 return DepthwiseConvolution2dNhwcTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0, biasEnabled);
Nikhil Rajcec6b652018-10-12 13:51:57 +0100773}
774
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000775LayerTestResult<float, 4> DepthwiseConvolution2dDepthMul1Test(
776 armnn::IWorkloadFactory& workloadFactory,
777 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
778 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000779 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000780{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000781 return DepthwiseConvolution2dDepthMul1TestImpl<float, float>(
782 workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000783}
784
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000785LayerTestResult<float, 4> DepthwiseConvolution2dAsymmetricTest(
786 armnn::IWorkloadFactory& workloadFactory,
787 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
788 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000789 const armnn::DataLayout layout)
surmeh013537c2c2018-05-18 16:31:43 +0100790{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000791 return DepthwiseConvolution2dAsymmetricTestCommon<float>(
792 workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout);
surmeh013537c2c2018-05-18 16:31:43 +0100793}
794
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000795LayerTestResult<uint8_t, 4> DepthwiseConvolution2dUint8Test(
796 armnn::IWorkloadFactory& workloadFactory,
797 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
798 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000799 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000800{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000801 return DepthwiseConvolution2dTestImpl<uint8_t, int32_t>(
802 workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000803}
804
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000805LayerTestResult<uint8_t, 4> DepthwiseConvolution2dDepthMul1Uint8Test(
806 armnn::IWorkloadFactory& workloadFactory,
807 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
808 bool biasEnabled,
Matthew Bentham8800c002018-11-19 13:19:28 +0000809 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000810{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000811 return DepthwiseConvolution2dDepthMul1TestImpl<uint8_t, int32_t>(
812 workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout);
telsoa014fcda012018-03-09 14:13:49 +0000813}
814
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000815LayerTestResult<float, 4> Convolution1dTest(
816 armnn::IWorkloadFactory& workloadFactory,
817 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
818 bool biasEnabled)
telsoa014fcda012018-03-09 14:13:49 +0000819{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000820 return Convolution1dTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, biasEnabled);
telsoa014fcda012018-03-09 14:13:49 +0000821}
822
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000823LayerTestResult<uint8_t, 4> Convolution1dUint8Test(
824 armnn::IWorkloadFactory& workloadFactory,
825 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
826 bool biasEnabled)
telsoa014fcda012018-03-09 14:13:49 +0000827{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000828 return Convolution1dTestImpl<uint8_t>(workloadFactory, memoryManager, 0.1f, 128, biasEnabled);
telsoa014fcda012018-03-09 14:13:49 +0000829}
830
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000831LayerTestResult<float,4> CompareConvolution2dTest(
832 armnn::IWorkloadFactory& workloadFactory,
833 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
834 armnn::IWorkloadFactory& refWorkloadFactory)
telsoa014fcda012018-03-09 14:13:49 +0000835{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000836 return CompareConvolution2dTestImpl<float>(workloadFactory, memoryManager, refWorkloadFactory);
telsoa014fcda012018-03-09 14:13:49 +0000837}
838
839template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000840LayerTestResult<T,4> CompareDepthwiseConvolution2dTest(
841 armnn::IWorkloadFactory& workloadFactory,
842 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
843 armnn::IWorkloadFactory& refWorkloadFactory,
Matthew Bentham8800c002018-11-19 13:19:28 +0000844 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +0000845{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000846 return CompareDepthwiseConvolution2dTestImpl<T>(workloadFactory, memoryManager, refWorkloadFactory, layout);
telsoa014fcda012018-03-09 14:13:49 +0000847}
848
849template LayerTestResult<float, 4> CompareDepthwiseConvolution2dTest<float>(
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000850 armnn::IWorkloadFactory&,
851 const armnn::IBackendInternal::IMemoryManagerSharedPtr&,
852 armnn::IWorkloadFactory&,
Matthew Bentham8800c002018-11-19 13:19:28 +0000853 const armnn::DataLayout);
telsoa014fcda012018-03-09 14:13:49 +0000854
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000855template LayerTestResult<uint8_t, 4> CompareDepthwiseConvolution2dTest<uint8_t>(
856 armnn::IWorkloadFactory&,
857 const armnn::IBackendInternal::IMemoryManagerSharedPtr&,
858 armnn::IWorkloadFactory&,
Matthew Bentham8800c002018-11-19 13:19:28 +0000859 const armnn::DataLayout);
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000860
861LayerTestResult<float,4> SimpleNormalizationAcrossTest(
862 armnn::IWorkloadFactory& workloadFactory,
863 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000864{
865 auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness;
866 auto normChannel = armnn::NormalizationAlgorithmChannel::Across;
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000867 return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod);
telsoa014fcda012018-03-09 14:13:49 +0000868}
869
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000870LayerTestResult<float,4> SimpleNormalizationWithinTest(
871 armnn::IWorkloadFactory& workloadFactory,
872 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000873{
874 auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness;
875 auto normChannel = armnn::NormalizationAlgorithmChannel::Within;
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000876 return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod);
telsoa014fcda012018-03-09 14:13:49 +0000877}
878
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000879LayerTestResult<float,4> SimpleNormalizationAcrossNhwcTest(
880 armnn::IWorkloadFactory& workloadFactory,
881 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra0155a97bc2018-10-02 14:35:53 +0100882{
883 auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness;
884 auto normChannel = armnn::NormalizationAlgorithmChannel::Across;
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000885 return SimpleNormalizationNhwcTestImpl(workloadFactory, memoryManager, normChannel, normMethod);
narpra0155a97bc2018-10-02 14:35:53 +0100886}
887
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000888LayerTestResult<float,2> SimpleSoftmaxTest(
889 armnn::IWorkloadFactory& workloadFactory,
890 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
891 float beta)
telsoa014fcda012018-03-09 14:13:49 +0000892{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000893 return SimpleSoftmaxTestImpl<float>(workloadFactory, memoryManager, beta);
telsoa014fcda012018-03-09 14:13:49 +0000894}
895
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000896LayerTestResult<uint8_t,2> SimpleSoftmaxUint8Test(
897 armnn::IWorkloadFactory& workloadFactory,
898 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
899 float beta)
telsoa014fcda012018-03-09 14:13:49 +0000900{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000901 return SimpleSoftmaxTestImpl<uint8_t>(workloadFactory, memoryManager, beta);
telsoa014fcda012018-03-09 14:13:49 +0000902}
903
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000904LayerTestResult<float,4> CompareNormalizationTest(
905 armnn::IWorkloadFactory& workloadFactory,
906 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
907 armnn::IWorkloadFactory& refWorkloadFactory,
908 armnn::NormalizationAlgorithmChannel normChannel,
909 armnn::NormalizationAlgorithmMethod normMethod)
telsoa014fcda012018-03-09 14:13:49 +0000910{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000911 return CompareNormalizationTestImpl(workloadFactory, memoryManager, refWorkloadFactory, normChannel, normMethod);
telsoa014fcda012018-03-09 14:13:49 +0000912}
913
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000914LayerTestResult<float,2> CompareSoftmaxTest(
915 armnn::IWorkloadFactory& workloadFactory,
916 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000917 armnn::IWorkloadFactory& refWorkloadFactory,
918 float beta)
919{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000920 return CompareSoftmaxTestImpl<float>(workloadFactory, memoryManager, refWorkloadFactory, beta);
telsoa014fcda012018-03-09 14:13:49 +0000921}
922
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000923LayerTestResult<uint8_t,2> CompareSoftmaxUint8Test(
924 armnn::IWorkloadFactory& workloadFactory,
925 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +0000926 armnn::IWorkloadFactory& refWorkloadFactory,
927 float beta)
928{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000929 return CompareSoftmaxTestImpl<uint8_t>(workloadFactory, memoryManager, refWorkloadFactory, beta);
telsoa014fcda012018-03-09 14:13:49 +0000930}
931
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000932std::vector<LayerTestResult<float,3>> SplitterTest(
933 armnn::IWorkloadFactory& workloadFactory,
934 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000935{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000936 return SplitterTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +0000937}
938
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000939std::vector<LayerTestResult<uint8_t,3>> SplitterUint8Test(
940 armnn::IWorkloadFactory& workloadFactory,
941 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000942{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000943 return SplitterTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +0000944}
945
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000946LayerTestResult<float, 3> CopyViaSplitterTest(
947 armnn::IWorkloadFactory& workloadFactory,
948 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000949{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000950 return CopyViaSplitterTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +0000951}
952
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000953LayerTestResult<uint8_t, 3> CopyViaSplitterUint8Test(
954 armnn::IWorkloadFactory& workloadFactory,
955 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +0000956{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000957 return CopyViaSplitterTestImpl<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +0000958}
959
telsoa01c577f2c2018-08-31 09:22:23 +0100960LayerTestResult<float, 2> LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest(
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000961 armnn::IWorkloadFactory& workloadFactory,
962 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa01c577f2c2018-08-31 09:22:23 +0100963{
964 armnn::TensorInfo inputDesc({ 2, 2 }, armnn::GetDataType<float>());
965 boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
966 { 2., 3., 3., 4. }));
967
968 armnn::TensorInfo outputDesc({ 2, 4 }, armnn::GetDataType<float>());
969 boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
970 {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f,
971 -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f}));
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000972 return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl(
973 workloadFactory, memoryManager, input, expectedOutput);
telsoa01c577f2c2018-08-31 09:22:23 +0100974}
975
976LayerTestResult<float, 2> LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest(
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000977 armnn::IWorkloadFactory& workloadFactory,
978 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa01c577f2c2018-08-31 09:22:23 +0100979{
980 armnn::TensorInfo inputDesc({ 2, 5 }, armnn::GetDataType<float>());
981 boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
982 {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f,
983 0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f}));
984
985 armnn::TensorInfo outputDesc({ 2, 16 }, armnn::GetDataType<float>());
986 boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
987 {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f,
988 -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f,
989 -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f,
990 0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f,
991 -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f,
992 0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f,
993 0.02168f}));
Matteo Martincigha65b7ae2018-11-14 12:39:55 +0000994 return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl(workloadFactory, memoryManager, input, expectedOutput);
telsoa01c577f2c2018-08-31 09:22:23 +0100995}
996
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +0000997LayerTestResult<float, 2> LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest(
998 armnn::IWorkloadFactory& workloadFactory,
999 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa01c577f2c2018-08-31 09:22:23 +01001000{
1001 armnn::TensorInfo inputDesc({2, 2}, armnn::GetDataType<float>());
1002 boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>(
1003 {2., 3., 3., 4.}));
1004
1005
1006 armnn::TensorInfo outputDesc({2, 4}, armnn::GetDataType<float>());
1007 boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>(
1008 {{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f,
1009 -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}}));
1010
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001011 return LstmNoCifgNoPeepholeNoProjectionTestImpl(
1012 workloadFactory, memoryManager, input, expectedOutput);
telsoa01c577f2c2018-08-31 09:22:23 +01001013}
1014
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001015LayerTestResult<float,3> MergerTest(
1016 armnn::IWorkloadFactory& workloadFactory,
1017 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001018{
surmeh013537c2c2018-05-18 16:31:43 +01001019 unsigned int outputWidth = 3;
telsoa014fcda012018-03-09 14:13:49 +00001020 unsigned int outputHeight = 6;
1021 unsigned int outputChannels = 3;
1022
surmeh013537c2c2018-05-18 16:31:43 +01001023 unsigned int inputWidth1 = 3;
1024 unsigned int inputHeight1 = 6;
1025 unsigned int inputChannels1 = 2;
telsoa014fcda012018-03-09 14:13:49 +00001026
surmeh013537c2c2018-05-18 16:31:43 +01001027 unsigned int inputWidth2 = 3;
1028 unsigned int inputHeight2 = 6;
1029 unsigned int inputChannels2 = 1;
telsoa014fcda012018-03-09 14:13:49 +00001030
telsoa01c577f2c2018-08-31 09:22:23 +01001031 // Define the tensor descriptors.
telsoa014fcda012018-03-09 14:13:49 +00001032 armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::Float32);
1033 armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::Float32);
1034 armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::Float32);
telsoa014fcda012018-03-09 14:13:49 +00001035
1036 LayerTestResult<float,3> ret(outputTensorInfo);
1037
telsoa014fcda012018-03-09 14:13:49 +00001038 ret.outputExpected = MakeTensor<float, 3>(outputTensorInfo, std::vector<float>(
surmeh013537c2c2018-05-18 16:31:43 +01001039 {
1040 1.0f, 2.0f, 3.0f,
1041 4.0f, 5.0f, 6.0f,
1042 7.0f, 8.0f, 9.0f,
1043 10.0f, 11.0f, 12.0f,
1044 13.0f, 14.0f, 15.0f,
1045 16.0f, 17.0f, 18.0f,
telsoa014fcda012018-03-09 14:13:49 +00001046
surmeh013537c2c2018-05-18 16:31:43 +01001047 19.0f, 20.0f, 21.0f,
1048 22.0f, 23.0f, 24.0f,
1049 25.0f, 26.0f, 27.0f,
1050 28.0f, 29.0f, 30.0f,
1051 31.0f, 32.0f, 33.0f,
1052 34.0f, 35.0f, 36.0f,
telsoa014fcda012018-03-09 14:13:49 +00001053
surmeh013537c2c2018-05-18 16:31:43 +01001054 37.0f, 38.0f, 39.0f,
1055 40.0f, 41.0f, 42.0f,
1056 43.0f, 44.0f, 45.0f,
1057 46.0f, 47.0f, 48.0f,
1058 49.0f, 50.0f, 51.0f,
1059 52.0f, 53.0f, 54.0f,
telsoa014fcda012018-03-09 14:13:49 +00001060 })
1061 );
1062
telsoa014fcda012018-03-09 14:13:49 +00001063 auto input1 = MakeTensor<float, 3>(inputTensorInfo1, std::vector<float>(
1064 {
surmeh013537c2c2018-05-18 16:31:43 +01001065 1.0f, 2.0f, 3.0f,
1066 4.0f, 5.0f, 6.0f,
1067 7.0f, 8.0f, 9.0f,
1068 10.0f, 11.0f, 12.0f,
1069 13.0f, 14.0f, 15.0f,
1070 16.0f, 17.0f, 18.0f,
telsoa014fcda012018-03-09 14:13:49 +00001071
surmeh013537c2c2018-05-18 16:31:43 +01001072 19.0f, 20.0f, 21.0f,
1073 22.0f, 23.0f, 24.0f,
1074 25.0f, 26.0f, 27.0f,
1075 28.0f, 29.0f, 30.0f,
1076 31.0f, 32.0f, 33.0f,
1077 34.0f, 35.0f, 36.0f,
telsoa014fcda012018-03-09 14:13:49 +00001078 })
1079 );
1080
1081 auto input2 = MakeTensor<float, 3>(inputTensorInfo2, std::vector<float>(
1082 {
surmeh013537c2c2018-05-18 16:31:43 +01001083 37.0f, 38.0f, 39.0f,
1084 40.0f, 41.0f, 42.0f,
telsoa014fcda012018-03-09 14:13:49 +00001085 43.0f, 44.0f, 45.0f,
surmeh013537c2c2018-05-18 16:31:43 +01001086 46.0f, 47.0f, 48.0f,
1087 49.0f, 50.0f, 51.0f,
1088 52.0f, 53.0f, 54.0f,
telsoa014fcda012018-03-09 14:13:49 +00001089 })
1090 );
1091
telsoa01c577f2c2018-08-31 09:22:23 +01001092 std::vector<unsigned int> wOrigin1 = {0, 0, 0}; //Extent of the window is defined by size of input[0].
telsoa014fcda012018-03-09 14:13:49 +00001093 armnn::MergerQueueDescriptor::ViewOrigin window1(wOrigin1);
1094
telsoa01c577f2c2018-08-31 09:22:23 +01001095 std::vector<unsigned int> wOrigin2 = {2, 0, 0}; //Extent of the window is defined by size of input[1].
telsoa014fcda012018-03-09 14:13:49 +00001096 armnn::MergerQueueDescriptor::ViewOrigin window2(wOrigin2);
1097
telsoa014fcda012018-03-09 14:13:49 +00001098 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1099
1100 bool subTensorsSupported = workloadFactory.SupportsSubTensors();
1101
1102 std::unique_ptr<armnn::ITensorHandle> inputHandle1 =
1103 subTensorsSupported ?
1104 workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) :
1105 workloadFactory.CreateTensorHandle(inputTensorInfo1);
1106
1107 std::unique_ptr<armnn::ITensorHandle> inputHandle2 =
1108 subTensorsSupported ?
1109 workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) :
1110 workloadFactory.CreateTensorHandle(inputTensorInfo2);
1111
telsoa014fcda012018-03-09 14:13:49 +00001112 armnn::MergerQueueDescriptor data;
1113 armnn::WorkloadInfo info;
1114 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1115 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
telsoa014fcda012018-03-09 14:13:49 +00001116 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1117
1118 data.m_ViewOrigins.push_back(window1);
1119 data.m_ViewOrigins.push_back(window2);
telsoa014fcda012018-03-09 14:13:49 +00001120
1121 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(data, info);
1122
1123 inputHandle1->Allocate();
1124 inputHandle2->Allocate();
telsoa014fcda012018-03-09 14:13:49 +00001125 outputHandle->Allocate();
1126
1127 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]);
1128 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]);
telsoa014fcda012018-03-09 14:13:49 +00001129
1130 workload->Execute();
1131
1132 CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get());
1133
1134 return ret;
1135}
1136
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001137LayerTestResult<float,4> AdditionTest(
1138 armnn::IWorkloadFactory& workloadFactory,
1139 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001140{
1141 unsigned int batchSize = 2;
1142 unsigned int channels = 2;
1143 unsigned int height = 2;
1144 unsigned int width = 3;
1145
1146 armnn::TensorInfo inputTensorInfo1, inputTensorInfo2;
1147 armnn::TensorInfo outputTensorInfo;
1148
1149 unsigned int shape[] = {batchSize, channels, height, width};
1150
1151 inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1152 inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1153 outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1154
1155
1156 auto input1 = MakeTensor<float, 4>(inputTensorInfo1, std::vector<float>(
1157 {
1158 0.0f, 2.0f, 1.0f,
1159 0.2f, 1.0f, 2.0f,
1160
1161 1.0f, 2.0f, 1.0f,
1162 0.2f, 1.0f, 2.0f,
1163
1164 0.0f, 2.0f, 1.0f,
1165 4.2f, 1.0f, 2.0f,
1166
1167 0.0f, 0.0f, 1.0f,
1168 0.2f, 1.0f, 2.0f,
1169 }));
1170
1171 auto input2 = MakeTensor<float, 4>(inputTensorInfo2, std::vector<float>(
1172 {
1173 1.0f, 2.0f, 1.0f,
1174 0.0f, 1.0f, 2.0f,
1175
1176 1.0f, 2.0f, -2.0f,
1177 0.2f, 1.0f, 2.0f,
1178
1179 0.0f, 2.0f, 1.0f,
1180 4.2f, 0.0f, -3.0f,
1181
1182 0.0f, 0.0f, 1.0f,
1183 0.7f, 1.0f, 5.0f,
1184 }));
1185
1186 LayerTestResult<float,4> ret(outputTensorInfo);
1187 ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, std::vector<float>(
1188 {
1189 1.0f, 4.0f, 2.0f,
1190 0.2f, 2.0f, 4.0f,
1191
1192 2.0f, 4.0f, -1.0f,
1193 0.4f, 2.0f, 4.0f,
1194
1195 0.0f, 4.0f, 2.0f,
1196 8.4f, 1.0f, -1.0f,
1197
1198 0.0f, 0.0f, 2.0f,
1199 0.9f, 2.0f, 7.0f,
1200 }));
1201
1202 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1203 std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2);
1204 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1205
1206 armnn::AdditionQueueDescriptor data;
1207 armnn::WorkloadInfo info;
1208 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1209 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
1210 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1211
1212 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info);
1213
1214 inputHandle1->Allocate();
1215 inputHandle2->Allocate();
1216 outputHandle->Allocate();
1217
1218 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1219 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]);
1220
1221 workload->Execute();
1222
1223 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
1224
1225 return ret;
1226}
1227
1228template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001229LayerTestResult<T, 4> AdditionBroadcastTestImpl(
1230 armnn::IWorkloadFactory& workloadFactory,
1231 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +00001232 float qScale,
1233 int32_t qOffset)
1234{
1235 armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 1}, armnn::GetDataType<T>());
1236 armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 2, 3}, armnn::GetDataType<T>());
1237 armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>());
1238
1239 if (armnn::IsQuantizedType<T>())
1240 {
1241 inputTensorInfo1.SetQuantizationScale(qScale);
1242 inputTensorInfo1.SetQuantizationOffset(qOffset);
1243 inputTensorInfo2.SetQuantizationScale(qScale);
1244 inputTensorInfo2.SetQuantizationOffset(qOffset);
1245 outputTensorInfo.SetQuantizationScale(qScale);
1246 outputTensorInfo.SetQuantizationOffset(qOffset);
1247 }
1248
1249 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset,
1250 {
1251 0.0f,
1252 1.0f,
1253
1254 2.0f,
1255 3.0f,
1256
1257 4.0f,
1258 5.0f,
1259 }));
1260
1261 auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset,
1262 {
1263 0.5f, 1.5f, 2.5f,
1264 3.5f, 4.5f, 5.5f,
1265 }));
1266
1267 LayerTestResult<T,4> ret(outputTensorInfo);
1268 ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset,
1269 {
1270 0.5f, 1.5f, 2.5f,
1271 4.5f, 5.5f, 6.5f,
1272
1273 2.5f, 3.5f, 4.5f,
1274 6.5f, 7.5f, 8.5f,
1275
1276 4.5f, 5.5f, 6.5f,
1277 8.5f, 9.5f, 10.5f,
1278 }));
1279
1280 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1281 std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2);
1282 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1283
1284 armnn::AdditionQueueDescriptor data;
1285 armnn::WorkloadInfo info;
1286 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1287 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
1288 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1289
1290 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info);
1291
1292 inputHandle1->Allocate();
1293 inputHandle2->Allocate();
1294 outputHandle->Allocate();
1295
1296 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1297 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]);
1298
1299 workload->Execute();
1300
1301 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
1302
1303 return ret;
1304}
1305
1306template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001307LayerTestResult<T, 4> AdditionBroadcast1ElementTestImpl(
1308 armnn::IWorkloadFactory& workloadFactory,
1309 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +00001310 float qScale,
1311 int32_t qOffset)
1312{
1313 armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>());
1314 armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 1, 1}, armnn::GetDataType<T>());
1315 armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>());
1316
1317 if (armnn::IsQuantizedType<T>())
1318 {
1319 inputTensorInfo1.SetQuantizationScale(qScale);
1320 inputTensorInfo1.SetQuantizationOffset(qOffset);
1321 inputTensorInfo2.SetQuantizationScale(qScale);
1322 inputTensorInfo2.SetQuantizationOffset(qOffset);
1323 outputTensorInfo.SetQuantizationScale(qScale);
1324 outputTensorInfo.SetQuantizationOffset(qOffset);
1325 }
1326
1327 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset,
1328 {
1329 0.0f, 1.0f, 2.0f,
1330 3.0f, 4.0f, 5.0f,
1331 6.0f, 7.0f, 8.0f,
1332 9.0f, 10.0f, 11.0f,
1333 12.0f, 13.0f, 14.0f,
1334 15.0f, 16.0f, 17.0f,
1335 }));
1336
1337 auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset,
1338 {
1339 0.5f,
1340 }));
1341
1342 LayerTestResult<T,4> ret(outputTensorInfo);
1343 ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset,
1344 {
1345 0.5f, 1.5f, 2.5f,
1346 3.5f, 4.5f, 5.5f,
1347 6.5f, 7.5f, 8.5f,
1348 9.5f, 10.5f, 11.5f,
1349 12.5f, 13.5f, 14.5f,
1350 15.5f, 16.5f, 17.5f,
1351 }));
1352
1353 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1354 std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2);
1355 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1356
1357 armnn::AdditionQueueDescriptor data;
1358 armnn::WorkloadInfo info;
1359 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1360 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
1361 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1362
1363 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info);
1364
1365 inputHandle1->Allocate();
1366 inputHandle2->Allocate();
1367 outputHandle->Allocate();
1368
1369 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1370 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]);
1371
1372 workload->Execute();
1373
1374 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
1375
1376 return ret;
1377}
1378
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001379LayerTestResult<float, 4> AdditionBroadcastTest(
1380 armnn::IWorkloadFactory& workloadFactory,
1381 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001382{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001383 return AdditionBroadcastTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00001384}
1385
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001386LayerTestResult<uint8_t, 4> AdditionBroadcastUint8Test(
1387 armnn::IWorkloadFactory& workloadFactory,
1388 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001389{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001390 return AdditionBroadcastTestImpl<uint8_t>(workloadFactory, memoryManager, 2.f, 0);
telsoa014fcda012018-03-09 14:13:49 +00001391}
1392
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001393LayerTestResult<float, 4> AdditionBroadcast1ElementTest(
1394 armnn::IWorkloadFactory& workloadFactory,
1395 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001396{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001397 return AdditionBroadcast1ElementTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00001398}
1399
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001400LayerTestResult<uint8_t, 4> AdditionBroadcast1ElementUint8Test(
1401 armnn::IWorkloadFactory& workloadFactory,
1402 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00001403{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001404 return AdditionBroadcast1ElementTestImpl<uint8_t>(workloadFactory, memoryManager, 0.1333333f, 128);
telsoa014fcda012018-03-09 14:13:49 +00001405}
1406
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001407LayerTestResult<float,4> CompareAdditionTest(
1408 armnn::IWorkloadFactory& workloadFactory,
1409 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
1410 armnn::IWorkloadFactory& refWorkloadFactory)
telsoa014fcda012018-03-09 14:13:49 +00001411{
1412 unsigned int batchSize = 4;
1413 unsigned int channels = 1;
1414 unsigned int height = 2;
1415 unsigned int width = 3;
1416
1417 armnn::TensorInfo inputTensorInfo1, inputTensorInfo2;
1418 armnn::TensorInfo outputTensorInfo;
1419
1420 unsigned int shape[] = {batchSize, channels, height, width};
1421
1422 inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1423 inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1424 outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
1425
1426 auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 1232);
1427 auto input2 = MakeRandomTensor<float, 4>(inputTensorInfo2, 456);
1428
1429 LayerTestResult<float,4> ret(outputTensorInfo);
1430
1431 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1432 std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2);
1433 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1434
1435 std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1);
1436 std::unique_ptr<armnn::ITensorHandle> inputHandle2Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo2);
1437 std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo);
1438
1439 armnn::AdditionQueueDescriptor data;
1440 armnn::WorkloadInfo info;
1441 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1442 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
1443 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1444
1445 armnn::AdditionQueueDescriptor refData = data;
1446 armnn::WorkloadInfo refInfo = info;
1447 SetWorkloadInput(refData, refInfo, 0, inputTensorInfo1, inputHandle1Ref.get());
1448 SetWorkloadInput(refData, refInfo, 1, inputTensorInfo2, inputHandle2Ref.get());
1449 SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get());
1450
1451 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info);
1452 std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateAddition(refData, refInfo);
1453
1454 inputHandle1->Allocate();
1455 inputHandle2->Allocate();
1456 outputHandle->Allocate();
1457 inputHandle1Ref->Allocate();
1458 inputHandle2Ref->Allocate();
1459 outputHandleRef->Allocate();
1460
1461 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1462 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]);
1463 CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]);
1464 CopyDataToITensorHandle(inputHandle2Ref.get(), &input2[0][0][0][0]);
1465
1466 workload->Execute();
1467 workloadRef->Execute();
1468
1469 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
1470 CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get());
1471
1472 return ret;
1473}
1474
surmeh01bceff2f2018-03-29 16:29:27 +01001475namespace {
David Beck5cd01f32018-09-12 16:00:08 +01001476template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001477LayerTestResult<T, 4> DivisionTestHelper(
1478 armnn::IWorkloadFactory& workloadFactory,
1479 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
1480 const unsigned int shape0[4],
1481 const std::vector<T>& values0,
1482 float scale0,
1483 int32_t offset0,
1484 const unsigned int shape1[4],
1485 const std::vector<T> & values1,
1486 float scale1,
1487 int32_t offset1,
1488 const unsigned int outShape[4],
1489 const std::vector<T> & outValues,
1490 float outScale,
1491 int32_t outOffset)
David Beck5cd01f32018-09-12 16:00:08 +01001492{
1493 auto dataType = (std::is_same<T, uint8_t>::value ?
1494 armnn::DataType::QuantisedAsymm8 :
1495 armnn::DataType::Float32);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001496
David Beck5cd01f32018-09-12 16:00:08 +01001497 armnn::TensorInfo inputTensorInfo0(4, shape0, dataType);
1498 armnn::TensorInfo inputTensorInfo1(4, shape1, dataType);
1499 armnn::TensorInfo outputTensorInfo(4, outShape, dataType);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001500
David Beck5cd01f32018-09-12 16:00:08 +01001501 inputTensorInfo0.SetQuantizationScale(scale0);
1502 inputTensorInfo0.SetQuantizationOffset(offset0);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001503
David Beck5cd01f32018-09-12 16:00:08 +01001504 inputTensorInfo1.SetQuantizationScale(scale1);
1505 inputTensorInfo1.SetQuantizationOffset(offset1);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001506
David Beck5cd01f32018-09-12 16:00:08 +01001507 outputTensorInfo.SetQuantizationScale(outScale);
1508 outputTensorInfo.SetQuantizationOffset(outOffset);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001509
David Beck5cd01f32018-09-12 16:00:08 +01001510 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0);
1511 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001512
David Beck5cd01f32018-09-12 16:00:08 +01001513 LayerTestResult<T, 4> result(outputTensorInfo);
1514 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001515
David Beck5cd01f32018-09-12 16:00:08 +01001516 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
1517 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1518 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001519
David Beck5cd01f32018-09-12 16:00:08 +01001520 armnn::DivisionQueueDescriptor data;
1521 armnn::WorkloadInfo info;
1522 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
1523 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1524 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001525
David Beck5cd01f32018-09-12 16:00:08 +01001526 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateDivision(data, info);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001527
David Beck5cd01f32018-09-12 16:00:08 +01001528 inputHandle0->Allocate();
1529 inputHandle1->Allocate();
1530 outputHandle->Allocate();
1531
1532 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
1533 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1534
David Beck5cd01f32018-09-12 16:00:08 +01001535 workload->Execute();
1536
1537 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
1538
1539 return result;
1540}
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001541} // anonymous namespace
1542
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001543LayerTestResult<float,4> DivisionByZeroTest(
1544 armnn::IWorkloadFactory& workloadFactory,
1545 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Francis Murtagh8c5e3dc2018-08-30 17:18:37 +01001546{
1547 const unsigned int width = 2;
1548 const unsigned int height = 2;
1549 const unsigned int channelCount = 2;
1550 const unsigned int batchSize = 2;
1551
1552 unsigned int shape[] = { batchSize, channelCount, height, width };
1553
1554 std::vector<float> input0({
1555 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f,
1556 -1.f, -1.f, -1.f, -1.f, 5.f, 5.f, 5.f, 5.f });
1557
1558 std::vector<float> input1({
1559 0.f, 0.f, -0.f, -0.f, 0.f, 0.f, -0.f, -0.f,
1560 0.f, 0.f, -0.f, -0.f, 5.f, 5.f, 5.f, 5.f });
1561
1562 std::vector<float> output({
1563 INFINITY, INFINITY, -INFINITY, -INFINITY, NAN, NAN, -NAN, -NAN,
1564 -INFINITY, -INFINITY, INFINITY, INFINITY, 1, 1, 1, 1 });
1565
David Beck5cd01f32018-09-12 16:00:08 +01001566 return DivisionTestHelper<float>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001567 memoryManager,
David Beck5cd01f32018-09-12 16:00:08 +01001568 shape, input0, 1.0f, 0,
1569 shape, input1, 1.0f, 0,
1570 shape, output, 1.0f, 0);
Francis Murtagh8c5e3dc2018-08-30 17:18:37 +01001571}
1572
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001573LayerTestResult<float,4> DivisionTest(
1574 armnn::IWorkloadFactory& workloadFactory,
1575 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001576{
1577 const unsigned int width = 2;
1578 const unsigned int height = 2;
1579 const unsigned int channelCount = 2;
1580 const unsigned int batchSize = 2;
1581
1582 unsigned int shape[] = { batchSize, channelCount, height, width };
1583
1584 std::vector<float> input0({
1585 2, 2, 2, 2, 3, 3, 3, 3,
1586 4, 4, 4, 4, 5, 5, 5, 5 });
1587
1588 std::vector<float> input1({
1589 1, 1, 1, 1, 2, 2, 2, 2,
1590 4, 4, 4, 4, 4, 4, 4, 4 });
1591
1592 std::vector<float> output({
1593 2, 2, 2, 2, 1.5, 1.5, 1.5, 1.5,
1594 1, 1, 1, 1, 1.25, 1.25, 1.25, 1.25 });
1595
David Beck5cd01f32018-09-12 16:00:08 +01001596
1597 return DivisionTestHelper<float>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001598 memoryManager,
David Beck5cd01f32018-09-12 16:00:08 +01001599 shape, input0, 1.0f, 0,
1600 shape, input1, 1.0f, 0,
1601 shape, output, 1.0f, 0);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001602}
1603
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001604LayerTestResult<float, 4> DivisionBroadcast1ElementTest(
1605 armnn::IWorkloadFactory& workloadFactory,
1606 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001607{
1608 unsigned int shape0[] = { 1, 2, 2, 2 };
1609 std::vector<float> input0({ 2, 4, 6, 8, 10, 12, 14, 16});
1610
1611 unsigned int shape1[] = { 1, 1, 1, 1 };
1612 std::vector<float> input1({ 2 });
1613
1614 std::vector<float> output({ 1, 2, 3, 4, 5, 6, 7, 8});
1615
David Beck5cd01f32018-09-12 16:00:08 +01001616
1617 return DivisionTestHelper<float>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001618 memoryManager,
David Beck5cd01f32018-09-12 16:00:08 +01001619 shape0, input0, 1.0f, 0,
1620 shape1, input1, 1.0f, 0,
1621 shape0, output, 1.0f, 0);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001622}
1623
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001624LayerTestResult<float, 4> DivisionBroadcast1DVectorTest(
1625 armnn::IWorkloadFactory& workloadFactory,
1626 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001627{
1628 unsigned int shape0[] = { 1, 3, 3, 2 };
1629 std::vector<float> input0({
1630 1, 4, 3, 8, 5, 12,
1631 7, 16, 9, 20, 11, 24,
1632 13, 28, 15, 32, 17, 36});
1633
1634 unsigned int shape1[] = { 1, 1, 1, 2 };
1635 std::vector<float> input1({ 1, 2 });
1636
1637 std::vector<float> output({
1638 1, 2, 3, 4, 5, 6,
1639 7, 8, 9, 10, 11, 12,
1640 13, 14, 15, 16, 17, 18});
1641
David Beck5cd01f32018-09-12 16:00:08 +01001642 return DivisionTestHelper<float>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001643 memoryManager,
David Beck5cd01f32018-09-12 16:00:08 +01001644 shape0, input0, 1.0f, 0,
1645 shape1, input1, 1.0f, 0,
1646 shape0, output, 1.0f, 0);
1647}
1648
1649
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001650LayerTestResult<uint8_t,4> DivisionUint8Test(
1651 armnn::IWorkloadFactory& workloadFactory,
1652 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beck5cd01f32018-09-12 16:00:08 +01001653{
1654 const unsigned int width = 2;
1655 const unsigned int height = 2;
1656 const unsigned int channelCount = 2;
1657 const unsigned int batchSize = 2;
1658
1659 unsigned int shape[] = { batchSize, channelCount, height, width };
1660
1661 std::vector<uint8_t> input0({2, 2, 2, 2, 3, 3, 3, 3,
1662 4, 4, 4, 4, 5, 5, 5, 5 });
1663
1664 std::vector<uint8_t> input1({1, 1, 1, 1, 2, 2, 2, 2,
1665 4, 4, 4, 4, 4, 4, 4, 4 });
1666
1667 std::vector<uint8_t> output({8, 8, 8, 8, 6, 6, 6, 6,
1668 4, 4, 4, 4, 5, 5, 5, 5});
1669
1670
1671 return DivisionTestHelper<uint8_t>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001672 memoryManager,
1673 shape, input0, 1.0f, 0,
1674 shape, input1, 1.0f, 0,
1675 shape, output, 0.25f, 0);
David Beck5cd01f32018-09-12 16:00:08 +01001676}
1677
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001678LayerTestResult<uint8_t, 4> DivisionBroadcast1ElementUint8Test(
1679 armnn::IWorkloadFactory& workloadFactory,
1680 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beck5cd01f32018-09-12 16:00:08 +01001681{
1682 unsigned int shape0[] = { 1, 2, 2, 2 };
1683 std::vector<uint8_t> input0({ 2, 4, 6, 8, 10, 12, 14, 16});
1684
1685 unsigned int shape1[] = { 1, 1, 1, 1 };
1686 std::vector<uint8_t> input1({ 2 });
1687
1688 std::vector<uint8_t> output({ 1, 2, 3, 4, 5, 6, 7, 8});
1689
1690 return DivisionTestHelper<uint8_t>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001691 memoryManager,
1692 shape0, input0, 1.0f, 0,
1693 shape1, input1, 1.0f, 0,
1694 shape0, output, 1.0f, 0);
David Beck5cd01f32018-09-12 16:00:08 +01001695}
1696
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001697LayerTestResult<uint8_t, 4> DivisionBroadcast1DVectorUint8Test(
1698 armnn::IWorkloadFactory& workloadFactory,
1699 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beck5cd01f32018-09-12 16:00:08 +01001700{
1701 unsigned int shape0[] = { 1, 3, 3, 2 };
1702 std::vector<uint8_t> input0({1, 4, 3, 8, 5, 12,
1703 7, 16, 9, 20, 11, 24,
1704 13, 28, 15, 32, 17, 36});
1705
1706 unsigned int shape1[] = { 1, 1, 1, 2 };
1707 std::vector<uint8_t> input1({ 1, 2 });
1708
1709 std::vector<uint8_t> output({1, 2, 3, 4, 5, 6,
1710 7, 8, 9, 10, 11, 12,
1711 13, 14, 15, 16, 17, 18});
1712
1713 return DivisionTestHelper<uint8_t>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00001714 memoryManager,
1715 shape0, input0, 1.0f, 0,
1716 shape1, input1, 1.0f, 0,
1717 shape0, output, 1.0f, 0);
Francis Murtaghe7a86a42018-08-29 12:42:10 +01001718}
1719
Éanna Ó Catháinde705582018-12-03 13:04:22 +00001720template<typename DescriptorType>
1721std::unique_ptr<armnn::IWorkload> CreateWorkload(
1722 const armnn::IWorkloadFactory& workloadFactory,
1723 const armnn::WorkloadInfo& info,
1724 const DescriptorType& descriptor)
1725{
1726 return CreateWorkload(workloadFactory, info, descriptor);
1727};
1728
1729template<>
1730std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MaximumQueueDescriptor>(
1731 const armnn::IWorkloadFactory& workloadFactory,
1732 const armnn::WorkloadInfo& info,
1733 const armnn::MaximumQueueDescriptor& descriptor)
1734{
1735 return workloadFactory.CreateMaximum(descriptor, info);
1736}
1737
Éanna Ó Catháin20e58802018-12-04 10:29:06 +00001738template<>
1739std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>(
1740 const armnn::IWorkloadFactory& workloadFactory,
1741 const armnn::WorkloadInfo& info,
1742 const armnn::MinimumQueueDescriptor& descriptor)
1743{
1744 return workloadFactory.CreateMinimum(descriptor, info);
1745}
1746
FrancisMurtagh30cdfca2018-12-18 12:57:35 +00001747template<>
1748std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::EqualQueueDescriptor>(
1749 const armnn::IWorkloadFactory& workloadFactory,
1750 const armnn::WorkloadInfo& info,
1751 const armnn::EqualQueueDescriptor& descriptor)
1752{
1753 return workloadFactory.CreateEqual(descriptor, info);
1754}
1755
FrancisMurtagh878f0232018-12-19 10:56:15 +00001756template<>
1757std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::GreaterQueueDescriptor>(
1758 const armnn::IWorkloadFactory& workloadFactory,
1759 const armnn::WorkloadInfo& info,
1760 const armnn::GreaterQueueDescriptor& descriptor)
1761{
1762 return workloadFactory.CreateGreater(descriptor, info);
1763}
1764
Éanna Ó Catháinde705582018-12-03 13:04:22 +00001765namespace {
1766 template <typename Descriptor, typename dataType>
1767 LayerTestResult<dataType, 4> ElementwiseTestHelper
1768 (armnn::IWorkloadFactory & workloadFactory,
1769 const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager,
1770 const unsigned int shape0[4], std::vector<dataType> values0,
1771 const unsigned int shape1[4], std::vector<dataType> values1,
1772 const unsigned int outShape[4], std::vector<dataType> outValues,
1773 float qScale = 0.0f, int qOffset = 0)
1774 {
1775 const size_t dimensionCount = 4;
1776 armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::GetDataType<dataType>()};
1777 armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::GetDataType<dataType>()};
1778 armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::GetDataType<dataType>()};
1779
1780 auto input0 = MakeTensor<dataType, 4>(inputTensorInfo0, values0);
1781 auto input1 = MakeTensor<dataType, 4>(inputTensorInfo1, values1);
1782
1783 if (armnn::IsQuantizedType<dataType>())
1784 {
1785 inputTensorInfo0.SetQuantizationScale(qScale);
1786 inputTensorInfo0.SetQuantizationOffset(qOffset);
1787
1788 inputTensorInfo1.SetQuantizationScale(qScale);
1789 inputTensorInfo1.SetQuantizationOffset(qOffset);
1790
1791 outputTensorInfo.SetQuantizationScale(qScale);
1792 outputTensorInfo.SetQuantizationOffset(qOffset);
1793 }
1794
1795 LayerTestResult<dataType,4> ret(outputTensorInfo);
1796
1797 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
1798 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
1799 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
1800
1801 Descriptor data;
1802 armnn::WorkloadInfo info;
1803 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
1804 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
1805 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
1806 auto workload = CreateWorkload<Descriptor>(workloadFactory, info, data);
1807
1808 inputHandle0->Allocate();
1809 inputHandle1->Allocate();
1810 outputHandle->Allocate();
1811
1812 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
1813 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
1814
1815 ExecuteWorkload(*workload, memoryManager);
1816
1817 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
1818
1819 ret.outputExpected = MakeTensor<dataType, 4>(outputTensorInfo, outValues);
1820 return ret;
1821 }
1822}
1823
FrancisMurtagh30cdfca2018-12-18 12:57:35 +00001824LayerTestResult<float, 4> EqualSimpleTest(armnn::IWorkloadFactory& workloadFactory,
1825 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1826{
1827 const unsigned int width = 2;
1828 const unsigned int height = 2;
1829 const unsigned int channelCount = 2;
1830 const unsigned int batchSize = 2;
1831
1832 unsigned int shape[] = { batchSize, channelCount, height, width };
1833
1834 std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5,
1835 3, 3, 3, 3, 4, 4, 4, 4 });
1836
1837 std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3,
1838 5, 5, 5, 5, 4, 4, 4, 4 });
1839
1840 std::vector<float> output({ 1, 1, 1, 1, 0, 0, 0, 0,
1841 0, 0, 0, 0, 1, 1, 1, 1 });
1842
1843 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float>
1844 (workloadFactory,
1845 memoryManager,
1846 shape,
1847 input0,
1848 shape,
1849 input1,
1850 shape,
1851 output);
1852}
1853
1854LayerTestResult<float, 4> EqualBroadcast1ElementTest(
1855 armnn::IWorkloadFactory& workloadFactory,
1856 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1857{
1858 unsigned int shape0[] = { 1, 2, 2, 2 };
1859 std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8});
1860
1861 unsigned int shape1[] = { 1, 1, 1, 1 };
1862 std::vector<float> input1({ 1 });
1863
1864 std::vector<float> output({ 1, 0, 0, 0, 0, 0, 0, 0});
1865
1866 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float>
1867 (workloadFactory,
1868 memoryManager,
1869 shape0,
1870 input0,
1871 shape1,
1872 input1,
1873 shape0,
1874 output);
1875}
1876
1877LayerTestResult<float, 4> EqualBroadcast1DVectorTest(
1878 armnn::IWorkloadFactory& workloadFactory,
1879 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1880{
1881 const unsigned int shape0[] = { 1, 2, 2, 3 };
1882 const unsigned int shape1[] = { 1, 1, 1, 3 };
1883
1884 std::vector<float> input0({ 1, 2, 3, 4, 5, 6,
1885 7, 8, 9, 10, 11, 12 });
1886
1887 std::vector<float> input1({ 1, 2, 3});
1888
1889 std::vector<float> output({ 1, 1, 1, 0, 0, 0,
1890 0, 0, 0, 0, 0, 0 });
1891
1892 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float>
1893 (workloadFactory,
1894 memoryManager,
1895 shape0,
1896 input0,
1897 shape1,
1898 input1,
1899 shape0,
1900 output);
1901}
1902
1903LayerTestResult<uint8_t, 4> EqualUint8Test(
1904 armnn::IWorkloadFactory& workloadFactory,
1905 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1906{
1907 unsigned int shape[] = { 2, 2, 2, 2 };
1908
1909 // See dequantized values to the right.
1910 std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6,
1911 3, 3, 3, 3, 5, 5, 5, 5 });
1912
1913 std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6,
1914 3, 3, 3, 3, 5, 5, 5, 5 });
1915
1916 std::vector<uint8_t> output({ 0, 0, 0, 0, 1, 1, 1, 1,
1917 1, 1, 1, 1, 0, 0, 0, 0 });
1918
1919 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t >
1920 (workloadFactory,
1921 memoryManager,
1922 shape,
1923 input0,
1924 shape,
1925 input1,
1926 shape,
1927 output,
1928 1.0f,
1929 0);
1930}
1931
1932LayerTestResult<uint8_t, 4> EqualBroadcast1ElementUint8Test(
1933 armnn::IWorkloadFactory& workloadFactory,
1934 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1935{
1936 const unsigned int shape0[] = { 1, 2, 2, 3 };
1937 const unsigned int shape1[] = { 1, 1, 1, 1 };
1938
1939 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
1940 7, 8, 9, 10, 11, 12 });
1941
1942 std::vector<uint8_t> input1({ 1 });
1943
1944 std::vector<uint8_t> output({ 1, 0, 0, 0, 0, 0,
1945 0, 0, 0, 0, 0, 0 });
1946
1947 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t >
1948 (workloadFactory,
1949 memoryManager,
1950 shape0,
1951 input0,
1952 shape1,
1953 input1,
1954 shape0,
1955 output,
1956 1.0f,
1957 0);
1958}
1959
1960LayerTestResult<uint8_t, 4> EqualBroadcast1DVectorUint8Test(
1961 armnn::IWorkloadFactory& workloadFactory,
1962 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1963{
1964 const unsigned int shape0[] = { 1, 2, 2, 3 };
1965 const unsigned int shape1[] = { 1, 1, 1, 3 };
1966
1967 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
1968 7, 8, 9, 10, 11, 12 });
1969
1970 std::vector<uint8_t> input1({ 1, 1, 3});
1971
1972 std::vector<uint8_t> output({ 1, 0, 1, 0, 0, 0,
1973 0, 0, 0, 0, 0, 0 });
1974
1975 return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t>
1976 (workloadFactory,
1977 memoryManager,
1978 shape0,
1979 input0,
1980 shape1,
1981 input1,
1982 shape0,
1983 output,
1984 1.0f,
1985 0);
1986}
Éanna Ó Catháinde705582018-12-03 13:04:22 +00001987
FrancisMurtagh878f0232018-12-19 10:56:15 +00001988LayerTestResult<float, 4> GreaterSimpleTest(armnn::IWorkloadFactory& workloadFactory,
1989 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
1990{
1991 const unsigned int width = 2;
1992 const unsigned int height = 2;
1993 const unsigned int channelCount = 2;
1994 const unsigned int batchSize = 2;
1995
1996 unsigned int shape[] = { batchSize, channelCount, height, width };
1997
1998 std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5,
1999 3, 3, 3, 3, 4, 4, 4, 4 });
2000
2001 std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3,
2002 5, 5, 5, 5, 4, 4, 4, 4 });
2003
2004 std::vector<float> output({ 0, 0, 0, 0, 1, 1, 1, 1,
2005 0, 0, 0, 0, 0, 0, 0, 0 });
2006
2007 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float>
2008 (workloadFactory,
2009 memoryManager,
2010 shape,
2011 input0,
2012 shape,
2013 input1,
2014 shape,
2015 output);
2016}
2017
2018LayerTestResult<float, 4> GreaterBroadcast1ElementTest(
2019 armnn::IWorkloadFactory& workloadFactory,
2020 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2021{
2022 unsigned int shape0[] = { 1, 2, 2, 2 };
2023 std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8});
2024
2025 unsigned int shape1[] = { 1, 1, 1, 1 };
2026 std::vector<float> input1({ 1 });
2027
2028 std::vector<float> output({ 0, 1, 1, 1, 1, 1, 1, 1});
2029
2030 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float>
2031 (workloadFactory,
2032 memoryManager,
2033 shape0,
2034 input0,
2035 shape1,
2036 input1,
2037 shape0,
2038 output);
2039}
2040
2041LayerTestResult<float, 4> GreaterBroadcast1DVectorTest(
2042 armnn::IWorkloadFactory& workloadFactory,
2043 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2044{
2045 const unsigned int shape0[] = { 1, 2, 2, 3 };
2046 const unsigned int shape1[] = { 1, 1, 1, 3 };
2047
2048 std::vector<float> input0({ 1, 2.9f, 2.1f, 4, 5, 6,
2049 7, 8, 9, 10, 11, 12 });
2050
2051 std::vector<float> input1({ 1, 3, 2});
2052
2053 std::vector<float> output({ 0, 0, 1, 1, 1, 1,
2054 1, 1, 1, 1, 1, 1 });
2055
2056 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float>
2057 (workloadFactory,
2058 memoryManager,
2059 shape0,
2060 input0,
2061 shape1,
2062 input1,
2063 shape0,
2064 output);
2065}
2066
2067LayerTestResult<uint8_t, 4> GreaterUint8Test(
2068 armnn::IWorkloadFactory& workloadFactory,
2069 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2070{
2071 unsigned int shape[] = { 2, 2, 2, 2 };
2072
2073 // See dequantized values to the right.
2074 std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6,
2075 3, 3, 3, 3, 5, 5, 5, 5 });
2076
2077 std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6,
2078 2, 2, 2, 2, 5, 5, 5, 5 });
2079
2080 std::vector<uint8_t> output({ 0, 0, 0, 0, 0, 0, 0, 0,
2081 1, 1, 1, 1, 0, 0, 0, 0 });
2082
2083 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t >
2084 (workloadFactory,
2085 memoryManager,
2086 shape,
2087 input0,
2088 shape,
2089 input1,
2090 shape,
2091 output,
2092 1.0f,
2093 0);
2094}
2095
2096LayerTestResult<uint8_t, 4> GreaterBroadcast1ElementUint8Test(
2097 armnn::IWorkloadFactory& workloadFactory,
2098 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2099{
2100 const unsigned int shape0[] = { 1, 2, 2, 3 };
2101 const unsigned int shape1[] = { 1, 1, 1, 1 };
2102
2103 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
2104 7, 8, 9, 10, 11, 12 });
2105
2106 std::vector<uint8_t> input1({ 1 });
2107
2108 std::vector<uint8_t> output({ 0, 1, 1, 1, 1, 1,
2109 1, 1, 1, 1, 1, 1 });
2110
2111 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t >
2112 (workloadFactory,
2113 memoryManager,
2114 shape0,
2115 input0,
2116 shape1,
2117 input1,
2118 shape0,
2119 output,
2120 1.0f,
2121 0);
2122}
2123
2124LayerTestResult<uint8_t, 4> GreaterBroadcast1DVectorUint8Test(
2125 armnn::IWorkloadFactory& workloadFactory,
2126 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2127{
2128 const unsigned int shape0[] = { 1, 2, 2, 3 };
2129 const unsigned int shape1[] = { 1, 1, 1, 3 };
2130
2131 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
2132 7, 8, 9, 10, 11, 12 });
2133
2134 std::vector<uint8_t> input1({ 1, 1, 3});
2135
2136 std::vector<uint8_t> output({ 0, 1, 0, 1, 1, 1,
2137 1, 1, 1, 1, 1, 1 });
2138
2139 return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t>
2140 (workloadFactory,
2141 memoryManager,
2142 shape0,
2143 input0,
2144 shape1,
2145 input1,
2146 shape0,
2147 output,
2148 1.0f,
2149 0);
2150}
2151
Éanna Ó Catháinde705582018-12-03 13:04:22 +00002152LayerTestResult<float, 4> MaximumSimpleTest(armnn::IWorkloadFactory& workloadFactory,
2153 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2154{
2155 const unsigned int width = 2;
2156 const unsigned int height = 2;
2157 const unsigned int channelCount = 2;
2158 const unsigned int batchSize = 2;
2159
2160 unsigned int shape[] = { batchSize, channelCount, height, width };
2161
2162 std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5,
2163 3, 3, 3, 3, 4, 4, 4, 4 });
2164
2165 std::vector<float> input1({ 2, 2, 2, 2, 3, 3, 3, 3,
2166 4, 4, 4, 4, 5, 5, 5, 5 });
2167
2168 std::vector<float> output({ 2, 2, 2, 2, 5, 5, 5, 5,
2169 4, 4, 4, 4, 5, 5, 5, 5 });
2170
2171 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float>
2172 (workloadFactory,
2173 memoryManager,
2174 shape,
2175 input0,
2176 shape,
2177 input1,
2178 shape,
2179 output);
2180}
2181
2182LayerTestResult<float, 4> MaximumBroadcast1ElementTest(
2183 armnn::IWorkloadFactory& workloadFactory,
2184 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2185{
2186 unsigned int shape0[] = { 1, 2, 2, 2 };
2187 std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8});
2188
2189 unsigned int shape1[] = { 1, 1, 1, 1 };
2190 std::vector<float> input1({ 2 });
2191
2192 std::vector<float> output({ 2, 2, 3, 4, 5, 6, 7, 8});
2193
2194 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float>
2195 (workloadFactory,
2196 memoryManager,
2197 shape0,
2198 input0,
2199 shape1,
2200 input1,
2201 shape0,
2202 output);
2203}
2204
2205LayerTestResult<float, 4> MaximumBroadcast1DVectorTest(
2206 armnn::IWorkloadFactory& workloadFactory,
2207 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2208{
2209 const unsigned int shape0[] = { 1, 2, 2, 3 };
2210 const unsigned int shape1[] = { 1, 1, 1, 3 };
2211
2212 std::vector<float> input0({ 1, 2, 3, 4, 5, 6,
2213 7, 8, 9, 10, 11, 12 });
2214
2215 std::vector<float> input1({ 1, 2, 3});
2216
2217 std::vector<float> output({ 1, 2, 3, 4, 5, 6,
2218 7, 8, 9, 10, 11, 12 });
2219
2220 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float>
2221 (workloadFactory,
2222 memoryManager,
2223 shape0,
2224 input0,
2225 shape1,
2226 input1,
2227 shape0,
2228 output);
2229}
2230
2231LayerTestResult<uint8_t, 4> MaximumUint8Test(
2232 armnn::IWorkloadFactory& workloadFactory,
2233 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2234{
2235 unsigned int shape[] = { 2, 2, 2, 2 };
2236
2237 // See dequantized values to the right.
2238 std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6,
2239 3, 3, 3, 3, 4, 4, 4, 4 });
2240
2241 std::vector<uint8_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3,
2242 4, 4, 4, 4, 5, 5, 5, 5 });
2243
2244 std::vector<uint8_t> output({ 2, 2, 2, 2, 6, 6, 6, 6,
2245 4, 4, 4, 4, 5, 5, 5, 5 });
2246
2247 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t >
2248 (workloadFactory,
2249 memoryManager,
2250 shape,
2251 input0,
2252 shape,
2253 input1,
2254 shape,
2255 output,
2256 1.0f,
2257 0);
2258}
2259
2260LayerTestResult<uint8_t, 4> MaximumBroadcast1ElementUint8Test(
2261 armnn::IWorkloadFactory& workloadFactory,
2262 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2263{
2264 const unsigned int shape0[] = { 1, 2, 2, 3 };
2265 const unsigned int shape1[] = { 1, 1, 1, 1 };
2266
2267 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
2268 7, 8, 9, 10, 11, 12 });
2269
2270 std::vector<uint8_t> input1({2});
2271
2272 std::vector<uint8_t> output({ 2, 2, 3, 4, 5, 6,
2273 7, 8, 9, 10, 11, 12 });
2274
2275 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t >
2276 (workloadFactory,
2277 memoryManager,
2278 shape0,
2279 input0,
2280 shape1,
2281 input1,
2282 shape0,
2283 output,
2284 1.0f,
2285 0);
2286}
2287
2288LayerTestResult<uint8_t, 4> MaximumBroadcast1DVectorUint8Test(
2289 armnn::IWorkloadFactory& workloadFactory,
2290 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2291{
2292 const unsigned int shape0[] = { 1, 2, 2, 3 };
2293 const unsigned int shape1[] = { 1, 1, 1, 3 };
2294
2295 std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6,
2296 7, 8, 9, 10, 11, 12 });
2297
2298 std::vector<uint8_t> input1({ 1, 10, 3});
2299
2300 std::vector<uint8_t> output({ 1, 10, 3, 4, 10, 6,
2301 7, 10, 9, 10, 11, 12 });
2302
Éanna Ó Catháin20e58802018-12-04 10:29:06 +00002303 return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t>
Éanna Ó Catháinde705582018-12-03 13:04:22 +00002304 (workloadFactory,
2305 memoryManager,
2306 shape0,
2307 input0,
2308 shape1,
2309 input1,
2310 shape0,
2311 output,
2312 1.0f,
2313 0);
2314}
2315
Éanna Ó Catháin20e58802018-12-04 10:29:06 +00002316LayerTestResult<float, 4> MinimumBroadcast1ElementTest1(
2317 armnn::IWorkloadFactory& workloadFactory,
2318 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2319{
2320 unsigned int shape0[] = { 1, 2, 2, 2 };
2321 std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8});
2322
2323 unsigned int shape1[] = { 1, 1, 1, 1 };
2324 std::vector<float> input1({ 2 });
2325
2326 std::vector<float> output({ 1, 2, 2, 2, 2, 2, 2, 2});
2327
2328 return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, float>(workloadFactory,
2329 memoryManager,
2330 shape0,
2331 input0,
2332 shape1,
2333 input1,
2334 shape0,
2335 output);
2336}
2337
2338
2339LayerTestResult<float, 4> MinimumBroadcast1ElementTest2(
2340 armnn::IWorkloadFactory& workloadFactory,
2341 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
2342{
2343 unsigned int shape0[] = { 1, 2, 2, 2 };
2344 std::vector<float> input0({ 1, 6, 3, 2, 8, 9, 1, 10});
2345
2346 unsigned int shape1[] = { 1, 1, 1, 1 };
2347 std::vector<float> input1({ 5 });
2348
2349 std::vector<float> output({ 1, 5, 3, 2, 5, 5, 1, 5});
2350
2351 return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, float>(workloadFactory,
2352 memoryManager,
2353 shape0,
2354 input0,
2355 shape1,
2356 input1,
2357 shape0,
2358 output);
2359}
2360
2361LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test(
2362 armnn::IWorkloadFactory & workloadFactory,
2363 const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager)
2364{
2365 const unsigned int shape0[] = { 1, 2, 2, 3 };
2366 const unsigned int shape1[] = { 1, 1, 1, 3 };
2367
2368 std::vector<uint8_t> input0({ 1, 2, 3, 3, 2, 1,
2369 7, 1, 2, 3, 4, 5 });
2370
2371 std::vector<uint8_t> input1({ 1, 2, 3});
2372
2373 std::vector<uint8_t> output({ 1, 2, 3, 1, 2, 1,
2374 1, 1, 2, 1, 2, 3 });
2375
2376 return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, uint8_t>(workloadFactory,
2377 memoryManager,
2378 shape0,
2379 input0,
2380 shape1,
2381 input1,
2382 shape0,
2383 output,
2384 1.0f,
2385 0);
2386}
2387
Francis Murtaghe7a86a42018-08-29 12:42:10 +01002388namespace {
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002389LayerTestResult<float,4> MultiplicationTestHelper(
2390 armnn::IWorkloadFactory& workloadFactory,
2391 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
2392 const unsigned int shape0[4],
2393 const std::vector<float> & values0,
2394 const unsigned int shape1[4],
2395 const std::vector<float> & values1,
2396 const unsigned int outShape[4],
2397 const std::vector<float> & outValues)
telsoa014fcda012018-03-09 14:13:49 +00002398{
surmeh01bceff2f2018-03-29 16:29:27 +01002399 const size_t dimensionCount = 4;
2400 armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::DataType::Float32};
2401 armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::DataType::Float32};
2402 armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::DataType::Float32};
telsoa014fcda012018-03-09 14:13:49 +00002403
surmeh01bceff2f2018-03-29 16:29:27 +01002404 auto input0 = MakeTensor<float, 4>(inputTensorInfo0, values0);
2405 auto input1 = MakeTensor<float, 4>(inputTensorInfo1, values1);
telsoa014fcda012018-03-09 14:13:49 +00002406
2407 LayerTestResult<float,4> ret(outputTensorInfo);
2408
2409 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
2410 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
2411 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
2412
2413 armnn::MultiplicationQueueDescriptor data;
2414 armnn::WorkloadInfo info;
2415 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
2416 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
2417 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
2418
2419 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info);
2420
2421 inputHandle0->Allocate();
2422 inputHandle1->Allocate();
2423 outputHandle->Allocate();
2424
2425 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
2426 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
2427
2428 workload->Execute();
2429
2430 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
2431
surmeh01bceff2f2018-03-29 16:29:27 +01002432 ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outValues);
telsoa014fcda012018-03-09 14:13:49 +00002433 return ret;
2434}
surmeh01bceff2f2018-03-29 16:29:27 +01002435} // anonymous namespace
2436
2437
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002438LayerTestResult<float,4> MultiplicationTest(
2439 armnn::IWorkloadFactory& workloadFactory,
2440 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01002441{
2442 const unsigned int width = 2;
2443 const unsigned int height = 2;
2444 const unsigned int channelCount = 2;
2445 const unsigned int batchSize = 2;
2446
2447 unsigned int shape[] = { batchSize, channelCount, height, width };
2448
2449 std::vector<float> input0({
2450 1, 1, 1, 1, 2, 2, 2, 2,
2451 3, 3, 3, 3, 4, 4, 4, 4 });
2452
2453 std::vector<float> input1({
2454 2, 2, 2, 2, 3, 3, 3, 3,
2455 4, 4, 4, 4, 5, 5, 5, 5 });
2456
2457 std::vector<float> output({
2458 2, 2, 2, 2, 6, 6, 6, 6,
2459 12, 12, 12, 12, 20, 20, 20, 20 });
2460
2461 return MultiplicationTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002462 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01002463 shape,
2464 input0,
2465 shape,
2466 input1,
2467 shape,
2468 output);
2469}
2470
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002471LayerTestResult<float, 4> MultiplicationBroadcast1ElementTest(
2472 armnn::IWorkloadFactory& workloadFactory,
2473 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01002474{
2475 unsigned int shape0[] = { 1, 2, 2, 2 };
2476 std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8});
2477
2478 unsigned int shape1[] = { 1, 1, 1, 1 };
2479 std::vector<float> input1({ 2 });
2480
2481 std::vector<float> output({ 2, 4, 6, 8, 10, 12, 14, 16});
2482
2483 return MultiplicationTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002484 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01002485 shape0,
2486 input0,
2487 shape1,
2488 input1,
2489 shape0,
2490 output);
2491}
2492
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002493LayerTestResult<float, 4> MultiplicationBroadcast1DVectorTest(
2494 armnn::IWorkloadFactory& workloadFactory,
2495 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01002496{
2497 unsigned int shape0[] = { 1, 3, 3, 2 };
2498 std::vector<float> input0({
2499 1, 2, 3, 4, 5, 6,
2500 7, 8, 9, 10, 11, 12,
2501 13, 14, 15, 16, 17, 18});
2502
2503 unsigned int shape1[] = { 1, 1, 1, 2 };
2504 std::vector<float> input1({ 1, 2 });
2505
2506 std::vector<float> output({
2507 1, 4, 3, 8, 5, 12,
2508 7, 16, 9, 20, 11, 24,
2509 13, 28, 15, 32, 17, 36});
2510
2511 return MultiplicationTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002512 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01002513 shape0,
2514 input0,
2515 shape1,
2516 input1,
2517 shape0,
2518 output);
2519}
telsoa014fcda012018-03-09 14:13:49 +00002520
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002521LayerTestResult<float,4> CompareMultiplicationTest(
2522 armnn::IWorkloadFactory& workloadFactory,
2523 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
2524 armnn::IWorkloadFactory& refWorkloadFactory)
telsoa014fcda012018-03-09 14:13:49 +00002525{
2526 const unsigned int width = 16;
2527 const unsigned int height = 32;
2528 const unsigned int channelCount = 2;
2529 const unsigned int batchSize = 5;
2530
2531 armnn::TensorInfo inputTensorInfo0;
2532 armnn::TensorInfo inputTensorInfo1;
2533 armnn::TensorInfo outputTensorInfo;
2534
2535 constexpr unsigned int shape[] = { batchSize, channelCount, height, width };
2536
2537 inputTensorInfo0 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
2538 inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
2539 outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
2540
2541 LayerTestResult<float,4> comparisonResult(outputTensorInfo);
2542
2543 auto input0 = MakeRandomTensor<float, 4>(inputTensorInfo0, 803506992);
2544 auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 54902257);
2545
2546 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
2547 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
2548 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
2549
2550 std::unique_ptr<armnn::ITensorHandle> inputHandle0Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo0);
2551 std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1);
2552 std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo);
2553
2554 armnn::MultiplicationQueueDescriptor data;
2555 armnn::WorkloadInfo info;
2556 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
2557 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
2558 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
2559
2560 armnn::MultiplicationQueueDescriptor refData = data;
2561 armnn::WorkloadInfo refInfo = info;
2562 SetWorkloadInput(refData, refInfo, 0, inputTensorInfo0, inputHandle0Ref.get());
2563 SetWorkloadInput(refData, refInfo, 1, inputTensorInfo1, inputHandle1Ref.get());
2564 SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get());
2565
2566 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info);
2567 std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateMultiplication(refData, refInfo);
2568
2569 inputHandle0->Allocate();
2570 inputHandle1->Allocate();
2571 outputHandle->Allocate();
2572 inputHandle0Ref->Allocate();
2573 inputHandle1Ref->Allocate();
2574 outputHandleRef->Allocate();
2575
2576 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
2577 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
2578 CopyDataToITensorHandle(inputHandle0Ref.get(), &input0[0][0][0][0]);
2579 CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]);
2580
2581 workload->Execute();
2582 workloadRef->Execute();
2583
2584 CopyDataFromITensorHandle(&comparisonResult.output[0][0][0][0], outputHandle.get());
2585 CopyDataFromITensorHandle(&comparisonResult.outputExpected[0][0][0][0], outputHandleRef.get());
2586
2587 return comparisonResult;
2588}
2589
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002590LayerTestResult<float,4> CompareBatchNormTest(
2591 armnn::IWorkloadFactory& workloadFactory,
2592 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
2593 armnn::IWorkloadFactory& refWorkloadFactory)
telsoa014fcda012018-03-09 14:13:49 +00002594{
2595 const unsigned int width = 2;
2596 const unsigned int height = 3;
2597 const unsigned int channels = 5;
2598 const unsigned int batchSize = 3;
2599
2600 armnn::TensorInfo inputTensorInfo;
2601 armnn::TensorInfo outputTensorInfo;
2602 armnn::TensorInfo tensorInfo;
2603
2604 constexpr unsigned int shape[] = {batchSize, channels, height, width};
2605 constexpr unsigned int tensorShape[] = {channels};
2606
2607 inputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
2608 outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32);
2609 tensorInfo = armnn::TensorInfo(1, tensorShape, armnn::DataType::Float32);
2610
2611 auto input = MakeRandomTensor<float, 4>(inputTensorInfo, 21312);
2612
2613 auto mean = MakeRandomTensor<float, 1>(tensorInfo, 123);
2614 auto variance = MakeRandomTensor<float, 1>(tensorInfo, 234, 0.0f);
2615 auto beta = MakeRandomTensor<float, 1>(tensorInfo, 123);
2616 auto gamma = MakeRandomTensor<float, 1>(tensorInfo, 345);
2617
2618 LayerTestResult<float,4> ret(outputTensorInfo);
2619
2620 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
2621 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
2622
2623 std::unique_ptr<armnn::ITensorHandle> inputHandleRef = refWorkloadFactory.CreateTensorHandle(inputTensorInfo);
2624 std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo);
2625
2626 armnn::BatchNormalizationQueueDescriptor data;
2627 armnn::WorkloadInfo info;
2628 armnn::ScopedCpuTensorHandle meanTensor(tensorInfo);
2629 armnn::ScopedCpuTensorHandle varianceTensor(tensorInfo);
2630 armnn::ScopedCpuTensorHandle betaTensor(tensorInfo);
2631 armnn::ScopedCpuTensorHandle gammaTensor(tensorInfo);
2632
2633 AllocateAndCopyDataToITensorHandle(&meanTensor, &mean[0]);
2634 AllocateAndCopyDataToITensorHandle(&varianceTensor, &variance[0]);
2635 AllocateAndCopyDataToITensorHandle(&betaTensor, &beta[0]);
2636 AllocateAndCopyDataToITensorHandle(&gammaTensor, &gamma[0]);
2637
2638 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
2639 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
2640 data.m_Mean = &meanTensor;
2641 data.m_Variance = &varianceTensor;
2642 data.m_Beta = &betaTensor;
2643 data.m_Gamma = &gammaTensor;
2644 data.m_Parameters.m_Eps = 0.01f;
2645
2646 armnn::BatchNormalizationQueueDescriptor refData = data;
2647 armnn::WorkloadInfo refInfo = info;
2648 SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get());
2649 SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get());
2650
2651 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchNormalization(data, info);
2652 std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateBatchNormalization(refData, refInfo);
2653
2654 inputHandle->Allocate();
2655 outputHandle->Allocate();
2656 inputHandleRef->Allocate();
2657 outputHandleRef->Allocate();
2658
2659 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
2660 CopyDataToITensorHandle(inputHandleRef.get(), &input[0][0][0][0]);
2661
2662 workload->Execute();
2663 workloadRef->Execute();
2664
2665 CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
2666 CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get());
2667
2668 return ret;
2669}
2670
surmeh013537c2c2018-05-18 16:31:43 +01002671template<typename T>
2672void PermuteTensorData(
2673 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002674 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002675 const armnn::PermutationVector& mappings,
2676 armnn::TensorInfo & inputTensorInfo,
2677 const T * inputData,
2678 std::vector<T>& outputData)
telsoa014fcda012018-03-09 14:13:49 +00002679{
surmeh013537c2c2018-05-18 16:31:43 +01002680 BOOST_ASSERT_MSG(inputData != nullptr, "inputData must not be null");
2681 if (inputData == nullptr)
2682 {
2683 // Nullptr is an error in the test. By returning without doing the concatenation
2684 // I expect the caller to fail the test. It still makes sense to report this as
2685 // an assert for Debug builds.
2686 return;
2687 }
telsoa014fcda012018-03-09 14:13:49 +00002688
surmeh013537c2c2018-05-18 16:31:43 +01002689 armnn::TensorInfo outputTensorInfo = armnnUtils::Permuted(inputTensorInfo, mappings);
2690
2691 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
2692 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
2693
2694 armnn::PermuteQueueDescriptor queueDescriptor;
2695 queueDescriptor.m_Parameters = armnn::PermuteDescriptor{mappings};
2696 armnn::WorkloadInfo workloadInfo;
2697 AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get());
2698 AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get());
2699
2700 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePermute(queueDescriptor, workloadInfo);
2701
2702 inputHandle->Allocate();
2703 outputHandle->Allocate();
2704
2705 CopyDataToITensorHandle(inputHandle.get(), inputData);
2706
2707 workload->Execute();
2708
2709 outputData.resize(outputTensorInfo.GetNumElements());
2710 CopyDataFromITensorHandle(&outputData[0], outputHandle.get());
2711 inputTensorInfo = outputTensorInfo;
2712}
2713
2714armnn::OriginsDescriptor CreateMergerDescriptorForConcatenation(
2715 const std::vector<armnn::TensorInfo> & inputTensorInfos,
2716 unsigned int concatDim)
2717{
telsoa014fcda012018-03-09 14:13:49 +00002718 std::vector<armnn::TensorShape> shapes;
2719 shapes.reserve(inputTensorInfos.size());
2720 for (const armnn::TensorInfo& it: inputTensorInfos)
2721 {
2722 shapes.push_back(it.GetShape());
2723 }
surmeh013537c2c2018-05-18 16:31:43 +01002724
2725 return armnn::CreateMergerDescriptorForConcatenation(shapes.begin(),
2726 shapes.end(),
2727 concatDim);
2728}
2729
2730//
narpra015cdda352018-11-19 15:30:27 +00002731// Concatenation is only supported for N and C dimensions for NCHW and the inner most dimension
2732// In case of <4 dimensions we need to make sure that the concat dimensions are at least
2733// the 3rd slowest iterating one or the inner most dimension.
surmeh013537c2c2018-05-18 16:31:43 +01002734//
2735
2736bool NeedPermuteForConcat(
2737 const std::vector<armnn::TensorInfo> & inputTensorInfos,
2738 unsigned int concatDim)
2739{
2740 // See note above. Additionally we expect the input shapes to have the
2741 // same number of dimensions.
2742 unsigned int nDimensions = 0;
2743
telsoa01c577f2c2018-08-31 09:22:23 +01002744 // Determine the number of dimensions as well as sanity check them
2745 // agains test implementation issues.
surmeh013537c2c2018-05-18 16:31:43 +01002746 for (auto && tensorInfo : inputTensorInfos)
2747 {
2748 if (!nDimensions)
2749 {
2750 nDimensions = tensorInfo.GetShape().GetNumDimensions();
2751 }
2752 else
2753 {
2754 BOOST_ASSERT_MSG(nDimensions == tensorInfo.GetShape().GetNumDimensions(),
2755 "Input shapes must have the same number of dimensions");
2756 }
2757 }
2758
narpra015cdda352018-11-19 15:30:27 +00002759 return (nDimensions < 3 || (nDimensions == 3 && (nDimensions-concatDim) < 3 && (nDimensions-concatDim) != 1));
surmeh013537c2c2018-05-18 16:31:43 +01002760}
2761
2762armnn::TensorShape ExpandTensorShapeTo3dForPermute(const armnn::TensorShape & inputShape)
2763{
2764 unsigned int numDims = inputShape.GetNumDimensions();
2765 if (numDims >= 3)
2766 {
2767 // Nothing to do if the inputShape has at least 3 dimensions.
2768 return inputShape;
2769 }
2770
2771 std::vector<unsigned int> newDims(size_t(3), 1u);
2772 unsigned int expandedBy = 3 - numDims;
2773 for (unsigned int i=0; i<numDims; ++i)
2774 {
2775 newDims[expandedBy+i] = inputShape[i];
2776 }
2777 return armnn::TensorShape(3u, &newDims[0]);
2778}
2779
2780void Generate3dPermuteVectorForConcat(
2781 unsigned int numDimensions,
2782 unsigned int & concatDim,
2783 std::pair<armnn::PermutationVector, armnn::PermutationVector> & permutations)
2784{
2785 BOOST_ASSERT_MSG(numDimensions <= 3,
2786 "Only dimensions 1,2 and 3 are supported by this helper");
surmeh013537c2c2018-05-18 16:31:43 +01002787 unsigned int expandedBy = 3 - numDimensions;
2788 unsigned int expandedConcatAxis = concatDim + expandedBy;
2789
2790 if (expandedConcatAxis == 2)
2791 {
2792 concatDim = 0;
2793 armnn::PermutationVector forwardPermutation({1, 2, 0});
2794 armnn::PermutationVector reversePermutation({2, 0, 1});
2795 permutations = std::make_pair(forwardPermutation, reversePermutation);
2796 }
2797 else if (expandedConcatAxis == 1)
2798 {
2799 concatDim = 0;
2800 armnn::PermutationVector forwardPermutation({2, 0, 1});
2801 armnn::PermutationVector reversePermutation({1, 2, 0});
2802 permutations = std::make_pair(forwardPermutation, reversePermutation);
2803 }
2804 else
2805 {
2806 BOOST_ASSERT(expandedConcatAxis == 0);
2807 concatDim = 0;
2808 }
2809}
2810
2811//
2812// Permute the input tensors so we can do a supported concatenation.
2813// Also treat lower than 3d tensors as 3d by adding dummy 1 dimensions
2814// at the front. Finally this function tells what the output shape
2815// of the permuted concatenated tensor is going to be.
2816//
2817template <typename T>
2818void PermuteInputsForConcat(
2819 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002820 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002821 std::vector<armnn::TensorInfo> & inputTensorInfos,
2822 std::vector<T *> & inputData,
2823 std::vector<std::vector<T>> & inputDataStorage,
2824 armnn::PermutationVector & permuteVector,
2825 unsigned int & concatDim,
2826 armnn::TensorInfo & outputTensorInfo)
2827{
2828 BOOST_ASSERT_MSG(inputTensorInfos.size() > 1,
2829 "Expecting more than one tensor to be concatenated here");
2830
2831 unsigned int numDims = 0;
2832 unsigned int nthInput = 0;
2833 const armnn::PermutationVector identity({0, 1, 2});
2834
2835 std::pair<armnn::PermutationVector, armnn::PermutationVector> permutations =
2836 std::make_pair(identity, identity);
2837
2838 inputDataStorage.resize(inputData.size());
2839
2840 for (auto && tensorInfo : inputTensorInfos)
2841 {
2842 if (numDims == 0)
2843 {
2844 numDims = tensorInfo.GetShape().GetNumDimensions();
2845 Generate3dPermuteVectorForConcat(numDims, concatDim, permutations);
narpra015cdda352018-11-19 15:30:27 +00002846
telsoa01c577f2c2018-08-31 09:22:23 +01002847 // Store the reverese permutation.
surmeh013537c2c2018-05-18 16:31:43 +01002848 permuteVector = permutations.second;
2849 BOOST_ASSERT_MSG(!permuteVector.IsEqual(identity),
2850 "Test logic error, we don't need permutation, so we shouldn't arrive here");
2851 }
2852 else
2853 {
2854 BOOST_ASSERT_MSG(numDims == tensorInfo.GetShape().GetNumDimensions(),
2855 "All inputs must have the same number of dimensions");
2856 }
2857
2858 armnn::TensorInfo newTensorInfo = tensorInfo;
2859 newTensorInfo.SetShape(ExpandTensorShapeTo3dForPermute(tensorInfo.GetShape()));
2860
2861 PermuteTensorData<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002862 memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002863 permutations.first,
2864 newTensorInfo,
2865 inputData[nthInput],
2866 inputDataStorage[nthInput]);
2867
2868 inputData[nthInput] = inputDataStorage[nthInput].data();
2869 inputTensorInfos[nthInput] = newTensorInfo;
2870
2871 ++nthInput;
2872 }
2873
2874 outputTensorInfo.SetShape(
2875 armnnUtils::Permuted(
2876 ExpandTensorShapeTo3dForPermute(outputTensorInfo.GetShape()),
2877 permutations.first));
2878}
2879
2880
2881//
2882// This is the pair of PermuteInputsForConcat(...) which permutes back
telsoa01c577f2c2018-08-31 09:22:23 +01002883// the output of the concatenation so we can check it against an expected
surmeh013537c2c2018-05-18 16:31:43 +01002884// output.
2885//
2886template <typename T>
2887void PermuteOutputForConcat(
2888 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002889 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002890 const armnn::TensorInfo & tensorInfo,
2891 const armnn::PermutationVector & permuteVector,
2892 std::unique_ptr<armnn::ITensorHandle> && inputDataHandle,
2893 T * data)
2894{
2895 BOOST_ASSERT_MSG(data != nullptr, "data must not be null");
2896 if (data == nullptr)
2897 {
2898 // Nullptr is an error in the test. By returning without doing the permutation
2899 // I expect the caller to fail the test. It still makes sense to report this as
2900 // an assert for Debug builds.
2901 return;
2902 }
2903
2904 armnn::TensorInfo resultTensorInfo = tensorInfo;
2905 std::vector<T> inputData(tensorInfo.GetNumElements());
2906 std::vector<T> outputData;
2907
2908 CopyDataFromITensorHandle(&inputData[0], inputDataHandle.get());
2909
2910 PermuteTensorData<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002911 memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002912 permuteVector,
2913 resultTensorInfo,
2914 &inputData[0],
2915 outputData);
2916
2917 ::memcpy(data, &outputData[0], sizeof(T)*outputData.size());
2918}
2919
2920template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002921void Concatenate(
2922 armnn::IWorkloadFactory& workloadFactory,
2923 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
2924 std::initializer_list<const armnn::TensorInfo> inputTensorInfosOrig,
2925 std::initializer_list<T *> inputsOrig,
2926 const armnn::TensorInfo& outputTensorInfoOrig,
2927 T * output,
narpra015cdda352018-11-19 15:30:27 +00002928 unsigned int concatDim,
2929 bool useSubtensor)
surmeh013537c2c2018-05-18 16:31:43 +01002930{
2931 BOOST_ASSERT_MSG(output != nullptr, "output must not be null");
2932 if (output == nullptr)
2933 {
2934 // Nullptr is an error in the test. By returning without doing the permutation
2935 // I expect the caller to fail the test. It still makes sense to report this as
2936 // an assert for Debug builds.
2937 return;
2938 }
2939
telsoa01c577f2c2018-08-31 09:22:23 +01002940 // Saves a copy of the parameters which we might need to change.
surmeh013537c2c2018-05-18 16:31:43 +01002941 std::vector<armnn::TensorInfo> inputTensorInfos(inputTensorInfosOrig.begin(), inputTensorInfosOrig.end());
2942 std::vector<T *> inputs = inputsOrig;
2943 armnn::TensorInfo outputTensorInfo = outputTensorInfoOrig;
2944
2945 armnn::PermutationVector permuteVector{0, 1, 2};
2946
telsoa01c577f2c2018-08-31 09:22:23 +01002947 // Holds and automatically releases memory for the reshaped input data.
surmeh013537c2c2018-05-18 16:31:43 +01002948 std::vector<std::vector<T>> tmpInputDataStorage;
2949
2950 const size_t inputCount = inputTensorInfos.size();
2951
2952 bool needPermuteForConcat = NeedPermuteForConcat(inputTensorInfos, concatDim);
2953
2954 if (needPermuteForConcat)
2955 {
2956 //
2957 // We need to permute the inputs, because concatenation along
telsoa01c577f2c2018-08-31 09:22:23 +01002958 // the requested axis is not supported.
surmeh013537c2c2018-05-18 16:31:43 +01002959 //
2960 PermuteInputsForConcat<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00002961 memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01002962 inputTensorInfos,
2963 inputs,
2964 tmpInputDataStorage,
2965 permuteVector,
2966 concatDim,
2967 outputTensorInfo);
2968 }
2969
narpra015cdda352018-11-19 15:30:27 +00002970 armnn::WorkloadInfo workloadInfo;
telsoa014fcda012018-03-09 14:13:49 +00002971
2972 std::vector<std::unique_ptr<armnn::ITensorHandle>> inputHandles;
2973 inputHandles.reserve(inputCount);
2974
narpra015cdda352018-11-19 15:30:27 +00002975 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
2976
2977 armnn::MergerQueueDescriptor queueDescriptor;
2978 armnn::OriginsDescriptor viewsDescriptor = CreateMergerDescriptorForConcatenation(inputTensorInfos, concatDim);
2979 queueDescriptor.m_Parameters = viewsDescriptor;
2980
2981 if (useSubtensor)
telsoa014fcda012018-03-09 14:13:49 +00002982 {
narpra015cdda352018-11-19 15:30:27 +00002983 queueDescriptor.m_ViewOrigins.reserve(viewsDescriptor.GetNumViews());
2984 for (unsigned int i = 0; i < viewsDescriptor.GetNumViews(); ++i)
2985 {
2986 queueDescriptor.m_ViewOrigins.emplace_back(std::vector<unsigned int>(viewsDescriptor.GetViewOrigin(i),
2987 viewsDescriptor.GetViewOrigin(i) + viewsDescriptor.GetNumDimensions()));
2988 }
telsoa014fcda012018-03-09 14:13:49 +00002989
narpra015cdda352018-11-19 15:30:27 +00002990 outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
telsoa014fcda012018-03-09 14:13:49 +00002991
narpra015cdda352018-11-19 15:30:27 +00002992 const bool subTensorsSupported = workloadFactory.SupportsSubTensors();
2993 for (unsigned int i = 0; i < inputCount; ++i)
2994 {
2995 const armnn::TensorInfo& inputTensorInfo = inputTensorInfos[i];
2996 std::unique_ptr<armnn::ITensorHandle> inputHandle =
2997 subTensorsSupported ?
2998 workloadFactory.CreateSubTensorHandle(*outputHandle,
2999 inputTensorInfo.GetShape(),
3000 queueDescriptor.m_ViewOrigins[i].m_Origin.data()) :
3001 workloadFactory.CreateTensorHandle(inputTensorInfo);
3002
3003 inputHandles.emplace_back(std::move(inputHandle));
3004 }
3005
telsoa014fcda012018-03-09 14:13:49 +00003006 }
narpra015cdda352018-11-19 15:30:27 +00003007 else
3008 {
3009 for (unsigned int i = 0; i < inputCount; ++i)
3010 {
3011 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfos[i]);
3012 inputHandles.emplace_back(std::move(inputHandle));
3013 }
3014 }
telsoa014fcda012018-03-09 14:13:49 +00003015
3016 for (unsigned int i = 0; i < inputCount; ++i)
3017 {
surmeh013537c2c2018-05-18 16:31:43 +01003018 AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfos[i], inputHandles[i].get());
telsoa014fcda012018-03-09 14:13:49 +00003019 }
3020
3021 AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get());
3022
3023 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(queueDescriptor, workloadInfo);
3024
3025 for (auto& inputHandle : inputHandles)
3026 {
3027 inputHandle->Allocate();
3028 }
3029
3030 outputHandle->Allocate();
3031
3032 unsigned int nextInputId = 0;
3033 for (auto& inputHandle : inputHandles)
3034 {
surmeh013537c2c2018-05-18 16:31:43 +01003035 CopyDataToITensorHandle(inputHandle.get(), inputs[nextInputId]);
3036 ++nextInputId;
telsoa014fcda012018-03-09 14:13:49 +00003037 }
3038
3039 workload->Execute();
3040
surmeh013537c2c2018-05-18 16:31:43 +01003041 if (needPermuteForConcat)
3042 {
3043 PermuteOutputForConcat<T>(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003044 memoryManager,
surmeh013537c2c2018-05-18 16:31:43 +01003045 outputTensorInfo,
3046 permuteVector,
3047 std::move(outputHandle),
3048 output);
3049 }
3050 else
3051 {
3052 CopyDataFromITensorHandle(output, outputHandle.get());
3053 }
telsoa014fcda012018-03-09 14:13:49 +00003054}
3055
3056template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003057LayerTestResult<T, 1> Concatenation1dTestImpl(
3058 armnn::IWorkloadFactory& workloadFactory,
3059 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3060 float qScale,
3061 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +00003062{
3063 armnn::TensorInfo inputTensorInfo({ 3 }, armnn::GetDataType<T>());
3064
3065 auto input0 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 1.0f, 2.0f, 3.0f }));
3066 auto input1 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 4.0f, 5.0f, 6.0f }));
3067 auto input2 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 7.0f, 8.0f, 9.0f }));
3068
3069 armnn::TensorInfo outputTensorInfo({ 9 }, armnn::GetDataType<T>());
3070
3071 LayerTestResult<T, 1> result(outputTensorInfo);
3072
3073 std::vector<T> output;
3074 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003075 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003076 { inputTensorInfo, inputTensorInfo, inputTensorInfo },
3077 { input0.data(), input1.data(), input2.data() },
3078 outputTensorInfo,
3079 output.data(),
3080 0,
3081 true);
telsoa014fcda012018-03-09 14:13:49 +00003082
3083 result.output = MakeTensor<T, 1>(outputTensorInfo, output);
3084 result.outputExpected = MakeTensor<T, 1>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3085 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f
3086 }));
3087
3088 return result;
3089}
3090
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003091LayerTestResult<float, 1> Concatenation1dTest(
3092 armnn::IWorkloadFactory& workloadFactory,
3093 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003094{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003095 return Concatenation1dTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003096}
3097
3098template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003099LayerTestResult<T, 2> Concatenation2dTestImpl(
3100 armnn::IWorkloadFactory& workloadFactory,
3101 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +00003102 const armnn::TensorInfo& outputTensorInfo,
3103 unsigned int dimension,
3104 const float qScale,
3105 const int32_t qOffset)
3106{
3107 armnn::TensorInfo inputTensorInfo({ 2, 3 }, armnn::GetDataType<T>());
3108
3109 auto input0 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3110 // Batch 0
3111 1.0f, 2.0f, 3.0f,
3112
3113 // Batch 1
3114 10.0f, 11.0f, 12.0f,
3115 }));
3116
3117 auto input1 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3118 // Batch 0
3119 4.0f, 5.0f, 6.0f,
3120
3121 // Batch 1
3122 13.0f, 14.0f, 15.0f,
3123 }));
3124
3125 auto input2 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3126 // Batch 0
3127 7.0f, 8.0f, 9.0f,
3128
3129 // Batch 1
3130 16.0f, 17.0f, 18.0f,
3131 }));
3132
3133 LayerTestResult<T, 2> result(outputTensorInfo);
3134
3135 std::vector<T> output;
3136 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003137 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003138 { inputTensorInfo, inputTensorInfo, inputTensorInfo },
3139 { input0.data(), input1.data(), input2.data() },
3140 outputTensorInfo,
3141 output.data(),
3142 dimension,
3143 true);
telsoa014fcda012018-03-09 14:13:49 +00003144
3145 result.output = MakeTensor<T, 2>(outputTensorInfo, output);
3146 return result;
3147}
3148
3149template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003150LayerTestResult<T, 2> Concatenation2dDim0TestImpl(
3151 armnn::IWorkloadFactory& workloadFactory,
3152 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3153 float qScale,
3154 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +00003155{
3156 armnn::TensorInfo outputTensorInfo({ 6, 3 }, armnn::GetDataType<T>());
3157
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003158 LayerTestResult<T, 2> result =
3159 Concatenation2dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0, qScale, qOffset);
telsoa014fcda012018-03-09 14:13:49 +00003160 result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3161 // Batch 0
3162 1.0f, 2.0f, 3.0f,
3163
3164 // Batch 1
3165 10.0f, 11.0f, 12.0f,
3166
3167 // Batch 2
3168 4.0f, 5.0f, 6.0f,
3169
3170 // Batch 3
3171 13.0f, 14.0f, 15.0f,
3172
3173 // Batch 4
3174 7.0f, 8.0f, 9.0f,
3175
3176 // Batch 5
3177 16.0f, 17.0f, 18.0f,
3178 }));
3179
3180 return result;
3181}
3182
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003183LayerTestResult<float, 2> Concatenation2dDim0Test(
3184 armnn::IWorkloadFactory& workloadFactory,
3185 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003186{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003187 return Concatenation2dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003188}
3189
3190template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003191LayerTestResult<T, 2> Concatenation2dDim1TestImpl(
3192 armnn::IWorkloadFactory& workloadFactory,
3193 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3194 float qScale,
3195 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +00003196{
3197 armnn::TensorInfo outputTensorInfo({ 2, 9 }, armnn::GetDataType<T>());
3198
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003199 LayerTestResult<T, 2> result =
3200 Concatenation2dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1, qScale, qOffset);
telsoa014fcda012018-03-09 14:13:49 +00003201 result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3202 // Batch 0
3203 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f,
3204
3205 // Batch 1
3206 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f
3207 }));
3208
3209 return result;
3210}
3211
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003212LayerTestResult<float, 2> Concatenation2dDim1Test(
3213 armnn::IWorkloadFactory& workloadFactory,
3214 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003215{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003216 return Concatenation2dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003217}
3218
3219template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003220LayerTestResult<T, 2> Concatenation2dDim0DiffInputDimsTestImpl(
3221 armnn::IWorkloadFactory& workloadFactory,
3222 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3223 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003224 int32_t qOffset)
3225{
3226 armnn::TensorInfo input0TensorInfo({ 2, 3 }, armnn::GetDataType<T>());
3227 auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3228 // Batch 0
3229 1.0f, 2.0f, 3.0f,
3230
3231 // Batch 1
3232 10.0f, 11.0f, 12.0f,
3233 }));
3234
3235 armnn::TensorInfo input1TensorInfo({ 3, 3 }, armnn::GetDataType<T>());
3236 auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3237 // Batch 0
3238 4.0f, 5.0f, 6.0f,
3239
3240 // Batch 1
3241 13.0f, 14.0f, 15.0f,
3242
3243 // Batch 0
3244 7.0f, 8.0f, 9.0f,
3245 }));
3246
3247 armnn::TensorInfo input2TensorInfo({ 1, 3 }, armnn::GetDataType<T>());
3248 auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3249 // Batch 1
3250 16.0f, 17.0f, 18.0f,
3251 }));
3252
3253 armnn::TensorInfo outputTensorInfo({ 6, 3 }, armnn::GetDataType<T>());
3254 LayerTestResult<T, 2> result(outputTensorInfo);
3255
3256 std::vector<T> output;
3257 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003258 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003259 { input0TensorInfo, input1TensorInfo, input2TensorInfo },
3260 { input0.data(), input1.data(), input2.data() },
3261 outputTensorInfo,
3262 output.data(),
3263 0,
3264 true);
telsoa014fcda012018-03-09 14:13:49 +00003265
3266 result.output = MakeTensor<T, 2>(outputTensorInfo, output);
3267 result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3268 // Batch 0
3269 1.0f, 2.0f, 3.0f,
3270
3271 // Batch 1
3272 10.0f, 11.0f, 12.0f,
3273
3274 // Batch 2
3275 4.0f, 5.0f, 6.0f,
3276
3277 // Batch 3
3278 13.0f, 14.0f, 15.0f,
3279
3280 // Batch 4
3281 7.0f, 8.0f, 9.0f,
3282
3283 // Batch 5
3284 16.0f, 17.0f, 18.0f,
3285 }));
3286
3287 return result;
3288}
3289
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003290LayerTestResult<float, 2> Concatenation2dDim0DiffInputDimsTest(
3291 armnn::IWorkloadFactory& workloadFactory,
3292 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003293{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003294 return Concatenation2dDim0DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003295}
3296
3297template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003298LayerTestResult<T, 2> Concatenation2dDim1DiffInputDimsTestImpl(
3299 armnn::IWorkloadFactory& workloadFactory,
3300 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3301 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003302 int32_t qOffset)
3303{
3304 armnn::TensorInfo input0TensorInfo({ 2, 3 }, armnn::GetDataType<T>());
3305 auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3306 // Batch 0
3307 1.0f, 2.0f, 3.0f,
3308
3309 // Batch 1
3310 10.0f, 11.0f, 12.0f,
3311 }));
3312
3313 armnn::TensorInfo input1TensorInfo({ 2, 5 }, armnn::GetDataType<T>());
3314 auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3315 // Batch 0
3316 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
3317
3318 // Batch 1
3319 13.0f, 14.0f, 15.0f, 16.0f, 17.0f,
3320 }));
3321
3322 armnn::TensorInfo input2TensorInfo({ 2, 1 }, armnn::GetDataType<T>());
3323 auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3324 // Batch 0
3325 9.0f,
3326
3327 // Batch 1
3328 18.0f
3329 }));
3330
3331 armnn::TensorInfo outputTensorInfo({ 2, 9 }, armnn::GetDataType<T>());
3332 LayerTestResult<T, 2> result(outputTensorInfo);
3333
3334 std::vector<T> output;
3335 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003336 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003337 { input0TensorInfo, input1TensorInfo, input2TensorInfo },
3338 { input0.data(), input1.data(), input2.data() },
3339 outputTensorInfo,
3340 output.data(),
3341 1,
3342 true);
telsoa014fcda012018-03-09 14:13:49 +00003343
3344 result.output = MakeTensor<T, 2>(outputTensorInfo, output);
3345 result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3346 // Batch 0
3347 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f,
3348
3349 // Batch 1
3350 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f,
3351 }));
3352
3353 return result;
3354}
3355
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003356LayerTestResult<float, 2> Concatenation2dDim1DiffInputDimsTest(
3357 armnn::IWorkloadFactory& workloadFactory,
3358 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003359{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003360 return Concatenation2dDim1DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003361}
3362
3363template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003364LayerTestResult<T, 3> Concatenation3dTestImpl(
3365 armnn::IWorkloadFactory& workloadFactory,
3366 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +00003367 const armnn::TensorInfo& outputTensorInfo,
3368 unsigned int dimension,
narpra015cdda352018-11-19 15:30:27 +00003369 bool useSubtensor,
telsoa014fcda012018-03-09 14:13:49 +00003370 float qScale,
3371 int32_t qOffset)
3372{
3373 armnn::TensorInfo inputTensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>());
3374
3375 auto input0 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3376 // Batch 0, Channel 0
3377 1.0f, 2.0f,
3378
3379 // Batch 0, Channel 1
3380 3.0f, 4.0f,
3381
3382 // Batch 0, Channel 2
3383 5.0f, 6.0f,
3384
3385 // Batch 1, Channel 0
3386 19.0f, 20.0f,
3387
3388 // Batch 1, Channel 1
3389 21.0f, 22.0f,
3390
3391 // Batch 1, Channel 2
3392 23.0f, 24.0f
3393 }));
3394
3395 auto input1 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3396 // Batch 0, Channel 0
3397 7.0f, 8.0f,
3398
3399 // Batch 0, Channel 1
3400 9.0f, 10.0f,
3401
3402 // Batch 0, Channel 2
3403 11.0f, 12.0f,
3404
3405 // Batch 1, Channel 0
3406 25.0f, 26.0f,
3407
3408 // Batch 1, Channel 1
3409 27.0f, 28.0f,
3410
3411 // Batch 1, Channel 2
3412 29.0f, 30.0f
3413 }));
3414
3415 auto input2 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3416 // Batch 0, Channel 0
3417 13.0f, 14.0f,
3418
3419 // Batch 0, Channel 1
3420 15.0f, 16.0f,
3421
3422 // Batch 0, Channel 2
3423 17.0f, 18.0f,
3424
3425 // Batch 1, Channel 0
3426 31.0f, 32.0f,
3427
3428 // Batch 1, Channel 1
3429 33.0f, 34.0f,
3430
3431 // Batch 1, Channel 2
3432 35.0f, 36.0f
3433 }));
3434
3435 LayerTestResult<T, 3> result(outputTensorInfo);
3436
3437 std::vector<T> output;
3438 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003439 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003440 { inputTensorInfo, inputTensorInfo, inputTensorInfo },
3441 { input0.data(), input1.data(), input2.data() },
3442 outputTensorInfo,
3443 output.data(),
3444 dimension,
3445 useSubtensor);
telsoa014fcda012018-03-09 14:13:49 +00003446
3447 result.output = MakeTensor<T, 3>(outputTensorInfo, output);
3448 return result;
3449}
3450
3451template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003452LayerTestResult<T, 3> Concatenation3dDim0TestImpl(
3453 armnn::IWorkloadFactory& workloadFactory,
3454 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3455 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003456 int32_t qOffset)
3457{
3458 armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, armnn::GetDataType<T>());
3459
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003460 LayerTestResult<T, 3> result =
narpra015cdda352018-11-19 15:30:27 +00003461 Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0, true, qScale, qOffset);
telsoa014fcda012018-03-09 14:13:49 +00003462 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3463 // Batch 0, Channel 0
3464 1.0f, 2.0f,
3465
3466 // Batch 0, Channel 1
3467 3.0f, 4.0f,
3468
3469 // Batch 0, Channel 2
3470 5.0f, 6.0f,
3471
3472 // Batch 1, Channel 0
3473 19.0f, 20.0f,
3474
3475 // Batch 1, Channel 1
3476 21.0f, 22.0f,
3477
3478 // Batch 1, Channel 2
3479 23.0f, 24.0f,
3480
3481 // Batch 2, Channel 0
3482 7.0f, 8.0f,
3483
3484 // Batch 2, Channel 1
3485 9.0f, 10.0f,
3486
3487 // Batch 2, Channel 2
3488 11.0f, 12.0f,
3489
3490 // Batch 3, Channel 0
3491 25.0f, 26.0f,
3492
3493 // Batch 3, Channel 1
3494 27.0f, 28.0f,
3495
3496 // Batch 3, Channel 2
3497 29.0f, 30.0f,
3498
3499 // Batch 4, Channel 0
3500 13.0f, 14.0f,
3501
3502 // Batch 4, Channel 1
3503 15.0f, 16.0f,
3504
3505 // Batch 4, Channel 2
3506 17.0f, 18.0f,
3507
3508 // Batch 5, Channel 0
3509 31.0f, 32.0f,
3510
3511 // Batch 5, Channel 1
3512 33.0f, 34.0f,
3513
3514 // Batch 5, Channel 2
3515 35.0f, 36.0f
3516 }));
narpra015cdda352018-11-19 15:30:27 +00003517
telsoa014fcda012018-03-09 14:13:49 +00003518 return result;
3519}
3520
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003521LayerTestResult<float, 3> Concatenation3dDim0Test(
3522 armnn::IWorkloadFactory& workloadFactory,
3523 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003524{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003525 return Concatenation3dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003526}
3527
3528template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003529LayerTestResult<T, 3> Concatenation3dDim1TestImpl(
3530 armnn::IWorkloadFactory& workloadFactory,
3531 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3532 float qScale,
3533 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +00003534{
3535 armnn::TensorInfo outputTensorInfo({ 2, 9, 2 }, armnn::GetDataType<T>());
3536
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003537 LayerTestResult<T, 3> result =
narpra015cdda352018-11-19 15:30:27 +00003538 Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1, true, qScale, qOffset);
3539
telsoa014fcda012018-03-09 14:13:49 +00003540 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3541 // Batch 0, Channel 0
3542 1.0f, 2.0f,
3543
3544 // Batch 0, Channel 1
3545 3.0f, 4.0f,
3546
3547 // Batch 0, Channel 2
3548 5.0f, 6.0f,
3549
3550 // Batch 0, Channel 3
3551 7.0f, 8.0f,
3552
3553 // Batch 0, Channel 4
3554 9.0f, 10.0f,
3555
3556 // Batch 0, Channel 5
3557 11.0f, 12.0f,
3558
3559 // Batch 0, Channel 6
3560 13.0f, 14.0f,
3561
3562 // Batch 0, Channel 7
3563 15.0f, 16.0f,
3564
3565 // Batch 0, Channel 8
3566 17.0f, 18.0f,
3567
3568 // Batch 1, Channel 0
3569 19.0f, 20.0f,
3570
3571 // Batch 1, Channel 1
3572 21.0f, 22.0f,
3573
3574 // Batch 1, Channel 2
3575 23.0f, 24.0f,
3576
3577 // Batch 1, Channel 3
3578 25.0f, 26.0f,
3579
3580 // Batch 1, Channel 4
3581 27.0f, 28.0f,
3582
3583 // Batch 1, Channel 5
3584 29.0f, 30.0f,
3585
3586 // Batch 1, Channel 6
3587 31.0f, 32.0f,
3588
3589 // Batch 1, Channel 7
3590 33.0f, 34.0f,
3591
3592 // Batch 1, Channel 8
3593 35.0f, 36.0f
3594 }));
3595
3596 return result;
3597}
3598
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003599LayerTestResult<float, 3> Concatenation3dDim1Test(
3600 armnn::IWorkloadFactory& workloadFactory,
3601 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003602{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003603 return Concatenation3dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003604}
3605
3606template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003607LayerTestResult<T, 3> Concatenation3dDim2TestImpl(
3608 armnn::IWorkloadFactory& workloadFactory,
3609 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003610 bool useSubtensor,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003611 float qScale,
3612 int32_t qOffset)
telsoa014fcda012018-03-09 14:13:49 +00003613{
3614 armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, armnn::GetDataType<T>());
3615
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003616 LayerTestResult<T, 3> result =
narpra015cdda352018-11-19 15:30:27 +00003617 Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 2, useSubtensor, qScale, qOffset);
3618
telsoa014fcda012018-03-09 14:13:49 +00003619 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3620 // Batch 0, Channel 0
3621 1.0f, 2.0f, 7.0f, 8.0f, 13.0f, 14.0f,
3622
3623 // Batch 0, Channel 1
3624 3.0f, 4.0f, 9.0f, 10.0f, 15.0f, 16.0f,
3625
3626 // Batch 0, Channel 2
3627 5.0f, 6.0f, 11.0f, 12.0f, 17.0f, 18.0f,
3628
3629 // Batch 1, Channel 0
3630 19.0f, 20.0f, 25.0f, 26.0f, 31.0f, 32.0f,
3631
3632 // Batch 1, Channel 1
3633 21.0f, 22.0f, 27.0f, 28.0f, 33.0f, 34.0f,
3634
3635 // Batch 1, Channel 2
3636 23.0f, 24.0f, 29.0f, 30.0f, 35.0f, 36.0f,
3637 }));
3638
3639 return result;
3640}
3641
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003642LayerTestResult<float, 3> Concatenation3dDim2Test(
3643 armnn::IWorkloadFactory& workloadFactory,
narpra015cdda352018-11-19 15:30:27 +00003644 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3645 bool useSubtensor)
telsoa014fcda012018-03-09 14:13:49 +00003646{
narpra015cdda352018-11-19 15:30:27 +00003647 return Concatenation3dDim2TestImpl<float>(workloadFactory, memoryManager, useSubtensor, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003648}
3649
3650template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003651LayerTestResult<T, 3> Concatenation3dDim0DiffInputDimsTestImpl(
3652 armnn::IWorkloadFactory& workloadFactory,
3653 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3654 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003655 int32_t qOffset)
3656{
3657 armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>());
3658 auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3659 // Batch 0, Channel 0
3660 1.0f, 2.0f,
3661
3662 // Batch 0, Channel 1
3663 3.0f, 4.0f,
3664
3665 // Batch 0, Channel 2
3666 5.0f, 6.0f,
3667
3668 // Batch 1, Channel 0
3669 19.0f, 20.0f,
3670
3671 // Batch 1, Channel 1
3672 21.0f, 22.0f,
3673
3674 // Batch 1, Channel 2
3675 23.0f, 24.0f
3676 }));
3677
3678 armnn::TensorInfo input1TensorInfo({ 1, 3, 2 }, armnn::GetDataType<T>());
3679 auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3680 // Batch 0, Channel 0
3681 7.0f, 8.0f,
3682
3683 // Batch 0, Channel 1
3684 9.0f, 10.0f,
3685
3686 // Batch 0, Channel 2
3687 11.0f, 12.0f,
3688 }));
3689
3690 armnn::TensorInfo input2TensorInfo({ 3, 3, 2 }, armnn::GetDataType<T>());
3691 auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3692 // Batch 0, Channel 0
3693 25.0f, 26.0f,
3694
3695 // Batch 0, Channel 1
3696 27.0f, 28.0f,
3697
3698 // Batch 0, Channel 2
3699 29.0f, 30.0f,
3700
3701 // Batch 1, Channel 0
3702 13.0f, 14.0f,
3703
3704 // Batch 1, Channel 1
3705 15.0f, 16.0f,
3706
3707 // Batch 1, Channel 2
3708 17.0f, 18.0f,
3709
3710 // Batch 2, Channel 0
3711 31.0f, 32.0f,
3712
3713 // Batch 2, Channel 1
3714 33.0f, 34.0f,
3715
3716 // Batch 2, Channel 2
3717 35.0f, 36.0f
3718 }));
3719
3720 armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, armnn::GetDataType<T>());
3721 LayerTestResult<T, 3> result(outputTensorInfo);
3722
3723 std::vector<T> output;
3724 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003725 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003726 { input0TensorInfo, input1TensorInfo, input2TensorInfo },
3727 { input0.data(), input1.data(), input2.data() },
3728 outputTensorInfo,
3729 output.data(),
3730 0,
3731 true);
telsoa014fcda012018-03-09 14:13:49 +00003732
3733 result.output = MakeTensor<T, 3>(outputTensorInfo, output);
3734 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3735 // Batch 0, Channel 0
3736 1.0f, 2.0f,
3737
3738 // Batch 0, Channel 1
3739 3.0f, 4.0f,
3740
3741 // Batch 0, Channel 2
3742 5.0f, 6.0f,
3743
3744 // Batch 1, Channel 0
3745 19.0f, 20.0f,
3746
3747 // Batch 1, Channel 1
3748 21.0f, 22.0f,
3749
3750 // Batch 1, Channel 2
3751 23.0f, 24.0f,
3752
3753 // Batch 2, Channel 0
3754 7.0f, 8.0f,
3755
3756 // Batch 2, Channel 1
3757 9.0f, 10.0f,
3758
3759 // Batch 2, Channel 2
3760 11.0f, 12.0f,
3761
3762 // Batch 3, Channel 0
3763 25.0f, 26.0f,
3764
3765 // Batch 3, Channel 1
3766 27.0f, 28.0f,
3767
3768 // Batch 3, Channel 2
3769 29.0f, 30.0f,
3770
3771 // Batch 4, Channel 0
3772 13.0f, 14.0f,
3773
3774 // Batch 4, Channel 1
3775 15.0f, 16.0f,
3776
3777 // Batch 4, Channel 2
3778 17.0f, 18.0f,
3779
3780 // Batch 5, Channel 0
3781 31.0f, 32.0f,
3782
3783 // Batch 5, Channel 1
3784 33.0f, 34.0f,
3785
3786 // Batch 5, Channel 2
3787 35.0f, 36.0f
3788 }));
3789
3790 return result;
3791}
3792
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003793LayerTestResult<float, 3> Concatenation3dDim0DiffInputDimsTest(
3794 armnn::IWorkloadFactory& workloadFactory,
3795 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003796{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003797 return Concatenation3dDim0DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003798}
3799
3800template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003801LayerTestResult<T, 3> Concatenation3dDim1DiffInputDimsTestImpl(
3802 armnn::IWorkloadFactory& workloadFactory,
3803 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
3804 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003805 int32_t qOffset)
3806{
3807 armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>());
3808 auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3809 // Batch 0, Channel 0
3810 1.0f, 2.0f,
3811
3812 // Batch 0, Channel 1
3813 3.0f, 4.0f,
3814
3815 // Batch 0, Channel 2
3816 5.0f, 6.0f,
3817
3818 // Batch 1, Channel 0
3819 19.0f, 20.0f,
3820
3821 // Batch 1, Channel 1
3822 21.0f, 22.0f,
3823
3824 // Batch 1, Channel 2
3825 23.0f, 24.0f
3826 }));
3827
3828 armnn::TensorInfo input1TensorInfo({ 2, 4, 2 }, armnn::GetDataType<T>());
3829 auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3830 // Batch 0, Channel 0
3831 7.0f, 8.0f,
3832
3833 // Batch 0, Channel 1
3834 9.0f, 10.0f,
3835
3836 // Batch 0, Channel 2
3837 11.0f, 12.0f,
3838
3839 // Batch 0, Channel 3
3840 25.0f, 26.0f,
3841
3842 // Batch 1, Channel 0
3843 27.0f, 28.0f,
3844
3845 // Batch 1, Channel 1
3846 29.0f, 30.0f,
3847
3848 // Batch 1, Channel 2
3849 13.0f, 14.0f,
3850
3851 // Batch 1, Channel 3
3852 15.0f, 16.0f,
3853 }));
3854
3855 armnn::TensorInfo input2TensorInfo({ 2, 1, 2 }, armnn::GetDataType<T>());
3856 auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3857 // Batch 0, Channel 0
3858 17.0f, 18.0f,
3859
3860 // Batch 1, Channel 0
3861 31.0f, 32.0f,
3862 }));
3863
3864 armnn::TensorInfo outputTensorInfo({ 2, 8, 2 }, armnn::GetDataType<T>());
3865 LayerTestResult<T, 3> result(outputTensorInfo);
3866
3867 std::vector<T> output;
3868 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003869 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003870 { input0TensorInfo, input1TensorInfo, input2TensorInfo },
3871 { input0.data(), input1.data(), input2.data() },
3872 outputTensorInfo,
3873 output.data(),
3874 1,
3875 true);
telsoa014fcda012018-03-09 14:13:49 +00003876
3877 result.output = MakeTensor<T, 3>(outputTensorInfo, output);
3878 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
3879 // Batch 0, Channel 0
3880 1.0f, 2.0f,
3881
3882 // Batch 0, Channel 1
3883 3.0f, 4.0f,
3884
3885 // Batch 0, Channel 2
3886 5.0f, 6.0f,
3887
3888 // Batch 0, Channel 3
3889 7.0f, 8.0f,
3890
3891 // Batch 0, Channel 4
3892 9.0f, 10.0f,
3893
3894 // Batch 0, Channel 5
3895 11.0f, 12.0f,
3896
3897 // Batch 0, Channel 6
3898 25.0f, 26.0f,
3899
3900 // Batch 0, Channel 7
3901 17.0f, 18.0f,
3902
3903 // Batch 1, Channel 0
3904 19.0f, 20.0f,
3905
3906 // Batch 1, Channel 1
3907 21.0f, 22.0f,
3908
3909 // Batch 1, Channel 2
3910 23.0f, 24.0f,
3911
3912 // Batch 1, Channel 3
3913 27.0f, 28.0f,
3914
3915 // Batch 1, Channel 4
3916 29.0f, 30.0f,
3917
3918 // Batch 1, Channel 5
3919 13.0f, 14.0f,
3920
3921 // Batch 1, Channel 6
3922 15.0f, 16.0f,
3923
3924 // Batch 1, Channel 7
3925 31.0f, 32.0f,
3926 }));
3927
3928 return result;
3929}
3930
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003931LayerTestResult<float, 3> Concatenation3dDim1DiffInputDimsTest(
3932 armnn::IWorkloadFactory& workloadFactory,
3933 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00003934{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003935 return Concatenation3dDim1DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00003936}
3937
3938template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003939LayerTestResult<T, 3> Concatenation3dDim2DiffInputDimsTestImpl(
3940 armnn::IWorkloadFactory& workloadFactory,
3941 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
narpra015cdda352018-11-19 15:30:27 +00003942 bool useSubtensor,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00003943 float qScale,
telsoa014fcda012018-03-09 14:13:49 +00003944 int32_t qOffset)
3945{
3946 armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>());
3947 auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3948 // Batch 0, Channel 0
3949 1.0f, 2.0f,
3950
3951 // Batch 0, Channel 1
3952 3.0f, 4.0f,
3953
3954 // Batch 0, Channel 2
3955 5.0f, 6.0f,
3956
3957 // Batch 1, Channel 0
3958 19.0f, 20.0f,
3959
3960 // Batch 1, Channel 1
3961 21.0f, 22.0f,
3962
3963 // Batch 1, Channel 2
3964 23.0f, 24.0f
3965 }));
3966
3967 armnn::TensorInfo input1TensorInfo({ 2, 3, 1 }, armnn::GetDataType<T>());
3968 auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3969 // Batch 0, Channel 0
3970 7.0f,
3971
3972 // Batch 0, Channel 1
3973 9.0f,
3974
3975 // Batch 0, Channel 2
3976 11.0f,
3977
3978 // Batch 1, Channel 0
3979 25.0f,
3980
3981 // Batch 1, Channel 1
3982 27.0f,
3983
3984 // Batch 1, Channel 2
3985 29.0f
3986 }));
3987
3988 armnn::TensorInfo input2TensorInfo({ 2, 3, 3 }, armnn::GetDataType<T>());
3989 auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, {
3990 // Batch 0, Channel 0
3991 13.0f, 14.0f, 50.0f,
3992
3993 // Batch 0, Channel 1
3994 15.0f, 16.0f, 51.0f,
3995
3996 // Batch 0, Channel 2
3997 17.0f, 18.0f, 52.0f,
3998
3999 // Batch 1, Channel 0
4000 31.0f, 32.0f, 53.0f,
4001
4002 // Batch 1, Channel 1
4003 33.0f, 34.0f, 54.0f,
4004
4005 // Batch 1, Channel 2
4006 35.0f, 36.0f, 55.0f,
4007 }));
4008
4009 armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, armnn::GetDataType<T>());
4010 LayerTestResult<T, 3> result(outputTensorInfo);
4011
4012 std::vector<T> output;
4013 output.resize(outputTensorInfo.GetNumElements());
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004014 Concatenate<T>(workloadFactory, memoryManager,
narpra015cdda352018-11-19 15:30:27 +00004015 { input0TensorInfo, input1TensorInfo, input2TensorInfo },
4016 { input0.data(), input1.data(), input2.data() },
4017 outputTensorInfo,
4018 output.data(),
4019 2,
4020 useSubtensor);
telsoa014fcda012018-03-09 14:13:49 +00004021
4022 result.output = MakeTensor<T, 3>(outputTensorInfo, output);
4023 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4024 // Batch 0, Channel 0
4025 1.0f, 2.0f, 7.0f, 13.0f, 14.0f, 50.0f,
4026
4027 // Batch 0, Channel 1
4028 3.0f, 4.0f, 9.0f, 15.0f, 16.0f, 51.0f,
4029
4030 // Batch 0, Channel 2
4031 5.0f, 6.0f, 11.0f, 17.0f, 18.0f, 52.0f,
4032
4033 // Batch 1, Channel 0
4034 19.0f, 20.0f, 25.0f, 31.0f, 32.0f, 53.0f,
4035
4036 // Batch 1, Channel 1
4037 21.0f, 22.0f, 27.0f, 33.0f, 34.0f, 54.0f,
4038
4039 // Batch 1, Channel 2
4040 23.0f, 24.0f, 29.0f, 35.0f, 36.0f, 55.0f,
4041 }));
4042
4043 return result;
4044}
4045
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004046LayerTestResult<float, 3> Concatenation3dDim2DiffInputDimsTest(
4047 armnn::IWorkloadFactory& workloadFactory,
narpra015cdda352018-11-19 15:30:27 +00004048 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4049 bool useSubtensor)
4050{
4051 return Concatenation3dDim2DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, useSubtensor, 0.0f, 0);
4052}
4053
4054template <typename T>
4055LayerTestResult<T, 4> Concatenation4dTestImpl(
4056 armnn::IWorkloadFactory& workloadFactory,
4057 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4058 const armnn::TensorInfo& outputTensorInfo,
4059 unsigned int dimension,
4060 bool useSubtensor,
4061 float qScale,
4062 int32_t qOffset)
4063{
4064 armnn::TensorInfo inputTensorInfo({ 1, 3, 2, 2 }, armnn::GetDataType<T>());
4065
4066 auto input0 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4067 1.0f, 2.0f,
4068 3.0f, 4.0f,
4069 5.0f, 6.0f,
4070 7.0f, 8.0f,
4071 9.0f, 10.0f,
4072 11.0f, 12.0f
4073 }));
4074
4075 auto input1 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4076 11.0f, 12.0f,
4077 13.0f, 14.0f,
4078 15.0f, 16.0f,
4079 17.0f, 18.0f,
4080 19.0f, 20.0f,
4081 21.0f, 22.0f
4082 }));
4083
4084 auto input2 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4085 21.0f, 22.0f,
4086 23.0f, 24.0f,
4087 25.0f, 26.0f,
4088 27.0f, 28.0f,
4089 29.0f, 30.0f,
4090 31.0f, 32.0f
4091 }));
4092
4093 LayerTestResult<T, 4> result(outputTensorInfo);
4094
4095 std::vector<T> output;
4096 output.resize(outputTensorInfo.GetNumElements());
4097
4098 Concatenate<T>(workloadFactory,
4099 memoryManager,
4100 {inputTensorInfo, inputTensorInfo, inputTensorInfo},
4101 {input0.data(), input1.data(), input2.data()},
4102 outputTensorInfo,
4103 output.data(),
4104 dimension,
4105 useSubtensor);
4106
4107 result.output = MakeTensor<T, 4>(outputTensorInfo, output);
4108 return result;
4109}
4110
4111template <typename T>
4112LayerTestResult<T, 4> Concatenation4dDim0TestImpl(
4113 armnn::IWorkloadFactory& workloadFactory,
4114 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4115 float qScale,
4116 int32_t qOffset)
4117{
4118 armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, armnn::GetDataType<T>());
4119
4120 LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0,
4121 true, qScale, qOffset);
4122 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4123 1.0f, 2.0f,
4124 3.0f, 4.0f,
4125 5.0f, 6.0f,
4126 7.0f, 8.0f,
4127 9.0f, 10.0f,
4128 11.0f, 12.0f,
4129
4130 11.0f, 12.0f,
4131 13.0f, 14.0f,
4132 15.0f, 16.0f,
4133 17.0f, 18.0f,
4134 19.0f, 20.0f,
4135 21.0f, 22.0f,
4136
4137 21.0f, 22.0f,
4138 23.0f, 24.0f,
4139 25.0f, 26.0f,
4140 27.0f, 28.0f,
4141 29.0f, 30.0f,
4142 31.0f, 32.0f
4143 }));
4144 return result;
4145}
4146
4147LayerTestResult<float, 4> Concatenation4dDim0Test(
4148 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004149 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00004150{
narpra015cdda352018-11-19 15:30:27 +00004151 return Concatenation4dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4152}
4153
4154template <typename T>
4155LayerTestResult<T, 4> Concatenation4dDim1TestImpl(
4156 armnn::IWorkloadFactory& workloadFactory,
4157 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4158 float qScale,
4159 int32_t qOffset)
4160{
4161 armnn::TensorInfo outputTensorInfo({ 1, 9, 2, 2 }, armnn::GetDataType<T>());
4162
4163 LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1,
4164 true, qScale, qOffset);
4165 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4166 1.0f, 2.0f,
4167 3.0f, 4.0f,
4168 5.0f, 6.0f,
4169 7.0f, 8.0f,
4170 9.0f, 10.0f,
4171 11.0f, 12.0f,
4172
4173 11.0f, 12.0f,
4174 13.0f, 14.0f,
4175 15.0f, 16.0f,
4176 17.0f, 18.0f,
4177 19.0f, 20.0f,
4178 21.0f, 22.0f,
4179
4180 21.0f, 22.0f,
4181 23.0f, 24.0f,
4182 25.0f, 26.0f,
4183 27.0f, 28.0f,
4184 29.0f, 30.0f,
4185 31.0f, 32.0f
4186 }));
4187
4188 return result;
4189}
4190
4191LayerTestResult<float, 4> Concatenation4dDim1Test(
4192 armnn::IWorkloadFactory& workloadFactory,
4193 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
4194{
4195 return Concatenation4dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4196}
4197
4198template <typename T>
4199LayerTestResult<T, 4> Concatenation4dDim2TestImpl(
4200 armnn::IWorkloadFactory& workloadFactory,
4201 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4202 float qScale,
4203 int32_t qOffset)
4204{
4205 armnn::TensorInfo outputTensorInfo({ 1, 3, 6, 2 }, armnn::GetDataType<T>());
4206
4207 LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 2,
4208 true, qScale, qOffset);
4209 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4210 1.0f, 2.0f,
4211 3.0f, 4.0f,
4212 11.0f, 12.0f,
4213 13.0f, 14.0f,
4214 21.0f, 22.0f,
4215 23.0f, 24.0f,
4216
4217 5.0f, 6.0f,
4218 7.0f, 8.0f,
4219 15.0f, 16.0f,
4220 17.0f, 18.0f,
4221 25.0f, 26.0f,
4222 27.0f, 28.0f,
4223
4224 9.0f, 10.0f,
4225 11.0f, 12.0f,
4226 19.0f, 20.0f,
4227 21.0f, 22.0f,
4228 29.0f, 30.0f,
4229 31.0f, 32.0f
4230 }));
4231
4232 return result;
4233}
4234
4235LayerTestResult<float, 4> Concatenation4dDim2Test(
4236 armnn::IWorkloadFactory& workloadFactory,
4237 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
4238{
4239 return Concatenation4dDim2TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4240}
4241
4242template <typename T>
4243LayerTestResult<T, 4> Concatenation4dDim3TestImpl(
4244 armnn::IWorkloadFactory& workloadFactory,
4245 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4246 float qScale,
4247 int32_t qOffset,
4248 bool useSubtensor)
4249{
4250 armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 6 }, armnn::GetDataType<T>());
4251
4252 LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 3,
4253 useSubtensor, qScale, qOffset);
4254 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4255 1.0f, 2.0f,
4256 11.0f, 12.0f,
4257 21.0f, 22.0f,
4258 3.0f, 4.0f,
4259 13.0f, 14.0f,
4260 23.0f, 24.0f,
4261
4262 5.0f, 6.0f,
4263 15.0f, 16.0f,
4264 25.0f, 26.0f,
4265 7.0f, 8.0f,
4266 17.0f, 18.0f,
4267 27.0f, 28.0f,
4268
4269 9.0f, 10.0f,
4270 19.0f, 20.0f,
4271 29.0f, 30.0f,
4272 11.0f, 12.0f,
4273 21.0f, 22.0f,
4274 31.0f, 32.0f
4275 }));
4276
4277 return result;
4278}
4279
4280LayerTestResult<float, 4> Concatenation4dDim3Test(
4281 armnn::IWorkloadFactory& workloadFactory,
4282 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4283 bool useSubtensor)
4284{
4285 return Concatenation4dDim3TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, useSubtensor);
4286}
4287
4288template <typename T>
4289LayerTestResult<T, 4> Concatenation4dDiffShapeDim0TestImpl(
4290 armnn::IWorkloadFactory& workloadFactory,
4291 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4292 float qScale,
4293 int32_t qOffset)
4294{
4295 unsigned int dimension = 0;
4296 armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>());
4297
4298 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, {
4299 1.0f, 2.0f,
4300 3.0f, 4.0f,
4301 5.0f, 6.0f,
4302 7.0f, 8.0f,
4303 9.0f, 10.0f,
4304 11.0f, 12.0f
4305 }));
4306
4307 armnn::TensorInfo inputTensorInfo1({ 2, 3, 2, 2 }, armnn::GetDataType<T>());
4308
4309 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, {
4310 11.0f, 12.0f,
4311 13.0f, 14.0f,
4312 15.0f, 16.0f,
4313 17.0f, 18.0f,
4314 19.0f, 20.0f,
4315 21.0f, 22.0f,
4316
4317 21.0f, 22.0f,
4318 23.0f, 24.0f,
4319 25.0f, 26.0f,
4320 27.0f, 28.0f,
4321 29.0f, 30.0f,
4322 31.0f, 32.0f
4323
4324 }));
4325
4326 armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, armnn::GetDataType<T>());
4327
4328 LayerTestResult<T, 4> result(outputTensorInfo);
4329
4330 std::vector<T> output;
4331 output.resize(outputTensorInfo.GetNumElements());
4332 Concatenate<T>(workloadFactory,
4333 memoryManager,
4334 {inputTensorInfo0, inputTensorInfo1},
4335 {input0.data(), input1.data()},
4336 outputTensorInfo,
4337 output.data(),
4338 dimension,
4339 true);
4340
4341 result.output = MakeTensor<T, 4>(outputTensorInfo, output);
4342 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4343 1.0f, 2.0f,
4344 3.0f, 4.0f,
4345 5.0f, 6.0f,
4346 7.0f, 8.0f,
4347 9.0f, 10.0f,
4348 11.0f, 12.0f,
4349
4350 11.0f, 12.0f,
4351 13.0f, 14.0f,
4352 15.0f, 16.0f,
4353 17.0f, 18.0f,
4354 19.0f, 20.0f,
4355 21.0f, 22.0f,
4356
4357 21.0f, 22.0f,
4358 23.0f, 24.0f,
4359 25.0f, 26.0f,
4360 27.0f, 28.0f,
4361 29.0f, 30.0f,
4362 31.0f, 32.0f
4363 }));
4364
4365 return result;
4366}
4367
4368LayerTestResult<float, 4> Concatenation4dDiffShapeDim0Test(
4369 armnn::IWorkloadFactory& workloadFactory,
4370 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
4371{
4372 return Concatenation4dDiffShapeDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4373}
4374
4375template <typename T>
4376LayerTestResult<T, 4> Concatenation4dDiffShapeDim1TestImpl(
4377 armnn::IWorkloadFactory& workloadFactory,
4378 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4379 float qScale,
4380 int32_t qOffset)
4381{
4382 unsigned int dimension = 1;
4383 armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>());
4384
4385 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, {
4386 1.0f, 2.0f,
4387 3.0f, 4.0f,
4388 5.0f, 6.0f,
4389 7.0f, 8.0f,
4390 9.0f, 10.0f,
4391 11.0f, 12.0f
4392 }));
4393
4394 armnn::TensorInfo inputTensorInfo1({ 1, 2, 2, 2 }, armnn::GetDataType<T>());
4395
4396 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, {
4397 11.0f, 12.0f,
4398 13.0f, 14.0f,
4399 15.0f, 16.0f,
4400 17.0f, 18.0f,
4401
4402 }));
4403
4404 armnn::TensorInfo outputTensorInfo({ 1, 5, 2, 2 }, armnn::GetDataType<T>());
4405
4406 LayerTestResult<T, 4> result(outputTensorInfo);
4407
4408 std::vector<T> output;
4409 output.resize(outputTensorInfo.GetNumElements());
4410 Concatenate<T>(workloadFactory,
4411 memoryManager,
4412 {inputTensorInfo0, inputTensorInfo1},
4413 {input0.data(), input1.data()},
4414 outputTensorInfo,
4415 output.data(),
4416 dimension,
4417 true);
4418
4419 result.output = MakeTensor<T, 4>(outputTensorInfo, output);
4420 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4421 1.0f, 2.0f,
4422 3.0f, 4.0f,
4423 5.0f, 6.0f,
4424 7.0f, 8.0f,
4425 9.0f, 10.0f,
4426 11.0f, 12.0f,
4427 11.0f, 12.0f,
4428 13.0f, 14.0f,
4429 15.0f, 16.0f,
4430 17.0f, 18.0f
4431 }));
4432
4433 return result;
4434}
4435
4436LayerTestResult<float, 4> Concatenation4dDiffShapeDim1Test(
4437 armnn::IWorkloadFactory& workloadFactory,
4438 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
4439{
4440 return Concatenation4dDiffShapeDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4441}
4442
4443template <typename T>
4444LayerTestResult<T, 4> Concatenation4dDiffShapeDim2TestImpl(
4445 armnn::IWorkloadFactory& workloadFactory,
4446 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4447 float qScale,
4448 int32_t qOffset)
4449{
4450 unsigned int dimension = 2;
4451 armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>());
4452
4453 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, {
4454 1.0f, 2.0f,
4455 3.0f, 4.0f,
4456 5.0f, 6.0f,
4457 7.0f, 8.0f,
4458 9.0f, 10.0f,
4459 11.0f, 12.0f
4460 }));
4461
4462 armnn::TensorInfo inputTensorInfo1({ 1, 3, 3, 2 }, armnn::GetDataType<T>());
4463
4464 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, {
4465 11.0f, 12.0f,
4466 13.0f, 14.0f,
4467 15.0f, 16.0f,
4468 17.0f, 18.0f,
4469 19.0f, 20.0f,
4470 21.0f, 22.0f,
4471 23.0f, 24.0f,
4472 25.0f, 26.0f,
4473 27.0f, 28.0f
4474 }));
4475
4476 armnn::TensorInfo outputTensorInfo({ 1, 3, 5, 2 }, armnn::GetDataType<T>());
4477
4478 LayerTestResult<T, 4> result(outputTensorInfo);
4479
4480 std::vector<T> output;
4481 output.resize(outputTensorInfo.GetNumElements());
4482 Concatenate<T>(workloadFactory,
4483 memoryManager,
4484 {inputTensorInfo0, inputTensorInfo1},
4485 {input0.data(), input1.data()},
4486 outputTensorInfo,
4487 output.data(),
4488 dimension,
4489 true);
4490
4491 result.output = MakeTensor<T, 4>(outputTensorInfo, output);
4492 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4493 1.0f, 2.0f,
4494 3.0f, 4.0f,
4495 11.0f, 12.0f,
4496 13.0f, 14.0f,
4497 15.0f, 16.0f,
4498
4499 5.0f, 6.0f,
4500 7.0f, 8.0f,
4501 17.0f, 18.0f,
4502 19.0f, 20.0f,
4503 21.0f, 22.0f,
4504
4505 9.0f, 10.0f,
4506 11.0f, 12.0f,
4507 23.0f, 24.0f,
4508 25.0f, 26.0f,
4509 27.0f, 28.0f
4510 }));
4511
4512 return result;
4513}
4514
4515LayerTestResult<float, 4> Concatenation4dDiffShapeDim2Test(
4516 armnn::IWorkloadFactory& workloadFactory,
4517 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
4518{
4519 return Concatenation4dDiffShapeDim2TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
4520}
4521
4522template <typename T>
4523LayerTestResult<T, 4> Concatenation4dDiffShapeDim3TestImpl(
4524 armnn::IWorkloadFactory& workloadFactory,
4525 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4526 float qScale,
4527 int32_t qOffset,
4528 bool useSubtensor)
4529{
4530 unsigned int dimension = 3;
4531 armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>());
4532
4533 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, {
4534 1.0f, 2.0f,
4535 3.0f, 4.0f,
4536 5.0f, 6.0f,
4537 7.0f, 8.0f,
4538 9.0f, 10.0f,
4539 11.0f, 12.0f
4540 }));
4541
4542 armnn::TensorInfo inputTensorInfo1({ 1, 3, 2, 3 }, armnn::GetDataType<T>());
4543
4544 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, {
4545 11.0f, 12.0f, 13.0f,
4546 14.0f, 15.0f, 16.0f,
4547
4548 17.0f, 18.0f, 19.0f,
4549 20.0f, 21.0f, 22.0f,
4550
4551 23.0f, 24.0f, 25.0f,
4552 26.0f, 27.0f, 28.0f
4553 }));
4554
4555 armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 5 }, armnn::GetDataType<T>());
4556
4557 LayerTestResult<T, 4> result(outputTensorInfo);
4558
4559 std::vector<T> output;
4560 output.resize(outputTensorInfo.GetNumElements());
4561 Concatenate<T>(workloadFactory,
4562 memoryManager,
4563 {inputTensorInfo0, inputTensorInfo1},
4564 {input0.data(), input1.data()},
4565 outputTensorInfo,
4566 output.data(),
4567 dimension,
4568 useSubtensor);
4569
4570 result.output = MakeTensor<T, 4>(outputTensorInfo, output);
4571 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, {
4572 1.0f, 2.0f, 11.0f, 12.0f, 13.0f,
4573 3.0f, 4.0f, 14.0f, 15.0f, 16.0f,
4574 5.0f, 6.0f, 17.0f, 18.0f, 19.0f,
4575 7.0f, 8.0f, 20.0f, 21.0f, 22.0f,
4576 9.0f, 10.0f, 23.0f, 24.0f, 25.0f,
4577 11.0f, 12.0f, 26.0f, 27.0f, 28.0f
4578 }));
4579
4580 return result;
4581}
4582
4583LayerTestResult<float, 4> Concatenation4dDiffShapeDim3Test(
4584 armnn::IWorkloadFactory& workloadFactory,
4585 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4586 bool useSubtensor)
4587{
4588 return Concatenation4dDiffShapeDim3TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, useSubtensor);
telsoa014fcda012018-03-09 14:13:49 +00004589}
4590
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004591LayerTestResult<float, 4> ResizeBilinearNopTest(
4592 armnn::IWorkloadFactory& workloadFactory,
4593 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00004594 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00004595{
Nina Drozdd41b2592018-11-19 13:03:36 +00004596 const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout);
4597 const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00004598
James Conroy6b965822018-11-01 11:33:09 +00004599 std::vector<float> inputData({
4600 1.0f, 2.0f, 3.0f, 4.0f,
4601 2.0f, 3.0f, 4.0f, 5.0f,
4602 3.0f, 4.0f, 5.0f, 6.0f,
4603 4.0f, 5.0f, 6.0f, 7.0f,
4604
telsoa014fcda012018-03-09 14:13:49 +00004605 1.0f, 2.0f, 3.0f, 4.0f,
4606 2.0f, 3.0f, 4.0f, 5.0f,
4607 3.0f, 4.0f, 5.0f, 6.0f,
4608 4.0f, 5.0f, 6.0f, 7.0f
James Conroy6b965822018-11-01 11:33:09 +00004609 });
4610
4611 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
Matthew Bentham8800c002018-11-19 13:19:28 +00004612 if (dataLayout == armnn::DataLayout::NHWC)
James Conroy6b965822018-11-01 11:33:09 +00004613 {
4614 std::vector<float> tmp(inputData.size());
4615 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4616 inputData = tmp;
4617 }
4618
4619 auto input = MakeTensor<float, 4>(inputTensorInfo, inputData);
telsoa014fcda012018-03-09 14:13:49 +00004620
4621 LayerTestResult<float, 4> result(outputTensorInfo);
4622 result.outputExpected = input;
4623
4624 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
4625 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
4626
4627 armnn::ResizeBilinearQueueDescriptor descriptor;
James Conroy074f3712018-10-03 09:32:03 +01004628 descriptor.m_Parameters.m_DataLayout = dataLayout;
4629 armnn::WorkloadInfo info;
4630 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
4631 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
4632
4633 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
4634
4635 inputHandle->Allocate();
4636 outputHandle->Allocate();
4637 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
4638
James Conroy074f3712018-10-03 09:32:03 +01004639 workload->Execute();
4640
4641 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
4642 return result;
4643}
4644
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004645LayerTestResult<float, 4> SimpleResizeBilinearTest(
4646 armnn::IWorkloadFactory& workloadFactory,
4647 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00004648 const armnn::DataLayout dataLayout)
James Conroy074f3712018-10-03 09:32:03 +01004649{
Nina Drozdd41b2592018-11-19 13:03:36 +00004650 const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 2, dataLayout);
4651 const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 1, 1, dataLayout);
James Conroy074f3712018-10-03 09:32:03 +01004652
James Conroy6b965822018-11-01 11:33:09 +00004653 std::vector<float> inputData({
James Conroy074f3712018-10-03 09:32:03 +01004654 1.0f, 255.0f,
James Conroy6b965822018-11-01 11:33:09 +00004655 200.0f, 250.0f,
4656
4657 250.0f, 200.0f,
4658 250.0f, 1.0f
4659 });
James Conroy074f3712018-10-03 09:32:03 +01004660
4661 // The 'resize bilinear' operation projects the top-left corner of output texels into the input image,
4662 // then figures out the interpolants and weights. Note this is different to projecting the centre of the
James Conroy6b965822018-11-01 11:33:09 +00004663 // output texel. Thus, for a input matrix of 2x2, we'll expect the output 1x1 matrix to contain, as
4664 // its single element, the value that was at position (0,0) of the input matrix (rather than an average,
4665 // which we would expect if projecting the centre).
4666
4667 std::vector<float> outputData({
4668 1.0f,
4669
4670 250.0f
4671 });
4672
4673 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
Matthew Bentham8800c002018-11-19 13:19:28 +00004674 if (dataLayout == armnn::DataLayout::NHWC)
James Conroy6b965822018-11-01 11:33:09 +00004675 {
4676 std::vector<float> tmp(inputData.size());
4677 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4678 inputData = tmp;
4679
4680 std::vector<float> tmp1(outputData.size());
4681 armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data());
4682 outputData = tmp1;
4683 }
4684
4685 auto input = MakeTensor<float, 4>(inputTensorInfo, inputData);
4686
James Conroy074f3712018-10-03 09:32:03 +01004687 LayerTestResult<float, 4> result(outputTensorInfo);
James Conroy6b965822018-11-01 11:33:09 +00004688 result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData);
James Conroy074f3712018-10-03 09:32:03 +01004689
4690 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
4691 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
4692
4693 armnn::ResizeBilinearQueueDescriptor descriptor;
4694 descriptor.m_Parameters.m_DataLayout = dataLayout;
telsoa014fcda012018-03-09 14:13:49 +00004695 armnn::WorkloadInfo info;
4696 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
4697 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
4698
4699 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
4700
4701 inputHandle->Allocate();
4702 outputHandle->Allocate();
4703 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
4704
4705 workload->Execute();
4706
4707 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
4708 return result;
4709}
4710
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004711LayerTestResult<float, 4> ResizeBilinearSqMinTest(
4712 armnn::IWorkloadFactory& workloadFactory,
4713 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00004714 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00004715{
Nina Drozdd41b2592018-11-19 13:03:36 +00004716 const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout);
4717 const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 2, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00004718
James Conroy6b965822018-11-01 11:33:09 +00004719 std::vector<float> inputData({
James Conroy074f3712018-10-03 09:32:03 +01004720 1.0f, 2.0f, 3.0f, 4.0f,
4721 2.0f, 3.0f, 4.0f, 5.0f,
4722 3.0f, 4.0f, 5.0f, 6.0f,
James Conroy6b965822018-11-01 11:33:09 +00004723 4.0f, 5.0f, 6.0f, 7.0f,
4724
4725 7.0f, 6.0f, 5.0f, 4.0f,
4726 6.0f, 5.0f, 4.0f, 3.0f,
4727 5.0f, 4.0f, 3.0f, 2.0f,
4728 4.0f, 3.0f, 2.0f, 1.0f
4729 });
4730
4731 std::vector<float> outputData({
4732 1.0f, 3.0f,
4733 3.0f, 5.0f,
4734
4735 7.0f, 5.0f,
4736 5.0f, 3.0f
4737 });
4738
4739 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
Matthew Bentham8800c002018-11-19 13:19:28 +00004740 if (dataLayout == armnn::DataLayout::NHWC)
James Conroy6b965822018-11-01 11:33:09 +00004741 {
4742 std::vector<float> tmp(inputData.size());
4743 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4744 inputData = tmp;
4745
4746 std::vector<float> tmp1(outputData.size());
4747 armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data());
4748 outputData = tmp1;
4749 }
4750
4751 auto input = MakeTensor<float, 4>(inputTensorInfo, inputData);
telsoa014fcda012018-03-09 14:13:49 +00004752
telsoa014fcda012018-03-09 14:13:49 +00004753 LayerTestResult<float, 4> result(outputTensorInfo);
James Conroy6b965822018-11-01 11:33:09 +00004754 result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData);
telsoa014fcda012018-03-09 14:13:49 +00004755
4756 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
4757 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
4758
4759 armnn::ResizeBilinearQueueDescriptor descriptor;
James Conroy074f3712018-10-03 09:32:03 +01004760 descriptor.m_Parameters.m_DataLayout = dataLayout;
telsoa014fcda012018-03-09 14:13:49 +00004761 armnn::WorkloadInfo info;
4762 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
4763 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
4764
4765 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
4766
4767 inputHandle->Allocate();
4768 outputHandle->Allocate();
4769 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
4770
4771 workload->Execute();
4772
4773 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
4774 return result;
4775}
4776
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004777LayerTestResult<float, 4> ResizeBilinearMinTest(
4778 armnn::IWorkloadFactory& workloadFactory,
4779 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00004780 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00004781{
Nina Drozdd41b2592018-11-19 13:03:36 +00004782 const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 5, dataLayout);
4783 const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 3, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00004784
James Conroy6b965822018-11-01 11:33:09 +00004785 std::vector<float> inputData({
James Conroy074f3712018-10-03 09:32:03 +01004786 1.0f, 2.0f, 3.0f, 5.0f, 8.0f,
4787 13.0f, 21.0f, 34.0f, 55.0f, 89.0f,
James Conroy6b965822018-11-01 11:33:09 +00004788 144.0f, 233.0f, 377.0f, 610.0f, 987.0f,
4789
4790 987.0f, 610.0f, 377.0f, 233.0f, 144.0f,
4791 89.0f, 55.0f, 34.0f, 21.0f, 13.0f,
4792 8.0f, 5.0f, 3.0f, 2.0f, 1.0f
4793 });
4794
4795 std::vector<float> outputData({
4796 1.0f, 2.6666f, 6.00f,
4797 78.5f, 179.3333f, 401.00f,
4798
4799 987.0f, 454.6670f, 203.33f,
4800 48.5f, 22.3333f, 10.00f
4801 });
4802
4803 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
Matthew Bentham8800c002018-11-19 13:19:28 +00004804 if (dataLayout == armnn::DataLayout::NHWC)
James Conroy6b965822018-11-01 11:33:09 +00004805 {
4806 std::vector<float> tmp(inputData.size());
4807 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4808 inputData = tmp;
4809
4810 std::vector<float> tmp1(outputData.size());
4811 armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data());
4812 outputData = tmp1;
4813 }
4814
4815 auto input = MakeTensor<float, 4>(inputTensorInfo, inputData);
telsoa014fcda012018-03-09 14:13:49 +00004816
4817 LayerTestResult<float, 4> result(outputTensorInfo);
James Conroy6b965822018-11-01 11:33:09 +00004818 result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData);
telsoa014fcda012018-03-09 14:13:49 +00004819
4820 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
4821 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
4822
4823 armnn::ResizeBilinearQueueDescriptor descriptor;
James Conroy074f3712018-10-03 09:32:03 +01004824 descriptor.m_Parameters.m_DataLayout = dataLayout;
telsoa014fcda012018-03-09 14:13:49 +00004825 armnn::WorkloadInfo info;
4826 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
4827 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
4828
4829 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
4830
4831 inputHandle->Allocate();
4832 outputHandle->Allocate();
4833 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
4834
4835 workload->Execute();
4836
4837 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
4838 return result;
4839}
4840
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004841LayerTestResult<float, 4> ResizeBilinearMagTest(
4842 armnn::IWorkloadFactory& workloadFactory,
4843 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00004844 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00004845{
Nina Drozdd41b2592018-11-19 13:03:36 +00004846 const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 2, dataLayout);
4847 const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 5, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00004848
James Conroy6b965822018-11-01 11:33:09 +00004849 std::vector<float> inputData({
James Conroy074f3712018-10-03 09:32:03 +01004850 1.0f, 2.0f,
4851 13.0f, 21.0f,
James Conroy6b965822018-11-01 11:33:09 +00004852 144.0f, 233.0f,
telsoa014fcda012018-03-09 14:13:49 +00004853
James Conroy6b965822018-11-01 11:33:09 +00004854 233.0f, 144.0f,
4855 21.0f, 13.0f,
4856 2.0f, 1.0f
4857 });
4858
4859 std::vector<float> outputData({
James Conroy074f3712018-10-03 09:32:03 +01004860 1.0f, 1.4f, 1.8f, 2.0f, 2.0f,
4861 13.0f, 16.2f, 19.4f, 21.0f, 21.0f,
James Conroy6b965822018-11-01 11:33:09 +00004862 144.0f, 179.6f, 215.2f, 233.0f, 233.0f,
4863
4864 233.0f, 197.4f, 161.8f, 144.0f, 144.0f,
4865 21.0f, 17.8f, 14.6f, 13.0f, 13.0f,
4866 2.0f, 1.6f, 1.2f, 1.0f, 1.0f
4867 });
4868
4869 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
Matthew Bentham8800c002018-11-19 13:19:28 +00004870 if (dataLayout == armnn::DataLayout::NHWC)
James Conroy6b965822018-11-01 11:33:09 +00004871 {
4872 std::vector<float> tmp(inputData.size());
4873 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4874 inputData = tmp;
4875
4876 std::vector<float> tmp1(outputData.size());
4877 armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data());
4878 outputData = tmp1;
4879 }
4880
4881 auto input = MakeTensor<float, 4>(inputTensorInfo, inputData);
4882
4883 LayerTestResult<float, 4> result(outputTensorInfo);
4884 result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData);
telsoa014fcda012018-03-09 14:13:49 +00004885
4886 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
4887 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
4888
4889 armnn::ResizeBilinearQueueDescriptor descriptor;
James Conroy074f3712018-10-03 09:32:03 +01004890 descriptor.m_Parameters.m_DataLayout = dataLayout;
telsoa014fcda012018-03-09 14:13:49 +00004891 armnn::WorkloadInfo info;
4892 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
4893 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
4894
4895 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
4896
4897 inputHandle->Allocate();
4898 outputHandle->Allocate();
4899 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
4900
4901 workload->Execute();
4902
4903 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
4904 return result;
4905}
4906
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004907LayerTestResult<float, 2> FakeQuantizationTest(
4908 armnn::IWorkloadFactory& workloadFactory,
4909 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00004910{
4911 constexpr unsigned int width = 2;
4912 constexpr unsigned int height = 3;
4913
4914 const armnn::TensorInfo tensorInfo({height, width },
4915 armnn::DataType::Float32);
4916 auto input = MakeTensor<float, 2>(tensorInfo, std::vector<float>({
4917 -10.0f, -5.0f,
4918 0.0f, 5.0f,
4919 10.0f, 10.0f
4920 }));
4921
4922 LayerTestResult<float, 2> ret(tensorInfo);
4923
4924 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(tensorInfo);
4925
4926 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(tensorInfo);
4927
4928 armnn::FakeQuantizationQueueDescriptor data;
4929 armnn::WorkloadInfo info;
4930
4931 AddInputToWorkload(data, info, tensorInfo, inputHandle.get());
4932 AddOutputToWorkload(data, info, tensorInfo, outputHandle.get());
4933 float min = -10.f;
4934 float max = 10.f;
4935
4936 data.m_Parameters.m_Min = min;
4937 data.m_Parameters.m_Max = max;
4938
4939 armnn::PassthroughCpuTensorHandle refHandle(tensorInfo, &ret.outputExpected[0][0]);
4940 armnn::FakeQuantizationQueueDescriptor refData = data;
4941 armnn::WorkloadInfo refInfo = info;
4942 SetWorkloadOutput(refData, refInfo, 0, tensorInfo, &refHandle);
4943
4944 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateFakeQuantization(data, info);
4945
4946 inputHandle->Allocate();
4947 outputHandle->Allocate();
4948
4949 CopyDataToITensorHandle(inputHandle.get(), &input[0][0]);
4950
4951 workload->Execute();
4952
4953 CopyDataFromITensorHandle(&ret.output[0][0], outputHandle.get());
4954
4955 ret.outputExpected = MakeTensor<float, 2>(tensorInfo, std::vector<float>({
4956 0.0f, 63.0f,
4957 128.0f, 191.0f,
4958 255.0f, 255.0f
4959 }));
4960 return ret;
4961}
4962
Matteo Martincigh539b44d2018-10-01 09:26:39 +01004963namespace
4964{
4965
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00004966LayerTestResult<float, 4> L2NormalizationTestImpl(
4967 armnn::IWorkloadFactory& workloadFactory,
4968 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
4969 const armnn::TensorShape& inputOutputTensorShape,
4970 const std::vector<float>& inputValues,
4971 const std::vector<float>& expectedOutputValues,
Matthew Bentham8800c002018-11-19 13:19:28 +00004972 const armnn::DataLayout layout)
Matteo Martincigh539b44d2018-10-01 09:26:39 +01004973{
4974 const armnn::TensorInfo inputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32);
4975 const armnn::TensorInfo outputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32);
4976
jimfly013aab7c32018-11-12 13:32:08 +00004977 // at this point if we require it permute the input data
4978 const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
4979 std::vector<float> inputData = inputValues;
Matthew Bentham8800c002018-11-19 13:19:28 +00004980 if (layout == armnn::DataLayout::NHWC)
jimfly013aab7c32018-11-12 13:32:08 +00004981 {
4982 std::vector<float> tmp(inputData.size());
4983 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data());
4984 inputData = tmp;
4985 }
4986
4987 auto inputTensor = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(inputData));
Matteo Martincigh539b44d2018-10-01 09:26:39 +01004988
4989 LayerTestResult<float, 4> result(outputTensorInfo);
jimfly013aab7c32018-11-12 13:32:08 +00004990 std::vector<float> expectedOutputData = expectedOutputValues;
Matthew Bentham8800c002018-11-19 13:19:28 +00004991 if (layout == armnn::DataLayout::NHWC)
jimfly013aab7c32018-11-12 13:32:08 +00004992 {
4993 std::vector<float> tmp(expectedOutputData.size());
4994 armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, expectedOutputData.data(), tmp.data());
4995 expectedOutputData = tmp;
4996 }
4997 result.outputExpected = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(expectedOutputData));
Matteo Martincigh539b44d2018-10-01 09:26:39 +01004998
4999 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
5000 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
5001
5002 armnn::L2NormalizationQueueDescriptor descriptor;
Matthew Bentham8800c002018-11-19 13:19:28 +00005003 descriptor.m_Parameters.m_DataLayout = layout;
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005004 armnn::WorkloadInfo info;
5005
5006 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
5007 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
5008
5009 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateL2Normalization(descriptor, info);
5010
5011 inputHandle->Allocate();
5012 outputHandle->Allocate();
5013
5014 CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]);
5015
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005016 ExecuteWorkload(*workload, memoryManager);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005017
5018 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
5019
5020 return result;
5021}
5022
5023float CalcInvL2Norm(std::initializer_list<float> elements)
5024{
5025 const float reduction = std::accumulate(elements.begin(), elements.end(), 0.0f,
5026 [](float acc, float element) { return acc + element * element; });
5027 return 1.0f / sqrtf(reduction);
5028}
5029
5030} // anonymous namespace
5031
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005032template<typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005033LayerTestResult<T, 2> Pad2dTestCommon(
5034 armnn::IWorkloadFactory& workloadFactory,
5035 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
5036 float qScale,
5037 int32_t qOffset)
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005038{
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005039 const armnn::TensorShape inputShape{ 3, 3 };
5040 const armnn::TensorShape outputShape{ 7, 7 };
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005041
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005042 const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>());
5043 const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>());
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005044
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005045 std::vector<T> inputValues(
5046 QuantizedVector<T>(qScale, qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005047 {
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005048 // Height (3) x Width (3)
5049 4, 8, 6,
5050 7, 4, 4,
5051 3, 2, 4
5052 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005053
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005054 std::vector<T> expectedOutputValues(
5055 QuantizedVector<T>(qScale, qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005056 {
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005057 0, 0, 0, 0, 0, 0, 0,
5058 0, 0, 0, 0, 0, 0, 0,
5059 0, 0, 4, 8, 6, 0, 0,
5060 0, 0, 7, 4, 4, 0, 0,
5061 0, 0, 3, 2, 4, 0, 0,
5062 0, 0, 0, 0, 0, 0, 0,
5063 0, 0, 0, 0, 0, 0, 0
5064 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005065
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005066 auto inputTensor = MakeTensor<T, 2>(inputTensorInfo, std::vector<T>(inputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005067
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005068 LayerTestResult<T, 2> result(outputTensorInfo);
5069 result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, std::vector<T>(expectedOutputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005070
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005071 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
5072 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005073
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005074 armnn::PadQueueDescriptor descriptor;
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005075
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005076 std::vector<std::pair<unsigned int, unsigned int>> PadList;
5077 PadList.push_back(std::pair<unsigned int, unsigned int>(2,2));
5078 PadList.push_back(std::pair<unsigned int, unsigned int>(2,2));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005079
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005080 descriptor.m_Parameters.m_PadList = PadList;
5081 armnn::WorkloadInfo info;
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005082
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005083 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
5084 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005085
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005086 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005087
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005088 inputHandle->Allocate();
5089 outputHandle->Allocate();
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005090
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005091 CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0]);
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005092
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005093 workload->Execute();
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005094
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005095 CopyDataFromITensorHandle(&result.output[0][0], outputHandle.get());
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005096
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005097 return result;
5098}
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005099
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005100template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005101LayerTestResult<T, 3> Pad3dTestCommon(
5102 armnn::IWorkloadFactory& workloadFactory,
5103 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
5104 float qScale,
5105 int32_t qOffset)
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005106{
5107 const armnn::TensorShape inputShape{ 2, 2, 2 };
5108 const armnn::TensorShape outputShape{ 3, 5, 6 };
5109
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005110 const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>());
5111 const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>());
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005112
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005113 std::vector<T> inputValues(
5114 QuantizedVector<T>(qScale,qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005115 {
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005116 // Channel 0, Height (2) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005117 0, 4,
5118 2, 5,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005119
5120 // Channel 1, Height (2) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005121 6, 1,
5122 5, 2
5123 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005124
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005125 std::vector<T> expectedOutputValues(
5126 QuantizedVector<T>(qScale,qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005127 {
5128
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005129 0, 0, 0, 0, 0, 0,
5130 0, 0, 0, 0, 0, 0,
5131 0, 0, 0, 4, 0, 0,
5132 0, 0, 2, 5, 0, 0,
5133 0, 0, 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005134
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005135 0, 0, 0, 0, 0, 0,
5136 0, 0, 0, 0, 0, 0,
5137 0, 0, 6, 1, 0, 0,
5138 0, 0, 5, 2, 0, 0,
5139 0, 0, 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005140
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005141 0, 0, 0, 0, 0, 0,
5142 0, 0, 0, 0, 0, 0,
5143 0, 0, 0, 0, 0, 0,
5144 0, 0, 0, 0, 0, 0,
5145 0, 0, 0, 0, 0, 0
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005146
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005147 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005148
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005149 auto inputTensor = MakeTensor<T, 3>(inputTensorInfo, std::vector<T>(inputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005150
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005151 LayerTestResult<T, 3> result(outputTensorInfo);
5152 result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, std::vector<T>(expectedOutputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005153
5154 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
5155 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
5156
5157 armnn::PadQueueDescriptor descriptor;
5158
5159 std::vector<std::pair<unsigned int, unsigned int>> PadList;
5160 PadList.push_back(std::pair<unsigned int, unsigned int>(0,1));
5161 PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
5162 PadList.push_back(std::pair<unsigned int, unsigned int>(2,2));
5163
5164 descriptor.m_Parameters.m_PadList = PadList;
5165 armnn::WorkloadInfo info;
5166
5167 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
5168 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
5169
5170 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
5171
5172 inputHandle->Allocate();
5173 outputHandle->Allocate();
5174
5175 CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0]);
5176
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005177 workload->Execute();
5178
5179 CopyDataFromITensorHandle(&result.output[0][0][0], outputHandle.get());
5180
5181 return result;
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005182}
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005183
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005184template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005185LayerTestResult<T, 4> Pad4dTestCommon(
5186 armnn::IWorkloadFactory& workloadFactory,
5187 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
5188 float qScale,
5189 int32_t qOffset)
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005190{
5191 const armnn::TensorShape inputShape{ 2, 2, 3, 2 };
5192 const armnn::TensorShape outputShape{ 4, 5, 7, 4 };
5193
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005194 const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>());
5195 const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>());
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005196
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005197 std::vector<T> inputValues(
5198 QuantizedVector<T>(qScale,qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005199 {
5200 // Batch 0, Channel 0, Height (3) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005201 0, 1,
5202 2, 3,
5203 4, 5,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005204
5205 // Batch 0, Channel 1, Height (3) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005206 6, 7,
5207 8, 9,
5208 10, 11,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005209
5210 // Batch 1, Channel 0, Height (3) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005211 12, 13,
5212 14, 15,
5213 16, 17,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005214
5215 // Batch 1, Channel 1, Height (3) x Width (2)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005216 18, 19,
5217 20, 21,
5218 22, 23
5219 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005220
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005221 std::vector<T> expectedOutputValues(
5222 QuantizedVector<T>(qScale,qOffset,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005223 {
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005224 0, 0, 0, 0,
5225 0, 0, 0, 0,
5226 0, 0, 0, 0,
5227 0, 0, 0, 0,
5228 0, 0, 0, 0,
5229 0, 0, 0, 0,
5230 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005231
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005232 0, 0, 0, 0,
5233 0, 0, 0, 0,
5234 0, 0, 0, 0,
5235 0, 0, 0, 0,
5236 0, 0, 0, 0,
5237 0, 0, 0, 0,
5238 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005239
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005240 0, 0, 0, 0,
5241 0, 0, 0, 0,
5242 0, 0, 0, 0,
5243 0, 0, 0, 0,
5244 0, 0, 0, 0,
5245 0, 0, 0, 0,
5246 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005247
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005248 0, 0, 0, 0,
5249 0, 0, 0, 0,
5250 0, 0, 0, 0,
5251 0, 0, 0, 0,
5252 0, 0, 0, 0,
5253 0, 0, 0, 0,
5254 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005255
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005256 0, 0, 0, 0,
5257 0, 0, 0, 0,
5258 0, 0, 0, 0,
5259 0, 0, 0, 0,
5260 0, 0, 0, 0,
5261 0, 0, 0, 0,
5262 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005263
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005264 0, 0, 0, 0,
5265 0, 0, 0, 0,
5266 0, 0, 0, 0,
5267 0, 0, 0, 0,
5268 0, 0, 0, 0,
5269 0, 0, 0, 0,
5270 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005271
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005272 0, 0, 0, 0,
5273 0, 0, 0, 0,
5274 0, 0, 0, 0,
5275 0, 0, 0, 0,
5276 0, 0, 0, 0,
5277 0, 0, 0, 0,
5278 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005279
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005280 0, 0, 0, 0,
5281 0, 0, 0, 0,
5282 0, 0, 0, 0,
5283 0, 0, 1, 0,
5284 0, 2, 3, 0,
5285 0, 4, 5, 0,
5286 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005287
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005288 0, 0, 0, 0,
5289 0, 0, 0, 0,
5290 0, 0, 0, 0,
5291 0, 6, 7, 0,
5292 0, 8, 9, 0,
5293 0, 10, 11, 0,
5294 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005295
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005296 0, 0, 0, 0,
5297 0, 0, 0, 0,
5298 0, 0, 0, 0,
5299 0, 0, 0, 0,
5300 0, 0, 0, 0,
5301 0, 0, 0, 0,
5302 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005303
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005304 0, 0, 0, 0,
5305 0, 0, 0, 0,
5306 0, 0, 0, 0,
5307 0, 0, 0, 0,
5308 0, 0, 0, 0,
5309 0, 0, 0, 0,
5310 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005311
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005312 0, 0, 0, 0,
5313 0, 0, 0, 0,
5314 0, 0, 0, 0,
5315 0, 0, 0, 0,
5316 0, 0, 0, 0,
5317 0, 0, 0, 0,
5318 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005319
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005320 0, 0, 0, 0,
5321 0, 0, 0, 0,
5322 0, 0, 0, 0,
5323 0, 12, 13, 0,
5324 0, 14, 15, 0,
5325 0, 16, 17, 0,
5326 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005327
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005328 0, 0, 0, 0,
5329 0, 0, 0, 0,
5330 0, 0, 0, 0,
5331 0, 18, 19, 0,
5332 0, 20, 21, 0,
5333 0, 22, 23, 0,
5334 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005335
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005336 0, 0, 0, 0,
5337 0, 0, 0, 0,
5338 0, 0, 0, 0,
5339 0, 0, 0, 0,
5340 0, 0, 0, 0,
5341 0, 0, 0, 0,
5342 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005343
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005344 0, 0, 0, 0,
5345 0, 0, 0, 0,
5346 0, 0, 0, 0,
5347 0, 0, 0, 0,
5348 0, 0, 0, 0,
5349 0, 0, 0, 0,
5350 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005351
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005352 0, 0, 0, 0,
5353 0, 0, 0, 0,
5354 0, 0, 0, 0,
5355 0, 0, 0, 0,
5356 0, 0, 0, 0,
5357 0, 0, 0, 0,
5358 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005359
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005360 0, 0, 0, 0,
5361 0, 0, 0, 0,
5362 0, 0, 0, 0,
5363 0, 0, 0, 0,
5364 0, 0, 0, 0,
5365 0, 0, 0, 0,
5366 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005367
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005368 0, 0, 0, 0,
5369 0, 0, 0, 0,
5370 0, 0, 0, 0,
5371 0, 0, 0, 0,
5372 0, 0, 0, 0,
5373 0, 0, 0, 0,
5374 0, 0, 0, 0,
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005375
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005376 0, 0, 0, 0,
5377 0, 0, 0, 0,
5378 0, 0, 0, 0,
5379 0, 0, 0, 0,
5380 0, 0, 0, 0,
5381 0, 0, 0, 0,
5382 0, 0, 0, 0
5383 }));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005384
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005385 auto inputTensor = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(inputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005386
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005387 LayerTestResult<T, 4> result(outputTensorInfo);
5388 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(expectedOutputValues));
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005389
5390 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
5391 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
5392
5393 armnn::PadQueueDescriptor descriptor;
5394
5395 std::vector<std::pair<unsigned int, unsigned int>> PadList;
5396 PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
5397 PadList.push_back(std::pair<unsigned int, unsigned int>(2,1));
5398 PadList.push_back(std::pair<unsigned int, unsigned int>(3,1));
5399 PadList.push_back(std::pair<unsigned int, unsigned int>(1,1));
5400
5401 descriptor.m_Parameters.m_PadList = PadList;
5402 armnn::WorkloadInfo info;
5403
5404 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
5405 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
5406
5407 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info);
5408
5409 inputHandle->Allocate();
5410 outputHandle->Allocate();
5411
5412 CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]);
5413
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005414 workload->Execute();
5415
5416 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
5417
5418 return result;
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005419}
5420
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005421LayerTestResult<uint8_t, 2> PadUint82dTest(
5422 armnn::IWorkloadFactory& workloadFactory,
5423 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005424{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005425 return Pad2dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005426}
5427
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005428LayerTestResult<uint8_t, 3> PadUint83dTest(
5429 armnn::IWorkloadFactory& workloadFactory,
5430 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005431{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005432 return Pad3dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005433}
5434
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005435LayerTestResult<uint8_t, 4> PadUint84dTest(
5436 armnn::IWorkloadFactory& workloadFactory,
5437 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005438{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005439 return Pad4dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005440}
5441
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005442LayerTestResult<float, 2> PadFloat322dTest(
5443 armnn::IWorkloadFactory& workloadFactory,
5444 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005445{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005446 return Pad2dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005447}
5448
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005449LayerTestResult<float, 3> PadFloat323dTest(
5450 armnn::IWorkloadFactory& workloadFactory,
5451 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005452{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005453 return Pad3dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005454}
5455
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005456LayerTestResult<float, 4> PadFloat324dTest(
5457 armnn::IWorkloadFactory& workloadFactory,
5458 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005459{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005460 return Pad4dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0);
Mohamed Nour Abouelseouddd6acea2018-10-18 12:26:19 +01005461}
Mohamed Nour Abouelseoud7420e552018-10-12 12:26:24 +01005462
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005463LayerTestResult<float, 4> L2Normalization1dTest(
5464 armnn::IWorkloadFactory& workloadFactory,
5465 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00005466 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +00005467{
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005468 // Width: 1
5469 // Height: 1
5470 // Channels: 10
5471 // BatchSize: 1
jimfly013aab7c32018-11-12 13:32:08 +00005472 unsigned int numberOfBatches = 1;
5473 unsigned int numberOfChannels = 10;
5474 unsigned int height = 1;
5475 unsigned int width = 1;
telsoa014fcda012018-03-09 14:13:49 +00005476
jimfly013aab7c32018-11-12 13:32:08 +00005477
Nina Drozdd41b2592018-11-19 13:03:36 +00005478 const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
jimfly013aab7c32018-11-12 13:32:08 +00005479 numberOfBatches, numberOfChannels, height, width, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005480 std::vector<float> inputValues
5481 {
5482 // Batch 0, Channel 0, Height (1) x Width (1)
5483 1.0f,
telsoa014fcda012018-03-09 14:13:49 +00005484
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005485 // Batch 0, Channel 1, Height (1) x Width (1)
5486 2.0f,
telsoa014fcda012018-03-09 14:13:49 +00005487
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005488 // Batch 0, Channel 2, Height (1) x Width (1)
5489 3.0f,
telsoa014fcda012018-03-09 14:13:49 +00005490
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005491 // Batch 0, Channel 3, Height (1) x Width (1)
5492 4.0f,
5493
5494 // Batch 0, Channel 4, Height (1) x Width (1)
5495 5.0f,
5496
5497 // Batch 0, Channel 5, Height (1) x Width (1)
5498 6.0f,
5499
5500 // Batch 0, Channel 6, Height (1) x Width (1)
5501 7.0f,
5502
5503 // Batch 0, Channel 7, Height (1) x Width (1)
5504 8.0f,
5505
5506 // Batch 0, Channel 8, Height (1) x Width (1)
5507 9.0f,
5508
5509 // Batch 0, Channel 9, Height (1) x Width (1)
5510 10.0f
5511 };
telsoa014fcda012018-03-09 14:13:49 +00005512 const float approxInvL2Norm = 0.050964719f;
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005513 std::vector<float> expectedOutputValues
5514 {
5515 // Batch 0, Channel 0, Height (1) x Width (1)
telsoa014fcda012018-03-09 14:13:49 +00005516 1.0f * approxInvL2Norm,
5517 2.0f * approxInvL2Norm,
5518 3.0f * approxInvL2Norm,
5519 4.0f * approxInvL2Norm,
5520 5.0f * approxInvL2Norm,
5521 6.0f * approxInvL2Norm,
5522 7.0f * approxInvL2Norm,
5523 8.0f * approxInvL2Norm,
5524 9.0f * approxInvL2Norm,
5525 10.0f * approxInvL2Norm
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005526 };
telsoa014fcda012018-03-09 14:13:49 +00005527
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005528
5529 return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape,
jimfly013aab7c32018-11-12 13:32:08 +00005530 inputValues, expectedOutputValues, layout);
telsoa014fcda012018-03-09 14:13:49 +00005531}
5532
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005533LayerTestResult<float, 4> L2Normalization2dTest(
5534 armnn::IWorkloadFactory& workloadFactory,
5535 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00005536 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +00005537{
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005538 // Width: 5
5539 // Height: 1
5540 // Channels: 2
5541 // BatchSize: 1
jimfly013aab7c32018-11-12 13:32:08 +00005542 unsigned int numberOfBatches = 1;
5543 unsigned int numberOfChannels = 2;
5544 unsigned int height = 1;
5545 unsigned int width = 5;
telsoa014fcda012018-03-09 14:13:49 +00005546
Nina Drozdd41b2592018-11-19 13:03:36 +00005547 const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
jimfly013aab7c32018-11-12 13:32:08 +00005548 numberOfBatches, numberOfChannels, height, width, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005549 std::vector<float> inputValues
5550 {
5551 // Batch 0, Channel 0, Height (1) x Width (5)
telsoa014fcda012018-03-09 14:13:49 +00005552 1.0f, 3.0f, 5.0f, 7.0f, 9.0f,
telsoa014fcda012018-03-09 14:13:49 +00005553
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005554 // Batch 0, Channel 1, Height (1) x Width (5)
5555 2.0f, 4.0f, 6.0f, 8.0f, 10.0f
5556 };
5557 std::vector<float> expectedOutputValues
5558 {
5559 // Batch 0, Channel 0, Height (1) x Width (5)
5560 1.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
5561 3.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
5562 5.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
5563 7.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
telsoa014fcda012018-03-09 14:13:49 +00005564 9.0f * CalcInvL2Norm({ 9.0f, 10.0f }),
5565
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005566 // Batch 0, Channel 1, Height (1) x Width (5)
5567 2.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
5568 4.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
5569 6.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
5570 8.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
telsoa014fcda012018-03-09 14:13:49 +00005571 10.0f * CalcInvL2Norm({ 9.0f, 10.0f })
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005572 };
telsoa014fcda012018-03-09 14:13:49 +00005573
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005574 return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape,
jimfly013aab7c32018-11-12 13:32:08 +00005575 inputValues, expectedOutputValues, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005576}
telsoa014fcda012018-03-09 14:13:49 +00005577
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005578LayerTestResult<float, 4> L2Normalization3dTest(
5579 armnn::IWorkloadFactory& workloadFactory,
5580 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00005581 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +00005582{
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005583 // Width: 3
5584 // Height: 4
5585 // Channels: 2
5586 // BatchSize: 1
jimfly013aab7c32018-11-12 13:32:08 +00005587 unsigned int numberOfBatches = 1;
5588 unsigned int numberOfChannels = 2;
5589 unsigned int height = 4;
5590 unsigned int width = 3;
telsoa014fcda012018-03-09 14:13:49 +00005591
Nina Drozdd41b2592018-11-19 13:03:36 +00005592 const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
jimfly013aab7c32018-11-12 13:32:08 +00005593 numberOfBatches, numberOfChannels, height, width, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005594 std::vector<float> inputValues
5595 {
5596 // Batch 0, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005597 119.0f, 21.0f, 150.0f,
5598 149.0f, 32.0f, 179.0f,
5599 15.0f, 227.0f, 141.0f,
5600 147.0f, 199.0f, 220.0f,
5601
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005602 // Batch 0, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005603 110.0f, 140.0f, 73.0f,
5604 211.0f, 212.0f, 89.0f,
5605 24.0f, 138.0f, 188.0f,
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005606 162.0f, 12.0f, 161.0f
5607 };
5608 std::vector<float> expectedOutputValues
5609 {
5610 // Batch 0, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005611 119.0f * CalcInvL2Norm({ 119.0f, 110.0f }),
5612 21.0f * CalcInvL2Norm({ 21.0f, 140.0f }),
5613 150.0f * CalcInvL2Norm({ 150.0f, 73.0f }),
5614 149.0f * CalcInvL2Norm({ 149.0f, 211.0f }),
5615 32.0f * CalcInvL2Norm({ 32.0f, 212.0f }),
5616 179.0f * CalcInvL2Norm({ 179.0f, 89.0f }),
5617 15.0f * CalcInvL2Norm({ 15.0f, 24.0f }),
5618 227.0f * CalcInvL2Norm({ 227.0f, 138.0f }),
5619 141.0f * CalcInvL2Norm({ 141.0f, 188.0f }),
5620 147.0f * CalcInvL2Norm({ 147.0f, 162.0f }),
5621 199.0f * CalcInvL2Norm({ 199.0f, 12.0f }),
5622 220.0f * CalcInvL2Norm({ 220.0f, 161.0f }),
5623
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005624 // Batch 0, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005625 110.0f * CalcInvL2Norm({ 119.0f, 110.0f }),
5626 140.0f * CalcInvL2Norm({ 21.0f, 140.0f }),
5627 73.0f * CalcInvL2Norm({ 150.0f, 73.0f }),
5628 211.0f * CalcInvL2Norm({ 149.0f, 211.0f }),
5629 212.0f * CalcInvL2Norm({ 32.0f, 212.0f }),
5630 89.0f * CalcInvL2Norm({ 179.0f, 89.0f }),
5631 24.0f * CalcInvL2Norm({ 15.0f, 24.0f }),
5632 138.0f * CalcInvL2Norm({ 227.0f, 138.0f }),
5633 188.0f * CalcInvL2Norm({ 141.0f, 188.0f }),
5634 162.0f * CalcInvL2Norm({ 147.0f, 162.0f }),
5635 12.0f * CalcInvL2Norm({ 199.0f, 12.0f }),
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005636 161.0f * CalcInvL2Norm({ 220.0f, 161.0f })
5637 };
telsoa014fcda012018-03-09 14:13:49 +00005638
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005639 return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape,
jimfly013aab7c32018-11-12 13:32:08 +00005640 inputValues, expectedOutputValues, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005641}
telsoa014fcda012018-03-09 14:13:49 +00005642
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005643LayerTestResult<float, 4> L2Normalization4dTest(
5644 armnn::IWorkloadFactory& workloadFactory,
5645 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00005646 const armnn::DataLayout layout)
telsoa014fcda012018-03-09 14:13:49 +00005647{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005648 // Width: 3
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005649 // Height: 4
5650 // Channels: 3
5651 // BatchSize: 2
jimfly013aab7c32018-11-12 13:32:08 +00005652 unsigned int numberOfBatches = 2;
5653 unsigned int numberOfChannels = 3;
5654 unsigned int height = 4;
5655 unsigned int width = 3;
telsoa014fcda012018-03-09 14:13:49 +00005656
Nina Drozdd41b2592018-11-19 13:03:36 +00005657 const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
jimfly013aab7c32018-11-12 13:32:08 +00005658 numberOfBatches, numberOfChannels, height, width, layout);
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005659 std::vector<float> inputValues
5660 {
5661 // Batch 0, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005662 235.0f, 46.0f, 178.0f,
5663 100.0f, 123.0f, 19.0f,
5664 172.0f, 74.0f, 250.0f,
5665 6.0f, 195.0f, 80.0f,
5666
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005667 // Batch 0, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005668 113.0f, 95.0f, 202.0f,
5669 77.0f, 114.0f, 71.0f,
5670 122.0f, 246.0f, 166.0f,
5671 82.0f, 28.0f, 37.0f,
5672
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005673 // Batch 0, Channel 2, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005674 56.0f, 170.0f, 162.0f,
5675 194.0f, 89.0f, 254.0f,
5676 12.0f, 209.0f, 200.0f,
5677 1.0f, 64.0f, 54.0f,
5678
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005679 // Batch 1, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005680 67.0f, 90.0f, 49.0f,
5681 7.0f, 163.0f, 18.0f,
5682 25.0f, 117.0f, 103.0f,
5683 247.0f, 59.0f, 189.0f,
5684
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005685 // Batch 1, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005686 239.0f, 104.0f, 199.0f,
5687 17.0f, 124.0f, 153.0f,
5688 222.0f, 217.0f, 75.0f,
5689 32.0f, 126.0f, 21.0f,
5690
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005691 // Batch 1, Channel 2, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005692 97.0f, 145.0f, 215.0f,
5693 115.0f, 116.0f, 238.0f,
5694 226.0f, 16.0f, 132.0f,
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005695 92.0f, 125.0f, 88.0f
5696 };
5697 std::vector<float> expectedOutputValues
5698 {
5699 // Batch 0, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005700 235.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
5701 46.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
5702 178.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
5703 100.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
5704 123.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
5705 19.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
5706 172.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
5707 74.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
5708 250.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
5709 6.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
5710 195.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
5711 80.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
5712
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005713 // Batch 0, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005714 113.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
5715 95.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
5716 202.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
5717 77.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
5718 114.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
5719 71.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
5720 122.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
5721 246.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
5722 166.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
5723 82.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
5724 28.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
5725 37.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
5726
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005727 // Batch 0, Channel 2, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005728 56.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
5729 170.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
5730 162.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
5731 194.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
5732 89.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
5733 254.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
5734 12.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
5735 209.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
5736 200.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
5737 1.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
5738 64.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
5739 54.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
5740
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005741 // Batch 1, Channel 0, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005742 67.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
5743 90.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
5744 49.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
5745 7.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
5746 163.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
5747 18.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
5748 25.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
5749 117.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
5750 103.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
5751 247.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
5752 59.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
5753 189.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }),
5754
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005755 // Batch 1, Channel 1, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005756 239.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
5757 104.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
5758 199.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
5759 17.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
5760 124.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
5761 153.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
5762 222.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
5763 217.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
5764 75.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
5765 32.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
5766 126.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
5767 21.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }),
5768
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005769 // Batch 1, Channel 2, Height (4) x Width (3)
telsoa014fcda012018-03-09 14:13:49 +00005770 97.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
5771 145.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
5772 215.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
5773 115.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
5774 116.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
5775 238.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
5776 226.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
5777 16.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
5778 132.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
5779 92.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
5780 125.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
Matteo Martincigh539b44d2018-10-01 09:26:39 +01005781 88.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f })
5782 };
telsoa014fcda012018-03-09 14:13:49 +00005783
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005784 return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape,
jimfly013aab7c32018-11-12 13:32:08 +00005785 inputValues, expectedOutputValues, layout);
telsoa014fcda012018-03-09 14:13:49 +00005786}
5787
5788template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005789LayerTestResult<T, 4> ConstantTestImpl(
5790 armnn::IWorkloadFactory& workloadFactory,
5791 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
telsoa014fcda012018-03-09 14:13:49 +00005792 float qScale,
5793 int32_t qOffset)
5794{
5795 constexpr unsigned int inputWidth = 3;
5796 constexpr unsigned int inputHeight = 4;
5797 constexpr unsigned int inputChannels = 3;
5798 constexpr unsigned int inputBatchSize = 2;
5799
5800 constexpr unsigned int outputWidth = inputWidth;
5801 constexpr unsigned int outputHeight = inputHeight;
5802 constexpr unsigned int outputChannels = inputChannels;
5803 constexpr unsigned int outputBatchSize = inputBatchSize;
5804
5805 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
5806 armnn::GetDataType<T>());
5807
5808 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
5809 armnn::GetDataType<T>());
5810
5811 // Set quantization parameters if the requested type is a quantized type.
5812 if(armnn::IsQuantizedType<T>())
5813 {
5814 inputTensorInfo.SetQuantizationScale(qScale);
5815 inputTensorInfo.SetQuantizationOffset(qOffset);
5816 outputTensorInfo.SetQuantizationScale(qScale);
5817 outputTensorInfo.SetQuantizationOffset(qOffset);
5818 }
5819
5820 auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(
5821 QuantizedVector<T>(qScale, qOffset, {
5822 // Batch 0, Channel 0
5823 235.0f, 46.0f, 178.0f,
5824 100.0f, 123.0f, 19.0f,
5825 172.0f, 74.0f, 250.0f,
5826 6.0f, 195.0f, 80.0f,
5827
5828 // Batch 0, Channel 1
5829 113.0f, 95.0f, 202.0f,
5830 77.0f, 114.0f, 71.0f,
5831 122.0f, 246.0f, 166.0f,
5832 82.0f, 28.0f, 37.0f,
5833
5834 // Batch 0, Channel 2
5835 56.0f, 170.0f, 162.0f,
5836 194.0f, 89.0f, 254.0f,
5837 12.0f, 209.0f, 200.0f,
5838 1.0f, 64.0f, 54.0f,
5839
5840 // Batch 1, Channel 0
5841 67.0f, 90.0f, 49.0f,
5842 7.0f, 163.0f, 18.0f,
5843 25.0f, 117.0f, 103.0f,
5844 247.0f, 59.0f, 189.0f,
5845
5846 // Batch 1, Channel 1
5847 239.0f, 104.0f, 199.0f,
5848 17.0f, 124.0f, 153.0f,
5849 222.0f, 217.0f, 75.0f,
5850 32.0f, 126.0f, 21.0f,
5851
5852 // Batch 1, Channel 2
5853 97.0f, 145.0f, 215.0f,
5854 115.0f, 116.0f, 238.0f,
5855 226.0f, 16.0f, 132.0f,
5856 92.0f, 125.0f, 88.0f,
5857 })));
5858
5859 LayerTestResult<T, 4> result(outputTensorInfo);
5860 result.outputExpected = input;
5861
5862 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
5863
5864 armnn::ScopedCpuTensorHandle constantTensor(inputTensorInfo);
5865 AllocateAndCopyDataToITensorHandle(&constantTensor, &input[0][0][0][0]);
5866
5867 armnn::ConstantQueueDescriptor descriptor;
5868 descriptor.m_LayerOutput = &constantTensor;
5869
5870 armnn::WorkloadInfo info;
5871 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
5872
5873 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConstant(descriptor, info);
5874
5875 outputHandle->Allocate();
5876
5877 workload->Execute();
5878
5879 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
5880 return result;
5881}
5882
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005883LayerTestResult<float, 4> ConstantTest(
5884 armnn::IWorkloadFactory& workloadFactory,
5885 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00005886{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005887 return ConstantTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00005888}
5889
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005890LayerTestResult<uint8_t, 4> ConstantTestUint8(
5891 armnn::IWorkloadFactory& workloadFactory,
5892 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00005893{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005894 return ConstantTestImpl<uint8_t>(workloadFactory, memoryManager, 1.0f, 0);
telsoa014fcda012018-03-09 14:13:49 +00005895}
5896
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00005897LayerTestResult<uint8_t, 3> MergerUint8Test(
5898 armnn::IWorkloadFactory& workloadFactory,
5899 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00005900{
surmeh013537c2c2018-05-18 16:31:43 +01005901 unsigned int outputWidth = 3;
telsoa014fcda012018-03-09 14:13:49 +00005902 unsigned int outputHeight = 6;
5903 unsigned int outputChannels = 3;
5904
surmeh013537c2c2018-05-18 16:31:43 +01005905 unsigned int inputWidth1 = 3;
5906 unsigned int inputHeight1 = 6;
5907 unsigned int inputChannels1 = 2;
telsoa014fcda012018-03-09 14:13:49 +00005908
surmeh013537c2c2018-05-18 16:31:43 +01005909 unsigned int inputWidth2 = 3;
5910 unsigned int inputHeight2 = 6;
5911 unsigned int inputChannels2 = 1;
telsoa014fcda012018-03-09 14:13:49 +00005912
telsoa01c577f2c2018-08-31 09:22:23 +01005913 // Defines the tensor descriptors.
telsoa014fcda012018-03-09 14:13:49 +00005914 armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::QuantisedAsymm8);
5915 armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::QuantisedAsymm8);
5916 armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::QuantisedAsymm8);
telsoa014fcda012018-03-09 14:13:49 +00005917
telsoa01c577f2c2018-08-31 09:22:23 +01005918 // Arbitrary scale and offsets. They don't really matter as the merger operator doesn't dequantize/quantize them.
telsoa014fcda012018-03-09 14:13:49 +00005919 const float scale = 0.13497836f;
5920 const int32_t offset = -7;
5921
5922 outputTensorInfo.SetQuantizationScale(scale);
5923 outputTensorInfo.SetQuantizationOffset(offset);
5924 inputTensorInfo1.SetQuantizationScale(scale);
5925 inputTensorInfo1.SetQuantizationOffset(offset);
5926 inputTensorInfo2.SetQuantizationScale(scale);
5927 inputTensorInfo2.SetQuantizationOffset(offset);
telsoa014fcda012018-03-09 14:13:49 +00005928
5929 LayerTestResult<uint8_t, 3> ret(outputTensorInfo);
5930
5931 ret.outputExpected = MakeTensor<uint8_t, 3>(outputTensorInfo, std::vector<uint8_t>(
surmeh013537c2c2018-05-18 16:31:43 +01005932 {
5933 1, 2, 3,
5934 4, 5, 6,
5935 7, 8, 9,
5936 10, 11, 12,
5937 13, 14, 15,
5938 16, 17, 18,
telsoa014fcda012018-03-09 14:13:49 +00005939
surmeh013537c2c2018-05-18 16:31:43 +01005940 19, 20, 21,
5941 22, 23, 24,
5942 25, 26, 27,
5943 28, 29, 30,
5944 31, 32, 33,
5945 34, 35, 36,
telsoa014fcda012018-03-09 14:13:49 +00005946
surmeh013537c2c2018-05-18 16:31:43 +01005947 37, 38, 39,
5948 40, 41, 42,
5949 43, 44, 45,
5950 46, 47, 48,
5951 49, 50, 51,
5952 52, 53, 54,
5953 })
telsoa014fcda012018-03-09 14:13:49 +00005954 );
5955
telsoa014fcda012018-03-09 14:13:49 +00005956 auto input1 = MakeTensor<uint8_t, 3>(inputTensorInfo1, std::vector<uint8_t>(
5957 {
surmeh013537c2c2018-05-18 16:31:43 +01005958 1, 2, 3,
5959 4, 5, 6,
5960 7, 8, 9,
5961 10, 11, 12,
5962 13, 14, 15,
5963 16, 17, 18,
telsoa014fcda012018-03-09 14:13:49 +00005964
surmeh013537c2c2018-05-18 16:31:43 +01005965 19, 20, 21,
5966 22, 23, 24,
5967 25, 26, 27,
5968 28, 29, 30,
5969 31, 32, 33,
5970 34, 35, 36,
telsoa014fcda012018-03-09 14:13:49 +00005971 })
5972 );
5973
5974 auto input2 = MakeTensor<uint8_t, 3>(inputTensorInfo2, std::vector<uint8_t>(
5975 {
surmeh013537c2c2018-05-18 16:31:43 +01005976 37, 38, 39,
5977 40, 41, 42,
telsoa014fcda012018-03-09 14:13:49 +00005978 43, 44, 45,
surmeh013537c2c2018-05-18 16:31:43 +01005979 46, 47, 48,
5980 49, 50, 51,
5981 52, 53, 54,
telsoa014fcda012018-03-09 14:13:49 +00005982 })
5983 );
5984
telsoa01c577f2c2018-08-31 09:22:23 +01005985 std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0].
telsoa014fcda012018-03-09 14:13:49 +00005986 armnn::MergerQueueDescriptor::ViewOrigin window1(wOrigin1);
5987
telsoa01c577f2c2018-08-31 09:22:23 +01005988 std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1].
telsoa014fcda012018-03-09 14:13:49 +00005989 armnn::MergerQueueDescriptor::ViewOrigin window2(wOrigin2);
5990
telsoa014fcda012018-03-09 14:13:49 +00005991
5992 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
5993
5994 bool subTensorsSupported = workloadFactory.SupportsSubTensors();
5995
5996 std::unique_ptr<armnn::ITensorHandle> inputHandle1 =
5997 subTensorsSupported ?
5998 workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) :
5999 workloadFactory.CreateTensorHandle(inputTensorInfo1);
6000
6001 std::unique_ptr<armnn::ITensorHandle> inputHandle2 =
6002 subTensorsSupported ?
6003 workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) :
6004 workloadFactory.CreateTensorHandle(inputTensorInfo2);
6005
telsoa014fcda012018-03-09 14:13:49 +00006006
6007 armnn::MergerQueueDescriptor data;
6008 armnn::WorkloadInfo info;
6009 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
6010 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
telsoa014fcda012018-03-09 14:13:49 +00006011 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
6012
6013 data.m_ViewOrigins.push_back(window1);
6014 data.m_ViewOrigins.push_back(window2);
telsoa014fcda012018-03-09 14:13:49 +00006015
6016 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(data, info);
6017
6018 inputHandle1->Allocate();
6019 inputHandle2->Allocate();
telsoa014fcda012018-03-09 14:13:49 +00006020 outputHandle->Allocate();
6021
6022 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]);
6023 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]);
telsoa014fcda012018-03-09 14:13:49 +00006024
6025 workload->Execute();
6026
6027 CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get());
6028
6029 return ret;
6030}
6031
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006032LayerTestResult<uint8_t, 4> AdditionUint8Test(
6033 armnn::IWorkloadFactory& workloadFactory,
6034 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006035{
6036 unsigned int batchSize = 1;
6037 unsigned int channels = 2;
6038 unsigned int height = 2;
6039 unsigned int width = 3;
6040
6041 const float scale = 7.0f;
6042 const int32_t offset = 3;
6043
6044 armnn::TensorInfo inputTensorInfo1, inputTensorInfo2;
6045 armnn::TensorInfo outputTensorInfo;
6046
6047 const unsigned int shape[] = { batchSize, channels, height, width };
6048 inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8);
6049 inputTensorInfo1.SetQuantizationScale(scale);
6050 inputTensorInfo1.SetQuantizationOffset(offset);
6051
6052 inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8);
6053 inputTensorInfo2.SetQuantizationScale(scale);
6054 inputTensorInfo2.SetQuantizationOffset(offset);
6055
6056 outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8);
6057 outputTensorInfo.SetQuantizationScale(scale);
6058 outputTensorInfo.SetQuantizationOffset(offset);
6059
telsoa01c577f2c2018-08-31 09:22:23 +01006060 // See dequantized values to the right.
telsoa014fcda012018-03-09 14:13:49 +00006061 auto input1 = MakeTensor<uint8_t, 4>(inputTensorInfo1, std::vector<uint8_t>(
6062 {
6063 63, 35, 77, 70, 56, 112, // 420, 224, 518, 469, 371, 763
6064 203, 28, 252, 168, 245, 91 // 1400, 175, 1743, 1155, 1694, 616
6065 }));
6066
telsoa01c577f2c2018-08-31 09:22:23 +01006067 // See dequantized values to the right.
telsoa014fcda012018-03-09 14:13:49 +00006068 auto input2 = MakeTensor<uint8_t, 4>(inputTensorInfo1, std::vector<uint8_t>(
6069 {
6070 21, 7, 175, 231, 175, 210, // 126, 28, 1204, 1596, 1204, 1449
6071 126, 161, 63, 21, 105, 126 // 861, 1106, 420, 126, 714, 861
6072 }));
6073
telsoa01c577f2c2018-08-31 09:22:23 +01006074 // See dequantized values to the right.
telsoa014fcda012018-03-09 14:13:49 +00006075 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6076 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>(
6077 {
6078 81, 39, 249, 255, 228, 255, // 546, 252, 1722, 2065(clamped), 1575, 2212(clamped)
6079 255, 186, 255, 186, 255, 214, // 2261(clamped), 1281, 2163(clamped), 1281, 2408(clamped), 1477
6080 }));
6081
6082 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
6083 std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2);
6084 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6085
6086 armnn::AdditionQueueDescriptor data;
6087 armnn::WorkloadInfo info;
6088 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
6089 AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get());
6090 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
6091
6092 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info);
6093
6094 inputHandle1->Allocate();
6095 inputHandle2->Allocate();
6096 outputHandle->Allocate();
6097
6098 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
6099 CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]);
6100
6101 workload->Execute();
6102
6103 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6104
6105 return result;
6106}
6107
surmeh01bceff2f2018-03-29 16:29:27 +01006108namespace
telsoa014fcda012018-03-09 14:13:49 +00006109{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006110LayerTestResult<uint8_t, 4> MultiplicationUint8TestHelper(
6111 armnn::IWorkloadFactory& workloadFactory,
6112 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
6113 const unsigned int shape0[4],
6114 const std::vector<uint8_t> & values0,
6115 float scale0,
6116 int32_t offset0,
6117 const unsigned int shape1[4],
6118 const std::vector<uint8_t> & values1,
6119 float scale1,
6120 int32_t offset1,
6121 const unsigned int outShape[4],
6122 const std::vector<uint8_t> & outValues,
6123 float outScale,
6124 int32_t outOffset)
surmeh01bceff2f2018-03-29 16:29:27 +01006125{
6126 armnn::TensorInfo inputTensorInfo0(4, shape0, armnn::DataType::QuantisedAsymm8);
6127 armnn::TensorInfo inputTensorInfo1(4, shape1, armnn::DataType::QuantisedAsymm8);
6128 armnn::TensorInfo outputTensorInfo(4, outShape, armnn::DataType::QuantisedAsymm8);
telsoa014fcda012018-03-09 14:13:49 +00006129
surmeh01bceff2f2018-03-29 16:29:27 +01006130 inputTensorInfo0.SetQuantizationScale(scale0);
6131 inputTensorInfo0.SetQuantizationOffset(offset0);
telsoa014fcda012018-03-09 14:13:49 +00006132
surmeh01bceff2f2018-03-29 16:29:27 +01006133 inputTensorInfo1.SetQuantizationScale(scale1);
6134 inputTensorInfo1.SetQuantizationOffset(offset1);
telsoa014fcda012018-03-09 14:13:49 +00006135
surmeh01bceff2f2018-03-29 16:29:27 +01006136 outputTensorInfo.SetQuantizationScale(outScale);
6137 outputTensorInfo.SetQuantizationOffset(outOffset);
telsoa014fcda012018-03-09 14:13:49 +00006138
surmeh01bceff2f2018-03-29 16:29:27 +01006139 auto input0 = MakeTensor<uint8_t, 4>(inputTensorInfo0, values0);
6140 auto input1 = MakeTensor<uint8_t, 4>(inputTensorInfo1, values1);
telsoa014fcda012018-03-09 14:13:49 +00006141
telsoa014fcda012018-03-09 14:13:49 +00006142 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
surmeh01bceff2f2018-03-29 16:29:27 +01006143 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, outValues);
telsoa014fcda012018-03-09 14:13:49 +00006144
surmeh01bceff2f2018-03-29 16:29:27 +01006145 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
telsoa014fcda012018-03-09 14:13:49 +00006146 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
telsoa014fcda012018-03-09 14:13:49 +00006147 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6148
6149 armnn::MultiplicationQueueDescriptor data;
6150 armnn::WorkloadInfo info;
surmeh01bceff2f2018-03-29 16:29:27 +01006151 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
6152 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
telsoa014fcda012018-03-09 14:13:49 +00006153 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
6154
6155 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info);
6156
surmeh01bceff2f2018-03-29 16:29:27 +01006157 inputHandle0->Allocate();
telsoa014fcda012018-03-09 14:13:49 +00006158 inputHandle1->Allocate();
telsoa014fcda012018-03-09 14:13:49 +00006159 outputHandle->Allocate();
6160
surmeh01bceff2f2018-03-29 16:29:27 +01006161 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
telsoa014fcda012018-03-09 14:13:49 +00006162 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
telsoa014fcda012018-03-09 14:13:49 +00006163
6164 workload->Execute();
6165
6166 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6167
6168 return result;
6169}
surmeh01bceff2f2018-03-29 16:29:27 +01006170} // anonymous namespace
6171
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006172LayerTestResult<uint8_t, 4> MultiplicationUint8Test(
6173 armnn::IWorkloadFactory& workloadFactory,
6174 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01006175{
6176 unsigned int batchSize = 1;
6177 unsigned int channels = 2;
6178 unsigned int height = 2;
6179 unsigned int width = 3;
6180 const unsigned int shape[] = { batchSize, channels, height, width };
6181
telsoa01c577f2c2018-08-31 09:22:23 +01006182 // See dequantized values to the right.
surmeh01bceff2f2018-03-29 16:29:27 +01006183 std::vector<uint8_t> input0({
6184 62, 37, 3, 172, 13, 111, // 244, 144, 8, 684, 48, 440,
6185 188, 20, 73, 31, 23, 31 // 748, 76, 288, 120, 88, 120
6186 });
6187
telsoa01c577f2c2018-08-31 09:22:23 +01006188 // See dequantized values to the right.
surmeh01bceff2f2018-03-29 16:29:27 +01006189 std::vector<uint8_t> input1({
6190 126, 240, 252, 183, 121, 247, // 384, 726, 762, 555, 369, 747,
6191 48, 115, 151, 79, 78, 97 // 150, 351, 459, 243, 240, 297
6192 });
6193
telsoa01c577f2c2018-08-31 09:22:23 +01006194 // See dequantized values to the right.
surmeh01bceff2f2018-03-29 16:29:27 +01006195 std::vector<uint8_t> output(
6196 {
6197 64, 72, 0, 255, 8, 236, // 93696, 104544, 6096(clamped), 379620(clamped), 17712, 328680,
6198 77, 15, 92, 16, 10, 21, // 112200, 26676, 132192, 29160, 21120, 35640
6199 });
6200
6201 return MultiplicationUint8TestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006202 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01006203 shape,
6204 input0,
6205 4.0f,
6206 1,
6207 shape,
6208 input1,
6209 3.0f,
6210 -2,
6211 shape,
6212 output,
telsoa01c577f2c2018-08-31 09:22:23 +01006213 1366.255f, // Scale/offset chosen to have output values out of range.
surmeh01bceff2f2018-03-29 16:29:27 +01006214 -5);
6215}
6216
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006217LayerTestResult<uint8_t, 4> MultiplicationBroadcast1ElementUint8Test(
6218 armnn::IWorkloadFactory& workloadFactory,
6219 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01006220{
6221 const unsigned int shape0[] = { 1, 2, 2, 3 };
6222 const unsigned int shape1[] = { 1, 1, 1, 1 };
6223
6224 std::vector<uint8_t> input0({
6225 1, 2, 3, 4, 5, 6,
6226 7, 8, 9, 10, 11, 12
6227 });
6228
6229 std::vector<uint8_t> input1({2});
6230
6231 std::vector<uint8_t> output({
6232 2, 4, 6, 8, 10, 12,
6233 14, 16, 18, 20, 22, 24
6234 });
6235
6236 return MultiplicationUint8TestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006237 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01006238 shape0,
6239 input0,
6240 1.0f,
6241 0,
6242 shape1,
6243 input1,
6244 1.0f,
6245 0,
6246 shape0,
6247 output,
6248 1.0f,
6249 0);
6250}
6251
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006252LayerTestResult<uint8_t, 4> MultiplicationBroadcast1DVectorUint8Test(
6253 armnn::IWorkloadFactory& workloadFactory,
6254 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01006255{
6256 const unsigned int shape0[] = { 1, 2, 2, 3 };
6257 const unsigned int shape1[] = { 1, 1, 1, 3 };
6258
6259 std::vector<uint8_t> input0({
6260 1, 2, 3, 4, 5, 6,
6261 7, 8, 9, 10, 11, 12
6262 });
6263
6264 std::vector<uint8_t> input1({1, 2, 3});
6265
6266 std::vector<uint8_t> output({
6267 1, 4, 9, 4, 10, 18,
6268 7, 16, 27, 10, 22, 36
6269 });
6270
6271 return MultiplicationUint8TestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006272 memoryManager,
surmeh01bceff2f2018-03-29 16:29:27 +01006273 shape0,
6274 input0,
6275 1.0f,
6276 0,
6277 shape1,
6278 input1,
6279 1.0f,
6280 0,
6281 shape0,
6282 output,
6283 1.0f,
6284 0);
6285}
telsoa014fcda012018-03-09 14:13:49 +00006286
David Beckf195f032018-09-06 16:46:34 +01006287namespace
6288{
6289template <typename T>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006290LayerTestResult<T, 4> SubtractionTestHelper(
6291 armnn::IWorkloadFactory& workloadFactory,
6292 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
6293 const unsigned int shape0[4],
6294 const std::vector<T>& values0,
6295 float scale0,
6296 int32_t offset0,
6297 const unsigned int shape1[4],
6298 const std::vector<T> & values1,
6299 float scale1,
6300 int32_t offset1,
6301 const unsigned int outShape[4],
6302 const std::vector<T> & outValues,
6303 float outScale,
6304 int32_t outOffset)
David Beckf195f032018-09-06 16:46:34 +01006305{
6306 auto dataType = (std::is_same<T, uint8_t>::value ?
6307 armnn::DataType::QuantisedAsymm8 :
6308 armnn::DataType::Float32);
6309
6310 armnn::TensorInfo inputTensorInfo0(4, shape0, dataType);
6311 armnn::TensorInfo inputTensorInfo1(4, shape1, dataType);
6312 armnn::TensorInfo outputTensorInfo(4, outShape, dataType);
6313
6314 inputTensorInfo0.SetQuantizationScale(scale0);
6315 inputTensorInfo0.SetQuantizationOffset(offset0);
6316
6317 inputTensorInfo1.SetQuantizationScale(scale1);
6318 inputTensorInfo1.SetQuantizationOffset(offset1);
6319
6320 outputTensorInfo.SetQuantizationScale(outScale);
6321 outputTensorInfo.SetQuantizationOffset(outOffset);
6322
6323 auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0);
6324 auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1);
6325
6326 LayerTestResult<T, 4> result(outputTensorInfo);
6327 result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues);
6328
6329 std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
6330 std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
6331 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6332
6333 armnn::SubtractionQueueDescriptor data;
6334 armnn::WorkloadInfo info;
6335 AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
6336 AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
6337 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
6338
6339 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateSubtraction(data, info);
6340
6341 inputHandle0->Allocate();
6342 inputHandle1->Allocate();
6343 outputHandle->Allocate();
6344
6345 CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]);
6346 CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]);
6347
David Beckf195f032018-09-06 16:46:34 +01006348 workload->Execute();
6349
6350 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6351
6352 return result;
6353}
6354} // anonymous namespace
6355
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006356LayerTestResult<uint8_t, 4> SubtractionUint8Test(
6357 armnn::IWorkloadFactory& workloadFactory,
6358 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006359{
6360 const unsigned int shape0[] = { 1, 1, 2, 2 };
6361 const unsigned int shape1[] = { 1, 1, 2, 2 };
6362
6363 std::vector<uint8_t> input0({ 10, 12, 14, 16 });
6364 std::vector<uint8_t> input1({ 1, 2, 1, 2 });
6365 std::vector<uint8_t> output({ 3, 3, 5, 5 });
6366
6367 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006368 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006369 shape0, input0, 0.5f, 2,
6370 shape1, input1, 1.0f, 0,
6371 shape0, output, 1.0f, 0);
6372}
6373
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006374LayerTestResult<uint8_t, 4> SubtractionBroadcast1ElementUint8Test(
6375 armnn::IWorkloadFactory& workloadFactory,
6376 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006377{
6378 const unsigned int shape0[] = { 1, 1, 2, 2 };
6379 const unsigned int shape1[] = { 1, 1, 1, 1 };
6380
6381 std::vector<uint8_t> input0({ 10, 12, 14, 16 });
6382 std::vector<uint8_t> input1({ 2 });
6383 std::vector<uint8_t> output({ 5, 6, 7, 8 });
6384
6385 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006386 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006387 shape0, input0, 0.5f, 2,
6388 shape1, input1, 1.0f, 0,
6389 shape0, output, 1.0f, 3);
6390}
6391
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006392LayerTestResult<uint8_t, 4> SubtractionBroadcastUint8Test(
6393 armnn::IWorkloadFactory& workloadFactory,
6394 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006395{
6396 const unsigned int shape0[] = { 1, 1, 2, 2 };
6397 const unsigned int shape1[] = { 1, 1, 2, 1 };
6398
6399 std::vector<uint8_t> input0({ 10, 12, 14, 16 });
6400 std::vector<uint8_t> input1({ 2, 1 });
6401 std::vector<uint8_t> output({ 8, 11, 12, 15 });
6402
6403 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006404 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006405 shape0, input0, 1.0f, 0,
6406 shape1, input1, 1.0f, 0,
6407 shape0, output, 1.0f, 0);
6408}
6409
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006410LayerTestResult<float, 4> SubtractionTest(
6411 armnn::IWorkloadFactory& workloadFactory,
6412 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006413{
6414 const unsigned int shape0[] = { 1, 1, 2, 2 };
6415 const unsigned int shape1[] = { 1, 1, 2, 2 };
6416
6417 std::vector<float> input0({ 1, 2, 3, 4 });
6418 std::vector<float> input1({ 1, -1, 0, 2 });
6419 std::vector<float> output({ 0, 3, 3, 2 });
6420
6421 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006422 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006423 shape0, input0, 1.0f, 0,
6424 shape1, input1, 1.0f, 0,
6425 shape0, output, 1.0f, 0);
6426}
6427
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006428LayerTestResult<float, 4> SubtractionBroadcast1ElementTest(
6429 armnn::IWorkloadFactory& workloadFactory,
6430 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006431{
6432 const unsigned int shape0[] = { 1, 1, 2, 2 };
6433 const unsigned int shape1[] = { 1, 1, 1, 1 };
6434
6435 std::vector<float> input0({ 1, 2, 3, 4 });
6436 std::vector<float> input1({ 10 });
6437 std::vector<float> output({ -9, -8, -7, -6 });
6438
6439 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006440 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006441 shape0, input0, 1.0f, 0,
6442 shape1, input1, 1.0f, 0,
6443 shape0, output, 1.0f, 0);
6444}
6445
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006446LayerTestResult<float, 4> SubtractionBroadcastTest(
6447 armnn::IWorkloadFactory& workloadFactory,
6448 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
David Beckf195f032018-09-06 16:46:34 +01006449{
6450 const unsigned int shape0[] = { 1, 1, 2, 2 };
6451 const unsigned int shape1[] = { 1, 1, 1, 2 };
6452
6453 std::vector<float> input0({ 1, 2, 3, 4 });
6454 std::vector<float> input1({ 10, -5 });
6455 std::vector<float> output({ -9, 7, -7, 9 });
6456
6457 return SubtractionTestHelper(workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006458 memoryManager,
David Beckf195f032018-09-06 16:46:34 +01006459 shape0, input0, 1.0f, 0,
6460 shape1, input1, 1.0f, 0,
6461 shape0, output, 1.0f, 0);
6462}
6463
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006464LayerTestResult<uint8_t, 4> ResizeBilinearNopUint8Test(
6465 armnn::IWorkloadFactory& workloadFactory,
6466 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006467{
6468 constexpr unsigned int inputWidth = 4;
6469 constexpr unsigned int inputHeight = 4;
6470 constexpr unsigned int inputChannels = 1;
6471 constexpr unsigned int inputBatchSize = 1;
6472
6473 constexpr unsigned int outputWidth = inputWidth;
6474 constexpr unsigned int outputHeight = inputHeight;
6475 constexpr unsigned int outputChannels = inputChannels;
6476 constexpr unsigned int outputBatchSize = inputBatchSize;
6477
6478 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
6479 armnn::DataType::QuantisedAsymm8);
6480 inputTensorInfo.SetQuantizationScale(1.5f);
6481 inputTensorInfo.SetQuantizationOffset(-3);
6482
6483 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
6484 armnn::DataType::QuantisedAsymm8);
6485 outputTensorInfo.SetQuantizationScale(1.5f);
6486 outputTensorInfo.SetQuantizationOffset(-3);
6487
6488 auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({
6489 1, 2, 3, 4,
6490 2, 3, 4, 5,
6491 3, 4, 5, 6,
6492 4, 5, 6, 7
6493 }));
6494
6495 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6496 result.outputExpected = input;
6497
6498 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
6499 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6500
6501 armnn::ResizeBilinearQueueDescriptor descriptor;
6502 armnn::WorkloadInfo info;
6503 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
6504 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
6505
6506 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
6507
6508 inputHandle->Allocate();
6509 outputHandle->Allocate();
6510 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
6511
6512 workload->Execute();
6513
6514 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6515 return result;
6516}
6517
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006518LayerTestResult<uint8_t, 4> SimpleResizeBilinearUint8Test(
6519 armnn::IWorkloadFactory& workloadFactory,
6520 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006521{
6522 constexpr unsigned int inputWidth = 2;
6523 constexpr unsigned int inputHeight = 2;
6524 constexpr unsigned int inputChannels = 1;
6525 constexpr unsigned int inputBatchSize = 1;
6526
6527 constexpr unsigned int outputWidth = inputWidth / 2;
6528 constexpr unsigned int outputHeight = inputHeight / 2;
6529 constexpr unsigned int outputChannels = inputChannels;
6530 constexpr unsigned int outputBatchSize = inputBatchSize;
6531
6532 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
6533 armnn::DataType::QuantisedAsymm8);
6534 inputTensorInfo.SetQuantizationScale(0.1567f);
6535 inputTensorInfo.SetQuantizationOffset(1);
6536
6537 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
6538 armnn::DataType::QuantisedAsymm8);
6539 outputTensorInfo.SetQuantizationScale(0.1567f);
6540 outputTensorInfo.SetQuantizationOffset(1);
6541
6542 auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({
6543 1, 255,
6544 200, 250
6545 }));
6546
6547 // The 'resize bilinear' operation projects the top-left corner of output texels into the input image,
6548 // then figures out the interpolants and weights. Note this is different to projecting the centre of the
telsoa01c577f2c2018-08-31 09:22:23 +01006549 // output texel - and thus we'll expect the output 1x1 matrix to contain, as its single element, the value
telsoa014fcda012018-03-09 14:13:49 +00006550 // that was at position (0,0) of the input matrix (rather than an average, which we would expect if projecting
6551 // the centre).
6552 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6553 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({
6554 1
6555 }));
6556
6557 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
6558 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6559
6560 armnn::ResizeBilinearQueueDescriptor descriptor;
6561 armnn::WorkloadInfo info;
6562 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
6563 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
6564
6565 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
6566
6567 inputHandle->Allocate();
6568 outputHandle->Allocate();
6569 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
6570
6571 workload->Execute();
6572
6573 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6574 return result;
6575}
6576
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006577LayerTestResult<uint8_t, 4> ResizeBilinearSqMinUint8Test(
6578 armnn::IWorkloadFactory& workloadFactory,
6579 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006580{
6581 constexpr unsigned int inputWidth = 4;
6582 constexpr unsigned int inputHeight = 4;
6583 constexpr unsigned int inputChannels = 1;
6584 constexpr unsigned int inputBatchSize = 1;
6585
6586 constexpr unsigned int outputWidth = inputWidth / 2;
6587 constexpr unsigned int outputHeight = inputHeight / 2;
6588 constexpr unsigned int outputChannels = inputChannels;
6589 constexpr unsigned int outputBatchSize = inputBatchSize;
6590
6591 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
6592 armnn::DataType::QuantisedAsymm8);
6593 inputTensorInfo.SetQuantizationScale(3.141592f);
6594 inputTensorInfo.SetQuantizationOffset(3);
6595
6596 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
6597 armnn::DataType::QuantisedAsymm8);
6598 outputTensorInfo.SetQuantizationScale(3.141592f);
6599 outputTensorInfo.SetQuantizationOffset(3);
6600
6601 auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({
6602 1, 2, 3, 4,
6603 2, 3, 4, 5,
6604 3, 4, 5, 6,
6605 4, 5, 6, 7
6606 }));
6607
6608 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6609 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({
6610 1, 3,
6611 3, 5
6612 }));
6613
6614 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
6615 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6616
6617 armnn::ResizeBilinearQueueDescriptor descriptor;
6618 armnn::WorkloadInfo info;
6619 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
6620 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
6621
6622 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
6623
6624 inputHandle->Allocate();
6625 outputHandle->Allocate();
6626 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
6627
6628 workload->Execute();
6629
6630 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6631 return result;
6632}
6633
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006634LayerTestResult<uint8_t, 4> ResizeBilinearMinUint8Test(
6635 armnn::IWorkloadFactory& workloadFactory,
6636 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006637{
6638 constexpr unsigned int inputWidth = 3;
6639 constexpr unsigned int inputHeight = 2;
6640 constexpr unsigned int inputChannels = 1;
6641 constexpr unsigned int inputBatchSize = 1;
6642
6643 constexpr unsigned int outputWidth = 2;
6644 constexpr unsigned int outputHeight = 1;
6645 constexpr unsigned int outputChannels = inputChannels;
6646 constexpr unsigned int outputBatchSize = inputBatchSize;
6647
6648 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
6649 armnn::DataType::QuantisedAsymm8);
6650 inputTensorInfo.SetQuantizationScale(1.5f);
6651 inputTensorInfo.SetQuantizationOffset(-1);
6652
6653 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
6654 armnn::DataType::QuantisedAsymm8);
6655 outputTensorInfo.SetQuantizationScale(1.5f);
6656 outputTensorInfo.SetQuantizationOffset(-1);
6657
6658 auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({
6659 1, 2, 3, // 3.0, 4.5, 6.0
6660 5, 8, 13 // 9.0, 13.5, 21.0
6661 }));
6662
6663 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6664 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({
6665 1, 3 // 3.0, 5.25
6666 }));
6667
6668 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
6669 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6670
6671 armnn::ResizeBilinearQueueDescriptor descriptor;
6672 armnn::WorkloadInfo info;
6673 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
6674 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
6675
6676 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
6677
6678 inputHandle->Allocate();
6679 outputHandle->Allocate();
6680
6681 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
6682
6683 workload->Execute();
6684
6685 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6686 return result;
6687}
6688
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006689LayerTestResult<uint8_t, 4> ResizeBilinearMagUint8Test(
6690 armnn::IWorkloadFactory& workloadFactory,
6691 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006692{
6693 constexpr unsigned int inputWidth = 2;
6694 constexpr unsigned int inputHeight = 3;
6695 constexpr unsigned int inputChannels = 1;
6696 constexpr unsigned int inputBatchSize = 1;
6697
6698 constexpr unsigned int outputWidth = 5;
6699 constexpr unsigned int outputHeight = 3;
6700 constexpr unsigned int outputChannels = inputChannels;
6701 constexpr unsigned int outputBatchSize = inputBatchSize;
6702
6703 armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth },
6704 armnn::DataType::QuantisedAsymm8);
6705 inputTensorInfo.SetQuantizationScale(0.010765f);
6706 inputTensorInfo.SetQuantizationOffset(7);
6707
6708 armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth },
6709 armnn::DataType::QuantisedAsymm8);
6710 outputTensorInfo.SetQuantizationScale(0.010132f);
6711 outputTensorInfo.SetQuantizationOffset(-18);
6712
6713 auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({
6714 24, 228, // 0.183005, 2.379065,
6715 105, 128, // 1.05497, 1.302565
6716 230, 71 // 2.400595, 0.68896
6717 }));
6718
6719 LayerTestResult<uint8_t, 4> result(outputTensorInfo);
6720 result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({
6721 0, 87, 173, 217, 217, // 0.18300501, 1.06142902, 1.93985295, 2.37906504, 2.37906504
6722 86, 96, 106, 111, 111, // 1.05497003, 1.15400803, 1.25304604, 1.30256498, 1.30256498
6723 219, 151, 84, 50, 50 // 2.40059495, 1.71594095, 1.03128707, 0.68896002, 0.68896002
6724 }));
6725
6726 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
6727 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
6728
6729 armnn::ResizeBilinearQueueDescriptor descriptor;
6730 armnn::WorkloadInfo info;
6731 AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
6732 AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
6733
6734 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info);
6735
6736 inputHandle->Allocate();
6737 outputHandle->Allocate();
6738 CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
6739
6740 workload->Execute();
6741
6742 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
6743 return result;
6744}
6745
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006746LayerTestResult<float, 4> BatchNormTest(
6747 armnn::IWorkloadFactory& workloadFactory,
6748 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006749{
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006750 // BatchSize: 1
6751 // Channels: 2
6752 // Height: 3
6753 // Width: 2
6754
6755 const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 };
6756 std::vector<float> inputValues
6757 {
6758 // Batch 0, Channel 0, Height (3) x Width (2)
6759 1.f, 4.f,
6760 4.f, 2.f,
6761 1.f, 6.f,
6762
6763 // Batch 0, Channel 1, Height (3) x Width (2)
6764 1.f, 1.f,
6765 4.f, 1.f,
6766 -2.f, 4.f
6767 };
6768 std::vector<float> expectedOutputValues
6769 {
6770 // Batch 0, Channel 0, Height (3) x Width (2)
6771 1.f, 4.f,
6772 4.f, 2.f,
6773 1.f, 6.f,
6774
6775 // Batch 0, Channel 1, Height (3) x Width (2)
6776 3.f, 3.f,
6777 4.f, 3.f,
6778 2.f, 4.f
6779 };
6780
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006781 return BatchNormTestImpl<float>(workloadFactory, memoryManager,
6782 inputOutputShape, inputValues, expectedOutputValues,
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006783 0.f, 0, armnn::DataLayout::NCHW);
6784}
6785
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006786LayerTestResult<float, 4> BatchNormNhwcTest(
6787 armnn::IWorkloadFactory& workloadFactory,
6788 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006789{
6790 // BatchSize: 1
6791 // Height: 3
6792 // Width: 2
6793 // Channels: 2
6794
6795 const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 };
6796 std::vector<float> inputValues
6797 {
6798 // Batch 0, Height 0, Width (2) x Channel (2)
6799 1.f, 1.f,
6800 4.f, 1.f,
6801
6802 // Batch 0, Height 1, Width (2) x Channel (2)
6803 4.f, 4.f,
6804 2.f, 1.f,
6805
6806 // Batch 0, Height 2, Width (2) x Channel (2)
6807 1.f, -2.f,
6808 6.f, 4.f
6809 };
6810 std::vector<float> expectedOutputValues
6811 {
6812 // Batch 0, Height 0, Width (2) x Channel (2)
6813 1.f, 3.f,
6814 4.f, 3.f,
6815
6816 // Batch 0, Height 1, Width (2) x Channel (2)
6817 4.f, 4.f,
6818 2.f, 3.f,
6819
6820 // Batch 0, Height 2, Width (2) x Channel (2)
6821 1.f, 2.f,
6822 6.f, 4.f
6823 };
6824
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006825 return BatchNormTestImpl<float>(workloadFactory, memoryManager,
6826 inputOutputShape, inputValues, expectedOutputValues,
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006827 0.f, 0, armnn::DataLayout::NHWC);
telsoa014fcda012018-03-09 14:13:49 +00006828}
6829
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006830LayerTestResult<uint8_t, 4> BatchNormUint8Test(
6831 armnn::IWorkloadFactory& workloadFactory,
6832 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006833{
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006834 // BatchSize: 1
6835 // Channels: 2
6836 // Height: 3
6837 // Width: 2
6838
6839 const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 };
6840 std::vector<float> inputValues
6841 {
6842 // Batch 0, Channel 0, Height (3) x Width (2)
6843 1.f, 4.f,
6844 4.f, 2.f,
6845 1.f, 6.f,
6846
6847 // Batch 0, Channel 1, Height (3) x Width (2)
6848 1.f, 1.f,
6849 4.f, 1.f,
6850 -2.f, 4.f
6851 };
6852 std::vector<float> expectedOutputValues
6853 {
6854 // Batch 0, Channel 0, Height (3) x Width (2)
6855 1.f, 4.f,
6856 4.f, 2.f,
6857 1.f, 6.f,
6858
6859 // Batch 0, Channel 1, Height (3) x Width (2)
6860 3.f, 3.f,
6861 4.f, 3.f,
6862 2.f, 4.f
6863 };
6864
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006865 return BatchNormTestImpl<uint8_t>(workloadFactory, memoryManager,
6866 inputOutputShape, inputValues, expectedOutputValues,
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006867 1.f/20.f, 50, armnn::DataLayout::NCHW);
6868}
6869
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006870LayerTestResult<uint8_t, 4> BatchNormUint8NhwcTest(
6871 armnn::IWorkloadFactory& workloadFactory,
6872 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006873{
6874 // BatchSize: 1
6875 // Height: 3
6876 // Width: 2
6877 // Channels: 2
6878
6879 const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 };
6880 std::vector<float> inputValues
6881 {
6882 // Batch 0, Height 0, Width (2) x Channel (2)
6883 1.f, 1.f,
6884 4.f, 1.f,
6885
6886 // Batch 0, Height 1, Width (2) x Channel (2)
6887 4.f, 4.f,
6888 2.f, 1.f,
6889
6890 // Batch 0, Height 2, Width (2) x Channel (2)
6891 1.f, -2.f,
6892 6.f, 4.f
6893 };
6894 std::vector<float> expectedOutputValues
6895 {
6896 // Batch 0, Height 0, Width (2) x Channel (2)
6897 1.f, 3.f,
6898 4.f, 3.f,
6899
6900 // Batch 0, Height 1, Width (2) x Channel (2)
6901 4.f, 4.f,
6902 2.f, 3.f,
6903
6904 // Batch 0, Height 2, Width (2) x Channel (2)
6905 1.f, 2.f,
6906 6.f, 4.f
6907 };
6908
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006909 return BatchNormTestImpl<uint8_t>(workloadFactory, memoryManager,
6910 inputOutputShape, inputValues, expectedOutputValues,
Matteo Martincigh8eb675e2018-10-17 14:43:29 +01006911 1.f/20.f, 50, armnn::DataLayout::NHWC);
telsoa014fcda012018-03-09 14:13:49 +00006912}
6913
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006914LayerTestResult<uint8_t, 4> ConstantUint8Test(
6915 armnn::IWorkloadFactory& workloadFactory,
6916 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006917{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006918 return ConstantTestImpl<uint8_t>(workloadFactory, memoryManager, 2e-6f, 1);
telsoa014fcda012018-03-09 14:13:49 +00006919}
6920
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006921LayerTestResult<uint8_t, 1> Concatenation1dUint8Test(
6922 armnn::IWorkloadFactory& workloadFactory,
6923 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006924{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006925 return Concatenation1dTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006926}
6927
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006928LayerTestResult<uint8_t, 2> Concatenation2dDim0Uint8Test(
6929 armnn::IWorkloadFactory& workloadFactory,
6930 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006931{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006932 return Concatenation2dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006933}
6934
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006935LayerTestResult<uint8_t, 2> Concatenation2dDim1Uint8Test(
6936 armnn::IWorkloadFactory& workloadFactory,
6937 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006938{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006939 return Concatenation2dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006940}
6941
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006942LayerTestResult<uint8_t, 2> Concatenation2dDim0DiffInputDimsUint8Test(
6943 armnn::IWorkloadFactory& workloadFactory,
6944 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006945{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006946 return Concatenation2dDim0DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006947}
6948
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006949LayerTestResult<uint8_t, 2> Concatenation2dDim1DiffInputDimsUint8Test(
6950 armnn::IWorkloadFactory& workloadFactory,
6951 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006952{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006953 return Concatenation2dDim1DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006954}
6955
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006956LayerTestResult<uint8_t, 3> Concatenation3dDim0Uint8Test(
6957 armnn::IWorkloadFactory& workloadFactory,
6958 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006959{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006960 return Concatenation3dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006961}
6962
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006963LayerTestResult<uint8_t, 3> Concatenation3dDim1Uint8Test(
6964 armnn::IWorkloadFactory& workloadFactory,
6965 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006966{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006967 return Concatenation3dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006968}
6969
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006970LayerTestResult<uint8_t, 3> Concatenation3dDim2Uint8Test(
6971 armnn::IWorkloadFactory& workloadFactory,
narpra015cdda352018-11-19 15:30:27 +00006972 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
6973 bool useSubtensor)
telsoa014fcda012018-03-09 14:13:49 +00006974{
narpra015cdda352018-11-19 15:30:27 +00006975 return Concatenation3dDim2TestImpl<uint8_t>(workloadFactory, memoryManager, useSubtensor, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006976}
6977
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006978LayerTestResult<uint8_t, 3> Concatenation3dDim0DiffInputDimsUint8Test(
6979 armnn::IWorkloadFactory& workloadFactory,
6980 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006981{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006982 return Concatenation3dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006983}
6984
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006985LayerTestResult<uint8_t, 3> Concatenation3dDim1DiffInputDimsUint8Test(
6986 armnn::IWorkloadFactory& workloadFactory,
6987 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00006988{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006989 return Concatenation3dDim1DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
telsoa014fcda012018-03-09 14:13:49 +00006990}
6991
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00006992LayerTestResult<uint8_t, 3> Concatenation3dDim2DiffInputDimsUint8Test(
6993 armnn::IWorkloadFactory& workloadFactory,
narpra015cdda352018-11-19 15:30:27 +00006994 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
6995 bool useSubtensor)
6996{
6997 return Concatenation3dDim2DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, useSubtensor, 0.5f, -1);
6998}
6999
7000LayerTestResult<uint8_t, 4> Concatenation4dDim0Uint8Test(
7001 armnn::IWorkloadFactory& workloadFactory,
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007002 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007003{
narpra015cdda352018-11-19 15:30:27 +00007004 return Concatenation4dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7005}
7006
7007LayerTestResult<uint8_t, 4> Concatenation4dDim1Uint8Test(
7008 armnn::IWorkloadFactory& workloadFactory,
7009 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
7010{
7011 return Concatenation4dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7012}
7013
7014LayerTestResult<uint8_t, 4> Concatenation4dDim2Uint8Test(
7015 armnn::IWorkloadFactory& workloadFactory,
7016 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
7017{
7018 return Concatenation4dDim2TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7019}
7020
7021LayerTestResult<uint8_t, 4> Concatenation4dDim3Uint8Test(
7022 armnn::IWorkloadFactory& workloadFactory,
7023 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, bool useSubtensor)
7024{
7025 return Concatenation4dDim3TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1, useSubtensor);
7026}
7027
7028LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim0Uint8Test(
7029 armnn::IWorkloadFactory& workloadFactory,
7030 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
7031{
7032 return Concatenation4dDiffShapeDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7033}
7034
7035LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim1Uint8Test(
7036 armnn::IWorkloadFactory& workloadFactory,
7037 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
7038{
7039 return Concatenation4dDiffShapeDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7040}
7041
7042LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim2Uint8Test(
7043 armnn::IWorkloadFactory& workloadFactory,
7044 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
7045{
7046 return Concatenation4dDiffShapeDim2TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1);
7047}
7048
7049LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim3Uint8Test(
7050 armnn::IWorkloadFactory& workloadFactory,
7051 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7052 bool useSubtensor)
7053{
7054 return Concatenation4dDiffShapeDim3TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1, useSubtensor);
telsoa014fcda012018-03-09 14:13:49 +00007055}
7056
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007057LayerTestResult<float, 4> SimpleMaxPooling2dSize2x2Stride2x2Test(
7058 armnn::IWorkloadFactory& workloadFactory,
7059 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7060 bool forceNoPadding)
telsoa014fcda012018-03-09 14:13:49 +00007061{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007062 return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<float>(workloadFactory, memoryManager, forceNoPadding);
telsoa014fcda012018-03-09 14:13:49 +00007063}
7064
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007065LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize2x2Stride2x2Uint8Test(
7066 armnn::IWorkloadFactory& workloadFactory,
7067 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7068 bool forceNoPadding)
telsoa014fcda012018-03-09 14:13:49 +00007069{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007070 return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<uint8_t>(
7071 workloadFactory, memoryManager, forceNoPadding, 3.0f, -5);
telsoa014fcda012018-03-09 14:13:49 +00007072}
7073
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007074LayerTestResult<float, 4> SimpleMaxPooling2dSize3x3Stride2x4Test(
7075 armnn::IWorkloadFactory& workloadFactory,
7076 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7077 bool forceNoPadding)
telsoa014fcda012018-03-09 14:13:49 +00007078{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007079 return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<float>(workloadFactory, memoryManager, forceNoPadding);
telsoa014fcda012018-03-09 14:13:49 +00007080}
7081
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007082LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize3x3Stride2x4Uint8Test(
7083 armnn::IWorkloadFactory& workloadFactory,
7084 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7085 bool forceNoPadding)
telsoa014fcda012018-03-09 14:13:49 +00007086{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007087 return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<uint8_t>(
7088 workloadFactory, memoryManager, forceNoPadding, 0.1f, 128);
telsoa014fcda012018-03-09 14:13:49 +00007089}
7090
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007091LayerTestResult<float, 4> SimpleMaxPooling2dTest(
7092 armnn::IWorkloadFactory& workloadFactory,
7093 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007094 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00007095{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007096 return SimpleMaxPooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00007097}
7098
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007099LayerTestResult<uint8_t, 4> SimpleMaxPooling2dUint8Test(
7100 armnn::IWorkloadFactory& workloadFactory,
7101 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007102 const armnn::DataLayout dataLayout)
Francis Murtagh043d0d02018-10-05 14:08:48 +01007103{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007104 return SimpleMaxPooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, dataLayout);
Francis Murtagh043d0d02018-10-05 14:08:48 +01007105}
7106
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007107LayerTestResult<float, 4> SimpleAveragePooling2dTest(
7108 armnn::IWorkloadFactory& workloadFactory,
7109 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007110 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00007111{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007112 return SimpleAveragePooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout);
James Conroy69482272018-10-19 10:41:35 +01007113}
7114
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007115LayerTestResult<uint8_t, 4> SimpleAveragePooling2dUint8Test(
7116 armnn::IWorkloadFactory& workloadFactory,
7117 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007118 const armnn::DataLayout dataLayout)
James Conroy69482272018-10-19 10:41:35 +01007119{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007120 return SimpleAveragePooling2dTestCommon<uint8_t>(
7121 workloadFactory, memoryManager, dataLayout, 0.5, -1);
telsoa014fcda012018-03-09 14:13:49 +00007122}
7123
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007124LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3x2Stride2x2Test(
7125 armnn::IWorkloadFactory& workloadFactory,
7126 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7127 bool forceNoPadding)
surmeh01bceff2f2018-03-29 16:29:27 +01007128{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007129 return IgnorePaddingAveragePooling2dSize3x2Stride2x2TestCommon<float>(
7130 workloadFactory, memoryManager, forceNoPadding);
surmeh01bceff2f2018-03-29 16:29:27 +01007131}
7132
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007133LayerTestResult<float, 4> LargeTensorsAveragePooling2dTest(
7134 armnn::IWorkloadFactory& workloadFactory,
7135 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007136{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007137 return LargeTensorsAveragePooling2dTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007138}
7139
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007140LayerTestResult<uint8_t, 4> LargeTensorsAveragePooling2dUint8Test(
7141 armnn::IWorkloadFactory& workloadFactory,
7142 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007143{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007144 return LargeTensorsAveragePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, 0.5, -1);
telsoa014fcda012018-03-09 14:13:49 +00007145}
7146
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007147LayerTestResult<float, 4> SimpleL2Pooling2dTest(
7148 armnn::IWorkloadFactory& workloadFactory,
7149 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007150 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00007151{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007152 return SimpleL2Pooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00007153}
7154
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007155LayerTestResult<uint8_t, 4> SimpleL2Pooling2dUint8Test(
7156 armnn::IWorkloadFactory& workloadFactory,
7157 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
Matthew Bentham8800c002018-11-19 13:19:28 +00007158 const armnn::DataLayout dataLayout)
telsoa014fcda012018-03-09 14:13:49 +00007159{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007160 return SimpleL2Pooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, dataLayout);
telsoa014fcda012018-03-09 14:13:49 +00007161}
7162
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007163LayerTestResult<float, 4> L2Pooling2dSize3Stride1Test(
7164 armnn::IWorkloadFactory& workloadFactory,
7165 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007166{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007167 return L2Pooling2dSize3Stride1TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007168}
7169
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007170LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride1Uint8Test(
7171 armnn::IWorkloadFactory& workloadFactory,
7172 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007173{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007174 return L2Pooling2dSize3Stride1TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007175}
7176
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007177LayerTestResult<float, 4> L2Pooling2dSize3Stride3Test(
7178 armnn::IWorkloadFactory& workloadFactory,
7179 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007180{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007181 return L2Pooling2dSize3Stride3TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007182}
7183
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007184LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride3Uint8Test(
7185 armnn::IWorkloadFactory& workloadFactory,
7186 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007187{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007188 return L2Pooling2dSize3Stride3TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007189}
7190
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007191LayerTestResult<float, 4> L2Pooling2dSize3Stride4Test(
7192 armnn::IWorkloadFactory& workloadFactory,
7193 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007194{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007195 return L2Pooling2dSize3Stride4TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007196}
7197
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007198LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride4Uint8Test(
7199 armnn::IWorkloadFactory& workloadFactory,
7200 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007201{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007202 return L2Pooling2dSize3Stride4TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007203}
7204
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007205LayerTestResult<float, 4> L2Pooling2dSize7Test(
7206 armnn::IWorkloadFactory& workloadFactory,
7207 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007208{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007209 return L2Pooling2dSize7TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007210}
7211
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007212LayerTestResult<uint8_t, 4> L2Pooling2dSize7Uint8Test(
7213 armnn::IWorkloadFactory& workloadFactory,
7214 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007215{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007216 return L2Pooling2dSize7TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007217}
7218
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007219LayerTestResult<float, 4> L2Pooling2dSize9Test(
7220 armnn::IWorkloadFactory& workloadFactory,
7221 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007222{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007223 return L2Pooling2dSize9TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007224}
7225
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007226LayerTestResult<uint8_t, 4> L2Pooling2dSize9Uint8Test(
7227 armnn::IWorkloadFactory& workloadFactory,
7228 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007229{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007230 return L2Pooling2dSize9TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007231}
7232
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007233LayerTestResult<float, 4> AsymmetricNonSquarePooling2dTest(
7234 armnn::IWorkloadFactory& workloadFactory,
7235 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007236{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007237 return AsymmetricNonSquarePooling2dTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007238}
7239
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007240LayerTestResult<uint8_t, 4> AsymmetricNonSquarePooling2dUint8Test(
7241 armnn::IWorkloadFactory& workloadFactory,
7242 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007243{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007244 return AsymmetricNonSquarePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007245}
7246
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007247LayerTestResult<float, 4> ComparePooling2dTest(
7248 armnn::IWorkloadFactory& workloadFactory,
7249 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7250 armnn::IWorkloadFactory& refWorkloadFactory,
7251 armnn::PoolingAlgorithm poolingType)
telsoa014fcda012018-03-09 14:13:49 +00007252{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007253 return ComparePooling2dTestCommon<float>(
7254 workloadFactory, memoryManager, refWorkloadFactory, poolingType);
telsoa014fcda012018-03-09 14:13:49 +00007255}
7256
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007257LayerTestResult<uint8_t, 4> ComparePooling2dUint8Test(
7258 armnn::IWorkloadFactory& workloadFactory,
7259 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7260 armnn::IWorkloadFactory& refWorkloadFactory,
7261 armnn::PoolingAlgorithm poolingType)
telsoa014fcda012018-03-09 14:13:49 +00007262{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007263 return ComparePooling2dTestCommon<uint8_t>(
7264 workloadFactory, memoryManager, refWorkloadFactory, poolingType, 0.1f, 128);
telsoa014fcda012018-03-09 14:13:49 +00007265}
7266
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007267LayerTestResult<float, 2> FullyConnectedLargeTest(
7268 armnn::IWorkloadFactory& workloadFactory,
7269 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7270 bool transposeWeights)
telsoa014fcda012018-03-09 14:13:49 +00007271{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007272 return FullyConnectedLargeTestCommon<float>(workloadFactory, memoryManager, transposeWeights);
telsoa014fcda012018-03-09 14:13:49 +00007273}
7274
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007275LayerTestResult<float, 4> IgnorePaddingSimpleMaxPooling2dTest(
7276 armnn::IWorkloadFactory& workloadFactory,
7277 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007278{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007279 return IgnorePaddingSimpleMaxPooling2dTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007280}
7281
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007282LayerTestResult<uint8_t, 4> IgnorePaddingSimpleMaxPooling2dUint8Test(
7283 armnn::IWorkloadFactory& workloadFactory,
7284 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007285{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007286 return IgnorePaddingSimpleMaxPooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, -5);
telsoa014fcda012018-03-09 14:13:49 +00007287}
7288
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007289LayerTestResult<float, 4> IgnorePaddingMaxPooling2dSize3Test(
7290 armnn::IWorkloadFactory& workloadFactory,
7291 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007292{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007293 return IgnorePaddingMaxPooling2dSize3TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007294}
7295
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007296LayerTestResult<uint8_t, 4> IgnorePaddingMaxPooling2dSize3Uint8Test(
7297 armnn::IWorkloadFactory& workloadFactory,
7298 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007299{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007300 return IgnorePaddingMaxPooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, -5);
telsoa014fcda012018-03-09 14:13:49 +00007301}
7302
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007303LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dTest(
7304 armnn::IWorkloadFactory& workloadFactory,
7305 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007306{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007307 return IgnorePaddingSimpleAveragePooling2dTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007308}
7309
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007310LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dUint8Test(
7311 armnn::IWorkloadFactory& workloadFactory,
7312 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007313{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007314 return IgnorePaddingSimpleAveragePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007315}
7316
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007317LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingTest(
7318 armnn::IWorkloadFactory& workloadFactory,
7319 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007320{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007321 return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007322}
7323
7324LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test(
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007325 armnn::IWorkloadFactory& workloadFactory,
7326 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007327{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007328 return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007329}
7330
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007331LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3Test(
7332 armnn::IWorkloadFactory& workloadFactory,
7333 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007334{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007335 return IgnorePaddingAveragePooling2dSize3TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007336}
7337
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007338LayerTestResult<uint8_t, 4> IgnorePaddingAveragePooling2dSize3Uint8Test(
7339 armnn::IWorkloadFactory& workloadFactory,
7340 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007341{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007342 return IgnorePaddingAveragePooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007343}
7344
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007345LayerTestResult<float, 4> IgnorePaddingSimpleL2Pooling2dTest(
7346 armnn::IWorkloadFactory& workloadFactory,
7347 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007348{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007349 return IgnorePaddingSimpleL2Pooling2dTestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007350}
7351
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007352LayerTestResult<uint8_t, 4> IgnorePaddingSimpleL2Pooling2dUint8Test(
7353 armnn::IWorkloadFactory& workloadFactory,
7354 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007355{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007356 return IgnorePaddingSimpleL2Pooling2dTestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007357}
7358
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007359LayerTestResult<float, 4> IgnorePaddingL2Pooling2dSize3Test(
7360 armnn::IWorkloadFactory& workloadFactory,
7361 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007362{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007363 return IgnorePaddingL2Pooling2dSize3TestCommon<float>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007364}
7365
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007366LayerTestResult<uint8_t, 4> IgnorePaddingL2Pooling2dSize3Uint8Test(
7367 armnn::IWorkloadFactory& workloadFactory,
7368 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007369{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007370 return IgnorePaddingL2Pooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007371}
7372
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007373LayerTestResult<float, 4> SimplePermuteFloat32Test(
7374 armnn::IWorkloadFactory& workloadFactory,
7375 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007376{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007377 return SimplePermuteFloat32TestCommon(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007378};
7379
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007380LayerTestResult<uint8_t, 4> SimplePermuteUint8Test(
7381 armnn::IWorkloadFactory& workloadFactory,
7382 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +00007383{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007384 return SimplePermuteUint8TestCommon(workloadFactory, memoryManager);
telsoa014fcda012018-03-09 14:13:49 +00007385};
surmeh01bceff2f2018-03-29 16:29:27 +01007386
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007387LayerTestResult<float, 4> PermuteFloat32ValueSet1Test(
7388 armnn::IWorkloadFactory& workloadFactory,
7389 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01007390{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007391 return PermuteFloat32ValueSet1TestCommon(workloadFactory, memoryManager);
surmeh01bceff2f2018-03-29 16:29:27 +01007392};
7393
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007394LayerTestResult<float, 4> PermuteFloat32ValueSet2Test(
7395 armnn::IWorkloadFactory& workloadFactory,
7396 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01007397{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007398 return PermuteFloat32ValueSet2TestCommon(workloadFactory, memoryManager);
surmeh01bceff2f2018-03-29 16:29:27 +01007399};
7400
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007401LayerTestResult<float, 4> PermuteFloat32ValueSet3Test(
7402 armnn::IWorkloadFactory& workloadFactory,
7403 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
surmeh01bceff2f2018-03-29 16:29:27 +01007404{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007405 return PermuteFloat32ValueSet3TestCommon(workloadFactory, memoryManager);
narpra011e4c31d2018-09-28 11:07:51 +01007406};
7407
7408namespace
7409{
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007410
narpra011e4c31d2018-09-28 11:07:51 +01007411template <typename T, std::size_t InputDim, std::size_t OutputDim>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007412LayerTestResult<T, OutputDim> MeanTestHelper(
7413 armnn::IWorkloadFactory& workloadFactory,
7414 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7415 const unsigned int* inputShape,
7416 const std::vector<T>& inputData,
7417 const std::vector<unsigned int>& axis,
7418 bool keepDims,
7419 const unsigned int* outputShape,
7420 const std::vector<T>& outputData,
7421 float scale = 1.0f,
7422 int32_t offset = 0)
narpra011e4c31d2018-09-28 11:07:51 +01007423{
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007424 auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32);
narpra011e4c31d2018-09-28 11:07:51 +01007425
7426 armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType);
7427 armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType);
7428
7429 inputTensorInfo.SetQuantizationScale(scale);
7430 inputTensorInfo.SetQuantizationOffset(offset);
7431
7432 outputTensorInfo.SetQuantizationScale(scale);
7433 outputTensorInfo.SetQuantizationOffset(offset);
7434
7435 auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData);
7436
7437 LayerTestResult<T, OutputDim> result(outputTensorInfo);
7438 result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData);
7439
7440 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
7441 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
7442
7443 armnn::MeanQueueDescriptor data;
7444 data.m_Parameters.m_Axis = axis;
7445 data.m_Parameters.m_KeepDims = keepDims;
7446 armnn::WorkloadInfo info;
7447 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
7448 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
7449
7450 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMean(data, info);
7451
7452 inputHandle->Allocate();
7453 outputHandle->Allocate();
7454
7455 CopyDataToITensorHandle(inputHandle.get(), input.origin());
7456
narpra011e4c31d2018-09-28 11:07:51 +01007457 workload->Execute();
7458
7459 CopyDataFromITensorHandle(result.output.origin(), outputHandle.get());
7460
7461 return result;
7462}
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007463
narpra011e4c31d2018-09-28 11:07:51 +01007464} // anonymous namespace
7465
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007466LayerTestResult<uint8_t, 1> MeanUint8SimpleTest(
7467 armnn::IWorkloadFactory& workloadFactory,
7468 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007469{
7470 const unsigned int inputShape[] = { 3, 2 };
7471 const unsigned int outputShape[] = { 1 };
7472
7473 std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 });
7474 std::vector<uint8_t> output({ 2 });
7475
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007476 return MeanTestHelper<uint8_t, 2, 1>(
7477 workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007478}
7479
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007480LayerTestResult<uint8_t, 3> MeanUint8SimpleAxisTest(
7481 armnn::IWorkloadFactory& workloadFactory,
7482 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007483{
7484 const unsigned int inputShape[] = { 1, 1, 3, 2 };
7485 const unsigned int outputShape[] = { 1, 1, 2 };
7486
7487 std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 });
7488 std::vector<uint8_t> output({ 2, 2 });
7489
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007490 return MeanTestHelper<uint8_t, 4, 3>(
7491 workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007492}
7493
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007494LayerTestResult<uint8_t, 4> MeanUint8KeepDimsTest(
7495 armnn::IWorkloadFactory& workloadFactory,
7496 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007497{
7498 const unsigned int inputShape[] = { 1, 1, 3, 2 };
7499 const unsigned int outputShape[] = { 1, 1, 1, 2 };
7500
7501 std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 });
7502 std::vector<uint8_t> output({ 2, 2 });
7503
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007504 return MeanTestHelper<uint8_t, 4, 4>(
7505 workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007506}
7507
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007508LayerTestResult<uint8_t, 4> MeanUint8MultipleDimsTest(
7509 armnn::IWorkloadFactory& workloadFactory,
7510 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007511{
7512 const unsigned int inputShape[] = { 2, 3, 1, 2 };
7513 const unsigned int outputShape[] = { 1, 3, 1, 1 };
7514
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007515 std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6 });
narpra011e4c31d2018-09-28 11:07:51 +01007516 std::vector<uint8_t> output({ 1, 3, 5 });
7517
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007518 return MeanTestHelper<uint8_t, 4, 4>(
7519 workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007520}
7521
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007522LayerTestResult<uint8_t, 1> MeanVtsUint8Test(
7523 armnn::IWorkloadFactory& workloadFactory,
7524 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007525{
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007526 const unsigned int inputShape[] = { 4, 3, 2 };
narpra011e4c31d2018-09-28 11:07:51 +01007527 const unsigned int outputShape[] = { 2 };
7528
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007529 std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
7530 24 });
7531 std::vector<uint8_t> output({ 12, 13 });
narpra011e4c31d2018-09-28 11:07:51 +01007532
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007533 return MeanTestHelper<uint8_t, 3, 1>(workloadFactory, memoryManager,
7534 inputShape, input, { 0, 1 }, false, outputShape,
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007535 output, 0.8f, 5);
narpra011e4c31d2018-09-28 11:07:51 +01007536}
7537
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007538LayerTestResult<float, 1> MeanFloatSimpleTest(
7539 armnn::IWorkloadFactory& workloadFactory,
7540 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007541{
7542 const unsigned int inputShape[] = { 3, 2 };
7543 const unsigned int outputShape[] = { 1 };
7544
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007545 std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f });
7546 std::vector<float> output({ 2.0f });
narpra011e4c31d2018-09-28 11:07:51 +01007547
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007548 return MeanTestHelper<float, 2, 1>(
7549 workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007550}
7551
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007552LayerTestResult<float, 3> MeanFloatSimpleAxisTest(
7553 armnn::IWorkloadFactory& workloadFactory,
7554 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007555{
7556 const unsigned int inputShape[] = { 2, 3, 1, 2 };
7557 const unsigned int outputShape[] = { 3, 1, 2 };
7558
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007559 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f });
7560 std::vector<float> output({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f });
narpra011e4c31d2018-09-28 11:07:51 +01007561
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007562 return MeanTestHelper<float, 4, 3>(
7563 workloadFactory, memoryManager, inputShape, input, { 0 }, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007564}
7565
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007566LayerTestResult<float, 4> MeanFloatKeepDimsTest(
7567 armnn::IWorkloadFactory& workloadFactory,
7568 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007569{
7570 const unsigned int inputShape[] = { 1, 1, 3, 2 };
7571 const unsigned int outputShape[] = { 1, 1, 1, 2 };
7572
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007573 std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f });
7574 std::vector<float> output({ 2.0f, 2.0f });
narpra011e4c31d2018-09-28 11:07:51 +01007575
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007576 return MeanTestHelper<float, 4, 4>(
7577 workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007578}
7579
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007580LayerTestResult<float, 4> MeanFloatMultipleDimsTest(
7581 armnn::IWorkloadFactory& workloadFactory,
7582 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007583{
7584 const unsigned int inputShape[] = { 2, 3, 1, 2 };
7585 const unsigned int outputShape[] = { 1, 3, 1, 1 };
7586
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007587 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f });
7588 std::vector<float> output({ 1.5f, 3.5f, 5.5f });
narpra011e4c31d2018-09-28 11:07:51 +01007589
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007590 return MeanTestHelper<float, 4, 4>(
7591 workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007592}
7593
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007594LayerTestResult<float, 1> MeanVtsFloat1Test(
7595 armnn::IWorkloadFactory& workloadFactory,
7596 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007597{
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007598 const unsigned int inputShape[] = { 4, 3, 2 };
narpra011e4c31d2018-09-28 11:07:51 +01007599 const unsigned int outputShape[] = { 2 };
7600
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007601 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f,
7602 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
7603 std::vector<float> output({ 12.0f, 13.0f });
narpra011e4c31d2018-09-28 11:07:51 +01007604
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007605 return MeanTestHelper<float, 3, 1>(
7606 workloadFactory, memoryManager, inputShape, input, { 0, 1 }, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007607}
7608
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007609LayerTestResult<float, 3> MeanVtsFloat2Test(
7610 armnn::IWorkloadFactory& workloadFactory,
7611 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
narpra011e4c31d2018-09-28 11:07:51 +01007612{
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007613 const unsigned int inputShape[] = { 4, 3, 2 };
7614 const unsigned int outputShape[] = { 1, 3, 1 };
narpra011e4c31d2018-09-28 11:07:51 +01007615
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007616 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f,
7617 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
7618 std::vector<float> output({ 10.5f, 12.5f, 14.5f });
narpra011e4c31d2018-09-28 11:07:51 +01007619
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007620 return MeanTestHelper<float, 3, 3>(
7621 workloadFactory, memoryManager, inputShape, input, { 0, 2 }, true, outputShape, output);
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007622}
7623
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007624LayerTestResult<float, 3> MeanVtsFloat3Test(
7625 armnn::IWorkloadFactory& workloadFactory,
7626 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Matteo Martincigh28dcab62018-10-19 16:40:03 +01007627{
7628 const unsigned int inputShape[] = { 1, 2, 2, 1 };
7629 const unsigned int outputShape[] = { 1, 2, 1 };
7630
7631 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f });
7632 std::vector<float> output({ 1.5f, 3.5f });
7633
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007634 return MeanTestHelper<float, 4, 3>(
7635 workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output);
narpra011e4c31d2018-09-28 11:07:51 +01007636}
Éanna Ó Catháin47c1ddb2018-10-12 14:24:13 +01007637
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007638LayerTestResult<float, 4> AdditionAfterMaxPoolTest(
7639 armnn::IWorkloadFactory& workloadFactory,
7640 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin47c1ddb2018-10-12 14:24:13 +01007641{
7642 // Create Initial Tensor
7643 // 1, 2, 3
7644 // 4, 5, 6
7645 // 7, 8, 9
7646
7647 armnn::TensorInfo poolingInputTensorInfo({ 1, 1, 3, 3}, armnn::GetDataType<float>());
7648 armnn::TensorInfo poolingOutputTensorInfo({ 1, 1, 2, 2}, armnn::GetDataType<float>());
7649
7650 boost::multi_array<float, 4> poolingInput = MakeTensor<float,4>(poolingInputTensorInfo,
7651 {1, 2, 3,
7652 4, 5, 6,
7653 7, 8, 9
7654 });
7655
7656 std::unique_ptr<armnn::ITensorHandle> poolingInputHandle =
7657 workloadFactory.CreateTensorHandle(poolingInputTensorInfo);
7658 std::unique_ptr<armnn::ITensorHandle> poolingOutputHandle =
7659 workloadFactory.CreateTensorHandle(poolingOutputTensorInfo);
7660
7661 // Apply MaxPool poolSize = 1x1, stride=2x2
7662 // Result =
7663 // 1, 3
7664 // 7, 9
7665 armnn::Pooling2dDescriptor descriptor;
7666 descriptor.m_PoolHeight = 1;
7667 descriptor.m_PoolWidth = 1;
7668 descriptor.m_StrideX = 2;
7669 descriptor.m_StrideY = 2;
7670 descriptor.m_PoolType = armnn::PoolingAlgorithm::Max;
7671
7672 armnn::Pooling2dQueueDescriptor queueDescriptor;
7673 queueDescriptor.m_Parameters = descriptor;
7674 armnn::WorkloadInfo workloadInfo;
7675 AddInputToWorkload(queueDescriptor, workloadInfo, poolingInputTensorInfo, poolingInputHandle.get());
7676 AddOutputToWorkload(queueDescriptor, workloadInfo, poolingOutputTensorInfo, poolingOutputHandle.get());
7677
7678 // Create the MaxPool
7679 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePooling2d(queueDescriptor, workloadInfo);
7680
7681 //LayerTestResult<float, 4> result(poolingOutputTensorInfo);
7682 auto shape( GetTensorShapeAsArray<4>(poolingOutputTensorInfo));
7683 boost::multi_array<float, 4> resultMaxPool;
7684 resultMaxPool.resize(shape);
7685
7686
7687 // Create addition with another tensor the same size
7688 // This would be the result to apply a Conv2d with kernel ones(2) and stride 1x1
7689 // with the initial tensor.
7690 // 12, 16
7691 // 24, 28
7692
7693 armnn::TensorInfo addInputTensorInfo({ 1,1,2,2}, armnn::GetDataType<float>());
7694 armnn::TensorInfo addOutputTensorInfo({ 1,1,2,2}, armnn::GetDataType<float>());
7695
7696 boost::multi_array<float, 4> addInput = MakeTensor<float,4>(addInputTensorInfo,
7697 {12, 16,
7698 24, 28,
7699 });
7700
7701 // Expected output tensor after MaxPool and Addition.
7702 LayerTestResult<float,4> addRet(addOutputTensorInfo);
7703 addRet.outputExpected = MakeTensor<float, 4>(addOutputTensorInfo, std::vector<float>(
7704 {
7705 13, 19,
7706 31, 37
7707 }));
7708
7709 std::unique_ptr<armnn::ITensorHandle> addInputHandle = workloadFactory.CreateTensorHandle(addInputTensorInfo);
7710 std::unique_ptr<armnn::ITensorHandle> addOutputHandle = workloadFactory.CreateTensorHandle(addOutputTensorInfo);
7711
7712 armnn::AdditionQueueDescriptor data;
7713 armnn::WorkloadInfo info;
7714
7715 // Add the output of the MaxPool and the new tensor
7716 AddInputToWorkload(data, info, poolingOutputTensorInfo, poolingOutputHandle.get());
7717 AddInputToWorkload(data, info, addInputTensorInfo, addInputHandle.get());
7718 AddOutputToWorkload(data, info, addOutputTensorInfo, addOutputHandle.get());
7719
7720 std::unique_ptr<armnn::IWorkload> addWorkload = workloadFactory.CreateAddition(data, info);
7721
7722 poolingInputHandle->Allocate();
7723 poolingOutputHandle->Allocate();
7724 addInputHandle->Allocate();
7725 addOutputHandle->Allocate();
7726
7727 CopyDataToITensorHandle(poolingInputHandle.get(), &poolingInput[0][0][0][0]);
7728 CopyDataFromITensorHandle(&resultMaxPool[0][0][0][0], poolingOutputHandle.get());
7729
7730 CopyDataToITensorHandle(poolingOutputHandle.get(), &resultMaxPool[0][0][0][0]);
7731 CopyDataToITensorHandle(addInputHandle.get(), &addInput[0][0][0][0]);
7732
7733 workload->Execute();
7734 addWorkload->Execute();
7735
7736 CopyDataFromITensorHandle(&addRet.output[0][0][0][0], addOutputHandle.get());
7737
Éanna Ó Catháin47c1ddb2018-10-12 14:24:13 +01007738 return addRet;
7739}
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007740
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007741LayerTestResult<float, 4> SpaceToBatchNdSimpleFloat32Test(
7742 armnn::IWorkloadFactory& workloadFactory,
7743 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007744{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007745 return SpaceToBatchNdSimpleTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007746}
7747
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007748LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsFloat32Test(
7749 armnn::IWorkloadFactory& workloadFactory,
7750 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007751{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007752 return SpaceToBatchNdMultiChannelsTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007753}
7754
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007755LayerTestResult<float, 4> SpaceToBatchNdMultiBlockFloat32Test(
7756 armnn::IWorkloadFactory& workloadFactory,
7757 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007758{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007759 return SpaceToBatchNdMultiBlockTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007760}
7761
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007762LayerTestResult<float, 4> SpaceToBatchNdPaddingFloat32Test(
7763 armnn::IWorkloadFactory& workloadFactory,
7764 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007765{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007766 return SpaceToBatchNdPaddingTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007767}
7768
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007769LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleUint8Test(
7770 armnn::IWorkloadFactory& workloadFactory,
7771 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007772{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007773 return SpaceToBatchNdSimpleTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007774}
7775
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007776LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsUint8Test(
7777 armnn::IWorkloadFactory& workloadFactory,
7778 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007779{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007780 return SpaceToBatchNdMultiChannelsTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007781}
7782
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007783LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockUint8Test(
7784 armnn::IWorkloadFactory& workloadFactory,
7785 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007786{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007787 return SpaceToBatchNdMultiBlockTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007788}
7789
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007790LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingUint8Test(
7791 armnn::IWorkloadFactory& workloadFactory,
7792 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007793{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007794 return SpaceToBatchNdPaddingTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007795}
7796
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007797LayerTestResult<float, 4> SpaceToBatchNdSimpleNHWCFloat32Test(
7798 armnn::IWorkloadFactory& workloadFactory,
7799 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007800{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007801 return SpaceToBatchNdSimpleNHWCTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007802}
7803
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007804LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsNHWCFloat32Test(
7805 armnn::IWorkloadFactory& workloadFactory,
7806 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007807{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007808 return SpaceToBatchNdMultiChannelsNHWCTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007809}
7810
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007811LayerTestResult<float, 4> SpaceToBatchNdMultiBlockNHWCFloat32Test(
7812 armnn::IWorkloadFactory& workloadFactory,
7813 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007814{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007815 return SpaceToBatchNdMultiBlockNHWCTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007816}
7817
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007818LayerTestResult<float, 4> SpaceToBatchNdPaddingNHWCFloat32Test(
7819 armnn::IWorkloadFactory& workloadFactory,
7820 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007821{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007822 return SpaceToBatchNdPaddingNHWCTest<float>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007823}
7824
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007825LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleNHWCUint8Test(
7826 armnn::IWorkloadFactory& workloadFactory,
7827 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007828{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007829 return SpaceToBatchNdSimpleNHWCTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007830}
7831
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007832LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsNHWCUint8Test(
7833 armnn::IWorkloadFactory& workloadFactory,
7834 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007835{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007836 return SpaceToBatchNdMultiChannelsNHWCTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007837}
7838
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007839LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockNHWCUint8Test(
7840 armnn::IWorkloadFactory& workloadFactory,
7841 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007842{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007843 return SpaceToBatchNdMultiBlockNHWCTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007844}
7845
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007846LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingNHWCUint8Test(
7847 armnn::IWorkloadFactory& workloadFactory,
7848 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007849{
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007850 return SpaceToBatchNdPaddingNHWCTest<uint8_t>(workloadFactory, memoryManager);
Nattapat Chaimanowong3ea76d52018-11-09 14:10:38 +00007851}
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007852
7853namespace {
7854
7855template<typename T, std::size_t InputDim, std::size_t OutputDim>
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007856LayerTestResult<T, OutputDim> BatchToSpaceNdHelper(
7857 armnn::IWorkloadFactory &workloadFactory,
7858 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
7859 const armnn::DataLayout& dataLayout,
7860 const unsigned int *inputShape,
7861 const std::vector<T> &inputData,
7862 const std::vector<unsigned int> &blockShape,
7863 const std::vector<std::pair<unsigned int, unsigned int>> &crops,
7864 const unsigned int *outputShape,
7865 const std::vector<T> &outputData,
7866 float scale = 1.0f,
7867 int32_t offset = 0)
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007868 {
7869 auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32);
7870
7871 armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType);
7872 armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType);
7873
7874 inputTensorInfo.SetQuantizationScale(scale);
7875 inputTensorInfo.SetQuantizationOffset(offset);
7876
7877 outputTensorInfo.SetQuantizationScale(scale);
7878 outputTensorInfo.SetQuantizationOffset(offset);
7879
7880 auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData);
7881
7882 LayerTestResult<T, OutputDim> result(outputTensorInfo);
7883 result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData);
7884
7885 std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo);
7886 std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
7887
7888 armnn::BatchToSpaceNdQueueDescriptor data;
7889 data.m_Parameters.m_DataLayout = dataLayout;
7890 data.m_Parameters.m_BlockShape = blockShape;
7891 data.m_Parameters.m_Crops = crops;
7892 armnn::WorkloadInfo info;
7893 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
7894 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
7895
7896 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchToSpaceNd(data, info);
7897
7898 inputHandle->Allocate();
7899 outputHandle->Allocate();
7900
7901 CopyDataToITensorHandle(inputHandle.get(), input.origin());
7902
7903 workload->Execute();
7904
7905 CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get());
7906
7907 return result;
7908}
7909
7910} // anonymous namespace
7911
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007912LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test1(
7913 armnn::IWorkloadFactory& workloadFactory,
7914 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007915{
7916 const unsigned int inputShape[] = {4, 2, 2, 1};
7917 const unsigned int outputShape[] = {1, 4, 4, 1 };
7918
7919 std::vector<float> input
7920 ({
7921 // Batch 0, Height 0, Width (2) x Channel (1)
7922 1.0f, 3.0f,
7923 // Batch 0, Height 1, Width (2) x Channel (1)
7924 9.0f, 11.0f,
7925
7926
7927 // Batch 1, Height 0, Width (2) x Channel (1)
7928 2.0f, 4.0f,
7929 // Batch 1, Height 1, Width (2) x Channel (1)
7930 10.0f, 12.0f,
7931
7932
7933 // Batch 2, Height 0, Width (2) x Channel (1)
7934 5.0f, 7.0f,
7935 // Batch 2, Height 1, Width (2) x Channel (1)
7936 13.0f, 15.0f,
7937
7938 // Batch 3, Height 0, Width (2) x Channel (3)
7939 6.0f, 8.0f,
7940 // Batch 3, Height 1, Width (2) x Channel (1)
7941 14.0f, 16.0f
7942 });
7943
7944 std::vector<float> expectedOutput
7945 ({
7946 1.0f, 2.0f, 3.0f, 4.0f,
7947 5.0f, 6.0f, 7.0f, 8.0f,
7948 9.0f, 10.0f, 11.0f, 12.0f,
7949 13.0f, 14.0f, 15.0f, 16.0f
7950 });
7951
7952 std::vector<unsigned int> blockShape {2, 2};
Éanna Ó Catháin95807ce2018-11-12 17:14:43 +00007953 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007954
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007955 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
7956 armnn::DataLayout::NHWC, inputShape, input, blockShape,
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007957 crops, outputShape, expectedOutput);
7958}
7959
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007960LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test2(
7961 armnn::IWorkloadFactory& workloadFactory,
7962 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007963{
7964 const unsigned int inputShape[] = {4, 1, 1, 1};
7965 const unsigned int outputShape[] = {1, 2, 2, 1};
7966
7967 std::vector<float> input
7968 ({
7969 // Batch 0, Height 0, Width (2) x Channel (1)
7970 1.0f, 2.0f, 3.0f, 4.0f
7971 });
7972
7973 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
7974
7975 std::vector<unsigned int> blockShape({2, 2});
Éanna Ó Catháin95807ce2018-11-12 17:14:43 +00007976 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007977
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007978 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
7979 armnn::DataLayout::NHWC, inputShape, input, blockShape,
7980 crops, outputShape, expectedOutput);
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007981}
7982
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007983LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test3(
7984 armnn::IWorkloadFactory& workloadFactory,
7985 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007986{
7987 const unsigned int inputShape[] = {4, 1, 1, 3};
7988 const unsigned int outputShape[] = {1, 2, 2, 3};
7989
7990 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f });
7991
7992 std::vector<float> expectedOutput({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f });
7993
7994 std::vector<unsigned int> blockShape({2, 2});
Éanna Ó Catháin95807ce2018-11-12 17:14:43 +00007995 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00007996
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00007997 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
7998 armnn::DataLayout::NHWC, inputShape, input, blockShape,
7999 crops, outputShape, expectedOutput);
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00008000}
8001
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00008002LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test1(
8003 armnn::IWorkloadFactory &workloadFactory,
8004 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00008005{
8006 const unsigned int inputShape[] = {4, 3, 1, 1};
8007 const unsigned int outputShape[] = {1, 3, 2, 2};
8008
8009 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f });
8010
8011 std::vector<float> expectedOutput
8012 ({
8013 // Batch 0, Channel 0, Height (2) x Width (2)
8014 1.0f, 4.0f,
8015 7.0f, 10.0f,
8016
8017 // Batch 0, Channel 1, Height (2) x Width (2)
8018 2.0f, 5.0f,
8019 8.0f, 11.0f,
8020
8021 // Batch 0, Channel 2, Height (2) x Width (2)
8022 3.0f, 6.0f,
8023 9.0f, 12.0f,
8024 });
8025
8026 std::vector<unsigned int> blockShape({2, 2});
Éanna Ó Catháin95807ce2018-11-12 17:14:43 +00008027 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00008028
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00008029 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
8030 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8031 crops, outputShape, expectedOutput);
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +00008032}
Éanna Ó Catháin262553e2018-11-14 11:26:23 +00008033
Mike Kelly831faed2018-11-28 11:52:08 +00008034LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test2(
8035 armnn::IWorkloadFactory& workloadFactory,
8036 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8037{
8038 const unsigned int inputShape[] = {4, 1, 1, 1};
8039 const unsigned int outputShape[] = {1, 1, 2, 2};
8040
8041 std::vector<float> input
8042 ({
8043 // Batch 0, Height 0, Width (2) x Channel (1)
8044 1.0f, 2.0f, 3.0f, 4.0f
8045 });
8046
8047 std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f});
8048
8049 std::vector<unsigned int> blockShape({2, 2});
8050 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8051
8052 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
8053 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8054 crops, outputShape, expectedOutput);
8055}
8056
8057LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test3(
8058 armnn::IWorkloadFactory& workloadFactory,
8059 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8060{
8061 const unsigned int inputShape[] = {4, 3, 1, 1};
8062 const unsigned int outputShape[] = {1, 3, 2, 2};
8063
8064 std::vector<float> input({ 1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f });
8065
8066 std::vector<float> expectedOutput
8067 ({
8068 // Batch 0, Channel 0, Height (2) x Width (2)
8069 1.0f, 7.0f,
8070 2.0f, 8.0f,
8071
8072 // Batch 0, Channel 1, Height (2) x Width (2)
8073 3.0f, 9.0f,
8074 4.0f, 10.0f,
8075
8076 // Batch 0, Channel 2, Height (2) x Width (2)
8077 5.0f, 11.0f,
8078 6.0f, 12.0f,
8079 });
8080
8081 std::vector<unsigned int> blockShape({2, 2});
8082 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8083
8084 return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager,
8085 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8086 crops, outputShape, expectedOutput);
8087}
Éanna Ó Catháin262553e2018-11-14 11:26:23 +00008088
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00008089LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest1(
8090 armnn::IWorkloadFactory& workloadFactory,
8091 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
Éanna Ó Catháin262553e2018-11-14 11:26:23 +00008092{
8093 const unsigned int inputShape[] = {4, 2, 2, 1};
8094 const unsigned int outputShape[] = {1, 4, 4, 1};
8095
8096 std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });
8097 std::vector<uint8_t> expectedOutput({ 1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16});
8098
8099 std::vector<unsigned int> blockShape({2, 2});
8100 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8101
Matteo Martincigha65b7ae2018-11-14 12:39:55 +00008102 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, armnn::DataLayout::NHWC, inputShape,
8103 input, blockShape, crops, outputShape, expectedOutput);
Aron Virginas-Tar5caf9072018-11-14 18:35:18 +00008104}
Nattapat Chaimanowong1216b582018-11-23 15:33:41 +00008105
8106LayerTestResult<float, 4> StridedSlice4DFloat32Test(
8107 armnn::IWorkloadFactory& workloadFactory,
8108 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8109{
8110 return StridedSlice4DTest<float>(workloadFactory, memoryManager);
8111}
8112
8113LayerTestResult<float, 4> StridedSlice4DReverseFloat32Test(
8114 armnn::IWorkloadFactory& workloadFactory,
8115 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8116{
8117 return StridedSlice4DReverseTest<float>(workloadFactory, memoryManager);
8118}
8119
8120LayerTestResult<float, 4> StridedSliceSimpleStrideFloat32Test(
8121 armnn::IWorkloadFactory& workloadFactory,
8122 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8123{
8124 return StridedSliceSimpleStrideTest<float>(workloadFactory, memoryManager);
8125}
8126
8127LayerTestResult<float, 4> StridedSliceSimpleRangeMaskFloat32Test(
8128 armnn::IWorkloadFactory& workloadFactory,
8129 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8130{
8131 return StridedSliceSimpleRangeMaskTest<float>(workloadFactory, memoryManager);
8132}
8133
8134LayerTestResult<float, 2> StridedSliceShrinkAxisMaskFloat32Test(
8135 armnn::IWorkloadFactory& workloadFactory,
8136 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8137{
8138 return StridedSliceShrinkAxisMaskTest<float>(workloadFactory, memoryManager);
8139}
8140
8141LayerTestResult<float, 3> StridedSlice3DFloat32Test(
8142 armnn::IWorkloadFactory& workloadFactory,
8143 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8144{
8145 return StridedSlice3DTest<float>(workloadFactory, memoryManager);
8146}
8147
8148LayerTestResult<float, 3> StridedSlice3DReverseFloat32Test(
8149 armnn::IWorkloadFactory& workloadFactory,
8150 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8151{
8152 return StridedSlice3DReverseTest<float>(workloadFactory, memoryManager);
8153}
8154
8155LayerTestResult<float, 2> StridedSlice2DFloat32Test(
8156 armnn::IWorkloadFactory& workloadFactory,
8157 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8158{
8159 return StridedSlice2DTest<float>(workloadFactory, memoryManager);
8160}
8161
8162LayerTestResult<float, 2> StridedSlice2DReverseFloat32Test(
8163 armnn::IWorkloadFactory& workloadFactory,
8164 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8165{
8166 return StridedSlice2DReverseTest<float>(workloadFactory, memoryManager);
8167}
8168
8169LayerTestResult<uint8_t, 4> StridedSlice4DUint8Test(
8170 armnn::IWorkloadFactory& workloadFactory,
8171 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8172{
8173 return StridedSlice4DTest<uint8_t>(workloadFactory, memoryManager);
8174}
8175
8176LayerTestResult<uint8_t, 4> StridedSlice4DReverseUint8Test(
8177 armnn::IWorkloadFactory& workloadFactory,
8178 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8179{
8180 return StridedSlice4DReverseTest<uint8_t>(workloadFactory, memoryManager);
8181}
8182
8183LayerTestResult<uint8_t, 4> StridedSliceSimpleStrideUint8Test(
8184 armnn::IWorkloadFactory& workloadFactory,
8185 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8186{
8187 return StridedSliceSimpleStrideTest<uint8_t>(workloadFactory, memoryManager);
8188}
8189
8190LayerTestResult<uint8_t, 4> StridedSliceSimpleRangeMaskUint8Test(
8191 armnn::IWorkloadFactory& workloadFactory,
8192 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8193{
8194 return StridedSliceSimpleRangeMaskTest<uint8_t>(workloadFactory, memoryManager);
8195}
8196
8197LayerTestResult<uint8_t, 2> StridedSliceShrinkAxisMaskUint8Test(
8198 armnn::IWorkloadFactory& workloadFactory,
8199 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8200{
8201 return StridedSliceShrinkAxisMaskTest<uint8_t>(workloadFactory, memoryManager);
8202}
8203
8204LayerTestResult<uint8_t, 3> StridedSlice3DUint8Test(
8205 armnn::IWorkloadFactory& workloadFactory,
8206 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8207{
8208 return StridedSlice3DTest<uint8_t>(workloadFactory, memoryManager);
8209}
8210
8211LayerTestResult<uint8_t, 3> StridedSlice3DReverseUint8Test(
8212 armnn::IWorkloadFactory& workloadFactory,
8213 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8214{
8215 return StridedSlice3DReverseTest<uint8_t>(workloadFactory, memoryManager);
8216}
8217
8218LayerTestResult<uint8_t, 2> StridedSlice2DUint8Test(
8219 armnn::IWorkloadFactory& workloadFactory,
8220 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8221{
8222 return StridedSlice2DTest<uint8_t>(workloadFactory, memoryManager);
8223}
8224
8225LayerTestResult<uint8_t, 2> StridedSlice2DReverseUint8Test(
8226 armnn::IWorkloadFactory& workloadFactory,
8227 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8228{
8229 return StridedSlice2DReverseTest<uint8_t>(workloadFactory, memoryManager);
8230}
Mike Kelly831faed2018-11-28 11:52:08 +00008231LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest2(
8232 armnn::IWorkloadFactory& workloadFactory,
8233 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8234{
8235 const unsigned int inputShape[] = {4, 1, 1, 1};
8236 const unsigned int outputShape[] = {1, 2, 2, 1};
8237
8238 std::vector<uint8_t> input
8239 ({
8240 // Batch 0, Height 0, Width (2) x Channel (1)
8241 1, 2, 3, 4
8242 });
8243
8244 std::vector<uint8_t> expectedOutput({1, 2, 3, 4});
8245
8246 std::vector<unsigned int> blockShape({2, 2});
8247 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8248
8249 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
8250 armnn::DataLayout::NHWC, inputShape, input, blockShape,
8251 crops, outputShape, expectedOutput);
8252}
8253
8254LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest3(
8255 armnn::IWorkloadFactory& workloadFactory,
8256 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8257{
8258 const unsigned int inputShape[] = {4, 1, 1, 3};
8259 const unsigned int outputShape[] = {1, 2, 2, 3};
8260
8261 std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
8262
8263 std::vector<uint8_t> expectedOutput({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
8264
8265 std::vector<unsigned int> blockShape({2, 2});
8266 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8267
8268 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
8269 armnn::DataLayout::NHWC, inputShape, input, blockShape,
8270 crops, outputShape, expectedOutput);
8271}
8272
8273
8274LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest1(
8275 armnn::IWorkloadFactory &workloadFactory,
8276 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8277{
8278 const unsigned int inputShape[] = {4, 3, 1, 1};
8279 const unsigned int outputShape[] = {1, 3, 2, 2};
8280
8281 std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
8282
8283 std::vector<uint8_t> expectedOutput
8284 ({
8285 // Batch 0, Channel 0, Height (2) x Width (2)
8286 1, 4,
8287 7, 10,
8288
8289 // Batch 0, Channel 1, Height (2) x Width (2)
8290 2, 5,
8291 8, 11,
8292
8293 // Batch 0, Channel 2, Height (2) x Width (2)
8294 3, 6,
8295 9, 12,
8296 });
8297
8298 std::vector<unsigned int> blockShape({2, 2});
8299 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8300
8301 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
8302 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8303 crops, outputShape, expectedOutput);
8304}
8305
8306LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest2(
8307 armnn::IWorkloadFactory& workloadFactory,
8308 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8309{
8310 const unsigned int inputShape[] = {4, 1, 1, 1};
8311 const unsigned int outputShape[] = {1, 1, 2, 2};
8312
8313 std::vector<uint8_t> input
8314 ({
8315 // Batch 0, Height 0, Width (2) x Channel (1)
8316 1, 2, 3, 4
8317 });
8318
8319 std::vector<uint8_t> expectedOutput({1, 2, 3, 4});
8320
8321 std::vector<unsigned int> blockShape({2, 2});
8322 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8323
8324 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
8325 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8326 crops, outputShape, expectedOutput);
8327}
8328
8329LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest3(
8330 armnn::IWorkloadFactory& workloadFactory,
8331 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8332{
8333 const unsigned int inputShape[] = {4, 3, 1, 1};
8334 const unsigned int outputShape[] = {1, 3, 2, 2};
8335
8336 std::vector<uint8_t> input({ 1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12 });
8337
8338 std::vector<uint8_t> expectedOutput
8339 ({
8340 // Batch 0, Channel 0, Height (2) x Width (2)
8341 1, 7,
8342 2, 8,
8343
8344 // Batch 0, Channel 1, Height (2) x Width (2)
8345 3, 9,
8346 4, 10,
8347
8348 // Batch 0, Channel 2, Height (2) x Width (2)
8349 5, 11,
8350 6, 12,
8351 });
8352 std::vector<unsigned int> blockShape({2, 2});
8353 std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}};
8354
8355 return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager,
8356 armnn::DataLayout::NCHW, inputShape, input, blockShape,
8357 crops, outputShape, expectedOutput);
Nattapat Chaimanowongcfdcadf2018-12-06 11:54:33 +00008358}
8359
8360LayerTestResult<float, 4> Debug4DFloat32Test(
8361 armnn::IWorkloadFactory& workloadFactory,
8362 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8363{
8364 return Debug4DTest<float>(workloadFactory, memoryManager);
8365}
8366
8367LayerTestResult<float, 3> Debug3DFloat32Test(
8368 armnn::IWorkloadFactory& workloadFactory,
8369 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8370{
8371 return Debug3DTest<float>(workloadFactory, memoryManager);
8372}
8373
8374LayerTestResult<float, 2> Debug2DFloat32Test(
8375 armnn::IWorkloadFactory& workloadFactory,
8376 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8377{
8378 return Debug2DTest<float>(workloadFactory, memoryManager);
8379}
8380
8381LayerTestResult<float, 1> Debug1DFloat32Test(
8382 armnn::IWorkloadFactory& workloadFactory,
8383 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8384{
8385 return Debug1DTest<float>(workloadFactory, memoryManager);
8386}
8387
8388LayerTestResult<uint8_t, 4> Debug4DUint8Test(
8389 armnn::IWorkloadFactory& workloadFactory,
8390 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8391{
8392 return Debug4DTest<uint8_t>(workloadFactory, memoryManager);
8393}
8394
8395LayerTestResult<uint8_t, 3> Debug3DUint8Test(
8396 armnn::IWorkloadFactory& workloadFactory,
8397 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8398{
8399 return Debug3DTest<uint8_t>(workloadFactory, memoryManager);
8400}
8401
8402LayerTestResult<uint8_t, 2> Debug2DUint8Test(
8403 armnn::IWorkloadFactory& workloadFactory,
8404 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8405{
8406 return Debug2DTest<uint8_t>(workloadFactory, memoryManager);
8407}
8408
8409LayerTestResult<uint8_t, 1> Debug1DUint8Test(
8410 armnn::IWorkloadFactory& workloadFactory,
8411 const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager)
8412{
8413 return Debug1DTest<uint8_t>(workloadFactory, memoryManager);
8414}