blob: 82effc2136b56ce66bf9b01245721b7dc4031052 [file] [log] [blame]
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +00001/*
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +01002 * Copyright (c) 2018-2020, 2023 Arm Limited.
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +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/CL/CLTensor.h"
27#include "arm_compute/runtime/CL/CLTensorAllocator.h"
28#include "arm_compute/runtime/CL/functions/CLReverse.h"
29#include "tests/CL/CLAccessor.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{
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010044using framework::dataset::make;
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000045namespace
46{
Adnan AlSinan704c22f2023-10-24 11:05:56 +010047auto run_small_dataset = combine(datasets::Small3DShapes(), datasets::Tiny1DShapes());
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000048auto run_large_dataset = combine(datasets::LargeShapes(), datasets::Tiny1DShapes());
49
50} // namespace
51TEST_SUITE(CL)
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
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +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
61 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
62 TensorInfo(TensorShape(2U), 1, DataType::U8),
63 }),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010064 make("OutputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S8),
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000065 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
66 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
67 TensorInfo(TensorShape(2U, 13U, 2U), 1, DataType::U8),
68 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
69 TensorInfo(TensorShape(2U), 1, DataType::U8),
70 })),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010071 make("AxisInfo",{ TensorInfo(TensorShape(3U), 1, DataType::U8),
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000072 TensorInfo(TensorShape(2U, 10U), 1, DataType::U32),
73 TensorInfo(TensorShape(8U), 1, DataType::U32),
74 TensorInfo(TensorShape(2U), 1, DataType::U32),
75 TensorInfo(TensorShape(2U), 1, DataType::U32),
76 TensorInfo(TensorShape(2U), 1, DataType::U32),
77 })),
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010078 make("Expected", { false, false, false, false, true, true})),
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000079 src_info, dst_info, axis_info, expected)
80{
81 Status s = CLReverse::validate(&src_info.clone()->set_is_resizable(false),
82 &dst_info.clone()->set_is_resizable(false),
Adnan AlSinan704c22f2023-10-24 11:05:56 +010083 &axis_info.clone()->set_is_resizable(false),
84 false);
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +000085 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
86}
87// clang-format on
88// *INDENT-ON*
89
90template <typename T>
91using CLReverseFixture = ReverseValidationFixture<CLTensor, CLAccessor, CLReverse, T>;
92
93TEST_SUITE(Float)
94TEST_SUITE(F16)
95FIXTURE_DATA_TEST_CASE(RunSmall,
96 CLReverseFixture<half>,
97 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010098 combine(
99 run_small_dataset,
100 make("DataType", DataType::F16),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100101 make("use_negative_axis", { true, false }),
102 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000103{
104 // Validate output
105 validate(CLAccessor(_target), _reference);
106}
107
108FIXTURE_DATA_TEST_CASE(RunLarge,
109 CLReverseFixture<half>,
110 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100111 combine(
112 run_large_dataset,
113 make("DataType", DataType::F16),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100114 make("use_negative_axis", { true, false }),
115 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000116{
117 // Validate output
118 validate(CLAccessor(_target), _reference);
119}
120TEST_SUITE_END() // F16
121
122TEST_SUITE(FP32)
123FIXTURE_DATA_TEST_CASE(RunSmall,
124 CLReverseFixture<float>,
125 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100126 combine(
127 run_small_dataset,
128 make("DataType", DataType::F32),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100129 make("use_negative_axis", { true, false }),
130 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000131{
132 // Validate output
133 validate(CLAccessor(_target), _reference);
134}
135
136FIXTURE_DATA_TEST_CASE(RunLarge,
137 CLReverseFixture<float>,
138 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100139 combine(
140 run_large_dataset,
141 make("DataType", DataType::F32),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100142 make("use_negative_axis", { true, false }),
143 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000144{
145 // Validate output
146 validate(CLAccessor(_target), _reference);
147}
148TEST_SUITE_END() // F32
149TEST_SUITE_END() // Float
150
151TEST_SUITE(Quantized)
152TEST_SUITE(QASYMM8)
153FIXTURE_DATA_TEST_CASE(RunSmall,
154 CLReverseFixture<uint8_t>,
155 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100156 combine(
157 run_small_dataset,
158 make("DataType", DataType::QASYMM8),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100159 make("use_negative_axis", { true, false }),
160 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000161{
162 // Validate output
163 validate(CLAccessor(_target), _reference);
164}
165
166FIXTURE_DATA_TEST_CASE(RunLarge,
167 CLReverseFixture<uint8_t>,
168 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100169 combine(
170 run_large_dataset,
171 make("DataType", DataType::QASYMM8),
Adnan AlSinan704c22f2023-10-24 11:05:56 +0100172 make("use_negative_axis", { true, false }),
173 make("use_inverted_axis", { true, false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000174{
175 // Validate output
176 validate(CLAccessor(_target), _reference);
177}
178TEST_SUITE_END() // QASYMM8
179TEST_SUITE_END() // Quantized
180
181TEST_SUITE_END() // Reverse
182TEST_SUITE_END() // CL
183} // namespace validation
184} // namespace test
185} // namespace arm_compute