blob: 0c00ee301b400e5365627f15069c600995848d76 [file] [log] [blame]
Sanghoon Leec8a85ba2017-11-29 11:23:14 +00001/*
Michalis Spyrou80943252019-01-10 17:19:50 +00002 * Copyright (c) 2017-2019 ARM Limited.
Sanghoon Leec8a85ba2017-11-29 11:23:14 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/CL/functions/CLConvolution.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/CL/CLAccessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/BorderModeDataset.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/ConvolutionFixture.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000044TEST_SUITE(CL)
45TEST_SUITE(CustomConvolution)
Sanghoon Leec0079e92018-01-29 17:28:49 +000046TEST_SUITE(Square3x3)
Michalis Spyrou80943252019-01-10 17:19:50 +000047DATA_TEST_CASE(Configuration, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })),
48 datasets::BorderModes()),
49 framework::dataset::make("filter_size", { 3 })),
Sanghoon Leec8d23162018-01-12 16:19:10 +000050 shape, output_data_type, border_mode, filter_size)
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000051{
52 // Create tensors
Sanghoon Leec8d23162018-01-12 16:19:10 +000053 CLTensor src = create_tensor<CLTensor>(shape, DataType::U8);
54 CLTensor dst = create_tensor<CLTensor>(shape, output_data_type);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000055
56 // Create conv matrix
57 int16_t conv[9];
58
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000059 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
60 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
61
62 // Create and configure function
63 CLConvolution3x3 convolution;
Sanghoon Leed7ba5392017-12-13 11:28:50 +000064 convolution.configure(&src, &dst, conv, 0, border_mode);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000065
66 // Validate valid region
Sanghoon Leed7ba5392017-12-13 11:28:50 +000067 const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000068 validate(dst.info()->valid_region(), dst_valid_region);
69
70 // Validate padding
71 PaddingCalculator calculator(shape.x(), 8);
72 calculator.set_border_size(1);
73 calculator.set_border_mode(border_mode);
74
75 const PaddingSize dst_padding = calculator.required_padding();
76
77 calculator.set_accessed_elements(16);
78 calculator.set_access_offset(-1);
79
80 const PaddingSize src_padding = calculator.required_padding();
81
82 validate(src.info()->padding(), src_padding);
83 validate(dst.info()->padding(), dst_padding);
84}
85
86template <typename T>
Sanghoon Leed7ba5392017-12-13 11:28:50 +000087using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution3x3, T>;
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000088
Sanghoon Leec0079e92018-01-29 17:28:49 +000089TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +000090FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
91 framework::dataset::make("DataType",
92 DataType::U8)),
Sanghoon Leed7ba5392017-12-13 11:28:50 +000093 datasets::BorderModes()),
94 framework::dataset::make("filter_size", { 3 })))
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000095{
96 // Validate output
Sanghoon Leed7ba5392017-12-13 11:28:50 +000097 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +000098}
Michalis Spyrou80943252019-01-10 17:19:50 +000099TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000100
Sanghoon Leec0079e92018-01-29 17:28:49 +0000101TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000102FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
103 framework::dataset::make("DataType",
104 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000105 datasets::BorderModes()),
106 framework::dataset::make("filter_size", { 3 })))
107{
108 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000109 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000110}
Michalis Spyrou80943252019-01-10 17:19:50 +0000111TEST_SUITE_END() // S16
112TEST_SUITE_END() // Square 3x3
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000113
Sanghoon Leec0079e92018-01-29 17:28:49 +0000114TEST_SUITE(Square5x5)
Michalis Spyrou80943252019-01-10 17:19:50 +0000115DATA_TEST_CASE(Configuration, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })),
116 datasets::BorderModes()),
117 framework::dataset::make("filter_size", { 5 })),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000118 shape, output_data_type, border_mode, filter_size)
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000119{
120 // Create tensors
Sanghoon Leec8d23162018-01-12 16:19:10 +0000121 CLTensor src = create_tensor<CLTensor>(shape, DataType::U8);
122 CLTensor dst = create_tensor<CLTensor>(shape, output_data_type);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000123
124 // Create conv matrix
125 int16_t conv[25];
126
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000127 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
128 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
129
130 // Create and configure function
131 CLConvolution5x5 convolution;
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000132 convolution.configure(&src, &dst, conv, 0, border_mode);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000133
134 // Validate valid region
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000135 const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000136 validate(dst.info()->valid_region(), dst_valid_region);
137
138 // Validate padding
139 PaddingCalculator calculator(shape.x(), 8);
140 calculator.set_border_size(2);
141 calculator.set_border_mode(border_mode);
142
143 const PaddingSize dst_padding = calculator.required_padding();
144
145 calculator.set_accessed_elements(16);
146 calculator.set_access_offset(-2);
147
148 const PaddingSize src_padding = calculator.required_padding();
149
150 validate(src.info()->padding(), src_padding);
151 validate(dst.info()->padding(), dst_padding);
152}
153
154template <typename T>
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000155using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution5x5, T>;
Sanghoon Leec8d23162018-01-12 16:19:10 +0000156
Sanghoon Leec0079e92018-01-29 17:28:49 +0000157TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000158FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
159 framework::dataset::make("DataType",
160 DataType::U8)),
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000161 datasets::BorderModes()),
162 framework::dataset::make("filter_size", { 5 })))
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000163{
164 // Validate output
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000165 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000166}
Michalis Spyrou80943252019-01-10 17:19:50 +0000167TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000168
Sanghoon Leec0079e92018-01-29 17:28:49 +0000169TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000170FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
171 framework::dataset::make("DataType",
172 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000173 datasets::BorderModes()),
174 framework::dataset::make("filter_size", { 5 })))
175{
176 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000177 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000178}
Michalis Spyrou80943252019-01-10 17:19:50 +0000179TEST_SUITE_END() // S16
180TEST_SUITE_END() // Square5x5
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000181
Sanghoon Leec0079e92018-01-29 17:28:49 +0000182TEST_SUITE(Square7x7)
Michalis Spyrou80943252019-01-10 17:19:50 +0000183DATA_TEST_CASE(Configuration, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })),
184 datasets::BorderModes()),
185 framework::dataset::make("filter_size", { 7 })),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000186 shape, output_data_type, border_mode, filter_size)
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000187{
188 // Create tensors
Sanghoon Leec8d23162018-01-12 16:19:10 +0000189 CLTensor src = create_tensor<CLTensor>(shape, DataType::U8);
190 CLTensor dst = create_tensor<CLTensor>(shape, output_data_type);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000191
192 // Create conv matrix
193 int16_t conv[49];
194
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000195 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
196 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
197
198 // Create and configure function
199 CLConvolution7x7 convolution;
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000200 convolution.configure(&src, &dst, conv, 0, border_mode);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000201
202 // Validate valid region
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000203 const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000204 validate(dst.info()->valid_region(), dst_valid_region);
205
206 // Validate padding
207 PaddingCalculator calculator(shape.x(), 8);
208 calculator.set_border_size(3);
209 calculator.set_border_mode(border_mode);
210
211 const PaddingSize dst_padding = calculator.required_padding();
212
213 calculator.set_accessed_elements(16);
214 calculator.set_access_offset(-3);
215
216 const PaddingSize src_padding = calculator.required_padding();
217
218 validate(src.info()->padding(), src_padding);
219 validate(dst.info()->padding(), dst_padding);
220}
221
222template <typename T>
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000223using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution7x7, T>;
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000224
Sanghoon Leec0079e92018-01-29 17:28:49 +0000225TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000226FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
227 framework::dataset::make("DataType",
228 DataType::U8)),
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000229 datasets::BorderModes()),
230 framework::dataset::make("filter_size", { 7 })))
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000231{
232 // Validate output
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000233 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000234}
Michalis Spyrou80943252019-01-10 17:19:50 +0000235TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000236
Sanghoon Leec0079e92018-01-29 17:28:49 +0000237TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000238FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
239 framework::dataset::make("DataType",
240 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000241 datasets::BorderModes()),
242 framework::dataset::make("filter_size", { 7 })))
243{
244 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000245 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000246}
Michalis Spyrou80943252019-01-10 17:19:50 +0000247TEST_SUITE_END() // S16
248TEST_SUITE_END() // Square7x7
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000249
Sanghoon Leec0079e92018-01-29 17:28:49 +0000250TEST_SUITE(Square9x9)
Michalis Spyrou80943252019-01-10 17:19:50 +0000251DATA_TEST_CASE(Configuration, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })),
252 datasets::BorderModes()),
253 framework::dataset::make("filter_size", { 9 })),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000254 shape, output_data_type, border_mode, filter_size)
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000255{
256 // Create tensors
Sanghoon Leec8d23162018-01-12 16:19:10 +0000257 CLTensor src = create_tensor<CLTensor>(shape, DataType::U8);
258 CLTensor dst = create_tensor<CLTensor>(shape, output_data_type);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000259
260 // Create conv matrix
261 int16_t conv[81];
262
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000263 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
264 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
265
266 // Create and configure function
267 CLConvolution9x9 convolution;
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000268 convolution.configure(&src, &dst, conv, 0, border_mode);
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000269
270 // Validate valid region
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000271 const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000272 validate(dst.info()->valid_region(), dst_valid_region);
273
274 // Validate padding
275 PaddingCalculator calculator(shape.x(), 8);
276 calculator.set_border_size(4);
277 calculator.set_border_mode(border_mode);
278
279 const PaddingSize dst_padding = calculator.required_padding();
280
281 calculator.set_accessed_elements(16);
282 calculator.set_access_offset(-4);
283
284 const PaddingSize src_padding = calculator.required_padding();
285
286 validate(src.info()->padding(), src_padding);
287 validate(dst.info()->padding(), dst_padding);
288}
289
290template <typename T>
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000291using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution9x9, T>;
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000292
Sanghoon Leec0079e92018-01-29 17:28:49 +0000293TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000294FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
295 framework::dataset::make("DataType",
296 DataType::U8)),
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000297 datasets::BorderModes()),
298 framework::dataset::make("filter_size", { 9 })))
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000299{
300 // Validate output
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000301 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000302}
Michalis Spyrou80943252019-01-10 17:19:50 +0000303TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000304
Sanghoon Leec0079e92018-01-29 17:28:49 +0000305TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000306FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
307 framework::dataset::make("DataType",
308 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000309 datasets::BorderModes()),
310 framework::dataset::make("filter_size", { 9 })))
311{
312 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000313 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000314}
Michalis Spyrou80943252019-01-10 17:19:50 +0000315TEST_SUITE_END() // S16
316TEST_SUITE_END() // Square9x9
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000317
Sanghoon Leec0079e92018-01-29 17:28:49 +0000318TEST_SUITE(Rectangle)
Michalis Spyrou80943252019-01-10 17:19:50 +0000319DATA_TEST_CASE(Configuration, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Sanghoon Leec8d23162018-01-12 16:19:10 +0000320{ DataType::U8, DataType::S16 })),
321datasets::BorderModes()),
322framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
323framework::dataset::make("filter_height", { 3, 5, 7, 9 })),
324shape, output_data_type, border_mode, filter_width, filter_height)
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000325{
326 // Create tensors
Sanghoon Leec8d23162018-01-12 16:19:10 +0000327 CLTensor src = create_tensor<CLTensor>(shape, DataType::U8);
328 CLTensor dst = create_tensor<CLTensor>(shape, output_data_type);
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000329
330 // Create conv matrix
331 int16_t conv[filter_width * filter_height];
332
333 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
334 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
335
336 // Create and configure function
337 CLConvolutionRectangle convolution;
338 convolution.configure(&src, &dst, conv, filter_width, filter_height, 1, border_mode);
339
340 // Validate valid region
341 const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_height / 2, filter_width / 2));
342 validate(dst.info()->valid_region(), dst_valid_region);
343
344 // Validate padding
345 PaddingCalculator calculator(shape.x(), 8);
346 calculator.set_border_size(filter_width / 2);
347 calculator.set_border_mode(border_mode);
348
349 const PaddingSize dst_padding = calculator.required_padding();
350
351 calculator.set_accessed_elements(16);
352 calculator.set_access_offset(-(filter_width / 2));
353
354 const PaddingSize width_padding = calculator.required_padding();
355
356 calculator.set_border_size(filter_height / 2);
357 calculator.set_access_offset(-(filter_height / 2));
358 const PaddingSize height_padding = calculator.required_padding();
359
360 validate(src.info()->padding(), width_padding, height_padding);
361 validate(dst.info()->padding(), dst_padding);
362}
363
364template <typename T>
365using CLConvolutionFixture = ConvolutionRectangleValidationFixture<CLTensor, CLAccessor, CLConvolutionRectangle, T>;
366
Sanghoon Leec0079e92018-01-29 17:28:49 +0000367TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000368FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
369 framework::dataset::make("DataType",
370 DataType::U8)),
Sanghoon Leed7ba5392017-12-13 11:28:50 +0000371 datasets::BorderModes()),
372 framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
373 framework::dataset::make("filter_height", { 3, 5, 7, 9 })))
374{
375 // Validate output
376 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
377}
Michalis Spyrou80943252019-01-10 17:19:50 +0000378TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000379
Sanghoon Leec0079e92018-01-29 17:28:49 +0000380TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000381FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
382 framework::dataset::make("DataType",
383 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000384 datasets::BorderModes()),
385 framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
386 framework::dataset::make("filter_height", { 3, 5, 7, 9 })))
387{
388 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000389 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000390}
Michalis Spyrou80943252019-01-10 17:19:50 +0000391TEST_SUITE_END() // S16
392TEST_SUITE_END() // Rectangle
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000393
Sanghoon Leec0079e92018-01-29 17:28:49 +0000394TEST_SUITE(Separable5x5)
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000395template <typename T>
396using CLConvolutionFixture = ConvolutionSeparableValidationFixture<CLTensor, CLAccessor, CLConvolution5x5, T>;
397
Sanghoon Leec0079e92018-01-29 17:28:49 +0000398TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000399FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
400 framework::dataset::make("DataType",
401 DataType::U8)),
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000402 datasets::BorderModes()),
403 framework::dataset::make("filter_size", { 5 })))
404{
405 // Validate output
406 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
407}
Michalis Spyrou80943252019-01-10 17:19:50 +0000408TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000409
Sanghoon Leec0079e92018-01-29 17:28:49 +0000410TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000411FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
412 framework::dataset::make("DataType",
413 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000414 datasets::BorderModes()),
415 framework::dataset::make("filter_size", { 5 })))
416{
417 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000418 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000419}
Michalis Spyrou80943252019-01-10 17:19:50 +0000420TEST_SUITE_END() // S16
421TEST_SUITE_END() // Separable5x5
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000422
Sanghoon Leec0079e92018-01-29 17:28:49 +0000423TEST_SUITE(Separable7x7)
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000424template <typename T>
425using CLConvolutionFixture = ConvolutionSeparableValidationFixture<CLTensor, CLAccessor, CLConvolution7x7, T>;
426
Sanghoon Leec0079e92018-01-29 17:28:49 +0000427TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000428FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
429 framework::dataset::make("DataType",
430 DataType::U8)),
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000431 datasets::BorderModes()),
432 framework::dataset::make("filter_size", { 7 })))
433{
434 // Validate output
435 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
436}
Michalis Spyrou80943252019-01-10 17:19:50 +0000437TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000438
Sanghoon Leec0079e92018-01-29 17:28:49 +0000439TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000440FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
441 framework::dataset::make("DataType",
442 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000443 datasets::BorderModes()),
444 framework::dataset::make("filter_size", { 7 })))
445{
446 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000447 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000448}
Michalis Spyrou80943252019-01-10 17:19:50 +0000449TEST_SUITE_END() // S16
450TEST_SUITE_END() // Separable7x7
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000451
Sanghoon Leec0079e92018-01-29 17:28:49 +0000452TEST_SUITE(Separable9x9)
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000453template <typename T>
454using CLConvolutionFixture = ConvolutionSeparableValidationFixture<CLTensor, CLAccessor, CLConvolution9x9, T>;
455
Sanghoon Leec0079e92018-01-29 17:28:49 +0000456TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000457FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
458 framework::dataset::make("DataType",
459 DataType::U8)),
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000460 datasets::BorderModes()),
461 framework::dataset::make("filter_size", { 9 })))
462{
463 // Validate output
464 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
465}
Michalis Spyrou80943252019-01-10 17:19:50 +0000466TEST_SUITE_END() // U8
Sanghoon Leec8d23162018-01-12 16:19:10 +0000467
Sanghoon Leec0079e92018-01-29 17:28:49 +0000468TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000469FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()),
470 framework::dataset::make("DataType",
471 DataType::S16)),
Sanghoon Leec8d23162018-01-12 16:19:10 +0000472 datasets::BorderModes()),
473 framework::dataset::make("filter_size", { 9 })))
474{
475 // Validate output
Georgios Pinitase9146ed2018-02-07 16:05:47 +0000476 validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
Sanghoon Leec8d23162018-01-12 16:19:10 +0000477}
478TEST_SUITE_END()
Michalis Spyrou80943252019-01-10 17:19:50 +0000479TEST_SUITE_END() // Separable9x9
Sanghoon Lee571b18a2017-12-22 16:20:11 +0000480
Michalis Spyrou80943252019-01-10 17:19:50 +0000481TEST_SUITE_END() // Custom Convolution
482TEST_SUITE_END() // CL
Sanghoon Leec8a85ba2017-11-29 11:23:14 +0000483} // namespace validation
484} // namespace test
485} // namespace arm_compute