blob: 0aea19939ee1b88582034229f7a1884d569c6ccf [file] [log] [blame]
John Kesapides2dce6cc2019-01-14 09:47:09 +00001/*
Mohammed Suhail Munshidc4f2762022-05-12 11:00:36 +01002 * Copyright (c) 2019-2022 Arm Limited.
John Kesapides2dce6cc2019-01-14 09:47:09 +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"
25#include "arm_compute/runtime/NEON/functions/NEGather.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28
29#include "tests/NEON/Accessor.h"
30#include "tests/PaddingCalculator.h"
31#include "tests/datasets/GatherDataset.h"
32#include "tests/datasets/ShapeDatasets.h"
33#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
37#include "tests/validation/fixtures/GatherFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45TEST_SUITE(NEON)
46TEST_SUITE(Gather)
47
48// *INDENT-OFF*
49// clang-format off
50DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
Georgios Pinitas8f5802f2019-02-22 11:08:32 +000051 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 27U), 1, DataType::F32),
John Kesapides2dce6cc2019-01-14 09:47:09 +000052 TensorInfo(TensorShape(27U, 27U), 1, DataType::F32),
53 TensorInfo(TensorShape(27U, 27U), 1, DataType::F32), // Invalid Indices data type
54 TensorInfo(TensorShape(27U, 27U), 1, DataType::F32), // Invalid Indices dimensionality
55 TensorInfo(TensorShape(5U, 5U, 5U, 5U, 5U), 1, DataType::F32), // Invalid Input dimensionality
56 TensorInfo(TensorShape(27U, 27U), 1, DataType::F16), // Mismatching data type input/output
57 TensorInfo(TensorShape(27U, 27U), 1, DataType::F32), // Invalid positive axis value
58 TensorInfo(TensorShape(27U, 27U), 1, DataType::F16), // Invalid negative axis value
59 }),
60 framework::dataset::make("IndicesInfo", {
61 TensorInfo(TensorShape(10U), 1, DataType::U32),
62 TensorInfo(TensorShape(10U), 1, DataType::U32),
John Kesapides2dce6cc2019-01-14 09:47:09 +000063 TensorInfo(TensorShape(10U), 1, DataType::U8),
64 TensorInfo(TensorShape(10U, 10U), 1, DataType::U32),
65 TensorInfo(TensorShape(10U), 1, DataType::U32),
66 TensorInfo(TensorShape(10U), 1, DataType::U32),
67 TensorInfo(TensorShape(10U), 1, DataType::U32),
68 TensorInfo(TensorShape(10U), 1, DataType::U32),
69 })),
70 framework::dataset::make("OutputInfo", {
John Kesapides2dce6cc2019-01-14 09:47:09 +000071 TensorInfo(TensorShape(27U, 10U), 1, DataType::F32),
72 TensorInfo(TensorShape(10U, 27U), 1, DataType::F32),
73 TensorInfo(TensorShape(10U, 27U), 1, DataType::F32),
74 TensorInfo(TensorShape(27U, 10U), 1, DataType::F32),
75 TensorInfo(TensorShape(10U, 5U, 5U, 5U, 5U), 1, DataType::F32),
76 TensorInfo(TensorShape(27U, 10U), 1, DataType::F32),
77 TensorInfo(TensorShape(27U, 27U), 1, DataType::F32),
78 TensorInfo(TensorShape(27U, 27U), 1, DataType::F16),
79 })),
80 framework::dataset::make("Axis", {
81 0,
82 1,
83 -2,
84 0,
85 1,
86 0,
87 1,
88 2,
89 -3,
90 })),
Georgios Pinitas8f5802f2019-02-22 11:08:32 +000091 framework::dataset::make("Expected", { true, true, false, false, false, false, false, false })),
John Kesapides2dce6cc2019-01-14 09:47:09 +000092 input_info, indices_info, output_info, axis, expected)
93{
94 const Status status = NEGather::validate(&input_info.clone()->set_is_resizable(true), &indices_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), axis);
95 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
96}
97// clang-format on
98// *INDENT-ON*
99
John Kesapides2dce6cc2019-01-14 09:47:09 +0000100template <typename T>
101using NEGatherFixture = GatherFixture<Tensor, Accessor, NEGather, T>;
102
Pablo Marquez Tello894659a2022-05-13 12:20:16 +0100103const auto gather_small_shapes = arm_compute::test::framework::dataset::concat(datasets::SmallGatherDataset(), datasets::SmallGatherMultiDimIndicesDataset());
104
John Kesapides2dce6cc2019-01-14 09:47:09 +0000105TEST_SUITE(Float)
106TEST_SUITE(FP16)
107FIXTURE_DATA_TEST_CASE(RunSmall,
108 NEGatherFixture<half>,
109 framework::DatasetMode::PRECOMMIT,
Pablo Marquez Tello894659a2022-05-13 12:20:16 +0100110 combine(gather_small_shapes, framework::dataset::make("DataType", DataType::F16)))
John Kesapides2dce6cc2019-01-14 09:47:09 +0000111{
112 // Validate output
113 validate(Accessor(_target), _reference);
114}
115
116FIXTURE_DATA_TEST_CASE(RunLarge,
117 NEGatherFixture<half>,
118 framework::DatasetMode::NIGHTLY,
119 combine(datasets::LargeGatherDataset(), framework::dataset::make("DataType", DataType::F16)))
120{
121 // Validate output
122 validate(Accessor(_target), _reference);
123}
124TEST_SUITE_END() // FP16
125
126TEST_SUITE(FP32)
127FIXTURE_DATA_TEST_CASE(RunSmall,
128 NEGatherFixture<float>,
129 framework::DatasetMode::PRECOMMIT,
Pablo Marquez Tello894659a2022-05-13 12:20:16 +0100130 combine(gather_small_shapes, framework::dataset::make("DataType", DataType::F32)))
John Kesapides2dce6cc2019-01-14 09:47:09 +0000131{
132 // Validate output
133 validate(Accessor(_target), _reference);
134}
135
136FIXTURE_DATA_TEST_CASE(RunLarge,
137 NEGatherFixture<float>,
138 framework::DatasetMode::NIGHTLY,
139 combine(datasets::LargeGatherDataset(), framework::dataset::make("DataType", DataType::F32)))
140{
141 // Validate output
142 validate(Accessor(_target), _reference);
143}
144TEST_SUITE_END() // FP32
145TEST_SUITE_END() // Float
146
147TEST_SUITE(U8)
148FIXTURE_DATA_TEST_CASE(RunSmall,
149 NEGatherFixture<uint8_t>,
150 framework::DatasetMode::PRECOMMIT,
Pablo Marquez Tello894659a2022-05-13 12:20:16 +0100151 combine(gather_small_shapes, framework::dataset::make("DataType", DataType::U8)))
John Kesapides2dce6cc2019-01-14 09:47:09 +0000152{
153 // Validate output
154 validate(Accessor(_target), _reference);
155}
156
157FIXTURE_DATA_TEST_CASE(RunLarge,
158 NEGatherFixture<uint8_t>,
159 framework::DatasetMode::NIGHTLY,
160 combine(datasets::LargeGatherDataset(), framework::dataset::make("DataType", DataType::U8)))
161{
162 // Validate output
163 validate(Accessor(_target), _reference);
164}
165TEST_SUITE_END() // U8
166
167TEST_SUITE(U16)
168FIXTURE_DATA_TEST_CASE(RunSmall,
169 NEGatherFixture<uint16_t>,
170 framework::DatasetMode::PRECOMMIT,
Pablo Marquez Tello894659a2022-05-13 12:20:16 +0100171 combine(gather_small_shapes, framework::dataset::make("DataType", DataType::U16)))
John Kesapides2dce6cc2019-01-14 09:47:09 +0000172{
173 // Validate output
174 validate(Accessor(_target), _reference);
175}
176
177FIXTURE_DATA_TEST_CASE(RunLarge,
178 NEGatherFixture<uint16_t>,
179 framework::DatasetMode::NIGHTLY,
180 combine(datasets::LargeGatherDataset(), framework::dataset::make("DataType", DataType::U16)))
181{
182 // Validate output
183 validate(Accessor(_target), _reference);
184}
185TEST_SUITE_END() // U16
186
187TEST_SUITE_END() // Gather
Sheri Zhangac6499a2021-02-10 15:32:38 +0000188TEST_SUITE_END() // Neon
John Kesapides2dce6cc2019-01-14 09:47:09 +0000189} // namespace validation
190} // namespace test
191} // namespace arm_compute