Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 1 | /* |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 2023 Arm Limited. |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 3 | * |
| 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/Helpers.h" |
| 25 | #include "arm_compute/core/Types.h" |
| 26 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 27 | #include "arm_compute/runtime/NEON/functions/NEStackLayer.h" |
| 28 | #include "arm_compute/runtime/Tensor.h" |
| 29 | #include "arm_compute/runtime/TensorAllocator.h" |
| 30 | #include "tests/NEON/Accessor.h" |
| 31 | #include "tests/PaddingCalculator.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/StackLayerFixture.h" |
| 38 | |
| 39 | #include <vector> |
| 40 | |
| 41 | namespace arm_compute |
| 42 | { |
| 43 | namespace test |
| 44 | { |
| 45 | namespace validation |
| 46 | { |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 47 | |
| 48 | using framework::dataset::make; |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 49 | namespace |
| 50 | { |
| 51 | // *INDENT-OFF* |
| 52 | // clang-format off |
| 53 | /** Data types */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 54 | const auto data_types = make("DataType", { DataType::QASYMM8, DataType::F16, DataType::F32 }); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 55 | |
| 56 | /** Num tensors values to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 57 | const auto n_values = make("NumTensors", { 3, 4 }); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 58 | |
| 59 | /** Shapes 1D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 60 | const auto shapes_1d_small = combine(datasets::Small1DShapes(), make("Axis", -1, 2)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 61 | |
| 62 | /** Shapes 2D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 63 | const auto shapes_2d_small = combine(datasets::Small2DShapes(), make("Axis", -2, 3)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 64 | |
| 65 | /** Shapes 3D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 66 | const auto shapes_3d_small = combine(datasets::Small3DShapes(), make("Axis", -3, 4)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 67 | |
| 68 | /** Shapes 4D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 69 | const auto shapes_4d_small = combine(datasets::Small4DShapes(), make("Axis", -4, 5)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 70 | |
| 71 | /** Shapes 1D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 72 | const auto shapes_1d_large = combine(datasets::Large1DShapes(), make("Axis", -1, 2)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 73 | |
| 74 | /** Shapes 2D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 75 | const auto shapes_2d_large = combine(datasets::Medium2DShapes(), make("Axis", -2, 3)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 76 | |
| 77 | /** Shapes 3D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 78 | const auto shapes_3d_large = combine(datasets::Medium3DShapes(), make("Axis", -3, 4)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 79 | |
| 80 | /** Shapes 4D to test */ |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 81 | const auto shapes_4d_large = combine(datasets::Medium4DShapes(), make("Axis", -4, 5)); |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 82 | } // namespace |
| 83 | |
| 84 | /** Fixture to use */ |
| 85 | template<typename T> |
| 86 | using NEStackLayerFixture = StackLayerValidationFixture<Tensor, ITensor, Accessor, NEStackLayer, T>; |
| 87 | |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 88 | template<typename T> |
| 89 | using NEStackLayerWithPaddingFixture = StackLayerWithPaddingValidationFixture<Tensor, ITensor, Accessor, NEStackLayer, T>; |
| 90 | |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 91 | using namespace arm_compute::misc::shape_calculator; |
| 92 | |
| 93 | TEST_SUITE(NEON) |
| 94 | TEST_SUITE(StackLayer) |
| 95 | |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 96 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip( |
| 97 | make("InputInfo", |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 98 | { |
| 99 | std::vector<TensorInfo>{ TensorInfo(TensorShape(9U, 8U), 1, DataType::U8) }, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 100 | std::vector<TensorInfo>{ TensorInfo(TensorShape(1U, 2U), 1, DataType::U8) , TensorInfo(TensorShape(1U, 2U), 1, DataType::U8), TensorInfo(TensorShape(1U, 2U), 1, DataType::U8)}, |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 101 | std::vector<TensorInfo>{ TensorInfo(TensorShape(2U, 3U), 1, DataType::S32) }, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 102 | std::vector<TensorInfo>{ TensorInfo(TensorShape(7U, 5U, 3U, 8U, 2U), 1, DataType::S32), TensorInfo(TensorShape(7U, 5U, 3U, 8U, 2U), 1, DataType::S32)}, |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 103 | std::vector<TensorInfo>{ TensorInfo(TensorShape(9U, 8U), 1, DataType::S32) }, |
| 104 | }), |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 105 | make("OutputInfo", |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 106 | { |
| 107 | TensorInfo(TensorShape(1U, 9U, 8U), 1, DataType::U8), // Passes, stack 1 tensor on x axis |
| 108 | TensorInfo(TensorShape(1U, 3U, 2U), 1, DataType::U8), // Passes, stack 3 tensors on y axis |
| 109 | TensorInfo(TensorShape(1U, 2U, 3U), 1, DataType::S32), // fails axis < (- input's rank) |
| 110 | TensorInfo(TensorShape(3U, 7U, 5U), 1, DataType::S32), // fails, input dimensions > 4 |
| 111 | TensorInfo(TensorShape(1U, 2U, 3U), 1, DataType::U8), // fails mismatching data types |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 112 | }), |
| 113 | make("Axis", { -3, 1, -4, -3, 1 }), |
| 114 | make("Expected", { true, true, false, false, false })), |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 115 | input_info, output_info, axis, expected) |
| 116 | { |
| 117 | std::vector<TensorInfo> ti(input_info); |
| 118 | std::vector<ITensorInfo *> vec(input_info.size()); |
| 119 | for(size_t j = 0; j < vec.size(); ++j) |
| 120 | { |
| 121 | vec[j] = &ti[j]; |
| 122 | } |
| 123 | ARM_COMPUTE_EXPECT(bool(NEStackLayer::validate(vec, axis, &output_info)) == expected, framework::LogLevel::ERRORS); |
| 124 | } |
| 125 | |
| 126 | TEST_SUITE(Shapes1D) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 127 | TEST_SUITE(S32) |
| 128 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<int>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 129 | combine(shapes_1d_small, |
| 130 | make("DataType", { DataType::S32 }), |
| 131 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 132 | { |
| 133 | // Validate output |
| 134 | validate(Accessor(_target), _reference); |
| 135 | } |
| 136 | |
| 137 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<int>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 138 | combine(shapes_1d_large, |
| 139 | make("DataType", { DataType::S32 }), |
| 140 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 141 | { |
| 142 | // Validate output |
| 143 | validate(Accessor(_target), _reference); |
| 144 | } |
| 145 | TEST_SUITE_END() // S32 |
| 146 | |
| 147 | TEST_SUITE(S16) |
| 148 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<short>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 149 | combine(shapes_1d_small, |
| 150 | make("DataType", { DataType::S16 }), |
| 151 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 152 | { |
| 153 | // Validate output |
| 154 | validate(Accessor(_target), _reference); |
| 155 | } |
| 156 | |
| 157 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<short>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 158 | combine(shapes_1d_large, |
| 159 | make("DataType", { DataType::S16 }), |
| 160 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 161 | { |
| 162 | // Validate output |
| 163 | validate(Accessor(_target), _reference); |
| 164 | } |
| 165 | TEST_SUITE_END() // S16 |
| 166 | |
| 167 | TEST_SUITE(S8) |
| 168 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<char>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 169 | combine(shapes_1d_small, |
| 170 | make("DataType", { DataType::S8 }), |
| 171 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 172 | { |
| 173 | // Validate output |
| 174 | validate(Accessor(_target), _reference); |
| 175 | } |
| 176 | |
| 177 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<char>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 178 | combine(shapes_1d_large, |
| 179 | make("DataType", { DataType::S8 }), |
| 180 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 181 | { |
| 182 | // Validate output |
| 183 | validate(Accessor(_target), _reference); |
| 184 | } |
| 185 | TEST_SUITE_END() // S8 |
| 186 | TEST_SUITE_END() // Shapes1D |
| 187 | |
| 188 | TEST_SUITE(Shapes2D) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 189 | TEST_SUITE(S32) |
| 190 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<int>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 191 | combine(shapes_2d_small, |
| 192 | make("DataType", { DataType::S32 }), |
| 193 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 194 | { |
| 195 | // Validate output |
| 196 | validate(Accessor(_target), _reference); |
| 197 | } |
| 198 | |
| 199 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<int>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 200 | combine(shapes_2d_large, |
| 201 | make("DataType", { DataType::S32 }), |
| 202 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 203 | { |
| 204 | // Validate output |
| 205 | validate(Accessor(_target), _reference); |
| 206 | } |
| 207 | TEST_SUITE_END() // S32 |
| 208 | |
| 209 | TEST_SUITE(S16) |
| 210 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<short>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 211 | combine(shapes_2d_small, |
| 212 | make("DataType", { DataType::S16 }), |
| 213 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 214 | { |
| 215 | // Validate output |
| 216 | validate(Accessor(_target), _reference); |
| 217 | } |
| 218 | |
| 219 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<short>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 220 | combine(shapes_2d_large, |
| 221 | make("DataType", { DataType::S16 }), |
| 222 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 223 | { |
| 224 | // Validate output |
| 225 | validate(Accessor(_target), _reference); |
| 226 | } |
| 227 | TEST_SUITE_END() // S16 |
| 228 | |
| 229 | TEST_SUITE(S8) |
| 230 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<char>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 231 | combine(shapes_2d_small, |
| 232 | make("DataType", { DataType::S8 }), |
| 233 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 234 | { |
| 235 | // Validate output |
| 236 | validate(Accessor(_target), _reference); |
| 237 | } |
| 238 | |
| 239 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<char>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 240 | combine(shapes_2d_large, |
| 241 | make("DataType", { DataType::S8 }), |
| 242 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 243 | { |
| 244 | // Validate output |
| 245 | validate(Accessor(_target), _reference); |
| 246 | } |
| 247 | TEST_SUITE_END() // S8 |
| 248 | TEST_SUITE_END() // Shapes2D |
| 249 | |
| 250 | TEST_SUITE(Shapes3D) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 251 | TEST_SUITE(S32) |
| 252 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<int>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 253 | combine(shapes_3d_small, |
| 254 | make("DataType", { DataType::S32 }), |
| 255 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 256 | { |
| 257 | // Validate output |
| 258 | validate(Accessor(_target), _reference); |
| 259 | } |
| 260 | |
| 261 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<int>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 262 | combine(shapes_3d_large, |
| 263 | make("DataType", { DataType::S32 }), |
| 264 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 265 | { |
| 266 | // Validate output |
| 267 | validate(Accessor(_target), _reference); |
| 268 | } |
| 269 | TEST_SUITE_END() // S32 |
| 270 | |
| 271 | TEST_SUITE(S16) |
| 272 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<short>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 273 | combine(shapes_3d_small, |
| 274 | make("DataType", { DataType::S16 }), |
| 275 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 276 | { |
| 277 | // Validate output |
| 278 | validate(Accessor(_target), _reference); |
| 279 | } |
| 280 | |
| 281 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<short>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 282 | combine(shapes_3d_large, |
| 283 | make("DataType", { DataType::S16 }), |
| 284 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 285 | { |
| 286 | // Validate output |
| 287 | validate(Accessor(_target), _reference); |
| 288 | } |
| 289 | TEST_SUITE_END() // S16 |
| 290 | |
| 291 | TEST_SUITE(S8) |
| 292 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<char>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 293 | combine(shapes_3d_small, |
| 294 | make("DataType", { DataType::S8 }), |
| 295 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 296 | { |
| 297 | // Validate output |
| 298 | validate(Accessor(_target), _reference); |
| 299 | } |
| 300 | |
| 301 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<char>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 302 | combine(shapes_3d_large, |
| 303 | make("DataType", { DataType::S8 }), |
| 304 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 305 | { |
| 306 | // Validate output |
| 307 | validate(Accessor(_target), _reference); |
| 308 | } |
| 309 | TEST_SUITE_END() // S8 |
| 310 | TEST_SUITE_END() // Shapes3D |
| 311 | |
| 312 | TEST_SUITE(Shapes4D) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 313 | TEST_SUITE(S32) |
| 314 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<int>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 315 | combine(shapes_4d_small, |
| 316 | make("DataType", { DataType::S32 }), |
| 317 | n_values)) |
| 318 | { |
| 319 | // Validate output |
| 320 | validate(Accessor(_target), _reference); |
| 321 | } |
| 322 | |
| 323 | // Testing the case with padding for only 4d shapes and for one data type. This is because the underlying code |
| 324 | // path depends only on the padding, which isn't affected by the shapes or data types. |
| 325 | FIXTURE_DATA_TEST_CASE(RunSmallWithPadding, NEStackLayerWithPaddingFixture<int>, framework::DatasetMode::ALL, |
| 326 | combine(shapes_4d_small, |
| 327 | make("DataType", { DataType::S32 }), |
| 328 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 329 | { |
| 330 | // Validate output |
| 331 | validate(Accessor(_target), _reference); |
| 332 | } |
| 333 | |
| 334 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<int>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 335 | combine(shapes_4d_large, |
| 336 | make("DataType", { DataType::S32 }), |
| 337 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 338 | { |
| 339 | // Validate output |
| 340 | validate(Accessor(_target), _reference); |
| 341 | } |
| 342 | TEST_SUITE_END() // S32 |
| 343 | |
| 344 | TEST_SUITE(S16) |
| 345 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<short>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 346 | combine(shapes_4d_small, |
| 347 | make("DataType", { DataType::S16 }), |
| 348 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 349 | { |
| 350 | // Validate output |
| 351 | validate(Accessor(_target), _reference); |
| 352 | } |
| 353 | |
| 354 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<short>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 355 | combine(shapes_4d_large, |
| 356 | make("DataType", { DataType::S16 }), |
| 357 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 358 | { |
| 359 | // Validate output |
| 360 | validate(Accessor(_target), _reference); |
| 361 | } |
| 362 | TEST_SUITE_END() // S16 |
| 363 | |
| 364 | TEST_SUITE(S8) |
| 365 | FIXTURE_DATA_TEST_CASE(RunSmall, NEStackLayerFixture<char>, framework::DatasetMode::ALL, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 366 | combine(shapes_4d_small, |
| 367 | make("DataType", { DataType::S8 }), |
| 368 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 369 | { |
| 370 | // Validate output |
| 371 | validate(Accessor(_target), _reference); |
| 372 | } |
| 373 | |
| 374 | FIXTURE_DATA_TEST_CASE(RunLarge, NEStackLayerFixture<char>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 375 | combine(shapes_4d_large, |
| 376 | make("DataType", { DataType::S8 }), |
| 377 | n_values)) |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 378 | { |
| 379 | // Validate output |
| 380 | validate(Accessor(_target), _reference); |
| 381 | } |
| 382 | TEST_SUITE_END() // S8 |
| 383 | TEST_SUITE_END() // Shapes4D |
Gunes Bayir | 0b72aa4 | 2023-10-07 23:52:48 +0100 | [diff] [blame] | 384 | |
| 385 | TEST_SUITE(HighDimensional) |
| 386 | // The Cpu implementation supports tensors of size 4D+, but reference implementation does not. |
| 387 | FIXTURE_DATA_TEST_CASE(RunHighDimensional, NEStackLayerFixture<char>, framework::DatasetMode::DISABLED, |
| 388 | combine(make("Shape", { TensorShape{2U, 3U, 4U, 5U, 3U} }), |
| 389 | make("Axis", { 5, 0, -3, 2 }), |
| 390 | make("DataType", { DataType::S8 }), |
| 391 | make("NumTensors", { 3 }))) |
| 392 | { |
| 393 | // Validate output |
| 394 | validate(Accessor(_target), _reference); |
| 395 | } |
| 396 | TEST_SUITE_END() // HighDimensional |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 397 | TEST_SUITE_END() // StackLayer |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 398 | TEST_SUITE_END() // Neon |
Isabella Gottardi | ee7c15d | 2018-12-17 16:15:34 +0000 | [diff] [blame] | 399 | } // namespace validation |
| 400 | } // namespace test |
| 401 | } // namespace arm_compute |