blob: ff46ba64adcfe3ac336c2d7877bba03890545459 [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{
47auto run_small_dataset = combine(datasets::SmallShapes(), datasets::Tiny1DShapes());
48auto 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),
83 &axis_info.clone()->set_is_resizable(false));
84 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
85}
86// clang-format on
87// *INDENT-ON*
88
89template <typename T>
90using CLReverseFixture = ReverseValidationFixture<CLTensor, CLAccessor, CLReverse, T>;
91
92TEST_SUITE(Float)
93TEST_SUITE(F16)
94FIXTURE_DATA_TEST_CASE(RunSmall,
95 CLReverseFixture<half>,
96 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +010097 combine(
98 run_small_dataset,
99 make("DataType", DataType::F16),
100 make("use_negative_axis", { false }),
101 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000102{
103 // Validate output
104 validate(CLAccessor(_target), _reference);
105}
106
107FIXTURE_DATA_TEST_CASE(RunLarge,
108 CLReverseFixture<half>,
109 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100110 combine(
111 run_large_dataset,
112 make("DataType", DataType::F16),
113 make("use_negative_axis", { false }),
114 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000115{
116 // Validate output
117 validate(CLAccessor(_target), _reference);
118}
119TEST_SUITE_END() // F16
120
121TEST_SUITE(FP32)
122FIXTURE_DATA_TEST_CASE(RunSmall,
123 CLReverseFixture<float>,
124 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100125 combine(
126 run_small_dataset,
127 make("DataType", DataType::F32),
128 make("use_negative_axis", { false }),
129 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000130{
131 // Validate output
132 validate(CLAccessor(_target), _reference);
133}
134
135FIXTURE_DATA_TEST_CASE(RunLarge,
136 CLReverseFixture<float>,
137 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100138 combine(
139 run_large_dataset,
140 make("DataType", DataType::F32),
141 make("use_negative_axis", { false }),
142 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000143{
144 // Validate output
145 validate(CLAccessor(_target), _reference);
146}
147TEST_SUITE_END() // F32
148TEST_SUITE_END() // Float
149
150TEST_SUITE(Quantized)
151TEST_SUITE(QASYMM8)
152FIXTURE_DATA_TEST_CASE(RunSmall,
153 CLReverseFixture<uint8_t>,
154 framework::DatasetMode::PRECOMMIT,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100155 combine(
156 run_small_dataset,
157 make("DataType", DataType::QASYMM8),
158 make("use_negative_axis", { false }),
159 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000160{
161 // Validate output
162 validate(CLAccessor(_target), _reference);
163}
164
165FIXTURE_DATA_TEST_CASE(RunLarge,
166 CLReverseFixture<uint8_t>,
167 framework::DatasetMode::NIGHTLY,
Adnan AlSinanbdcb4c12023-09-18 14:49:45 +0100168 combine(
169 run_large_dataset,
170 make("DataType", DataType::QASYMM8),
171 make("use_negative_axis", { false }),
172 make("use_inverted_axis", { false })))
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000173{
174 // Validate output
175 validate(CLAccessor(_target), _reference);
176}
177TEST_SUITE_END() // QASYMM8
178TEST_SUITE_END() // Quantized
179
180TEST_SUITE_END() // Reverse
181TEST_SUITE_END() // CL
182} // namespace validation
183} // namespace test
184} // namespace arm_compute