blob: e090bcd6e21b5941734ad56fe8baaaabb284af3e [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/NEON/functions/NESobel3x3.h"
26#include "arm_compute/runtime/NEON/functions/NESobel5x5.h"
27#include "arm_compute/runtime/NEON/functions/NESobel7x7.h"
28#include "arm_compute/runtime/Tensor.h"
29#include "arm_compute/runtime/TensorAllocator.h"
30#include "tests/NEON/Accessor.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(NEON)
47TEST_SUITE(Sobel)
48
49TEST_SUITE(W3x3)
50using NESobel3x3Fixture = SobelValidationFixture<Tensor, Accessor, NESobel3x3, uint8_t, int16_t>;
51
Isabella Gottardi43ce8982017-11-08 11:13:23 +000052TEST_SUITE(X)
53FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
54 Format::U8)),
55 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
56{
57 // Validate output
58 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
59 validate(Accessor(_target.first), _reference.first, valid_region_x);
60}
61
62FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, 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(Accessor(_target.first), _reference.first, valid_region_x);
69}
70TEST_SUITE_END()
71TEST_SUITE(Y)
72FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
73 Format::U8)),
74 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
75{
76 // Validate output
77 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
78 validate(Accessor(_target.second), _reference.second, valid_region_y);
79}
80
81FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
82 Format::U8)),
83 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
84{
85 // Validate output
86 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
87 validate(Accessor(_target.second), _reference.second, valid_region_y);
88}
89TEST_SUITE_END()
90TEST_SUITE(XY)
91FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
92 Format::U8)),
93 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +010094{
95 // Validate output
96 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
97 validate(Accessor(_target.first), _reference.first, valid_region_x);
98
99 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
100 validate(Accessor(_target.second), _reference.second, valid_region_y);
101}
102
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000103FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
104 Format::U8)),
105 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100106{
107 // Validate output
108 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
109 validate(Accessor(_target.first), _reference.first, valid_region_x);
110
111 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1));
112 validate(Accessor(_target.second), _reference.second, valid_region_y);
113}
114TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000115TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100116
117TEST_SUITE(W5x5)
118using NESobel5x5Fixture = SobelValidationFixture<Tensor, Accessor, NESobel5x5, uint8_t, int16_t>;
119
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000120TEST_SUITE(X)
121FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
122 Format::U8)),
123 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
124{
125 // Validate output
126 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
127 validate(Accessor(_target.first), _reference.first, valid_region_x);
128}
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100129
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000130FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
131 Format::U8)),
132 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
133{
134 // Validate output
135 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
136 validate(Accessor(_target.first), _reference.first, valid_region_x);
137}
138TEST_SUITE_END()
139TEST_SUITE(Y)
140FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
141 Format::U8)),
142 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
143{
144 // Validate output
145 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
146 validate(Accessor(_target.second), _reference.second, valid_region_y);
147}
148
149FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
150 Format::U8)),
151 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
152{
153 // Validate output
154 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
155 validate(Accessor(_target.second), _reference.second, valid_region_y);
156}
157TEST_SUITE_END()
158TEST_SUITE(XY)
159FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
160 Format::U8)),
161 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100162{
163 // Validate output
164 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
165 validate(Accessor(_target.first), _reference.first, valid_region_x);
166
167 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
168 validate(Accessor(_target.second), _reference.second, valid_region_y);
169}
170
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000171FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
172 Format::U8)),
173 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100174{
175 // Validate output
176 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
177 validate(Accessor(_target.first), _reference.first, valid_region_x);
178
179 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2));
180 validate(Accessor(_target.second), _reference.second, valid_region_y);
181}
182TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000183TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100184
185TEST_SUITE(W7x7)
186using NESobel7x7Fixture = SobelValidationFixture<Tensor, Accessor, NESobel7x7, uint8_t, int32_t>;
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000187TEST_SUITE(X)
188FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
189 Format::U8)),
190 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
191{
192 // Validate output
193 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
194 validate(Accessor(_target.first), _reference.first, valid_region_x);
195}
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100196
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000197FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
198 Format::U8)),
199 framework::dataset::make("GradientDimension", GradientDimension::GRAD_X)))
200{
201 // Validate output
202 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
203 validate(Accessor(_target.first), _reference.first, valid_region_x);
204}
205TEST_SUITE_END()
206TEST_SUITE(Y)
207FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
208 Format::U8)),
209 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
210{
211 // Validate output
212 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
213 validate(Accessor(_target.second), _reference.second, valid_region_y);
214}
215
216FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
217 Format::U8)),
218 framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y)))
219{
220 // Validate output
221 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
222 validate(Accessor(_target.second), _reference.second, valid_region_y);
223}
224TEST_SUITE_END()
225TEST_SUITE(XY)
226FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
227 Format::U8)),
228 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100229{
230 // Validate output
231 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
232 validate(Accessor(_target.first), _reference.first, valid_region_x);
233
234 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
235 validate(Accessor(_target.second), _reference.second, valid_region_y);
236}
237
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000238FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format",
239 Format::U8)),
240 framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY)))
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100241{
242 // Validate output
243 ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
244 validate(Accessor(_target.first), _reference.first, valid_region_x);
245
246 ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3));
247 validate(Accessor(_target.second), _reference.second, valid_region_y);
248}
249TEST_SUITE_END()
Isabella Gottardi43ce8982017-11-08 11:13:23 +0000250TEST_SUITE_END()
Moritz Pflanzer7655a672017-09-23 11:57:33 +0100251
252TEST_SUITE_END()
253TEST_SUITE_END()
254} // namespace validation
255} // namespace test
256} // namespace arm_compute