blob: 7b5337f14b42bd5dcc26f6db21e37168dfffd400 [file] [log] [blame]
Michalis Spyrou110b9202018-12-28 16:32:49 +00001/*
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +01002 * Copyright (c) 2018-2021, 2023 Arm Limited.
Michalis Spyrou110b9202018-12-28 16:32:49 +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
25#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/NEON/functions/NEReverse.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
29#include "tests/NEON/Accessor.h"
30#include "tests/PaddingCalculator.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/ReverseFixture.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010046using framework::dataset::make;
Adnan AlSinan4ea9bac2023-10-13 16:51:58 +010047auto run_small_dataset = combine(datasets::Small3DShapes(), datasets::Tiny1DShapes());
Michalis Spyrou110b9202018-12-28 16:32:49 +000048auto run_large_dataset = combine(datasets::LargeShapes(), datasets::Tiny1DShapes());
49
50} // namespace
51TEST_SUITE(NEON)
52TEST_SUITE(Reverse)
53
54// *INDENT-OFF*
55// clang-format off
56DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010057 make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S8), // Invalid axis datatype
Michalis Spyrou110b9202018-12-28 16:32:49 +000058 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid axis shape
59 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid axis length (> 4)
60 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Mismatching shapes
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010061 TensorInfo(TensorShape(32U, 13U, 17U, 3U, 2U), 1, DataType::U8), // Unsupported source dimensions (>4)
Michalis Spyrou110b9202018-12-28 16:32:49 +000062 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
63 TensorInfo(TensorShape(2U), 1, DataType::U8),
64 }),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010065 make("OutputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S8),
Michalis Spyrou110b9202018-12-28 16:32:49 +000066 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
67 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
68 TensorInfo(TensorShape(2U, 13U, 2U), 1, DataType::U8),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010069 TensorInfo(TensorShape(32U, 13U, 17U, 3U, 2U), 1, DataType::U8),
Michalis Spyrou110b9202018-12-28 16:32:49 +000070 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
71 TensorInfo(TensorShape(2U), 1, DataType::U8),
72 })),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010073 make("AxisInfo", { TensorInfo(TensorShape(3U), 1, DataType::U8),
Michalis Spyrou110b9202018-12-28 16:32:49 +000074 TensorInfo(TensorShape(2U, 10U), 1, DataType::U32),
75 TensorInfo(TensorShape(8U), 1, DataType::U32),
76 TensorInfo(TensorShape(2U), 1, DataType::U32),
77 TensorInfo(TensorShape(2U), 1, DataType::U32),
78 TensorInfo(TensorShape(2U), 1, DataType::U32),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010079 TensorInfo(TensorShape(2U), 1, DataType::U32),
Michalis Spyrou110b9202018-12-28 16:32:49 +000080 })),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010081 make("Expected", { false, false, false, false, false, true, true})),
Michalis Spyrou110b9202018-12-28 16:32:49 +000082 src_info, dst_info, axis_info, expected)
83{
84 Status s = NEReverse::validate(&src_info.clone()->set_is_resizable(false),
85 &dst_info.clone()->set_is_resizable(false),
86 &axis_info.clone()->set_is_resizable(false));
87 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
88}
89// clang-format on
90// *INDENT-ON*
91
92template <typename T>
93using NEReverseFixture = ReverseValidationFixture<Tensor, Accessor, NEReverse, T>;
94
95TEST_SUITE(Float)
96
97#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
98TEST_SUITE(F16)
99FIXTURE_DATA_TEST_CASE(RunSmall,
100 NEReverseFixture<half>,
101 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100102 combine(
103 run_small_dataset,
104 make("DataType", DataType::F16),
105 make("use_negative_axis", { true, false }),
106 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000107{
108 // Validate output
109 validate(Accessor(_target), _reference);
110}
111
112FIXTURE_DATA_TEST_CASE(RunLarge,
113 NEReverseFixture<half>,
114 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100115 combine(
116 run_large_dataset,
117 make("DataType", DataType::F16),
118 make("use_negative_axis", { true, false }),
119 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000120{
121 // Validate output
122 validate(Accessor(_target), _reference);
123}
124TEST_SUITE_END() // F16
125#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
126
127TEST_SUITE(FP32)
128FIXTURE_DATA_TEST_CASE(RunSmall,
129 NEReverseFixture<float>,
130 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100131 combine(
132 run_small_dataset,
133 make("DataType", DataType::F32),
134 make("use_negative_axis", { true, false }),
135 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000136{
137 // Validate output
138 validate(Accessor(_target), _reference);
139}
140
141FIXTURE_DATA_TEST_CASE(RunLarge,
142 NEReverseFixture<float>,
143 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100144 combine(
145 run_large_dataset,
146 make("DataType", DataType::F32),
147 make("use_negative_axis", { true, false }),
148 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000149{
150 // Validate output
151 validate(Accessor(_target), _reference);
152}
153TEST_SUITE_END() // F32
154TEST_SUITE_END() // Float
155
156TEST_SUITE(Quantized)
157TEST_SUITE(QASYMM8)
158FIXTURE_DATA_TEST_CASE(RunSmall,
159 NEReverseFixture<uint8_t>,
160 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100161 combine(
162 run_small_dataset,
163 make("DataType", DataType::QASYMM8),
164 make("use_negative_axis", { true, false }),
165 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000166{
167 // Validate output
168 validate(Accessor(_target), _reference);
169}
170
171FIXTURE_DATA_TEST_CASE(RunLarge,
172 NEReverseFixture<uint8_t>,
173 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100174 combine(
175 run_large_dataset,
176 make("DataType", DataType::QASYMM8),
177 make("use_negative_axis", { true, false }),
178 make("use_inverted_axis", { true, false })))
Michalis Spyrou110b9202018-12-28 16:32:49 +0000179{
180 // Validate output
181 validate(Accessor(_target), _reference);
182}
183TEST_SUITE_END() // QASYMM8
184TEST_SUITE_END() // Quantized
185
186TEST_SUITE_END() // Reverse
Sheri Zhangac6499a2021-02-10 15:32:38 +0000187TEST_SUITE_END() // Neon
Michalis Spyrou110b9202018-12-28 16:32:49 +0000188} // namespace validation
189} // namespace test
190} // namespace arm_compute