IVGCVSW-1946: Remove armnn/src from the include paths
[platform/upstream/armnn.git] / src / backends / neon / test / NeonLayerTests.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include <test/TensorHelpers.hpp>
7 #include <test/UnitTests.hpp>
8
9 #include <backendsCommon/CpuTensorHandle.hpp>
10 #include <neon/NeonLayerSupport.hpp>
11 #include <neon/NeonWorkloadFactory.hpp>
12 #include <reference/RefWorkloadFactory.hpp>
13 #include <backendsCommon/test/ActivationFixture.hpp>
14 #include <backendsCommon/test/LayerTests.hpp>
15 #include <backendsCommon/test/TensorCopyUtils.hpp>
16 #include <backendsCommon/test/WorkloadTestUtils.hpp>
17
18 #include <boost/test/unit_test.hpp>
19
20 BOOST_AUTO_TEST_SUITE(Compute_ArmComputeNeon)
21 using FactoryType = armnn::NeonWorkloadFactory;
22
23 // ============================================================================
24 // UNIT tests
25
26 // Convolution
27 ARMNN_AUTO_TEST_CASE(SimpleConvolution1d, Convolution1dTest, true)
28
29 ARMNN_AUTO_TEST_CASE(SimpleConvolution2d, SimpleConvolution2d3x5Test, true, armnn::DataLayout::NCHW)
30 ARMNN_AUTO_TEST_CASE(SimpleConvolution2dNhwc, SimpleConvolution2d3x5Test, true, armnn::DataLayout::NHWC)
31 ARMNN_AUTO_TEST_CASE(SimpleConvolution2d3x3Uint8, SimpleConvolution2d3x3Uint8Test, true, armnn::DataLayout::NCHW)
32 ARMNN_AUTO_TEST_CASE(SimpleConvolution2d3x3Uint8Nhwc, SimpleConvolution2d3x3Uint8Test, true, armnn::DataLayout::NHWC)
33 ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2d, SimpleConvolution2d3x5Test, false, armnn::DataLayout::NCHW)
34 ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dNhwc, SimpleConvolution2d3x5Test, false, armnn::DataLayout::NHWC)
35
36 ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dSquare, SimpleConvolution2d3x3Test, false, armnn::DataLayout::NCHW)
37 ARMNN_AUTO_TEST_CASE(SimpleConvolution2dAsymmetricPadding, Convolution2dAsymmetricPaddingTest, armnn::DataLayout::NCHW)
38
39 ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dSquareNhwc, SimpleConvolution2d3x3Test, false, armnn::DataLayout::NHWC)
40 ARMNN_AUTO_TEST_CASE(SimpleConvolution2dAsymmetricPaddingNhwc,
41                      Convolution2dAsymmetricPaddingTest,
42                      armnn::DataLayout::NHWC)
43
44 ARMNN_AUTO_TEST_CASE(SimpleConvolution2dSquareNhwc, SimpleConvolution2d3x3NhwcTest, false)
45 namespace
46 {
47
48 armnn::Convolution2dDescriptor MakeConv2dDesc(uint32_t strideX, uint32_t strideY,
49     uint32_t padLeft = 0, uint32_t padRight = 0, uint32_t padTop = 0, uint32_t padBottom = 0)
50 {
51     armnn::Convolution2dDescriptor result;
52     result.m_StrideX = strideX;
53     result.m_StrideY = strideY;
54     result.m_PadLeft = padLeft;
55     result.m_PadRight = padRight;
56     result.m_PadTop = padTop;
57     result.m_PadBottom = padBottom;
58     result.m_BiasEnabled = true;
59     return result;
60 }
61
62 }
63
64 BOOST_AUTO_TEST_CASE(Conv2dUtils)
65 {
66     // The only preferred Neon convolution is 1x1 with padding=0 and stride size {1,2,3}.
67     armnn::TensorShape shape1x1({ 1,1,1,1 });
68     armnn::TensorInfo info1x1(shape1x1, armnn::DataType::Float32);
69     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 1)));
70     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 2)));
71     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 3)));
72     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(2, 1)));
73     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(2, 2)));
74     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(2, 3)));
75     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(3, 1)));
76     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(3, 2)));
77     BOOST_TEST(armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(3, 3)));
78
79     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(4, 1)));
80     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(4, 5)));
81     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(3, 6)));
82
83     // non zero padding is not preferred for direct convolution
84     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 1, 1, 0)));
85     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 1, 0, 1)));
86     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info1x1, MakeConv2dDesc(1, 1, 1, 1)));
87
88     // 2x2 filter not preferred for direct convolution
89     armnn::TensorShape shape2x2({ 1,1,2,2 });
90     armnn::TensorInfo info2x2(shape2x2, armnn::DataType::Float32);
91     BOOST_TEST(!armnn::IsNeonDirectConvolutionPreferred(info2x2, MakeConv2dDesc(1, 1)));
92 }
93
94 // Depthwise Convolution
95 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1,
96                      DepthwiseConvolution2dDepthMul1Test, true, armnn::DataLayout::NCHW)
97 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1,
98                      DepthwiseConvolution2dDepthMul1Test, false, armnn::DataLayout::NCHW)
99 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1Uint8,
100                      DepthwiseConvolution2dDepthMul1Uint8Test, true, armnn::DataLayout::NCHW)
101 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Uint8,
102                      DepthwiseConvolution2dDepthMul1Uint8Test, false, armnn::DataLayout::NCHW)
103
104 // NHWC Depthwise Convolution
105 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1NHhwc,
106                      DepthwiseConvolution2dDepthMul1Test, true, armnn::DataLayout::NHWC)
107 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Nhwc,
108                      DepthwiseConvolution2dDepthMul1Test, false, armnn::DataLayout::NHWC)
109 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1Uint8Nhwc,
110                      DepthwiseConvolution2dDepthMul1Uint8Test, true, armnn::DataLayout::NHWC)
111 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Uint8Nhwc,
112                      DepthwiseConvolution2dDepthMul1Uint8Test, false, armnn::DataLayout::NHWC)
113
114 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthNhwc, DepthwiseConvolution2dDepthNhwcTest, false)
115
116
117 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dAsymmetric,
118                      DepthwiseConvolution2dAsymmetricTest, true, armnn::DataLayout::NCHW)
119 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dAsymmetric,
120                      DepthwiseConvolution2dAsymmetricTest, false, armnn::DataLayout::NCHW)
121 ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dAsymmetricNhwc,
122                      DepthwiseConvolution2dAsymmetricTest, true, armnn::DataLayout::NHWC)
123 ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dAsymmetricNhwc,
124                      DepthwiseConvolution2dAsymmetricTest, false, armnn::DataLayout::NHWC)
125
126 namespace
127 {
128
129 armnn::DepthwiseConvolution2dDescriptor MakeDepthwiseConv2dDesc(uint32_t strideX, uint32_t strideY,
130     uint32_t depthMultiplier = 1, uint32_t padLeft = 0, uint32_t padRight = 0,
131     uint32_t padTop = 0, uint32_t padBottom = 0)
132 {
133     boost::ignore_unused(depthMultiplier);
134
135     armnn::DepthwiseConvolution2dDescriptor desc;
136
137     desc.m_PadLeft = padLeft;
138     desc.m_PadRight = padRight;
139
140     desc.m_PadTop = padTop;
141     desc.m_PadBottom = padBottom;
142     desc.m_StrideX = strideX;
143     desc.m_StrideY = strideY;
144     desc.m_BiasEnabled = false;
145
146     return desc;
147 }
148
149 armnn::TensorInfo CreateOutputTensorInfo(const armnn::TensorInfo& inputInfo,
150                                          const armnn::TensorInfo& weightsInfo,
151                                          const armnn::DepthwiseConvolution2dDescriptor& descriptor,
152                                          armnn::DataType dataType)
153 {
154     const armnn::TensorShape& inputShape  = inputInfo.GetShape();
155     const armnn::TensorShape& filterShape = weightsInfo.GetShape();
156
157     unsigned int inWidth = inputShape[3];
158     unsigned int inHeight = inputShape[2];
159     unsigned int inBatchSize = inputShape[0];
160
161     unsigned int filterWidth = filterShape[3];
162     unsigned int readWidth = (inWidth + descriptor.m_PadLeft + descriptor.m_PadRight) - (filterWidth);
163     unsigned int outWidth =  1u + (readWidth / descriptor.m_StrideX);
164
165     unsigned int filterHeight = filterShape[2];
166     unsigned int readHeight = (inHeight + descriptor.m_PadTop + descriptor.m_PadBottom) - (filterHeight);
167     unsigned int outHeight = 1u + (readHeight / descriptor.m_StrideY);
168     unsigned int depthMultiplier = filterShape[0];
169
170     unsigned int outChannels = filterShape[1] * depthMultiplier;
171     unsigned int outBatchSize = inBatchSize;
172
173     armnn::TensorShape outputShape({outBatchSize, outChannels, outHeight, outWidth});
174     return armnn::TensorInfo(outputShape, dataType);
175 }
176 }
177
178 BOOST_AUTO_TEST_CASE(DepthwiseConv2dUtils)
179 {
180     const armnn::DataType dataType = armnn::DataType::Float32;
181
182     armnn::TensorInfo inputInfo({1, 1, 10, 10 }, dataType);
183     armnn::TensorInfo outputInfo;
184     armnn::TensorInfo weightsInfo3x3({ 1, 1, 3, 3 }, dataType);
185     armnn::TensorInfo biasesInfo;
186
187     armnn::DepthwiseConvolution2dDescriptor descriptor;
188     armnn::NeonLayerSupport layerSupport;
189
190     // Strides supported: 1,2,3
191     descriptor = MakeDepthwiseConv2dDesc(1, 1);
192     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
193     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
194                                                             weightsInfo3x3, biasesInfo));
195
196     descriptor = MakeDepthwiseConv2dDesc(1, 2);
197     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
198     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
199                                                             weightsInfo3x3, biasesInfo));
200
201     descriptor = MakeDepthwiseConv2dDesc(1, 3);
202     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
203     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
204                                                             weightsInfo3x3, biasesInfo));
205
206     descriptor = MakeDepthwiseConv2dDesc(2, 1);
207     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
208     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
209                                                             weightsInfo3x3, biasesInfo));
210
211     descriptor = MakeDepthwiseConv2dDesc(2, 2);
212     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
213     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
214                                                             weightsInfo3x3, biasesInfo));
215
216     descriptor = MakeDepthwiseConv2dDesc(2, 3);
217     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
218     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
219                                                             weightsInfo3x3, biasesInfo));
220
221     descriptor = MakeDepthwiseConv2dDesc(3, 1);
222     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
223     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
224                                                             weightsInfo3x3, biasesInfo));
225
226     descriptor = MakeDepthwiseConv2dDesc(3, 2);
227     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
228     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
229                                                             weightsInfo3x3, biasesInfo));
230
231     descriptor = MakeDepthwiseConv2dDesc(3, 3);
232     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
233     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
234                                                             weightsInfo3x3, biasesInfo));
235
236     // Supported stride 4
237     descriptor = MakeDepthwiseConv2dDesc(4, 1);
238     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
239     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
240                                                             weightsInfo3x3, biasesInfo));
241
242     // Supported weights shape 1x1
243     armnn::TensorInfo weightsInfo1x1({ 1, 1, 1, 1 }, armnn::DataType::Float32);
244     descriptor = MakeDepthwiseConv2dDesc(1, 1);
245     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo1x1, descriptor, dataType);
246     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
247                                                             weightsInfo1x1, biasesInfo));
248
249     // Supported shape 2x2
250     armnn::TensorInfo weightsInfo2x2({ 1, 1, 2, 2 }, armnn::DataType::Float32);
251     descriptor = MakeDepthwiseConv2dDesc(1, 1);
252     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo2x2, descriptor, dataType);
253     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
254                                                             weightsInfo2x2, biasesInfo));
255
256     // Asymmetric padding
257     descriptor = MakeDepthwiseConv2dDesc(1, 1, 1, 1, 2, 1, 2);
258     outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
259     BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
260                                                             weightsInfo3x3, biasesInfo));
261 }
262
263 // Pooling
264 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dSize3x3Stride2x4, SimpleMaxPooling2dSize3x3Stride2x4Test, true)
265 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dSize3x3Stride2x4Uint8, SimpleMaxPooling2dSize3x3Stride2x4Uint8Test, true)
266
267 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2d, SimpleMaxPooling2dTest, armnn::DataLayout::NCHW)
268 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dNhwc, SimpleMaxPooling2dTest, armnn::DataLayout::NHWC)
269 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dUint8, SimpleMaxPooling2dUint8Test, armnn::DataLayout::NCHW)
270 ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dUint8Nhwc, SimpleMaxPooling2dUint8Test, armnn::DataLayout::NHWC)
271
272 ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2d, SimpleAveragePooling2dTest, armnn::DataLayout::NCHW)
273 ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dNhwc, SimpleAveragePooling2dTest, armnn::DataLayout::NCHW)
274 ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dUint8, SimpleAveragePooling2dUint8Test, armnn::DataLayout::NCHW)
275 ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dUint8Nhwc, SimpleAveragePooling2dUint8Test, armnn::DataLayout::NHWC)
276
277 ARMNN_AUTO_TEST_CASE(LargeTensorsAveragePooling2d, LargeTensorsAveragePooling2dTest)
278 ARMNN_AUTO_TEST_CASE(LargeTensorsAveragePooling2dUint8, LargeTensorsAveragePooling2dUint8Test)
279
280 ARMNN_AUTO_TEST_CASE(SimpleL2Pooling2d, SimpleL2Pooling2dTest, armnn::DataLayout::NCHW)
281 ARMNN_AUTO_TEST_CASE(SimpleL2Pooling2dNeon, SimpleL2Pooling2dTest, armnn::DataLayout::NHWC)
282 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_SimpleL2Pooling2dUint8, SimpleL2Pooling2dUint8Test, armnn::DataLayout::NCHW)
283
284 ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride1, L2Pooling2dSize3Stride1Test)
285 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride1Uint8, L2Pooling2dSize3Stride1Uint8Test)
286 ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride3, L2Pooling2dSize3Stride3Test)
287 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride3Uint8, L2Pooling2dSize3Stride3Uint8Test)
288 ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride4, L2Pooling2dSize3Stride4Test)
289 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride4Uint8, L2Pooling2dSize3Stride4Uint8Test)
290 ARMNN_AUTO_TEST_CASE(L2Pooling2dSize7, L2Pooling2dSize7Test)
291 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize7Uint8, L2Pooling2dSize7Uint8Test)
292 ARMNN_AUTO_TEST_CASE(L2Pooling2dSize9, L2Pooling2dSize9Test)
293 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize9Uint8, L2Pooling2dSize9Uint8Test)
294
295 // Ignore padding values for pooling but count padding fields into the divisor
296 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleMaxPooling2d, IgnorePaddingSimpleMaxPooling2dTest)
297 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleMaxPooling2dUint8, IgnorePaddingSimpleMaxPooling2dUint8Test)
298 ARMNN_AUTO_TEST_CASE(IgnorePaddingMaxPooling2dSize3, IgnorePaddingMaxPooling2dSize3Test)
299 ARMNN_AUTO_TEST_CASE(IgnorePaddingMaxPooling2dSize3Uint8, IgnorePaddingMaxPooling2dSize3Uint8Test)
300
301 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2d, IgnorePaddingSimpleAveragePooling2dTest)
302 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dUint8, IgnorePaddingSimpleAveragePooling2dUint8Test)
303 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dNoPadding, IgnorePaddingSimpleAveragePooling2dNoPaddingTest)
304 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dNoPaddingUint8,
305     IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test)
306 ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3, IgnorePaddingAveragePooling2dSize3Test)
307 ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3Uint8, IgnorePaddingAveragePooling2dSize3Uint8Test)
308 ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3x2Stride2x2,
309                              IgnorePaddingAveragePooling2dSize3x2Stride2x2Test, false)
310 ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3x2Stride2x2NoPadding,
311                              IgnorePaddingAveragePooling2dSize3x2Stride2x2Test,
312                                           true)
313
314 ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleL2Pooling2d, IgnorePaddingSimpleL2Pooling2dTest)
315 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_IgnorePaddingSimpleL2Pooling2dUint8, IgnorePaddingSimpleL2Pooling2dUint8Test)
316 ARMNN_AUTO_TEST_CASE(IgnorePaddingL2Pooling2dSize3, IgnorePaddingL2Pooling2dSize3Test)
317 ARMNN_AUTO_TEST_CASE(UNSUPPORTED_IgnorePaddingL2Pooling2dSize3Uint8, IgnorePaddingL2Pooling2dSize3Uint8Test)
318
319 // Activation
320 ARMNN_AUTO_TEST_CASE(ConstantLinearActivation, ConstantLinearActivationTest)
321
322 ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta1, SimpleSoftmaxTest, 1.0f)
323 ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta2, SimpleSoftmaxTest, 2.0f)
324
325 ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta1Uint8, SimpleSoftmaxUint8Test, 1.0f)
326 ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta2Uint8, SimpleSoftmaxUint8Test, 2.0f)
327
328 ARMNN_AUTO_TEST_CASE(ReLu1Uint8, BoundedReLuUint8UpperAndLowerBoundTest)
329 ARMNN_AUTO_TEST_CASE(ReLu6Uint8, BoundedReLuUint8UpperBoundOnlyTest)
330
331 // Softmax
332 BOOST_AUTO_TEST_CASE(Softmax4dSupport)
333 {
334     const unsigned int numDimensions = 4u;
335     std::array<unsigned int, numDimensions> dimensionSizes;
336     dimensionSizes.fill(1u);
337
338     const armnn::TensorInfo inputInfo(numDimensions, &dimensionSizes.front(), armnn::DataType::Float32);
339     const armnn::TensorInfo outputInfo(numDimensions, &dimensionSizes.front(), armnn::DataType::Float32);
340
341     // 4D Softmax should be reported as unsupported on the NEON backend
342     armnn::NeonLayerSupport layerSupport;
343     BOOST_TEST(!layerSupport.IsSoftmaxSupported(inputInfo, outputInfo, armnn::SoftmaxDescriptor()));
344 }
345
346 // Splitter
347 ARMNN_AUTO_TEST_CASE(SimpleSplitter, SplitterTest)
348 ARMNN_AUTO_TEST_CASE(SimpleSplitterUint8, SplitterUint8Test)
349
350 ARMNN_AUTO_TEST_CASE(CopyViaSplitter, CopyViaSplitterTest)
351 ARMNN_AUTO_TEST_CASE(CopyViaSplitterUint8, CopyViaSplitterUint8Test)
352
353 // Merger
354 ARMNN_AUTO_TEST_CASE(SimpleMerger, MergerTest)
355 ARMNN_AUTO_TEST_CASE(MergerUint8, MergerUint8Test)
356
357 // Fully Connected
358 ARMNN_AUTO_TEST_CASE(SimpleFullyConnected, FullyConnectedFloat32Test, false, false)
359 ARMNN_AUTO_TEST_CASE(SimpleFullyConnectedWithBias, FullyConnectedFloat32Test, true, false)
360 ARMNN_AUTO_TEST_CASE(SimpleFullyConnectedWithTranspose, FullyConnectedFloat32Test, false, true)
361 ARMNN_AUTO_TEST_CASE(FullyConnectedLarge, FullyConnectedLargeTest, false)
362 ARMNN_AUTO_TEST_CASE(FullyConnectedLargeTransposed, FullyConnectedLargeTest, true)
363 ARMNN_AUTO_TEST_CASE(FullyConnectedUint8, FullyConnectedUint8Test, false)
364 ARMNN_AUTO_TEST_CASE(FullyConnectedBiasedUint8, FullyConnectedUint8Test, true)
365
366 // Add
367 ARMNN_AUTO_TEST_CASE(SimpleAdd, AdditionTest)
368 ARMNN_AUTO_TEST_CASE(AddBroadcast, AdditionBroadcastTest)
369 ARMNN_AUTO_TEST_CASE(AddBroadcast1Element, AdditionBroadcast1ElementTest)
370
371 // Sub
372 ARMNN_AUTO_TEST_CASE(SimpleSub, SubtractionTest)
373
374 // Mul
375 ARMNN_AUTO_TEST_CASE(SimpleMultiplication, MultiplicationTest)
376 ARMNN_AUTO_TEST_CASE(MultiplicationBroadcast1Element, MultiplicationBroadcast1ElementTest)
377 ARMNN_AUTO_TEST_CASE(MultiplicationBroadcast1DVector, MultiplicationBroadcast1DVectorTest)
378
379 // Batch Norm
380 ARMNN_AUTO_TEST_CASE(BatchNorm, BatchNormTest)
381 ARMNN_AUTO_TEST_CASE(BatchNormNhwc, BatchNormNhwcTest)
382
383 // Constant
384 ARMNN_AUTO_TEST_CASE(Constant, ConstantTest)
385 ARMNN_AUTO_TEST_CASE(ConstantUint8, ConstantTestUint8)
386
387 // Concatenation
388 ARMNN_AUTO_TEST_CASE(Concatenation1d, Concatenation1dTest)
389 ARMNN_AUTO_TEST_CASE(Concatenation1dUint8, Concatenation1dUint8Test)
390
391 ARMNN_AUTO_TEST_CASE(Concatenation2dDim0, Concatenation2dDim0Test)
392 ARMNN_AUTO_TEST_CASE(Concatenation2dDim0Uint8, Concatenation2dDim0Uint8Test)
393 ARMNN_AUTO_TEST_CASE(Concatenation2dDim1, Concatenation2dDim1Test)
394 ARMNN_AUTO_TEST_CASE(Concatenation2dDim1Uint8, Concatenation2dDim1Uint8Test)
395
396 ARMNN_AUTO_TEST_CASE(Concatenation2dDim0DiffInputDims, Concatenation2dDim0DiffInputDimsTest)
397 ARMNN_AUTO_TEST_CASE(Concatenation2dDim0DiffInputDimsUint8, Concatenation2dDim0DiffInputDimsUint8Test)
398 ARMNN_AUTO_TEST_CASE(Concatenation2dDim1DiffInputDims, Concatenation2dDim1DiffInputDimsTest)
399 ARMNN_AUTO_TEST_CASE(Concatenation2dDim1DiffInputDimsUint8, Concatenation2dDim1DiffInputDimsUint8Test)
400
401 ARMNN_AUTO_TEST_CASE(Concatenation3dDim0, Concatenation3dDim0Test)
402 ARMNN_AUTO_TEST_CASE(Concatenation3dDim0Uint8, Concatenation3dDim0Uint8Test)
403 ARMNN_AUTO_TEST_CASE(Concatenation3dDim1, Concatenation3dDim1Test)
404 ARMNN_AUTO_TEST_CASE(Concatenation3dDim1Uint8, Concatenation3dDim1Uint8Test)
405 ARMNN_AUTO_TEST_CASE(Concatenation3dDim2, Concatenation3dDim2Test)
406 ARMNN_AUTO_TEST_CASE(Concatenation3dDim2Uint8, Concatenation3dDim2Uint8Test)
407
408 ARMNN_AUTO_TEST_CASE(Concatenation3dDim0DiffInputDims, Concatenation3dDim0DiffInputDimsTest)
409 ARMNN_AUTO_TEST_CASE(Concatenation3dDim0DiffInputDimsUint8, Concatenation3dDim0DiffInputDimsUint8Test)
410 ARMNN_AUTO_TEST_CASE(Concatenation3dDim1DiffInputDims, Concatenation3dDim1DiffInputDimsTest)
411 ARMNN_AUTO_TEST_CASE(Concatenation3dDim1DiffInputDimsUint8, Concatenation3dDim1DiffInputDimsUint8Test)
412 ARMNN_AUTO_TEST_CASE(Concatenation3dDim2DiffInputDims, Concatenation3dDim2DiffInputDimsTest)
413 ARMNN_AUTO_TEST_CASE(Concatenation3dDim2DiffInputDimsUint8, Concatenation3dDim2DiffInputDimsUint8Test)
414
415 // L2 Normalization
416 ARMNN_AUTO_TEST_CASE(L2Normalization1d, L2Normalization1dTest)
417 ARMNN_AUTO_TEST_CASE(L2Normalization2d, L2Normalization2dTest)
418 ARMNN_AUTO_TEST_CASE(L2Normalization3d, L2Normalization3dTest)
419 ARMNN_AUTO_TEST_CASE(L2Normalization4d, L2Normalization4dTest)
420
421 ARMNN_AUTO_TEST_CASE(L2Normalization1dNhwc, L2Normalization1dNhwcTest)
422 ARMNN_AUTO_TEST_CASE(L2Normalization2dNhwc, L2Normalization2dNhwcTest)
423 ARMNN_AUTO_TEST_CASE(L2Normalization3dNhwc, L2Normalization3dNhwcTest)
424 ARMNN_AUTO_TEST_CASE(L2Normalization4dNhwc, L2Normalization4dNhwcTest)
425
426 // Floor
427 ARMNN_AUTO_TEST_CASE(SimpleFloor, SimpleFloorTest)
428
429 // Reshape
430 ARMNN_AUTO_TEST_CASE(SimpleReshapeFloat32, SimpleReshapeFloat32Test)
431 ARMNN_AUTO_TEST_CASE(SimpleReshapeUint8, SimpleReshapeUint8Test)
432
433 // Permute
434 ARMNN_AUTO_TEST_CASE(SimplePermuteFloat32, SimplePermuteFloat32Test)
435 ARMNN_AUTO_TEST_CASE(SimplePermuteUint8, SimplePermuteUint8Test)
436 ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet1, PermuteFloat32ValueSet1Test)
437 ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet2, PermuteFloat32ValueSet2Test)
438 ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet3, PermuteFloat32ValueSet3Test)
439
440 // Lstm
441 ARMNN_AUTO_TEST_CASE(LstmLayerFloat32WithCifgWithPeepholeNoProjection,
442                      LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest)
443 ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgNoPeepholeNoProjection,
444                      LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest)
445 ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgWithPeepholeWithProjection,
446                      LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest)
447
448 // Normalization
449 ARMNN_AUTO_TEST_CASE(SimpleNormalizationAcross, SimpleNormalizationAcrossTest)
450 ARMNN_AUTO_TEST_CASE(SimpleNormalizationWithin, SimpleNormalizationWithinTest)
451 ARMNN_AUTO_TEST_CASE(SimpleNormalizationAcrossNhwc, SimpleNormalizationAcrossNhwcTest)
452
453 // ============================================================================
454 // COMPARE tests
455
456 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareConv2dWithReference, CompareConvolution2dTest)
457
458 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceFloat32,
459                                  CompareDepthwiseConvolution2dTest<float>,
460                                  armnn::DataLayout::NCHW)
461 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceUint8,
462                                  CompareDepthwiseConvolution2dTest<uint8_t>,
463                                  armnn::DataLayout::NCHW)
464
465 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceFloat32Nhwc,
466                                  CompareDepthwiseConvolution2dTest<float>,
467                                  armnn::DataLayout::NHWC)
468 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceUint8Nhwc,
469                                  CompareDepthwiseConvolution2dTest<uint8_t>,
470                                  armnn::DataLayout::NHWC)
471
472 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareNormalizationWithinWithReference, CompareNormalizationTest,
473                                  armnn::NormalizationAlgorithmChannel::Within,
474                                  armnn::NormalizationAlgorithmMethod::LocalBrightness)
475 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareNormalizationAcrossWithReference, CompareNormalizationTest,
476                                  armnn::NormalizationAlgorithmChannel::Across,
477                                  armnn::NormalizationAlgorithmMethod::LocalBrightness)
478
479 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMaxPooling2dWithReference, ComparePooling2dTest, armnn::PoolingAlgorithm::Max)
480 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMaxPooling2dWithReferenceUint8, ComparePooling2dUint8Test,
481                                  armnn::PoolingAlgorithm::Max)
482 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAveragePooling2dWithReference, ComparePooling2dTest,
483                                  armnn::PoolingAlgorithm::Average)
484 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAveragePooling2dWithReferenceUint8, ComparePooling2dUint8Test,
485                                  armnn::PoolingAlgorithm::Average)
486 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareL2Pooling2dWithReference, ComparePooling2dTest, armnn::PoolingAlgorithm::L2)
487 ARMNN_COMPARE_REF_AUTO_TEST_CASE(UNSUPPORTED_CompareL2Pooling2dWithReferenceUint8, ComparePooling2dUint8Test,
488                                  armnn::PoolingAlgorithm::L2)
489
490 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxBeta1WithReference, CompareSoftmaxTest, 1.0f)
491 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxBeta2WithReference, CompareSoftmaxTest, 2.0f)
492
493 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxUint8Beta1WithReference, CompareSoftmaxUint8Test, 1.0f)
494 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxUint8Beta2WithReference, CompareSoftmaxUint8Test, 2.0f)
495
496 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAddition, CompareAdditionTest)
497
498 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMultiplicationWithReference, CompareMultiplicationTest)
499
500 ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareBatchNorm, CompareBatchNormTest)
501
502 ARMNN_COMPARE_REF_AUTO_TEST_CASE(ReLu1, CompareBoundedReLuTest, 1.0f, -1.0f)
503 ARMNN_COMPARE_REF_AUTO_TEST_CASE(ReLu6, CompareBoundedReLuTest, 6.0f, 0.0f)
504
505 // ============================================================================
506 // FIXTURE tests
507
508 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSigmoidActivationWithReference, ActivationFixture,
509                                     CompareActivationTest, armnn::ActivationFunction::Sigmoid, 5u)
510
511 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareTanhActivationWithReference, ActivationFixture,
512                                     CompareActivationTest, armnn::ActivationFunction::TanH, 5u)
513
514 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareLinearActivationWithReference, ActivationFixture,
515                                     CompareActivationTest, armnn::ActivationFunction::Linear, 5u)
516
517 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareReLuActivationWithReference, ActivationFixture,
518                                     CompareActivationTest, armnn::ActivationFunction::ReLu, 5u)
519
520 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareBoundedReLuActivationWithReference, ActivationFixture,
521                                     CompareActivationTest, armnn::ActivationFunction::BoundedReLu, 5u)
522 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareBoundedReLuActivationWithReferenceUint8, ActivationFixture,
523                                     CompareActivationUint8Test, armnn::ActivationFunction::BoundedReLu)
524
525 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSoftReLuActivationWithReference, ActivationFixture,
526                                     CompareActivationTest, armnn::ActivationFunction::SoftReLu, 1u)
527
528 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareLeakyReLuActivationWithReference, ActivationFixture,
529                                     CompareActivationTest, armnn::ActivationFunction::LeakyReLu, 5u)
530
531 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareAbsActivationWithReference, ActivationFixture,
532                                     CompareActivationTest, armnn::ActivationFunction::Abs, 5u)
533
534 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSqrtActivationWithReference, PositiveActivationFixture,
535                                     CompareActivationTest, armnn::ActivationFunction::Sqrt, 5u)
536
537 ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSquareActivationWithReference, ActivationFixture,
538                                     CompareActivationTest, armnn::ActivationFunction::Square, 5u)
539 BOOST_AUTO_TEST_SUITE_END()