blob: 3aee0fe2e1058eadcc229bcc76b52118cb64f50d [file] [log] [blame]
Moritz Pflanzer7655a672017-09-23 11:57:33 +01001/*
Michalis Spyroud175ece2020-07-30 23:39:32 +01002 * Copyright (c) 2017-2020 Arm Limited.
Moritz Pflanzer7655a672017-09-23 11:57:33 +01003 *
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/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
27#include "arm_compute/runtime/CL/functions/CLSobel3x3.h"
28#include "arm_compute/runtime/CL/functions/CLSobel5x5.h"
29#include "arm_compute/runtime/CL/functions/CLSobel7x7.h"
30#include "tests/CL/CLAccessor.h"
31#include "tests/PaddingCalculator.h"
32#include "tests/datasets/BorderModeDataset.h"
33#include "tests/datasets/ShapeDatasets.h"
34#include "tests/framework/Asserts.h"
35#include "tests/framework/Macros.h"
36#include "tests/framework/datasets/Datasets.h"
37#include "tests/validation/Validation.h"
38#include "tests/validation/fixtures/SobelFixture.h"
39
40namespace arm_compute
41{
42namespace test
43{
44namespace validation
45{
46TEST_SUITE(CL)
47TEST_SUITE(Sobel)
48
49TEST_SUITE(W3x3)
50using CLSobel3x3Fixture = SobelValidationFixture<CLTensor, CLAccessor, CLSobel3x3, uint8_t, int16_t>;
51
Isabella Gottardi43ce8982017-11-08 11:13:23 +000052TEST_SUITE(X)
Michalis Spyroucac09dc2020-11-24 00:16:49 +000053FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
54 Format::U8)),
55 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +000056{
57 // Validate output
58 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
59 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
60}
61
62FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
63 Format::U8)),
64 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
65{
66 // Validate output
67 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
68 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
69}
70TEST_SUITE_END()
71
72TEST_SUITE(Y)
Michalis Spyroucac09dc2020-11-24 00:16:49 +000073FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
74 Format::U8)),
75 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +000076{
77 // Validate output
78 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
79 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
80}
81
82FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
83 Format::U8)),
84 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
85{
86 // Validate output
87 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
88 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
89}
90TEST_SUITE_END()
91
92TEST_SUITE(XY)
Michalis Spyroucac09dc2020-11-24 00:16:49 +000093FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
94 Format::U8)),
95 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +010096{
97 // Validate output
98 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
99 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
100
101 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
102 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
103}
104
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000105FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
106 Format::U8)),
107 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100108{
109 // Validate output
110 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
111 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
112
113 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
114 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
115}
116TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000117TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100118
119TEST_SUITE(W5x5)
120using CLSobel5x5Fixture = SobelValidationFixture<CLTensor, CLAccessor, CLSobel5x5, uint8_t, int16_t>;
121
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000122TEST_SUITE(X)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000123FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
124 Format::U8)),
125 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000126{
127 // Validate output
128 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
129 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
130}
131
132FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
133 Format::U8)),
134 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
135{
136 // Validate output
137 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
138 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
139}
140TEST_SUITE_END()
141TEST_SUITE(Y)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000142FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
143 Format::U8)),
144 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000145{
146 // Validate output
147 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
148 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
149}
150
151FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
152 Format::U8)),
153 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
154{
155 // Validate output
156 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
157 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
158}
159TEST_SUITE_END()
160TEST_SUITE(XY)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000161FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
162 Format::U8)),
163 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100164{
165 // Validate output
166 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
167 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
168
169 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
170 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
171}
172
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000173FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
174 Format::U8)),
175 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100176{
177 // Validate output
178 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
179 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
180
181 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
182 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
183}
184TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000185TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100186
187TEST_SUITE(W7x7)
188using CLSobel7x7Fixture = SobelValidationFixture<CLTensor, CLAccessor, CLSobel7x7, uint8_t, int32_t>;
189
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000190TEST_SUITE(X)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000191FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
192 Format::U8)),
193 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000194{
195 // Validate output
196 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
197 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
198}
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100199
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000200FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
201 Format::U8)),
202 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
203{
204 // Validate output
205 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
206 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
207}
208TEST_SUITE_END()
209TEST_SUITE(Y)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000210FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
211 Format::U8)),
212 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000213{
214 // Validate output
215 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
216 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
217}
218
219FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
220 Format::U8)),
221 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
222{
223 // Validate output
224 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
225 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
226}
227TEST_SUITE_END()
228TEST_SUITE(XY)
Michalis Spyroucac09dc2020-11-24 00:16:49 +0000229FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
230 Format::U8)),
231 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100232{
233 // Validate output
234 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
235 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
236
237 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
238 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
239}
240
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000241FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
242 Format::U8)),
243 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100244{
245 // Validate output
246 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
247 validate(CLAccessor(_target.first), _reference.first, valid_region_x);
248
249 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
250 validate(CLAccessor(_target.second), _reference.second, valid_region_y);
251}
252TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000253TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100254
255TEST_SUITE_END()
256TEST_SUITE_END()
257} // namespace validation
258} // namespace test
259} // namespace arm_compute