blob: 4a1c5f98368e8aff2778c6658922d310876291f0 [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//
telsoa014fcda012018-03-09 14:13:49 +00005
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00006#include <test/TensorHelpers.hpp>
7#include <test/UnitTests.hpp>
telsoa014fcda012018-03-09 14:13:49 +00008
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00009#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>
telsoa014fcda012018-03-09 14:13:49 +000017
arovir0143095f32018-10-09 18:04:24 +010018#include <boost/test/unit_test.hpp>
telsoa014fcda012018-03-09 14:13:49 +000019
20BOOST_AUTO_TEST_SUITE(Compute_ArmComputeNeon)
21using FactoryType = armnn::NeonWorkloadFactory;
22
23// ============================================================================
24// UNIT tests
25
26// Convolution
27ARMNN_AUTO_TEST_CASE(SimpleConvolution1d, Convolution1dTest, true)
28
jimfly010a088a62018-10-25 17:05:05 +010029ARMNN_AUTO_TEST_CASE(SimpleConvolution2d, SimpleConvolution2d3x5Test, true, armnn::DataLayout::NCHW)
30ARMNN_AUTO_TEST_CASE(SimpleConvolution2dNhwc, SimpleConvolution2d3x5Test, true, armnn::DataLayout::NHWC)
narpra015f703182018-10-26 16:24:58 +010031ARMNN_AUTO_TEST_CASE(SimpleConvolution2d3x3Uint8, SimpleConvolution2d3x3Uint8Test, true, armnn::DataLayout::NCHW)
32ARMNN_AUTO_TEST_CASE(SimpleConvolution2d3x3Uint8Nhwc, SimpleConvolution2d3x3Uint8Test, true, armnn::DataLayout::NHWC)
jimfly010a088a62018-10-25 17:05:05 +010033ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2d, SimpleConvolution2d3x5Test, false, armnn::DataLayout::NCHW)
34ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dNhwc, SimpleConvolution2d3x5Test, false, armnn::DataLayout::NHWC)
35
narpra015f703182018-10-26 16:24:58 +010036ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dSquare, SimpleConvolution2d3x3Test, false, armnn::DataLayout::NCHW)
37ARMNN_AUTO_TEST_CASE(SimpleConvolution2dAsymmetricPadding, Convolution2dAsymmetricPaddingTest, armnn::DataLayout::NCHW)
38
39ARMNN_AUTO_TEST_CASE(UnbiasedConvolution2dSquareNhwc, SimpleConvolution2d3x3Test, false, armnn::DataLayout::NHWC)
40ARMNN_AUTO_TEST_CASE(SimpleConvolution2dAsymmetricPaddingNhwc,
41 Convolution2dAsymmetricPaddingTest,
42 armnn::DataLayout::NHWC)
telsoa014fcda012018-03-09 14:13:49 +000043
Francis Murtaghd59116e2018-10-04 16:03:07 +010044ARMNN_AUTO_TEST_CASE(SimpleConvolution2dSquareNhwc, SimpleConvolution2d3x3NhwcTest, false)
telsoa014fcda012018-03-09 14:13:49 +000045namespace
46{
47
48armnn::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
64BOOST_AUTO_TEST_CASE(Conv2dUtils)
65{
telsoa01c577f2c2018-08-31 09:22:23 +010066 // The only preferred Neon convolution is 1x1 with padding=0 and stride size {1,2,3}.
telsoa014fcda012018-03-09 14:13:49 +000067 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
jimfly01b9c89632018-10-26 16:50:13 +010095ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1,
96 DepthwiseConvolution2dDepthMul1Test, true, armnn::DataLayout::NCHW)
97ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1,
98 DepthwiseConvolution2dDepthMul1Test, false, armnn::DataLayout::NCHW)
99ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1Uint8,
100 DepthwiseConvolution2dDepthMul1Uint8Test, true, armnn::DataLayout::NCHW)
101ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Uint8,
102 DepthwiseConvolution2dDepthMul1Uint8Test, false, armnn::DataLayout::NCHW)
103
104// NHWC Depthwise Convolution
105ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1NHhwc,
106 DepthwiseConvolution2dDepthMul1Test, true, armnn::DataLayout::NHWC)
107ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Nhwc,
108 DepthwiseConvolution2dDepthMul1Test, false, armnn::DataLayout::NHWC)
109ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul1Uint8Nhwc,
110 DepthwiseConvolution2dDepthMul1Uint8Test, true, armnn::DataLayout::NHWC)
111ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dDepthMul1Uint8Nhwc,
112 DepthwiseConvolution2dDepthMul1Uint8Test, false, armnn::DataLayout::NHWC)
113
Nikhil Rajcec6b652018-10-12 13:51:57 +0100114ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthNhwc, DepthwiseConvolution2dDepthNhwcTest, false)
jimfly01b9c89632018-10-26 16:50:13 +0100115
telsoa014fcda012018-03-09 14:13:49 +0000116
jimfly01382a91d2018-10-26 15:55:50 +0100117ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dAsymmetric,
118 DepthwiseConvolution2dAsymmetricTest, true, armnn::DataLayout::NCHW)
119ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dAsymmetric,
120 DepthwiseConvolution2dAsymmetricTest, false, armnn::DataLayout::NCHW)
121ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dAsymmetricNhwc,
122 DepthwiseConvolution2dAsymmetricTest, true, armnn::DataLayout::NHWC)
123ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dAsymmetricNhwc,
124 DepthwiseConvolution2dAsymmetricTest, false, armnn::DataLayout::NHWC)
surmeh013537c2c2018-05-18 16:31:43 +0100125
telsoa014fcda012018-03-09 14:13:49 +0000126namespace
127{
128
129armnn::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{
telsoa01c577f2c2018-08-31 09:22:23 +0100133 boost::ignore_unused(depthMultiplier);
134
telsoa014fcda012018-03-09 14:13:49 +0000135 armnn::DepthwiseConvolution2dDescriptor desc;
telsoa01c577f2c2018-08-31 09:22:23 +0100136
telsoa014fcda012018-03-09 14:13:49 +0000137 desc.m_PadLeft = padLeft;
138 desc.m_PadRight = padRight;
telsoa01c577f2c2018-08-31 09:22:23 +0100139
telsoa014fcda012018-03-09 14:13:49 +0000140 desc.m_PadTop = padTop;
141 desc.m_PadBottom = padBottom;
142 desc.m_StrideX = strideX;
143 desc.m_StrideY = strideY;
telsoa01c577f2c2018-08-31 09:22:23 +0100144 desc.m_BiasEnabled = false;
145
telsoa014fcda012018-03-09 14:13:49 +0000146 return desc;
147}
148
telsoa01c577f2c2018-08-31 09:22:23 +0100149armnn::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}
telsoa014fcda012018-03-09 14:13:49 +0000176}
177
178BOOST_AUTO_TEST_CASE(DepthwiseConv2dUtils)
179{
telsoa01c577f2c2018-08-31 09:22:23 +0100180 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;
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100188 armnn::NeonLayerSupport layerSupport;
telsoa014fcda012018-03-09 14:13:49 +0000189
190 // Strides supported: 1,2,3
telsoa01c577f2c2018-08-31 09:22:23 +0100191 descriptor = MakeDepthwiseConv2dDesc(1, 1);
192 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100193 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
194 weightsInfo3x3, biasesInfo));
telsoa014fcda012018-03-09 14:13:49 +0000195
telsoa01c577f2c2018-08-31 09:22:23 +0100196 descriptor = MakeDepthwiseConv2dDesc(1, 2);
197 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100198 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
199 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100200
201 descriptor = MakeDepthwiseConv2dDesc(1, 3);
202 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100203 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
204 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100205
206 descriptor = MakeDepthwiseConv2dDesc(2, 1);
207 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100208 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
209 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100210
211 descriptor = MakeDepthwiseConv2dDesc(2, 2);
212 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100213 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
214 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100215
216 descriptor = MakeDepthwiseConv2dDesc(2, 3);
217 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100218 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
219 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100220
221 descriptor = MakeDepthwiseConv2dDesc(3, 1);
222 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100223 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
224 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100225
226 descriptor = MakeDepthwiseConv2dDesc(3, 2);
227 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100228 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
229 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100230
231 descriptor = MakeDepthwiseConv2dDesc(3, 3);
232 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100233 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
234 weightsInfo3x3, biasesInfo));
telsoa01c577f2c2018-08-31 09:22:23 +0100235
236 // Supported stride 4
237 descriptor = MakeDepthwiseConv2dDesc(4, 1);
238 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100239 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
240 weightsInfo3x3, biasesInfo));
telsoa014fcda012018-03-09 14:13:49 +0000241
242 // Supported weights shape 1x1
243 armnn::TensorInfo weightsInfo1x1({ 1, 1, 1, 1 }, armnn::DataType::Float32);
telsoa01c577f2c2018-08-31 09:22:23 +0100244 descriptor = MakeDepthwiseConv2dDesc(1, 1);
245 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo1x1, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100246 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
247 weightsInfo1x1, biasesInfo));
telsoa014fcda012018-03-09 14:13:49 +0000248
249 // Supported shape 2x2
250 armnn::TensorInfo weightsInfo2x2({ 1, 1, 2, 2 }, armnn::DataType::Float32);
telsoa01c577f2c2018-08-31 09:22:23 +0100251 descriptor = MakeDepthwiseConv2dDesc(1, 1);
252 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo2x2, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100253 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
254 weightsInfo2x2, biasesInfo));
surmeh013537c2c2018-05-18 16:31:43 +0100255
256 // Asymmetric padding
telsoa01c577f2c2018-08-31 09:22:23 +0100257 descriptor = MakeDepthwiseConv2dDesc(1, 1, 1, 1, 2, 1, 2);
258 outputInfo = CreateOutputTensorInfo(inputInfo, weightsInfo3x3, descriptor, dataType);
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100259 BOOST_TEST(layerSupport.IsDepthwiseConvolutionSupported(inputInfo, outputInfo, descriptor,
260 weightsInfo3x3, biasesInfo));
telsoa014fcda012018-03-09 14:13:49 +0000261}
262
263// Pooling
264ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dSize3x3Stride2x4, SimpleMaxPooling2dSize3x3Stride2x4Test, true)
265ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dSize3x3Stride2x4Uint8, SimpleMaxPooling2dSize3x3Stride2x4Uint8Test, true)
James Conroy45a9b772018-10-31 11:47:53 +0000266
267ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2d, SimpleMaxPooling2dTest, armnn::DataLayout::NCHW)
268ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dNhwc, SimpleMaxPooling2dTest, armnn::DataLayout::NHWC)
269ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dUint8, SimpleMaxPooling2dUint8Test, armnn::DataLayout::NCHW)
270ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dUint8Nhwc, SimpleMaxPooling2dUint8Test, armnn::DataLayout::NHWC)
271
272ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2d, SimpleAveragePooling2dTest, armnn::DataLayout::NCHW)
273ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dNhwc, SimpleAveragePooling2dTest, armnn::DataLayout::NCHW)
274ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dUint8, SimpleAveragePooling2dUint8Test, armnn::DataLayout::NCHW)
275ARMNN_AUTO_TEST_CASE(SimpleAveragePooling2dUint8Nhwc, SimpleAveragePooling2dUint8Test, armnn::DataLayout::NHWC)
surmeh01bceff2f2018-03-29 16:29:27 +0100276
telsoa014fcda012018-03-09 14:13:49 +0000277ARMNN_AUTO_TEST_CASE(LargeTensorsAveragePooling2d, LargeTensorsAveragePooling2dTest)
278ARMNN_AUTO_TEST_CASE(LargeTensorsAveragePooling2dUint8, LargeTensorsAveragePooling2dUint8Test)
279
James Conroy45a9b772018-10-31 11:47:53 +0000280ARMNN_AUTO_TEST_CASE(SimpleL2Pooling2d, SimpleL2Pooling2dTest, armnn::DataLayout::NCHW)
281ARMNN_AUTO_TEST_CASE(SimpleL2Pooling2dNeon, SimpleL2Pooling2dTest, armnn::DataLayout::NHWC)
282ARMNN_AUTO_TEST_CASE(UNSUPPORTED_SimpleL2Pooling2dUint8, SimpleL2Pooling2dUint8Test, armnn::DataLayout::NCHW)
283
telsoa014fcda012018-03-09 14:13:49 +0000284ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride1, L2Pooling2dSize3Stride1Test)
285ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride1Uint8, L2Pooling2dSize3Stride1Uint8Test)
286ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride3, L2Pooling2dSize3Stride3Test)
287ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride3Uint8, L2Pooling2dSize3Stride3Uint8Test)
288ARMNN_AUTO_TEST_CASE(L2Pooling2dSize3Stride4, L2Pooling2dSize3Stride4Test)
289ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize3Stride4Uint8, L2Pooling2dSize3Stride4Uint8Test)
290ARMNN_AUTO_TEST_CASE(L2Pooling2dSize7, L2Pooling2dSize7Test)
291ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize7Uint8, L2Pooling2dSize7Uint8Test)
292ARMNN_AUTO_TEST_CASE(L2Pooling2dSize9, L2Pooling2dSize9Test)
293ARMNN_AUTO_TEST_CASE(UNSUPPORTED_L2Pooling2dSize9Uint8, L2Pooling2dSize9Uint8Test)
294
295// Ignore padding values for pooling but count padding fields into the divisor
296ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleMaxPooling2d, IgnorePaddingSimpleMaxPooling2dTest)
297ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleMaxPooling2dUint8, IgnorePaddingSimpleMaxPooling2dUint8Test)
298ARMNN_AUTO_TEST_CASE(IgnorePaddingMaxPooling2dSize3, IgnorePaddingMaxPooling2dSize3Test)
299ARMNN_AUTO_TEST_CASE(IgnorePaddingMaxPooling2dSize3Uint8, IgnorePaddingMaxPooling2dSize3Uint8Test)
300
301ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2d, IgnorePaddingSimpleAveragePooling2dTest)
302ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dUint8, IgnorePaddingSimpleAveragePooling2dUint8Test)
303ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dNoPadding, IgnorePaddingSimpleAveragePooling2dNoPaddingTest)
304ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleAveragePooling2dNoPaddingUint8,
305 IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test)
306ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3, IgnorePaddingAveragePooling2dSize3Test)
307ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3Uint8, IgnorePaddingAveragePooling2dSize3Uint8Test)
surmeh01bceff2f2018-03-29 16:29:27 +0100308ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3x2Stride2x2,
309 IgnorePaddingAveragePooling2dSize3x2Stride2x2Test, false)
310ARMNN_AUTO_TEST_CASE(IgnorePaddingAveragePooling2dSize3x2Stride2x2NoPadding,
311 IgnorePaddingAveragePooling2dSize3x2Stride2x2Test,
312 true)
telsoa014fcda012018-03-09 14:13:49 +0000313
314ARMNN_AUTO_TEST_CASE(IgnorePaddingSimpleL2Pooling2d, IgnorePaddingSimpleL2Pooling2dTest)
315ARMNN_AUTO_TEST_CASE(UNSUPPORTED_IgnorePaddingSimpleL2Pooling2dUint8, IgnorePaddingSimpleL2Pooling2dUint8Test)
316ARMNN_AUTO_TEST_CASE(IgnorePaddingL2Pooling2dSize3, IgnorePaddingL2Pooling2dSize3Test)
317ARMNN_AUTO_TEST_CASE(UNSUPPORTED_IgnorePaddingL2Pooling2dSize3Uint8, IgnorePaddingL2Pooling2dSize3Uint8Test)
318
319// Activation
320ARMNN_AUTO_TEST_CASE(ConstantLinearActivation, ConstantLinearActivationTest)
321
322ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta1, SimpleSoftmaxTest, 1.0f)
323ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta2, SimpleSoftmaxTest, 2.0f)
324
325ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta1Uint8, SimpleSoftmaxUint8Test, 1.0f)
326ARMNN_AUTO_TEST_CASE(SimpleSoftmaxBeta2Uint8, SimpleSoftmaxUint8Test, 2.0f)
327
328ARMNN_AUTO_TEST_CASE(ReLu1Uint8, BoundedReLuUint8UpperAndLowerBoundTest)
329ARMNN_AUTO_TEST_CASE(ReLu6Uint8, BoundedReLuUint8UpperBoundOnlyTest)
330
telsoa01c577f2c2018-08-31 09:22:23 +0100331// Softmax
332BOOST_AUTO_TEST_CASE(Softmax4dSupport)
telsoa014fcda012018-03-09 14:13:49 +0000333{
telsoa01c577f2c2018-08-31 09:22:23 +0100334 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
Aron Virginas-Tarfc824312018-10-15 15:00:13 +0100342 armnn::NeonLayerSupport layerSupport;
343 BOOST_TEST(!layerSupport.IsSoftmaxSupported(inputInfo, outputInfo, armnn::SoftmaxDescriptor()));
telsoa014fcda012018-03-09 14:13:49 +0000344}
345
telsoa01c577f2c2018-08-31 09:22:23 +0100346// Splitter
347ARMNN_AUTO_TEST_CASE(SimpleSplitter, SplitterTest)
348ARMNN_AUTO_TEST_CASE(SimpleSplitterUint8, SplitterUint8Test)
telsoa014fcda012018-03-09 14:13:49 +0000349
350ARMNN_AUTO_TEST_CASE(CopyViaSplitter, CopyViaSplitterTest)
351ARMNN_AUTO_TEST_CASE(CopyViaSplitterUint8, CopyViaSplitterUint8Test)
352
353// Merger
354ARMNN_AUTO_TEST_CASE(SimpleMerger, MergerTest)
355ARMNN_AUTO_TEST_CASE(MergerUint8, MergerUint8Test)
356
357// Fully Connected
358ARMNN_AUTO_TEST_CASE(SimpleFullyConnected, FullyConnectedFloat32Test, false, false)
359ARMNN_AUTO_TEST_CASE(SimpleFullyConnectedWithBias, FullyConnectedFloat32Test, true, false)
360ARMNN_AUTO_TEST_CASE(SimpleFullyConnectedWithTranspose, FullyConnectedFloat32Test, false, true)
361ARMNN_AUTO_TEST_CASE(FullyConnectedLarge, FullyConnectedLargeTest, false)
362ARMNN_AUTO_TEST_CASE(FullyConnectedLargeTransposed, FullyConnectedLargeTest, true)
kevmay01e448be32018-09-26 10:21:55 +0100363ARMNN_AUTO_TEST_CASE(FullyConnectedUint8, FullyConnectedUint8Test, false)
364ARMNN_AUTO_TEST_CASE(FullyConnectedBiasedUint8, FullyConnectedUint8Test, true)
telsoa014fcda012018-03-09 14:13:49 +0000365
366// Add
367ARMNN_AUTO_TEST_CASE(SimpleAdd, AdditionTest)
David Beckbc392452018-09-10 14:47:28 +0100368ARMNN_AUTO_TEST_CASE(AddBroadcast, AdditionBroadcastTest)
telsoa014fcda012018-03-09 14:13:49 +0000369ARMNN_AUTO_TEST_CASE(AddBroadcast1Element, AdditionBroadcast1ElementTest)
370
David Beckbc392452018-09-10 14:47:28 +0100371// Sub
372ARMNN_AUTO_TEST_CASE(SimpleSub, SubtractionTest)
373
telsoa014fcda012018-03-09 14:13:49 +0000374// Mul
375ARMNN_AUTO_TEST_CASE(SimpleMultiplication, MultiplicationTest)
surmeh013537c2c2018-05-18 16:31:43 +0100376ARMNN_AUTO_TEST_CASE(MultiplicationBroadcast1Element, MultiplicationBroadcast1ElementTest)
377ARMNN_AUTO_TEST_CASE(MultiplicationBroadcast1DVector, MultiplicationBroadcast1DVectorTest)
telsoa014fcda012018-03-09 14:13:49 +0000378
379// Batch Norm
380ARMNN_AUTO_TEST_CASE(BatchNorm, BatchNormTest)
Nikhil Rajd1340932018-10-18 14:27:50 +0100381ARMNN_AUTO_TEST_CASE(BatchNormNhwc, BatchNormNhwcTest)
telsoa014fcda012018-03-09 14:13:49 +0000382
383// Constant
384ARMNN_AUTO_TEST_CASE(Constant, ConstantTest)
385ARMNN_AUTO_TEST_CASE(ConstantUint8, ConstantTestUint8)
386
387// Concatenation
388ARMNN_AUTO_TEST_CASE(Concatenation1d, Concatenation1dTest)
389ARMNN_AUTO_TEST_CASE(Concatenation1dUint8, Concatenation1dUint8Test)
390
391ARMNN_AUTO_TEST_CASE(Concatenation2dDim0, Concatenation2dDim0Test)
392ARMNN_AUTO_TEST_CASE(Concatenation2dDim0Uint8, Concatenation2dDim0Uint8Test)
393ARMNN_AUTO_TEST_CASE(Concatenation2dDim1, Concatenation2dDim1Test)
394ARMNN_AUTO_TEST_CASE(Concatenation2dDim1Uint8, Concatenation2dDim1Uint8Test)
395
396ARMNN_AUTO_TEST_CASE(Concatenation2dDim0DiffInputDims, Concatenation2dDim0DiffInputDimsTest)
397ARMNN_AUTO_TEST_CASE(Concatenation2dDim0DiffInputDimsUint8, Concatenation2dDim0DiffInputDimsUint8Test)
398ARMNN_AUTO_TEST_CASE(Concatenation2dDim1DiffInputDims, Concatenation2dDim1DiffInputDimsTest)
399ARMNN_AUTO_TEST_CASE(Concatenation2dDim1DiffInputDimsUint8, Concatenation2dDim1DiffInputDimsUint8Test)
400
401ARMNN_AUTO_TEST_CASE(Concatenation3dDim0, Concatenation3dDim0Test)
402ARMNN_AUTO_TEST_CASE(Concatenation3dDim0Uint8, Concatenation3dDim0Uint8Test)
403ARMNN_AUTO_TEST_CASE(Concatenation3dDim1, Concatenation3dDim1Test)
404ARMNN_AUTO_TEST_CASE(Concatenation3dDim1Uint8, Concatenation3dDim1Uint8Test)
405ARMNN_AUTO_TEST_CASE(Concatenation3dDim2, Concatenation3dDim2Test)
406ARMNN_AUTO_TEST_CASE(Concatenation3dDim2Uint8, Concatenation3dDim2Uint8Test)
407
408ARMNN_AUTO_TEST_CASE(Concatenation3dDim0DiffInputDims, Concatenation3dDim0DiffInputDimsTest)
409ARMNN_AUTO_TEST_CASE(Concatenation3dDim0DiffInputDimsUint8, Concatenation3dDim0DiffInputDimsUint8Test)
410ARMNN_AUTO_TEST_CASE(Concatenation3dDim1DiffInputDims, Concatenation3dDim1DiffInputDimsTest)
411ARMNN_AUTO_TEST_CASE(Concatenation3dDim1DiffInputDimsUint8, Concatenation3dDim1DiffInputDimsUint8Test)
412ARMNN_AUTO_TEST_CASE(Concatenation3dDim2DiffInputDims, Concatenation3dDim2DiffInputDimsTest)
413ARMNN_AUTO_TEST_CASE(Concatenation3dDim2DiffInputDimsUint8, Concatenation3dDim2DiffInputDimsUint8Test)
414
415// L2 Normalization
Matteo Martincigh539b44d2018-10-01 09:26:39 +0100416ARMNN_AUTO_TEST_CASE(L2Normalization1d, L2Normalization1dTest)
417ARMNN_AUTO_TEST_CASE(L2Normalization2d, L2Normalization2dTest)
418ARMNN_AUTO_TEST_CASE(L2Normalization3d, L2Normalization3dTest)
419ARMNN_AUTO_TEST_CASE(L2Normalization4d, L2Normalization4dTest)
420
421ARMNN_AUTO_TEST_CASE(L2Normalization1dNhwc, L2Normalization1dNhwcTest)
422ARMNN_AUTO_TEST_CASE(L2Normalization2dNhwc, L2Normalization2dNhwcTest)
423ARMNN_AUTO_TEST_CASE(L2Normalization3dNhwc, L2Normalization3dNhwcTest)
424ARMNN_AUTO_TEST_CASE(L2Normalization4dNhwc, L2Normalization4dNhwcTest)
telsoa014fcda012018-03-09 14:13:49 +0000425
426// Floor
427ARMNN_AUTO_TEST_CASE(SimpleFloor, SimpleFloorTest)
428
429// Reshape
430ARMNN_AUTO_TEST_CASE(SimpleReshapeFloat32, SimpleReshapeFloat32Test)
431ARMNN_AUTO_TEST_CASE(SimpleReshapeUint8, SimpleReshapeUint8Test)
432
433// Permute
434ARMNN_AUTO_TEST_CASE(SimplePermuteFloat32, SimplePermuteFloat32Test)
435ARMNN_AUTO_TEST_CASE(SimplePermuteUint8, SimplePermuteUint8Test)
surmeh01bceff2f2018-03-29 16:29:27 +0100436ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet1, PermuteFloat32ValueSet1Test)
437ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet2, PermuteFloat32ValueSet2Test)
438ARMNN_AUTO_TEST_CASE(PermuteFloat32ValueSet3, PermuteFloat32ValueSet3Test)
439
Les Bellde9011b2018-10-03 10:37:52 +0100440// Lstm
441ARMNN_AUTO_TEST_CASE(LstmLayerFloat32WithCifgWithPeepholeNoProjection,
442 LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest)
443ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgNoPeepholeNoProjection,
444 LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest)
445ARMNN_AUTO_TEST_CASE(LstmLayerFloat32NoCifgWithPeepholeWithProjection,
446 LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest)
447
narpra0155a97bc2018-10-02 14:35:53 +0100448// Normalization
449ARMNN_AUTO_TEST_CASE(SimpleNormalizationAcross, SimpleNormalizationAcrossTest)
450ARMNN_AUTO_TEST_CASE(SimpleNormalizationWithin, SimpleNormalizationWithinTest)
451ARMNN_AUTO_TEST_CASE(SimpleNormalizationAcrossNhwc, SimpleNormalizationAcrossNhwcTest)
452
telsoa014fcda012018-03-09 14:13:49 +0000453// ============================================================================
454// COMPARE tests
455
456ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareConv2dWithReference, CompareConvolution2dTest)
457
jimfly017af00da2018-10-31 14:43:53 +0000458ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceFloat32,
459 CompareDepthwiseConvolution2dTest<float>,
460 armnn::DataLayout::NCHW)
461ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceUint8,
462 CompareDepthwiseConvolution2dTest<uint8_t>,
463 armnn::DataLayout::NCHW)
464
465ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceFloat32Nhwc,
466 CompareDepthwiseConvolution2dTest<float>,
467 armnn::DataLayout::NHWC)
468ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareDepthwiseConv2dWithReferenceUint8Nhwc,
469 CompareDepthwiseConvolution2dTest<uint8_t>,
470 armnn::DataLayout::NHWC)
telsoa014fcda012018-03-09 14:13:49 +0000471
472ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareNormalizationWithinWithReference, CompareNormalizationTest,
473 armnn::NormalizationAlgorithmChannel::Within,
474 armnn::NormalizationAlgorithmMethod::LocalBrightness)
475ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareNormalizationAcrossWithReference, CompareNormalizationTest,
476 armnn::NormalizationAlgorithmChannel::Across,
477 armnn::NormalizationAlgorithmMethod::LocalBrightness)
478
479ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMaxPooling2dWithReference, ComparePooling2dTest, armnn::PoolingAlgorithm::Max)
480ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMaxPooling2dWithReferenceUint8, ComparePooling2dUint8Test,
481 armnn::PoolingAlgorithm::Max)
482ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAveragePooling2dWithReference, ComparePooling2dTest,
483 armnn::PoolingAlgorithm::Average)
484ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAveragePooling2dWithReferenceUint8, ComparePooling2dUint8Test,
485 armnn::PoolingAlgorithm::Average)
486ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareL2Pooling2dWithReference, ComparePooling2dTest, armnn::PoolingAlgorithm::L2)
487ARMNN_COMPARE_REF_AUTO_TEST_CASE(UNSUPPORTED_CompareL2Pooling2dWithReferenceUint8, ComparePooling2dUint8Test,
488 armnn::PoolingAlgorithm::L2)
489
490ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxBeta1WithReference, CompareSoftmaxTest, 1.0f)
491ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxBeta2WithReference, CompareSoftmaxTest, 2.0f)
492
493ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxUint8Beta1WithReference, CompareSoftmaxUint8Test, 1.0f)
494ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareSoftmaxUint8Beta2WithReference, CompareSoftmaxUint8Test, 2.0f)
495
496ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareAddition, CompareAdditionTest)
497
498ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareMultiplicationWithReference, CompareMultiplicationTest)
499
500ARMNN_COMPARE_REF_AUTO_TEST_CASE(CompareBatchNorm, CompareBatchNormTest)
501
502ARMNN_COMPARE_REF_AUTO_TEST_CASE(ReLu1, CompareBoundedReLuTest, 1.0f, -1.0f)
503ARMNN_COMPARE_REF_AUTO_TEST_CASE(ReLu6, CompareBoundedReLuTest, 6.0f, 0.0f)
504
505// ============================================================================
506// FIXTURE tests
507
508ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSigmoidActivationWithReference, ActivationFixture,
509 CompareActivationTest, armnn::ActivationFunction::Sigmoid, 5u)
510
511ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareTanhActivationWithReference, ActivationFixture,
512 CompareActivationTest, armnn::ActivationFunction::TanH, 5u)
513
514ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareLinearActivationWithReference, ActivationFixture,
515 CompareActivationTest, armnn::ActivationFunction::Linear, 5u)
516
517ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareReLuActivationWithReference, ActivationFixture,
518 CompareActivationTest, armnn::ActivationFunction::ReLu, 5u)
519
520ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareBoundedReLuActivationWithReference, ActivationFixture,
521 CompareActivationTest, armnn::ActivationFunction::BoundedReLu, 5u)
522ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareBoundedReLuActivationWithReferenceUint8, ActivationFixture,
523 CompareActivationUint8Test, armnn::ActivationFunction::BoundedReLu)
524
525ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSoftReLuActivationWithReference, ActivationFixture,
526 CompareActivationTest, armnn::ActivationFunction::SoftReLu, 1u)
527
528ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareLeakyReLuActivationWithReference, ActivationFixture,
529 CompareActivationTest, armnn::ActivationFunction::LeakyReLu, 5u)
530
531ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareAbsActivationWithReference, ActivationFixture,
532 CompareActivationTest, armnn::ActivationFunction::Abs, 5u)
533
534ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSqrtActivationWithReference, PositiveActivationFixture,
535 CompareActivationTest, armnn::ActivationFunction::Sqrt, 5u)
536
537ARMNN_COMPARE_REF_FIXTURE_TEST_CASE(CompareSquareActivationWithReference, ActivationFixture,
538 CompareActivationTest, armnn::ActivationFunction::Square, 5u)
telsoa014fcda012018-03-09 14:13:49 +0000539BOOST_AUTO_TEST_SUITE_END()