IVGCVSW-4444 Adding Elu end to end test
[platform/upstream/armnn.git] / src / backends / neon / test / NeonEndToEndTests.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include <backendsCommon/test/EndToEndTestImpl.hpp>
7
8 #include <backendsCommon/test/ActivationEndToEndTestImpl.hpp>
9 #include <backendsCommon/test/ArgMinMaxEndToEndTestImpl.hpp>
10 #include <backendsCommon/test/ComparisonEndToEndTestImpl.hpp>
11 #include <backendsCommon/test/ConcatEndToEndTestImpl.hpp>
12 #include <backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp>
13 #include <backendsCommon/test/DequantizeEndToEndTestImpl.hpp>
14 #include <backendsCommon/test/DetectionPostProcessEndToEndTestImpl.hpp>
15 #include <backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp>
16 #include <backendsCommon/test/InstanceNormalizationEndToEndTestImpl.hpp>
17 #include <backendsCommon/test/PreluEndToEndTestImpl.hpp>
18 #include <backendsCommon/test/QuantizedLstmEndToEndTestImpl.hpp>
19 #include <backendsCommon/test/SpaceToDepthEndToEndTestImpl.hpp>
20 #include <backendsCommon/test/SplitterEndToEndTestImpl.hpp>
21 #include <backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp>
22
23 #include <boost/test/unit_test.hpp>
24
25 BOOST_AUTO_TEST_SUITE(NeonEndToEnd)
26
27 std::vector<armnn::BackendId> defaultBackends = {armnn::Compute::CpuAcc};
28
29 // Abs
30 BOOST_AUTO_TEST_CASE(NeonAbsEndToEndTestFloat32)
31 {
32     std::vector<float> expectedOutput =
33     {
34         1.f, 1.f, 1.f, 1.f, 5.f, 5.f, 5.f, 5.f,
35         3.f, 3.f, 3.f, 3.f, 4.f, 4.f, 4.f, 4.f
36     };
37
38     ElementwiseUnarySimpleEndToEnd<armnn::DataType::Float32>(defaultBackends,
39                                                              UnaryOperation::Abs,
40                                                              expectedOutput);
41 }
42
43 // Constant
44 BOOST_AUTO_TEST_CASE(ConstantUsage_Neon_Float32)
45 {
46     BOOST_TEST(ConstantUsageFloat32Test(defaultBackends));
47 }
48
49 #if defined(ARMNNREF_ENABLED)
50
51 // This test unit needs the reference backend, it's not available if the reference backend is not built
52
53 BOOST_AUTO_TEST_CASE(FallbackToCpuRef)
54 {
55     using namespace armnn;
56
57     // Create runtime in which test will run and allow fallback to CpuRef.
58     IRuntime::CreationOptions options;
59     IRuntimePtr runtime(IRuntime::Create(options));
60
61     // Builds up the structure of the network.
62     INetworkPtr net(INetwork::Create());
63
64     IConnectableLayer* input = net->AddInputLayer(0);
65
66     // This layer configuration isn't supported by CpuAcc but we allow fallback to CpuRef so it shoud pass.
67     NormalizationDescriptor descriptor;
68     IConnectableLayer* pooling = net->AddNormalizationLayer(descriptor);
69
70     IConnectableLayer* output = net->AddOutputLayer(0);
71
72     input->GetOutputSlot(0).Connect(pooling->GetInputSlot(0));
73     pooling->GetOutputSlot(0).Connect(output->GetInputSlot(0));
74
75     input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
76     pooling->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
77
78     // optimize the network
79     std::vector<BackendId> backends = {Compute::CpuAcc, Compute::CpuRef};
80     IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
81
82     // Load it into the runtime. It should pass.
83     NetworkId netId;
84     BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success);
85 }
86
87 #endif
88
89 BOOST_AUTO_TEST_CASE(NeonGreaterSimpleEndToEndTest)
90 {
91     const std::vector<uint8_t> expectedOutput({ 0, 0, 0, 0,  1, 1, 1, 1,
92                                                 0, 0, 0, 0,  0, 0, 0, 0 });
93
94     ComparisonSimpleEndToEnd<armnn::DataType::Float32>(defaultBackends,
95                                                        ComparisonOperation::Greater,
96                                                        expectedOutput);
97 }
98
99 BOOST_AUTO_TEST_CASE(NeonGreaterSimpleEndToEndUint8Test)
100 {
101     const std::vector<uint8_t> expectedOutput({ 0, 0, 0, 0,  1, 1, 1, 1,
102                                                 0, 0, 0, 0,  0, 0, 0, 0 });
103
104     ComparisonSimpleEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends,
105                                                                ComparisonOperation::Greater,
106                                                                expectedOutput);
107 }
108
109 BOOST_AUTO_TEST_CASE(NeonGreaterBroadcastEndToEndTest)
110 {
111     const std::vector<uint8_t> expectedOutput({ 0, 1, 0, 0, 0, 1,
112                                                 1, 1, 1, 1, 1, 1 });
113
114     ComparisonBroadcastEndToEnd<armnn::DataType::Float32>(defaultBackends,
115                                                           ComparisonOperation::Greater,
116                                                           expectedOutput);
117 }
118
119 BOOST_AUTO_TEST_CASE(NeonGreaterBroadcastEndToEndUint8Test)
120 {
121     const std::vector<uint8_t> expectedOutput({ 0, 1, 0, 0, 0, 1,
122                                                 1, 1, 1, 1, 1, 1 });
123
124     ComparisonBroadcastEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends,
125                                                                   ComparisonOperation::Greater,
126                                                                   expectedOutput);
127 }
128
129 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim0Test)
130 {
131     ConcatDim0EndToEnd<armnn::DataType::Float32>(defaultBackends);
132 }
133
134 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim0Uint8Test)
135 {
136     ConcatDim0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
137 }
138
139 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim1Test)
140 {
141     ConcatDim1EndToEnd<armnn::DataType::Float32>(defaultBackends);
142 }
143
144 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim1Uint8Test)
145 {
146     ConcatDim1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
147 }
148
149 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim3Test)
150 {
151     ConcatDim3EndToEnd<armnn::DataType::Float32>(defaultBackends);
152 }
153
154 BOOST_AUTO_TEST_CASE(NeonConcatEndToEndDim3Uint8Test)
155 {
156     ConcatDim3EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
157 }
158
159 // DepthToSpace
160 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNchwFloat32)
161 {
162     DepthToSpaceEndToEnd<armnn::DataType::Float32>(defaultBackends, armnn::DataLayout::NCHW);
163 }
164
165 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNchwFloat16)
166 {
167     DepthToSpaceEndToEnd<armnn::DataType::Float16>(defaultBackends, armnn::DataLayout::NCHW);
168 }
169
170 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNchwUint8)
171 {
172     DepthToSpaceEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends, armnn::DataLayout::NCHW);
173 }
174
175 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNchwInt16)
176 {
177     DepthToSpaceEndToEnd<armnn::DataType::QSymmS16>(defaultBackends, armnn::DataLayout::NCHW);
178 }
179
180 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNhwcFloat32)
181 {
182     DepthToSpaceEndToEnd<armnn::DataType::Float32>(defaultBackends, armnn::DataLayout::NHWC);
183 }
184
185 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNhwcFloat16)
186 {
187     DepthToSpaceEndToEnd<armnn::DataType::Float16>(defaultBackends, armnn::DataLayout::NHWC);
188 }
189
190 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNhwcUint8)
191 {
192     DepthToSpaceEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends, armnn::DataLayout::NHWC);
193 }
194
195 BOOST_AUTO_TEST_CASE(DephtToSpaceEndToEndNhwcInt16)
196 {
197     DepthToSpaceEndToEnd<armnn::DataType::QSymmS16>(defaultBackends, armnn::DataLayout::NHWC);
198 }
199
200 // Dequantize
201 BOOST_AUTO_TEST_CASE(DequantizeEndToEndSimpleTest)
202 {
203     DequantizeEndToEndSimple<armnn::DataType::QAsymmU8>(defaultBackends);
204 }
205
206 BOOST_AUTO_TEST_CASE(DequantizeEndToEndOffsetTest)
207 {
208     DequantizeEndToEndOffset<armnn::DataType::QAsymmU8>(defaultBackends);
209 }
210
211 BOOST_AUTO_TEST_CASE(NeonEluEndToEndTestFloat32)
212 {
213     EluEndToEndTest<armnn::DataType::Float32>(defaultBackends);
214 }
215
216 BOOST_AUTO_TEST_CASE(NeonEluEndToEndTestFloat16)
217 {
218     EluEndToEndTest<armnn::DataType::Float16>(defaultBackends);
219 }
220
221 BOOST_AUTO_TEST_CASE(NeonPreluEndToEndFloat32Test)
222 {
223     PreluEndToEndNegativeTest<armnn::DataType::Float32>(defaultBackends);
224 }
225
226 BOOST_AUTO_TEST_CASE(NeonPreluEndToEndTestUint8Test)
227 {
228     PreluEndToEndPositiveTest<armnn::DataType::QAsymmU8>(defaultBackends);
229 }
230
231 BOOST_AUTO_TEST_CASE(NeonSpaceToDepthNhwcEndToEndTest1)
232 {
233     SpaceToDepthNhwcEndToEndTest1(defaultBackends);
234 }
235
236 BOOST_AUTO_TEST_CASE(NeonSpaceToDepthNchwEndToEndTest1)
237 {
238     SpaceToDepthNchwEndToEndTest1(defaultBackends);
239 }
240
241 BOOST_AUTO_TEST_CASE(NeonSpaceToDepthNhwcEndToEndTest2)
242 {
243     SpaceToDepthNhwcEndToEndTest2(defaultBackends);
244 }
245
246 BOOST_AUTO_TEST_CASE(NeonSpaceToDepthNchwEndToEndTest2)
247 {
248     SpaceToDepthNchwEndToEndTest2(defaultBackends);
249 }
250
251 BOOST_AUTO_TEST_CASE(NeonSplitter1dEndToEndTest)
252 {
253     Splitter1dEndToEnd<armnn::DataType::Float32>(defaultBackends);
254 }
255
256 BOOST_AUTO_TEST_CASE(NeonSplitter1dEndToEndUint8Test)
257 {
258     Splitter1dEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
259 }
260
261 BOOST_AUTO_TEST_CASE(NeonSplitter2dDim0EndToEndTest)
262 {
263     Splitter2dDim0EndToEnd<armnn::DataType::Float32>(defaultBackends);
264 }
265
266 BOOST_AUTO_TEST_CASE(NeonSplitter2dDim1EndToEndTest)
267 {
268     Splitter2dDim1EndToEnd<armnn::DataType::Float32>(defaultBackends);
269 }
270
271 BOOST_AUTO_TEST_CASE(NeonSplitter2dDim0EndToEndUint8Test)
272 {
273     Splitter2dDim0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
274 }
275
276 BOOST_AUTO_TEST_CASE(NeonSplitter2dDim1EndToEndUint8Test)
277 {
278     Splitter2dDim1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
279 }
280
281 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim0EndToEndTest)
282 {
283     Splitter3dDim0EndToEnd<armnn::DataType::Float32>(defaultBackends);
284 }
285
286 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim1EndToEndTest)
287 {
288     Splitter3dDim1EndToEnd<armnn::DataType::Float32>(defaultBackends);
289 }
290
291 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim2EndToEndTest)
292 {
293     Splitter3dDim2EndToEnd<armnn::DataType::Float32>(defaultBackends);
294 }
295
296 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim0EndToEndUint8Test)
297 {
298     Splitter3dDim0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
299 }
300
301 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim1EndToEndUint8Test)
302 {
303     Splitter3dDim1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
304 }
305
306 BOOST_AUTO_TEST_CASE(NeonSplitter3dDim2EndToEndUint8Test)
307 {
308     Splitter3dDim2EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
309 }
310
311 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim0EndToEndTest)
312 {
313     Splitter4dDim0EndToEnd<armnn::DataType::Float32>(defaultBackends);
314 }
315
316 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim1EndToEndTest)
317 {
318     Splitter4dDim1EndToEnd<armnn::DataType::Float32>(defaultBackends);
319 }
320
321 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim2EndToEndTest)
322 {
323     Splitter4dDim2EndToEnd<armnn::DataType::Float32>(defaultBackends);
324 }
325
326 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim3EndToEndTest)
327 {
328     Splitter4dDim3EndToEnd<armnn::DataType::Float32>(defaultBackends);
329 }
330
331 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim0EndToEndUint8Test)
332 {
333     Splitter4dDim0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
334 }
335
336 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim1EndToEndUint8Test)
337 {
338     Splitter4dDim1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
339 }
340
341 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim2EndToEndUint8Test)
342 {
343     Splitter4dDim2EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
344 }
345
346 BOOST_AUTO_TEST_CASE(NeonSplitter4dDim3EndToEndUint8Test)
347 {
348     Splitter4dDim3EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
349 }
350
351 BOOST_AUTO_TEST_CASE(NeonQuantizedLstmEndToEndTest)
352 {
353     QuantizedLstmEndToEnd(defaultBackends);
354 }
355
356 BOOST_AUTO_TEST_CASE(NeonTransposeConvolution2dEndToEndFloatNchwTest)
357 {
358     TransposeConvolution2dEndToEnd<armnn::DataType::Float32, armnn::DataType::Float32>(
359         defaultBackends, armnn::DataLayout::NCHW);
360 }
361
362 BOOST_AUTO_TEST_CASE(NeonTransposeConvolution2dEndToEndUint8NchwTest)
363 {
364     TransposeConvolution2dEndToEnd<armnn::DataType::QAsymmU8, armnn::DataType::Signed32>(
365         defaultBackends, armnn::DataLayout::NCHW);
366 }
367
368 BOOST_AUTO_TEST_CASE(NeonTransposeConvolution2dEndToEndFloatNhwcTest)
369 {
370     TransposeConvolution2dEndToEnd<armnn::DataType::Float32, armnn::DataType::Float32>(
371         defaultBackends, armnn::DataLayout::NHWC);
372 }
373
374 BOOST_AUTO_TEST_CASE(NeonTransposeConvolution2dEndToEndUint8NhwcTest)
375 {
376     TransposeConvolution2dEndToEnd<armnn::DataType::QAsymmU8, armnn::DataType::Signed32>(
377         defaultBackends, armnn::DataLayout::NHWC);
378 }
379
380 BOOST_AUTO_TEST_CASE(NeonImportNonAlignedInputPointerTest)
381 {
382     ImportNonAlignedInputPointerTest(defaultBackends);
383 }
384
385 BOOST_AUTO_TEST_CASE(NeonExportNonAlignedOutputPointerTest)
386 {
387     ExportNonAlignedOutputPointerTest(defaultBackends);
388 }
389
390 BOOST_AUTO_TEST_CASE(NeonImportAlignedPointerTest, * boost::unit_test::disabled())
391 {
392     ImportAlignedPointerTest(defaultBackends);
393 }
394
395 BOOST_AUTO_TEST_CASE(NeonImportOnlyWorkload, * boost::unit_test::disabled())
396 {
397     ImportOnlyWorkload(defaultBackends);
398 }
399
400 BOOST_AUTO_TEST_CASE(NeonExportOnlyWorkload, * boost::unit_test::disabled())
401 {
402     ExportOnlyWorkload(defaultBackends);
403 }
404
405 BOOST_AUTO_TEST_CASE(NeonImportAndExportWorkload, * boost::unit_test::disabled())
406 {
407     ImportAndExportWorkload(defaultBackends);
408 }
409
410 BOOST_AUTO_TEST_CASE(NeonExportOutputWithSeveralOutputSlotConnectionsTest, * boost::unit_test::disabled())
411 {
412     ExportOutputWithSeveralOutputSlotConnectionsTest(defaultBackends);
413 }
414
415 // InstanceNormalization
416 BOOST_AUTO_TEST_CASE(NeonInstanceNormalizationNchwEndToEndTest1)
417 {
418     InstanceNormalizationNchwEndToEndTest1(defaultBackends);
419 }
420
421 BOOST_AUTO_TEST_CASE(NeonInstanceNormalizationNchwEndToEndTest2)
422 {
423     InstanceNormalizationNchwEndToEndTest2(defaultBackends);
424 }
425
426 // ArgMinMax
427 BOOST_AUTO_TEST_CASE(NeonArgMaxSimpleTest)
428 {
429     ArgMaxEndToEndSimple<armnn::DataType::Float32>(defaultBackends);
430 }
431
432 BOOST_AUTO_TEST_CASE(NeonArgMinSimpleTest)
433 {
434     ArgMinEndToEndSimple<armnn::DataType::Float32>(defaultBackends);
435 }
436
437 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis0Test)
438 {
439     ArgMaxAxis0EndToEnd<armnn::DataType::Float32>(defaultBackends);
440 }
441
442 BOOST_AUTO_TEST_CASE(NeonArgMinAxis0Test)
443 {
444     ArgMinAxis0EndToEnd<armnn::DataType::Float32>(defaultBackends);
445 }
446
447 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis1Test)
448 {
449     ArgMaxAxis1EndToEnd<armnn::DataType::Float32>(defaultBackends);
450 }
451
452 BOOST_AUTO_TEST_CASE(NeonArgMinAxis1Test)
453 {
454     ArgMinAxis1EndToEnd<armnn::DataType::Float32>(defaultBackends);
455 }
456
457 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis2Test)
458 {
459     ArgMaxAxis2EndToEnd<armnn::DataType::Float32>(defaultBackends);
460 }
461
462 BOOST_AUTO_TEST_CASE(NeonArgMinAxis2Test)
463 {
464     ArgMinAxis2EndToEnd<armnn::DataType::Float32>(defaultBackends);
465 }
466
467 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis3Test)
468 {
469     ArgMaxAxis3EndToEnd<armnn::DataType::Float32>(defaultBackends);
470 }
471
472 BOOST_AUTO_TEST_CASE(NeonArgMinAxis3Test)
473 {
474     ArgMinAxis3EndToEnd<armnn::DataType::Float32>(defaultBackends);
475 }
476
477 BOOST_AUTO_TEST_CASE(NeonArgMaxSimpleTestQuantisedAsymm8)
478 {
479     ArgMaxEndToEndSimple<armnn::DataType::QAsymmU8>(defaultBackends);
480 }
481
482 BOOST_AUTO_TEST_CASE(NeonArgMinSimpleTestQuantisedAsymm8)
483 {
484     ArgMinEndToEndSimple<armnn::DataType::QAsymmU8>(defaultBackends);
485 }
486
487 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis0TestQuantisedAsymm8)
488 {
489     ArgMaxAxis0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
490 }
491
492 BOOST_AUTO_TEST_CASE(NeonArgMinAxis0TestQuantisedAsymm8)
493 {
494     ArgMinAxis0EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
495 }
496
497 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis1TestQuantisedAsymm8)
498 {
499     ArgMaxAxis1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
500 }
501
502 BOOST_AUTO_TEST_CASE(NeonArgMinAxis1TestQuantisedAsymm8)
503 {
504     ArgMinAxis1EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
505 }
506
507 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis2TestQuantisedAsymm8)
508 {
509     ArgMaxAxis2EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
510 }
511
512 BOOST_AUTO_TEST_CASE(NeonArgMinAxis2TestQuantisedAsymm8)
513 {
514     ArgMinAxis2EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
515 }
516
517 BOOST_AUTO_TEST_CASE(NeonArgMaxAxis3TestQuantisedAsymm8)
518 {
519     ArgMaxAxis3EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
520 }
521
522 BOOST_AUTO_TEST_CASE(NeonArgMinAxis3TestQuantisedAsymm8)
523 {
524     ArgMinAxis3EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
525 }
526
527 BOOST_AUTO_TEST_CASE(NeonStridedSliceInvalidSliceEndToEndTest)
528 {
529     StridedSliceInvalidSliceEndToEndTest(defaultBackends);
530 }
531
532 BOOST_AUTO_TEST_CASE(NeonDetectionPostProcessRegularNmsTest, * boost::unit_test::disabled())
533 {
534     std::vector<float> boxEncodings({
535                                         0.0f, 0.0f, 0.0f, 0.0f,
536                                         0.0f, 1.0f, 0.0f, 0.0f,
537                                         0.0f, -1.0f, 0.0f, 0.0f,
538                                         0.0f, 0.0f, 0.0f, 0.0f,
539                                         0.0f, 1.0f, 0.0f, 0.0f,
540                                         0.0f, 0.0f, 0.0f, 0.0f
541                                     });
542     std::vector<float> scores({
543                                   0.0f, 0.9f, 0.8f,
544                                   0.0f, 0.75f, 0.72f,
545                                   0.0f, 0.6f, 0.5f,
546                                   0.0f, 0.93f, 0.95f,
547                                   0.0f, 0.5f, 0.4f,
548                                   0.0f, 0.3f, 0.2f
549                               });
550     std::vector<float> anchors({
551                                    0.5f, 0.5f, 1.0f, 1.0f,
552                                    0.5f, 0.5f, 1.0f, 1.0f,
553                                    0.5f, 0.5f, 1.0f, 1.0f,
554                                    0.5f, 10.5f, 1.0f, 1.0f,
555                                    0.5f, 10.5f, 1.0f, 1.0f,
556                                    0.5f, 100.5f, 1.0f, 1.0f
557                                });
558     DetectionPostProcessRegularNmsEndToEnd<armnn::DataType::Float32>(defaultBackends, boxEncodings, scores, anchors);
559 }
560
561 inline void QuantizeData(uint8_t* quant, const float* dequant, const TensorInfo& info)
562 {
563     for (size_t i = 0; i < info.GetNumElements(); i++)
564     {
565         quant[i] = armnn::Quantize<uint8_t>(dequant[i], info.GetQuantizationScale(), info.GetQuantizationOffset());
566     }
567 }
568
569 BOOST_AUTO_TEST_CASE(NeonDetectionPostProcessRegularNmsUint8Test, * boost::unit_test::disabled())
570 {
571     armnn::TensorInfo boxEncodingsInfo({ 1, 6, 4 }, armnn::DataType::Float32);
572     armnn::TensorInfo scoresInfo({ 1, 6, 3 }, armnn::DataType::Float32);
573     armnn::TensorInfo anchorsInfo({ 6, 4 }, armnn::DataType::Float32);
574
575     boxEncodingsInfo.SetQuantizationScale(1.0f);
576     boxEncodingsInfo.SetQuantizationOffset(1);
577     scoresInfo.SetQuantizationScale(0.01f);
578     scoresInfo.SetQuantizationOffset(0);
579     anchorsInfo.SetQuantizationScale(0.5f);
580     anchorsInfo.SetQuantizationOffset(0);
581
582     std::vector<float> boxEncodings({
583                                         0.0f, 0.0f, 0.0f, 0.0f,
584                                         0.0f, 1.0f, 0.0f, 0.0f,
585                                         0.0f, -1.0f, 0.0f, 0.0f,
586                                         0.0f, 0.0f, 0.0f, 0.0f,
587                                         0.0f, 1.0f, 0.0f, 0.0f,
588                                         0.0f, 0.0f, 0.0f, 0.0f
589                                     });
590     std::vector<float> scores({
591                                   0.0f, 0.9f, 0.8f,
592                                   0.0f, 0.75f, 0.72f,
593                                   0.0f, 0.6f, 0.5f,
594                                   0.0f, 0.93f, 0.95f,
595                                   0.0f, 0.5f, 0.4f,
596                                   0.0f, 0.3f, 0.2f
597                               });
598     std::vector<float> anchors({
599                                    0.5f, 0.5f, 1.0f, 1.0f,
600                                    0.5f, 0.5f, 1.0f, 1.0f,
601                                    0.5f, 0.5f, 1.0f, 1.0f,
602                                    0.5f, 10.5f, 1.0f, 1.0f,
603                                    0.5f, 10.5f, 1.0f, 1.0f,
604                                    0.5f, 100.5f, 1.0f, 1.0f
605                                });
606
607     std::vector<uint8_t> qBoxEncodings(boxEncodings.size(), 0);
608     std::vector<uint8_t> qScores(scores.size(), 0);
609     std::vector<uint8_t> qAnchors(anchors.size(), 0);
610     QuantizeData(qBoxEncodings.data(), boxEncodings.data(), boxEncodingsInfo);
611     QuantizeData(qScores.data(), scores.data(), scoresInfo);
612     QuantizeData(qAnchors.data(), anchors.data(), anchorsInfo);
613     DetectionPostProcessRegularNmsEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends, qBoxEncodings,
614                                                                              qScores, qAnchors,
615                                                                              1.0f, 1, 0.01f, 0, 0.5f, 0);
616 }
617
618 BOOST_AUTO_TEST_CASE(NeonDetectionPostProcessFastNmsTest, * boost::unit_test::disabled())
619 {
620     std::vector<float> boxEncodings({
621                                         0.0f, 0.0f, 0.0f, 0.0f,
622                                         0.0f, 1.0f, 0.0f, 0.0f,
623                                         0.0f, -1.0f, 0.0f, 0.0f,
624                                         0.0f, 0.0f, 0.0f, 0.0f,
625                                         0.0f, 1.0f, 0.0f, 0.0f,
626                                         0.0f, 0.0f, 0.0f, 0.0f
627                                     });
628     std::vector<float> scores({
629                                   0.0f, 0.9f, 0.8f,
630                                   0.0f, 0.75f, 0.72f,
631                                   0.0f, 0.6f, 0.5f,
632                                   0.0f, 0.93f, 0.95f,
633                                   0.0f, 0.5f, 0.4f,
634                                   0.0f, 0.3f, 0.2f
635                               });
636     std::vector<float> anchors({
637                                    0.5f, 0.5f, 1.0f, 1.0f,
638                                    0.5f, 0.5f, 1.0f, 1.0f,
639                                    0.5f, 0.5f, 1.0f, 1.0f,
640                                    0.5f, 10.5f, 1.0f, 1.0f,
641                                    0.5f, 10.5f, 1.0f, 1.0f,
642                                    0.5f, 100.5f, 1.0f, 1.0f
643                                });
644     DetectionPostProcessFastNmsEndToEnd<armnn::DataType::Float32>(defaultBackends, boxEncodings, scores, anchors);
645 }
646
647 BOOST_AUTO_TEST_CASE(NeonDetectionPostProcessFastNmsUint8Test, * boost::unit_test::disabled())
648 {
649     armnn::TensorInfo boxEncodingsInfo({ 1, 6, 4 }, armnn::DataType::Float32);
650     armnn::TensorInfo scoresInfo({ 1, 6, 3 }, armnn::DataType::Float32);
651     armnn::TensorInfo anchorsInfo({ 6, 4 }, armnn::DataType::Float32);
652
653     boxEncodingsInfo.SetQuantizationScale(1.0f);
654     boxEncodingsInfo.SetQuantizationOffset(1);
655     scoresInfo.SetQuantizationScale(0.01f);
656     scoresInfo.SetQuantizationOffset(0);
657     anchorsInfo.SetQuantizationScale(0.5f);
658     anchorsInfo.SetQuantizationOffset(0);
659
660     std::vector<float> boxEncodings({
661                                         0.0f, 0.0f, 0.0f, 0.0f,
662                                         0.0f, 1.0f, 0.0f, 0.0f,
663                                         0.0f, -1.0f, 0.0f, 0.0f,
664                                         0.0f, 0.0f, 0.0f, 0.0f,
665                                         0.0f, 1.0f, 0.0f, 0.0f,
666                                         0.0f, 0.0f, 0.0f, 0.0f
667                                     });
668     std::vector<float> scores({
669                                   0.0f, 0.9f, 0.8f,
670                                   0.0f, 0.75f, 0.72f,
671                                   0.0f, 0.6f, 0.5f,
672                                   0.0f, 0.93f, 0.95f,
673                                   0.0f, 0.5f, 0.4f,
674                                   0.0f, 0.3f, 0.2f
675                               });
676     std::vector<float> anchors({
677                                    0.5f, 0.5f, 1.0f, 1.0f,
678                                    0.5f, 0.5f, 1.0f, 1.0f,
679                                    0.5f, 0.5f, 1.0f, 1.0f,
680                                    0.5f, 10.5f, 1.0f, 1.0f,
681                                    0.5f, 10.5f, 1.0f, 1.0f,
682                                    0.5f, 100.5f, 1.0f, 1.0f
683                                });
684
685     std::vector<uint8_t> qBoxEncodings(boxEncodings.size(), 0);
686     std::vector<uint8_t> qScores(scores.size(), 0);
687     std::vector<uint8_t> qAnchors(anchors.size(), 0);
688     QuantizeData(qBoxEncodings.data(), boxEncodings.data(), boxEncodingsInfo);
689     QuantizeData(qScores.data(), scores.data(), scoresInfo);
690     QuantizeData(qAnchors.data(), anchors.data(), anchorsInfo);
691     DetectionPostProcessFastNmsEndToEnd<armnn::DataType::QAsymmU8>(defaultBackends, qBoxEncodings,
692                                                                           qScores, qAnchors,
693                                                                           1.0f, 1, 0.01f, 0, 0.5f, 0);
694 }
695
696 BOOST_AUTO_TEST_SUITE_END()