blob: bc08666c5fb0160178becce73c33e6b76993a9f9 [file] [log] [blame]
John Richardsonf89a49f2017-09-05 11:21:56 +01001/*
Michalis Spyrou5c9f0c42019-01-16 14:48:48 +00002 * Copyright (c) 2017-2019 ARM Limited.
John Richardsonf89a49f2017-09-05 11:21:56 +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
25#include "arm_compute/runtime/NEON/functions/NEMinMaxLocation.h"
26#include "tests/NEON/Accessor.h"
27#include "tests/NEON/ArrayAccessor.h"
28#include "tests/PaddingCalculator.h"
29#include "tests/datasets/ShapeDatasets.h"
30#include "tests/framework/Macros.h"
31#include "tests/validation/Validation.h"
32#include "tests/validation/fixtures/MinMaxLocationFixture.h"
33
34namespace arm_compute
35{
36namespace test
37{
38namespace validation
39{
40TEST_SUITE(NEON)
41TEST_SUITE(MinMaxLocation)
42
43template <typename T>
44using NEMinMaxLocationFixture = MinMaxLocationValidationFixture<Tensor, Accessor, Array<Coordinates2D>, ArrayAccessor<Coordinates2D>, NEMinMaxLocation, T>;
45
46void validate_configuration(const Tensor &src, TensorShape shape)
47{
48 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
49
50 // Create output storage
51 int32_t min{};
52 int32_t max{};
53 Coordinates2DArray min_loc(shape.total_size());
54 Coordinates2DArray max_loc(shape.total_size());
55
56 // Create and configure function
57 NEMinMaxLocation min_max_loc;
58 min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc);
59
60 // Validate padding
61 const PaddingSize padding = PaddingCalculator(shape.x(), 1).required_padding();
62 validate(src.info()->padding(), padding);
63}
64
65TEST_SUITE(U8)
Michalis Spyrou5c9f0c42019-01-16 14:48:48 +000066DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +010067{
68 // Create tensors
69 Tensor src = create_tensor<Tensor>(shape, data_type);
70 src.info()->set_format(Format::U8);
71
72 validate_configuration(src, shape);
73}
74
75FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
76 DataType::U8)))
77{
78 validate_min_max_loc(_target, _reference);
79}
80
81FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
82 DataType::U8)))
83{
84 validate_min_max_loc(_target, _reference);
85}
86
87TEST_SUITE_END() // U8
88
89TEST_SUITE(S16)
Michalis Spyrou5c9f0c42019-01-16 14:48:48 +000090DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::S16)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +010091{
92 // Create tensors
93 Tensor src = create_tensor<Tensor>(shape, data_type);
94 src.info()->set_format(Format::S16);
95
96 validate_configuration(src, shape);
97}
98
99FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
100 DataType::S16)))
101{
102 validate_min_max_loc(_target, _reference);
103}
104
105FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
106 DataType::S16)))
107{
108 validate_min_max_loc(_target, _reference);
109}
110
111TEST_SUITE_END() // S16
112
113TEST_SUITE(Float)
Michalis Spyrou5c9f0c42019-01-16 14:48:48 +0000114DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +0100115{
116 // Create tensors
117 Tensor src = create_tensor<Tensor>(shape, data_type);
118 src.info()->set_format(Format::F32);
119
120 validate_configuration(src, shape);
121}
122
123FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
124 DataType::F32)))
125{
126 validate_min_max_loc(_target, _reference);
127}
128
129FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
130 DataType::F32)))
131{
132 validate_min_max_loc(_target, _reference);
133}
134
135TEST_SUITE_END() // F32
136
137TEST_SUITE_END() // MinMaxLocation
138TEST_SUITE_END() // NEON
139} // namespace validation
140} // namespace test
141} // namespace arm_compute