blob: e7ab4a4bbf330c0d9df95e66a8a4b1fffd77ca75 [file] [log] [blame]
Michalis Spyrouaea14c62019-01-03 11:10:25 +00001/*
Michalis Spyrou7317e392020-01-17 11:27:49 +00002 * Copyright (c) 2018-2020 ARM Limited.
Michalis Spyrouaea14c62019-01-03 11:10:25 +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"
Michalis Spyroub9626ab2019-05-13 17:41:01 +010025#include "arm_compute/core/utils/misc/Traits.h"
Michalis Spyrouaea14c62019-01-03 11:10:25 +000026#include "arm_compute/runtime/NEON/functions/NEArgMinMaxLayer.h"
Sang-Hoon Park2697fd82019-10-15 16:49:24 +010027#include "arm_compute/runtime/NEON/functions/NEReductionOperation.h"
Michalis Spyrouaea14c62019-01-03 11:10:25 +000028#include "arm_compute/runtime/Tensor.h"
29#include "arm_compute/runtime/TensorAllocator.h"
30
Sang-Hoon Park2697fd82019-10-15 16:49:24 +010031#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Michalis Spyrouaea14c62019-01-03 11:10:25 +000032#include "tests/NEON/Accessor.h"
33#include "tests/datasets/ShapeDatasets.h"
34#include "tests/datasets/SplitDataset.h"
35#include "tests/framework/Asserts.h"
36#include "tests/framework/Macros.h"
37#include "tests/validation/Validation.h"
38#include "tests/validation/fixtures/ArgMinMaxFixture.h"
39
40namespace arm_compute
41{
42namespace test
43{
44namespace validation
45{
46TEST_SUITE(NEON)
47TEST_SUITE(ArgMinMax)
48
49// *INDENT-OFF*
50// clang-format off
51DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
52 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid axis
53 TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid output shape
54 TensorInfo(TensorShape(32U, 16U, 16U, 2U), 1, DataType::F32),
55 TensorInfo(TensorShape(32U, 16U, 16U, 2U), 1, DataType::F32) // Invalid operation
56 }),
57 framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(27U, 3U, 1U, 2U), 1, DataType::F32),
58 TensorInfo(TensorShape(27U, 3U, 1U, 2U), 1, DataType::F32),
Sang-Hoon Parkeaa01ab2019-11-11 17:33:28 +000059 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::S32),
Michalis Spyrouaea14c62019-01-03 11:10:25 +000060 TensorInfo(TensorShape(32U, 16U, 1U, 2U), 1, DataType::F32)
61 })),
62 framework::dataset::make("Axis", { 4, 0, 2, 0 })),
63 framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MAX, ReductionOperation::ARG_IDX_MAX, ReductionOperation::ARG_IDX_MAX, ReductionOperation::MEAN_SUM })),
64 framework::dataset::make("Expected", { false, false, true, false })),
65 input_info, output_info, axis, operation, expected)
66{
67 const Status status = NEArgMinMaxLayer::validate(&input_info.clone()->set_is_resizable(false), axis, &output_info.clone()->set_is_resizable(false), operation);
68 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
69}
70// clang-format on
71// *INDENT-ON*
72
Michalis Spyrouaea14c62019-01-03 11:10:25 +000073template <typename T>
74using NEArgMinMaxValidationFixture = ArgMinMaxValidationFixture<Tensor, Accessor, NEArgMinMaxLayer, T>;
75
Michalis Spyroub9626ab2019-05-13 17:41:01 +010076TEST_SUITE(S32)
77FIXTURE_DATA_TEST_CASE(RunSmall,
78 NEArgMinMaxValidationFixture<int32_t>,
79 framework::DatasetMode::PRECOMMIT,
80 combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::S32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
81{
82 // Validate output
83 validate(Accessor(_target), _reference);
84}
85
86FIXTURE_DATA_TEST_CASE(RunLarge,
87 NEArgMinMaxValidationFixture<int32_t>,
88 framework::DatasetMode::NIGHTLY,
89 combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::S32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
90{
91 // Validate output
92 validate(Accessor(_target), _reference);
93}
94TEST_SUITE_END() // S32
95
Michalis Spyrouaea14c62019-01-03 11:10:25 +000096TEST_SUITE(Float)
97#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
98TEST_SUITE(FP16)
99FIXTURE_DATA_TEST_CASE(RunSmall,
100 NEArgMinMaxValidationFixture<half>,
101 framework::DatasetMode::PRECOMMIT,
102 combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
103{
104 // Validate output
105 validate(Accessor(_target), _reference);
106}
107
108FIXTURE_DATA_TEST_CASE(RunLarge,
109 NEArgMinMaxValidationFixture<half>,
110 framework::DatasetMode::NIGHTLY,
111 combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
112{
113 // Validate output
114 validate(Accessor(_target), _reference);
115}
116TEST_SUITE_END() // FP16
117#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
118
Michalis Spyrou254a48a2019-01-14 17:27:39 +0000119TEST_SUITE(FP32)
120FIXTURE_DATA_TEST_CASE(RunSmall,
121 NEArgMinMaxValidationFixture<float>,
122 framework::DatasetMode::PRECOMMIT,
123 combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
124{
125 // Validate output
126 validate(Accessor(_target), _reference);
127}
128
129FIXTURE_DATA_TEST_CASE(RunLarge,
130 NEArgMinMaxValidationFixture<float>,
131 framework::DatasetMode::NIGHTLY,
132 combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
133{
134 // Validate output
135 validate(Accessor(_target), _reference);
136}
137TEST_SUITE_END() // FP32
138TEST_SUITE_END() // Float
139
Michalis Spyrouaea14c62019-01-03 11:10:25 +0000140template <typename T>
141using NEArgMinMaxQuantizedValidationFixture = ArgMinMaxValidationQuantizedFixture<Tensor, Accessor, NEArgMinMaxLayer, T>;
142
143TEST_SUITE(QASYMM8)
144FIXTURE_DATA_TEST_CASE(RunSmall,
145 NEArgMinMaxQuantizedValidationFixture<uint8_t>,
146 framework::DatasetMode::PRECOMMIT,
147 combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
148 framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })),
149 framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 255.f, 20) })))
150{
151 // Validate output
152 validate(Accessor(_target), _reference);
153}
154
155FIXTURE_DATA_TEST_CASE(RunLarge,
156 NEArgMinMaxQuantizedValidationFixture<uint8_t>,
157 framework::DatasetMode::NIGHTLY,
158 combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
159 framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })),
160 framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 255.f, 20) })))
161{
162 // Validate output
163 validate(Accessor(_target), _reference);
164}
165TEST_SUITE_END() // QASYMM8
Luca Foschianiee939fb2020-01-28 10:38:07 +0000166
167TEST_SUITE(QASYMM8_SIGNED)
168FIXTURE_DATA_TEST_CASE(RunSmall,
169 NEArgMinMaxQuantizedValidationFixture<int8_t>,
170 framework::DatasetMode::PRECOMMIT,
171 combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
172 framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })),
173 framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 127.f, 20) })))
174{
175 // Validate output
176 validate(Accessor(_target), _reference);
177}
178
179FIXTURE_DATA_TEST_CASE(RunLarge,
180 NEArgMinMaxQuantizedValidationFixture<int8_t>,
181 framework::DatasetMode::NIGHTLY,
182 combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
183 framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })),
184 framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 127.f, 20) })))
185{
186 // Validate output
187 validate(Accessor(_target), _reference);
188}
189TEST_SUITE_END() // QASYMM8_SIGNED
Michalis Spyrouaea14c62019-01-03 11:10:25 +0000190TEST_SUITE_END() // ArgMinMax
191TEST_SUITE_END() // NEON
192} // namespace validation
193} // namespace test
194} // namespace arm_compute