Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | fbf0e5b | 2020-08-17 01:01:06 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "StackTestImpl.hpp" |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 7 | #include <armnnTestUtils/LayerTestResult.hpp> |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 8 | |
| 9 | #include <ResolveType.hpp> |
| 10 | |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 11 | |
Matteo Martincigh | e5b8eb9 | 2019-11-28 15:45:42 +0000 | [diff] [blame] | 12 | #include <armnn/backends/IBackendInternal.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 13 | #include <armnn/backends/WorkloadFactory.hpp> |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 14 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 15 | #include <armnnTestUtils/TensorCopyUtils.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 16 | #include <armnnTestUtils/WorkloadTestUtils.hpp> |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 17 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 18 | #include <TensorHelpers.hpp> |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 19 | |
| 20 | namespace |
| 21 | { |
| 22 | |
| 23 | template<armnn::DataType ArmnnType, typename T, std::size_t outputDimLength> |
| 24 | LayerTestResult<T, outputDimLength> StackTestHelper( |
| 25 | armnn::IWorkloadFactory& workloadFactory, |
| 26 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 27 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 28 | const armnn::TensorInfo& inputTensorInfo, |
| 29 | const armnn::TensorInfo& outputTensorInfo, |
| 30 | unsigned int axis, |
| 31 | const std::vector<std::vector<T>>& inputData, |
| 32 | const std::vector<T>& outputExpectedData) |
| 33 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 34 | IgnoreUnused(memoryManager); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 35 | unsigned int numInputs = static_cast<unsigned int>(inputData.size()); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 36 | std::vector<std::vector<T>> inputs; |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 37 | for (unsigned int i = 0; i < numInputs; ++i) |
| 38 | { |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 39 | inputs.emplace_back(inputData[i]); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 40 | } |
| 41 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 42 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 43 | |
| 44 | std::vector<std::unique_ptr<armnn::ITensorHandle>> inputHandles; |
| 45 | for (unsigned int i = 0; i < numInputs; ++i) |
| 46 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 47 | inputHandles.push_back(tensorHandleFactory.CreateTensorHandle(inputTensorInfo)); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 48 | } |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 49 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 50 | |
| 51 | armnn::StackQueueDescriptor descriptor; |
| 52 | descriptor.m_Parameters.m_Axis = axis; |
| 53 | descriptor.m_Parameters.m_InputShape = inputTensorInfo.GetShape(); |
| 54 | descriptor.m_Parameters.m_NumInputs = numInputs; |
| 55 | |
| 56 | armnn::WorkloadInfo info; |
| 57 | for (unsigned int i = 0; i < numInputs; ++i) |
| 58 | { |
| 59 | std::unique_ptr<armnn::ITensorHandle>& inputHandle = inputHandles[i]; |
| 60 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 61 | inputHandle->Allocate(); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 62 | CopyDataToITensorHandle(inputHandle.get(), inputs[i].data()); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 66 | outputHandle->Allocate(); |
| 67 | |
| 68 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateStack(descriptor, info); |
| 69 | |
| 70 | workload->Execute(); |
| 71 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 72 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 73 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 74 | return LayerTestResult<T, outputDimLength>(actualOutput, |
| 75 | outputExpectedData, |
| 76 | outputHandle->GetShape(), |
| 77 | outputTensorInfo.GetShape()); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | } // anonymous namespace |
| 81 | |
| 82 | // |
| 83 | // Implementation templates |
| 84 | // |
| 85 | |
| 86 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 87 | LayerTestResult<T, 4> StackAxis0TestImpl( |
| 88 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 89 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 90 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 91 | { |
| 92 | armnn::TensorInfo inputTensorInfo ({ 3, 2, 3 }, ArmnnType); |
| 93 | armnn::TensorInfo outputTensorInfo({ 2, 3, 2, 3 }, ArmnnType); |
| 94 | |
| 95 | std::vector<std::vector<T>> inputData; |
| 96 | |
| 97 | inputData.push_back( |
| 98 | { |
| 99 | 1, 2, 3, |
| 100 | 4, 5, 6, |
| 101 | |
| 102 | 7, 8, 9, |
| 103 | 10, 11, 12, |
| 104 | |
| 105 | 13, 14, 15, |
| 106 | 16, 17, 18 |
| 107 | }); |
| 108 | |
| 109 | inputData.push_back( |
| 110 | { |
| 111 | 19, 20, 21, |
| 112 | 22, 23, 24, |
| 113 | |
| 114 | 25, 26, 27, |
| 115 | 28, 29, 30, |
| 116 | |
| 117 | 31, 32, 33, |
| 118 | 34, 35, 36 |
| 119 | }); |
| 120 | |
| 121 | std::vector<T> outputExpectedData = |
| 122 | { |
| 123 | 1, 2, 3, |
| 124 | 4, 5, 6, |
| 125 | |
| 126 | 7, 8, 9, |
| 127 | 10, 11, 12, |
| 128 | |
| 129 | 13, 14, 15, |
| 130 | 16, 17, 18, |
| 131 | |
| 132 | |
| 133 | 19, 20, 21, |
| 134 | 22, 23, 24, |
| 135 | |
| 136 | 25, 26, 27, |
| 137 | 28, 29, 30, |
| 138 | |
| 139 | 31, 32, 33, |
| 140 | 34, 35, 36 |
| 141 | }; |
| 142 | |
| 143 | return StackTestHelper<ArmnnType, T, 4>( |
| 144 | workloadFactory, |
| 145 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 146 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 147 | inputTensorInfo, |
| 148 | outputTensorInfo, |
| 149 | 0U, |
| 150 | inputData, |
| 151 | outputExpectedData |
| 152 | ); |
| 153 | } |
| 154 | |
| 155 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 156 | LayerTestResult<T, 4> StackOutput4DAxis1TestImpl( |
| 157 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 158 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 159 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 160 | { |
| 161 | armnn::TensorInfo inputTensorInfo ({ 3, 2, 3 }, ArmnnType); |
| 162 | armnn::TensorInfo outputTensorInfo({ 3, 2, 2, 3 }, ArmnnType); |
| 163 | |
| 164 | std::vector<std::vector<T>> inputData; |
| 165 | |
| 166 | inputData.push_back( |
| 167 | { |
| 168 | 1, 2, 3, |
| 169 | 4, 5, 6, |
| 170 | |
| 171 | 7, 8, 9, |
| 172 | 10, 11, 12, |
| 173 | |
| 174 | 13, 14, 15, |
| 175 | 16, 17, 18 |
| 176 | }); |
| 177 | |
| 178 | inputData.push_back( |
| 179 | { |
| 180 | 19, 20, 21, |
| 181 | 22, 23, 24, |
| 182 | |
| 183 | 25, 26, 27, |
| 184 | 28, 29, 30, |
| 185 | |
| 186 | 31, 32, 33, |
| 187 | 34, 35, 36 |
| 188 | }); |
| 189 | |
| 190 | std::vector<T> outputExpectedData = |
| 191 | { |
| 192 | 1, 2, 3, |
| 193 | 4, 5, 6, |
| 194 | |
| 195 | 19, 20, 21, |
| 196 | 22, 23, 24, |
| 197 | |
| 198 | |
| 199 | 7, 8, 9, |
| 200 | 10, 11, 12, |
| 201 | |
| 202 | 25, 26, 27, |
| 203 | 28, 29, 30, |
| 204 | |
| 205 | |
| 206 | 13, 14, 15, |
| 207 | 16, 17, 18, |
| 208 | |
| 209 | 31, 32, 33, |
| 210 | 34, 35, 36 |
| 211 | }; |
| 212 | |
| 213 | return StackTestHelper<ArmnnType, T, 4>( |
| 214 | workloadFactory, |
| 215 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 216 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 217 | inputTensorInfo, |
| 218 | outputTensorInfo, |
| 219 | 1U, |
| 220 | inputData, |
| 221 | outputExpectedData |
| 222 | ); |
| 223 | } |
| 224 | |
| 225 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 226 | LayerTestResult<T, 4> StackOutput4DAxis2TestImpl( |
| 227 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 228 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 229 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 230 | { |
| 231 | armnn::TensorInfo inputTensorInfo ({ 3, 2, 3 }, ArmnnType); |
| 232 | armnn::TensorInfo outputTensorInfo({ 3, 2, 2, 3 }, ArmnnType); |
| 233 | |
| 234 | std::vector<std::vector<T>> inputData; |
| 235 | |
| 236 | inputData.push_back( |
| 237 | { |
| 238 | 1, 2, 3, |
| 239 | 4, 5, 6, |
| 240 | |
| 241 | 7, 8, 9, |
| 242 | 10, 11, 12, |
| 243 | |
| 244 | 13, 14, 15, |
| 245 | 16, 17, 18 |
| 246 | }); |
| 247 | |
| 248 | inputData.push_back( |
| 249 | { |
| 250 | 19, 20, 21, |
| 251 | 22, 23, 24, |
| 252 | |
| 253 | 25, 26, 27, |
| 254 | 28, 29, 30, |
| 255 | |
| 256 | 31, 32, 33, |
| 257 | 34, 35, 36 |
| 258 | }); |
| 259 | |
| 260 | std::vector<T> outputExpectedData = |
| 261 | { |
| 262 | 1, 2, 3, |
| 263 | 19, 20, 21, |
| 264 | |
| 265 | 4, 5, 6, |
| 266 | 22, 23, 24, |
| 267 | |
| 268 | 7, 8, 9, |
| 269 | 25, 26, 27, |
| 270 | |
| 271 | 10, 11, 12, |
| 272 | 28, 29, 30, |
| 273 | |
| 274 | 13, 14, 15, |
| 275 | 31, 32, 33, |
| 276 | |
| 277 | 16, 17, 18, |
| 278 | 34, 35, 36 |
| 279 | }; |
| 280 | |
| 281 | return StackTestHelper<ArmnnType, T, 4>( |
| 282 | workloadFactory, |
| 283 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 284 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 285 | inputTensorInfo, |
| 286 | outputTensorInfo, |
| 287 | 2U, |
| 288 | inputData, |
| 289 | outputExpectedData |
| 290 | ); |
| 291 | } |
| 292 | |
| 293 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 294 | LayerTestResult<T, 4> StackOutput4DAxis3TestImpl( |
| 295 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 296 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 297 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 298 | { |
| 299 | armnn::TensorInfo inputTensorInfo ({ 3, 2, 3 }, ArmnnType); |
| 300 | armnn::TensorInfo outputTensorInfo({ 3, 2, 3, 2 }, ArmnnType); |
| 301 | |
| 302 | std::vector<std::vector<T>> inputData; |
| 303 | |
| 304 | inputData.push_back( |
| 305 | { |
| 306 | 1, 2, 3, |
| 307 | 4, 5, 6, |
| 308 | |
| 309 | 7, 8, 9, |
| 310 | 10, 11, 12, |
| 311 | |
| 312 | 13, 14, 15, |
| 313 | 16, 17, 18 |
| 314 | }); |
| 315 | |
| 316 | inputData.push_back( |
| 317 | { |
| 318 | 19, 20, 21, |
| 319 | 22, 23, 24, |
| 320 | |
| 321 | 25, 26, 27, |
| 322 | 28, 29, 30, |
| 323 | |
| 324 | 31, 32, 33, |
| 325 | 34, 35, 36 |
| 326 | }); |
| 327 | |
| 328 | std::vector<T> outputExpectedData = |
| 329 | { |
| 330 | 1, 19, |
| 331 | 2, 20, |
| 332 | 3, 21, |
| 333 | |
| 334 | 4, 22, |
| 335 | 5, 23, |
| 336 | 6, 24, |
| 337 | |
| 338 | |
| 339 | 7, 25, |
| 340 | 8, 26, |
| 341 | 9, 27, |
| 342 | |
| 343 | 10, 28, |
| 344 | 11, 29, |
| 345 | 12, 30, |
| 346 | |
| 347 | |
| 348 | 13, 31, |
| 349 | 14, 32, |
| 350 | 15, 33, |
| 351 | |
| 352 | 16, 34, |
| 353 | 17, 35, |
| 354 | 18, 36 |
| 355 | }; |
| 356 | |
| 357 | return StackTestHelper<ArmnnType, T, 4>( |
| 358 | workloadFactory, |
| 359 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 360 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 361 | inputTensorInfo, |
| 362 | outputTensorInfo, |
| 363 | 3U, |
| 364 | inputData, |
| 365 | outputExpectedData |
| 366 | ); |
| 367 | } |
| 368 | |
| 369 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 370 | LayerTestResult<T, 3> StackOutput3DInputs3TestImpl( |
| 371 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 372 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 373 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 374 | { |
| 375 | armnn::TensorInfo inputTensorInfo ({ 3, 3 }, ArmnnType); |
| 376 | armnn::TensorInfo outputTensorInfo({ 3, 3, 3 }, ArmnnType); |
| 377 | |
| 378 | std::vector<std::vector<T>> inputData; |
| 379 | |
| 380 | inputData.push_back( |
| 381 | { |
| 382 | 1, 2, 3, |
| 383 | 4, 5, 6, |
| 384 | 7, 8, 9 |
| 385 | }); |
| 386 | |
| 387 | inputData.push_back( |
| 388 | { |
| 389 | 10, 11, 12, |
| 390 | 13, 14, 15, |
| 391 | 16, 17, 18 |
| 392 | }); |
| 393 | |
| 394 | inputData.push_back( |
| 395 | { |
| 396 | 19, 20, 21, |
| 397 | 22, 23, 24, |
| 398 | 25, 26, 27 |
| 399 | }); |
| 400 | |
| 401 | std::vector<T> outputExpectedData = |
| 402 | { |
| 403 | 1, 2, 3, |
| 404 | 10, 11, 12, |
| 405 | 19, 20, 21, |
| 406 | |
| 407 | 4, 5, 6, |
| 408 | 13, 14, 15, |
| 409 | 22, 23, 24, |
| 410 | |
| 411 | 7, 8, 9, |
| 412 | 16, 17, 18, |
| 413 | 25, 26, 27 |
| 414 | }; |
| 415 | |
| 416 | return StackTestHelper<ArmnnType, T, 3>( |
| 417 | workloadFactory, |
| 418 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 419 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 420 | inputTensorInfo, |
| 421 | outputTensorInfo, |
| 422 | 1U, |
| 423 | inputData, |
| 424 | outputExpectedData |
| 425 | ); |
| 426 | } |
| 427 | |
| 428 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 429 | LayerTestResult<T, 5> StackOutput5DTestImpl( |
| 430 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 431 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 432 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 433 | { |
| 434 | armnn::TensorInfo inputTensorInfo ({ 2, 2, 2, 3 }, ArmnnType); |
| 435 | armnn::TensorInfo outputTensorInfo({ 2, 2, 2, 2, 3 }, ArmnnType); |
| 436 | |
| 437 | std::vector<std::vector<T>> inputData; |
| 438 | |
| 439 | inputData.push_back( |
| 440 | { |
| 441 | 1, 2, 3, |
| 442 | 4, 5, 6, |
| 443 | |
| 444 | 7, 8, 9, |
| 445 | 10, 11, 12, |
| 446 | |
| 447 | |
| 448 | 13, 14, 15, |
| 449 | 16, 17, 18, |
| 450 | |
| 451 | 19, 20, 21, |
| 452 | 22, 23, 24 |
| 453 | }); |
| 454 | |
| 455 | inputData.push_back( |
| 456 | { |
| 457 | 25, 26, 27, |
| 458 | 28, 29, 30, |
| 459 | |
| 460 | 31, 32, 33, |
| 461 | 34, 35, 36, |
| 462 | |
| 463 | |
| 464 | 37, 38, 39, |
| 465 | 40, 41, 42, |
| 466 | |
| 467 | 43, 44, 45, |
| 468 | 46, 47, 48 |
| 469 | }); |
| 470 | |
| 471 | std::vector<T> outputExpectedData = |
| 472 | { |
| 473 | 1, 2, 3, |
| 474 | 4, 5, 6, |
| 475 | |
| 476 | 7, 8, 9, |
| 477 | 10, 11, 12, |
| 478 | |
| 479 | |
| 480 | 25, 26, 27, |
| 481 | 28, 29, 30, |
| 482 | |
| 483 | 31, 32, 33, |
| 484 | 34, 35, 36, |
| 485 | |
| 486 | |
| 487 | |
| 488 | 13, 14, 15, |
| 489 | 16, 17, 18, |
| 490 | |
| 491 | 19, 20, 21, |
| 492 | 22, 23, 24, |
| 493 | |
| 494 | |
| 495 | 37, 38, 39, |
| 496 | 40, 41, 42, |
| 497 | |
| 498 | 43, 44, 45, |
| 499 | 46, 47, 48 |
| 500 | |
| 501 | }; |
| 502 | |
| 503 | return StackTestHelper<ArmnnType, T, 5>( |
| 504 | workloadFactory, |
| 505 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 506 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 507 | inputTensorInfo, |
| 508 | outputTensorInfo, |
| 509 | 1U, |
| 510 | inputData, |
| 511 | outputExpectedData |
| 512 | ); |
| 513 | } |
| 514 | |
| 515 | // |
| 516 | // Implementation functions |
| 517 | // |
| 518 | |
| 519 | LayerTestResult<float, 4> StackAxis0Float32Test( |
| 520 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 521 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 522 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 523 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 524 | return StackAxis0TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | LayerTestResult<float, 4> StackOutput4DAxis1Float32Test( |
| 528 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 529 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 530 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 531 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 532 | return StackOutput4DAxis1TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | LayerTestResult<float, 4> StackOutput4DAxis2Float32Test( |
| 536 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 537 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 538 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 539 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 540 | return StackOutput4DAxis2TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | LayerTestResult<float, 4> StackOutput4DAxis3Float32Test( |
| 544 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 545 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 546 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 547 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 548 | return StackOutput4DAxis3TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | LayerTestResult<float, 3> StackOutput3DInputs3Float32Test( |
| 552 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 553 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 554 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 555 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 556 | return StackOutput3DInputs3TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | LayerTestResult<float, 5> StackOutput5DFloat32Test( |
| 560 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 561 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 562 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 563 | { |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 564 | return StackOutput5DTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory); |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | LayerTestResult<armnn::Half, 4> StackFloat16Test( |
| 568 | armnn::IWorkloadFactory& workloadFactory, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 569 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 570 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 571 | { |
| 572 | using namespace half_float::literal; |
| 573 | |
| 574 | armnn::TensorInfo inputTensorInfo ({ 3, 2, 3 }, armnn::DataType::Float16); |
| 575 | armnn::TensorInfo outputTensorInfo({ 3, 2, 2, 3 }, armnn::DataType::Float16); |
| 576 | |
| 577 | std::vector<std::vector<armnn::Half>> inputData; |
| 578 | |
| 579 | inputData.push_back( |
| 580 | { |
| 581 | 1.0_h, 2.0_h, 3.0_h, |
| 582 | 4.0_h, 5.0_h, 6.0_h, |
| 583 | |
| 584 | 7.0_h, 8.0_h, 9.0_h, |
| 585 | 10.0_h, 11.0_h, 12.0_h, |
| 586 | |
| 587 | 13.0_h, 14.0_h, 15.0_h, |
| 588 | 16.0_h, 17.0_h, 18.0_h |
| 589 | }); |
| 590 | |
| 591 | inputData.push_back( |
| 592 | { |
| 593 | 19.0_h, 20.0_h, 21.0_h, |
| 594 | 22.0_h, 23.0_h, 24.0_h, |
| 595 | |
| 596 | 25.0_h, 26.0_h, 27.0_h, |
| 597 | 28.0_h, 29.0_h, 30.0_h, |
| 598 | |
| 599 | 31.0_h, 32.0_h, 33.0_h, |
| 600 | 34.0_h, 35.0_h, 36.0_h |
| 601 | }); |
| 602 | |
| 603 | std::vector<armnn::Half> outputExpectedData = |
| 604 | { |
| 605 | 1.0_h, 2.0_h, 3.0_h, |
| 606 | 19.0_h, 20.0_h, 21.0_h, |
| 607 | |
| 608 | 4.0_h, 5.0_h, 6.0_h, |
| 609 | 22.0_h, 23.0_h, 24.0_h, |
| 610 | |
| 611 | 7.0_h, 8.0_h, 9.0_h, |
| 612 | 25.0_h, 26.0_h, 27.0_h, |
| 613 | |
| 614 | 10.0_h, 11.0_h, 12.0_h, |
| 615 | 28.0_h, 29.0_h, 30.0_h, |
| 616 | |
| 617 | 13.0_h, 14.0_h, 15.0_h, |
| 618 | 31.0_h, 32.0_h, 33.0_h, |
| 619 | |
| 620 | 16.0_h, 17.0_h, 18.0_h, |
| 621 | 34.0_h, 35.0_h, 36.0_h |
| 622 | }; |
| 623 | |
| 624 | return StackTestHelper<armnn::DataType::Float16, armnn::Half, 4>( |
| 625 | workloadFactory, |
| 626 | memoryManager, |
Sadik Armagan | 5e71984 | 2020-08-28 12:17:33 +0100 | [diff] [blame] | 627 | tensorHandleFactory, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 628 | inputTensorInfo, |
| 629 | outputTensorInfo, |
| 630 | 2U, |
| 631 | inputData, |
| 632 | outputExpectedData |
| 633 | ); |
| 634 | } |