Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2021 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | |
| 7 | #include "Pooling3dTestImpl.hpp" |
| 8 | |
| 9 | #include <QuantizeHelper.hpp> |
| 10 | #include <ResolveType.hpp> |
| 11 | |
| 12 | #include <armnnUtils/TensorUtils.hpp> |
| 13 | #include <armnnUtils/DataLayoutIndexed.hpp> |
| 14 | #include <armnnUtils/Permute.hpp> |
| 15 | |
| 16 | #include <armnn/utility/IgnoreUnused.hpp> |
| 17 | #include <armnn/utility/NumericCast.hpp> |
| 18 | |
| 19 | #include <armnn/BackendHelper.hpp> |
| 20 | #include <backendsCommon/WorkloadInfo.hpp> |
| 21 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 22 | #include <armnnTestUtils/TensorCopyUtils.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 23 | #include <armnnTestUtils/WorkloadTestUtils.hpp> |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 24 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 25 | #include <TensorHelpers.hpp> |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 26 | |
| 27 | namespace |
| 28 | { |
| 29 | |
| 30 | using namespace armnnUtils; |
| 31 | |
| 32 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 33 | LayerTestResult<T, 5> SimplePooling3dTestImpl( |
| 34 | armnn::IWorkloadFactory& workloadFactory, |
| 35 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 36 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 37 | armnn::Pooling3dDescriptor descriptor, |
| 38 | float qScale, |
| 39 | int32_t qOffset, |
| 40 | const std::vector<T>& input, |
| 41 | const std::vector<T>& outputExpected, |
| 42 | const armnn::TensorShape& inputShape, |
| 43 | const armnn::TensorShape& outputShape) |
| 44 | { |
| 45 | IgnoreUnused(memoryManager); |
| 46 | const armnn::DataLayout dataLayout = descriptor.m_DataLayout; |
| 47 | const armnnUtils::DataLayoutIndexed dimensionIndices = dataLayout; |
| 48 | auto heightIndex = dimensionIndices.GetHeightIndex(); |
| 49 | auto widthIndex = dimensionIndices.GetWidthIndex(); |
| 50 | auto depthIndex = dimensionIndices.GetDepthIndex(); |
| 51 | auto channelsIndex = dimensionIndices.GetChannelsIndex(); |
| 52 | |
| 53 | unsigned int inputDepth = armnn::numeric_cast<unsigned int>(inputShape[depthIndex]); |
| 54 | unsigned int inputHeight = armnn::numeric_cast<unsigned int>(inputShape[heightIndex]); |
| 55 | unsigned int inputWidth = armnn::numeric_cast<unsigned int>(inputShape[widthIndex]); |
| 56 | unsigned int inputChannels = armnn::numeric_cast<unsigned int>(inputShape[channelsIndex]); |
| 57 | unsigned int inputBatchSize = armnn::numeric_cast<unsigned int>(inputShape[0]); |
| 58 | |
| 59 | unsigned int outputDepth = armnn::numeric_cast<unsigned int>(outputShape[depthIndex]); |
| 60 | unsigned int outputHeight = armnn::numeric_cast<unsigned int>(outputShape[heightIndex]); |
| 61 | unsigned int outputWidth = armnn::numeric_cast<unsigned int>(outputShape[widthIndex]); |
| 62 | unsigned int outputChannels = armnn::numeric_cast<unsigned int>(outputShape[channelsIndex]); |
| 63 | unsigned int outputBatchSize = armnn::numeric_cast<unsigned int>(outputShape[0]); |
| 64 | |
| 65 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo( |
| 66 | inputBatchSize, inputChannels, inputDepth, inputHeight, inputWidth, dataLayout, ArmnnType); |
| 67 | |
| 68 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo( |
| 69 | outputBatchSize, outputChannels, outputDepth, outputHeight, outputWidth, dataLayout, ArmnnType); |
| 70 | |
| 71 | // Set quantization parameters if the requested type is a quantized type. |
| 72 | if (armnn::IsQuantizedType<T>()) |
| 73 | { |
| 74 | inputTensorInfo.SetQuantizationScale(qScale); |
| 75 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 76 | outputTensorInfo.SetQuantizationScale(qScale); |
| 77 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 78 | } |
| 79 | |
| 80 | LayerTestResult<T, 5> result(outputTensorInfo); |
| 81 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
| 82 | |
| 83 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 84 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 85 | |
| 86 | armnn::Pooling3dQueueDescriptor queueDescriptor; |
| 87 | queueDescriptor.m_Parameters = descriptor; |
| 88 | queueDescriptor.m_Parameters.m_DataLayout = dataLayout; |
| 89 | |
| 90 | armnn::WorkloadInfo workloadInfo; |
| 91 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get()); |
| 92 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 93 | |
| 94 | // Don't execute if Pooling is not supported, as an exception will be raised. |
| 95 | armnn::BackendId backend = workloadFactory.GetBackendId(); |
| 96 | std::string reasonIfUnsupported; |
| 97 | armnn::LayerSupportHandle handle = armnn::GetILayerSupportByBackendId(backend); |
| 98 | result.m_Supported = handle.IsPooling3dSupported(inputTensorInfo, |
| 99 | outputTensorInfo, |
| 100 | queueDescriptor.m_Parameters, |
| 101 | reasonIfUnsupported); |
| 102 | if (!result.m_Supported) |
| 103 | { |
| 104 | return result; |
| 105 | } |
| 106 | |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame^] | 107 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateWorkload(armnn::LayerType::Pooling3d, |
| 108 | queueDescriptor, |
| 109 | workloadInfo); |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 110 | |
| 111 | inputHandle->Allocate(); |
| 112 | outputHandle->Allocate(); |
| 113 | |
| 114 | CopyDataToITensorHandle(inputHandle.get(), input.data()); |
| 115 | |
| 116 | workload->Execute(); |
| 117 | |
| 118 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
| 119 | |
| 120 | result.m_ActualData = actualOutput; |
| 121 | result.m_ExpectedData = outputExpected; |
| 122 | |
| 123 | return result; |
| 124 | } |
| 125 | |
| 126 | // |
| 127 | // Tests max pooling with the following parameters: |
| 128 | // |
| 129 | // Pooling size: 2x2x2 |
| 130 | // Stride: (1,1,1) |
| 131 | // input size: 3x3x3 |
| 132 | // channels: 2 |
| 133 | // batch size: 2 |
| 134 | // |
| 135 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 136 | LayerTestResult<T, 5> SimpleMaxPooling3dSize2x2x2Stride1x1x1TestCommon( |
| 137 | armnn::IWorkloadFactory& workloadFactory, |
| 138 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 139 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 140 | float qScale = 1.0f, |
| 141 | int32_t qOffset = 0) |
| 142 | { |
| 143 | armnn::Pooling3dDescriptor descriptor; |
| 144 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 145 | descriptor.m_PoolWidth = 2; |
| 146 | descriptor.m_PoolHeight = 2; |
| 147 | descriptor.m_PoolDepth = 2; |
| 148 | descriptor.m_StrideX = 1; |
| 149 | descriptor.m_StrideY = 1; |
| 150 | descriptor.m_StrideZ = 1; |
| 151 | descriptor.m_PadLeft = descriptor.m_PadRight = 0; |
| 152 | descriptor.m_PadTop = descriptor.m_PadBottom = 0; |
| 153 | descriptor.m_PadFront = descriptor.m_PadBack = 0; |
| 154 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 155 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 156 | |
| 157 | unsigned int inputWidth = 3; |
| 158 | unsigned int inputHeight = 3; |
| 159 | unsigned int inputDepth = 3; |
| 160 | unsigned int outputWidth = |
| 161 | (inputWidth + descriptor.m_PadLeft + descriptor.m_PadRight + descriptor.m_StrideX - descriptor.m_PoolWidth) / |
| 162 | descriptor.m_StrideX; |
| 163 | unsigned int outputHeight = |
| 164 | (inputHeight + descriptor.m_PadTop + descriptor.m_PadBottom + descriptor.m_StrideY - descriptor.m_PoolHeight) / |
| 165 | descriptor.m_StrideY; |
| 166 | unsigned int outputDepth = |
| 167 | (inputDepth + descriptor.m_PadFront + descriptor.m_PadBack + descriptor.m_StrideZ - descriptor.m_PoolDepth) / |
| 168 | descriptor.m_StrideZ; |
| 169 | unsigned int channels = 2; |
| 170 | unsigned int batchSize = 2; |
| 171 | |
| 172 | armnn::TensorInfo inputTensorInfo({ batchSize, channels, inputDepth, inputHeight, inputWidth }, ArmnnType); |
| 173 | armnn::TensorInfo outputTensorInfo({ batchSize, channels, outputDepth, outputHeight, outputWidth }, ArmnnType); |
| 174 | |
| 175 | // Set quantization parameters if the requested type is a quantized type. |
| 176 | if(armnn::IsQuantizedType<T>()) |
| 177 | { |
| 178 | inputTensorInfo.SetQuantizationScale(qScale); |
| 179 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 180 | outputTensorInfo.SetQuantizationScale(qScale); |
| 181 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 182 | } |
| 183 | |
| 184 | std::vector<float> singleChannelData({ |
| 185 | 1.0f, 1.0f, 1.0f, |
| 186 | 1.0f, 1.0f, 1.0f, |
| 187 | 1.0f, 1.0f, 1.0f, |
| 188 | |
| 189 | 1.0f, 1.0f, 1.0f, |
| 190 | 1.0f, 1.0f, 1.0f, |
| 191 | 1.0f, 1.0f, 1.0f, |
| 192 | |
| 193 | 1.0f, 1.0f, 1.0f, |
| 194 | 1.0f, 1.0f, 1.0f, |
| 195 | 1.0f, 1.0f, 1.0f, |
| 196 | }); |
| 197 | |
| 198 | // Constructs input data. |
| 199 | std::vector<float> inputData; |
| 200 | auto negator = [](float f) { return -f; }; |
| 201 | |
| 202 | // First image (two channels where the second channel is the negative of the first one). |
| 203 | inputData.insert(inputData.end(), singleChannelData.begin(), singleChannelData.end()); |
| 204 | std::transform(singleChannelData.begin(), singleChannelData.end(), std::back_inserter(inputData), negator); |
| 205 | |
| 206 | // Second image (same as first image). |
| 207 | inputData.insert(inputData.end(), singleChannelData.begin(), singleChannelData.end()); |
| 208 | std::transform(singleChannelData.begin(), singleChannelData.end(), std::back_inserter(inputData), negator); |
| 209 | |
| 210 | auto input = QuantizedVector<T>(inputData, qScale, qOffset); |
| 211 | |
| 212 | // These were calculated manually. |
| 213 | std::vector<T> outputExpected = QuantizedVector<T>( |
| 214 | { |
| 215 | 1.0f, 1.0f, |
| 216 | 1.0f, 1.0f, |
| 217 | |
| 218 | 1.0f, 1.0f, |
| 219 | 1.0f, 1.0f, |
| 220 | |
| 221 | -1.0f, -1.0f, |
| 222 | -1.0f, -1.0f, |
| 223 | |
| 224 | -1.0f, -1.0f, |
| 225 | -1.0f, -1.0f, |
| 226 | |
| 227 | |
| 228 | 1.0f, 1.0f, |
| 229 | 1.0f, 1.0f, |
| 230 | |
| 231 | 1.0f, 1.0f, |
| 232 | 1.0f, 1.0f, |
| 233 | |
| 234 | -1.0f, -1.0f, |
| 235 | -1.0f, -1.0f, |
| 236 | |
| 237 | -1.0f, -1.0f, |
| 238 | -1.0f, -1.0f, |
| 239 | }, |
| 240 | qScale, qOffset); |
| 241 | |
| 242 | return SimplePooling3dTestImpl<ArmnnType>( |
| 243 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 244 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 245 | } |
| 246 | |
| 247 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 248 | LayerTestResult<T, 5> SimpleMaxPooling3dTestCommon( |
| 249 | armnn::IWorkloadFactory& workloadFactory, |
| 250 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 251 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 252 | const armnn::DataLayout dataLayout = armnn::DataLayout::NCDHW, |
| 253 | float qScale = 1.0f, |
| 254 | int32_t qOffset = 0) |
| 255 | { |
| 256 | armnn::Pooling3dDescriptor descriptor; |
| 257 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 258 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 259 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 260 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 261 | descriptor.m_DataLayout = dataLayout; |
| 262 | |
| 263 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 4, 4, 4, dataLayout, ArmnnType); |
| 264 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 2, 2, 2, dataLayout, ArmnnType); |
| 265 | |
| 266 | // Set quantization parameters if the requested type is a quantized type. |
| 267 | if(armnn::IsQuantizedType<T>()) |
| 268 | { |
| 269 | inputTensorInfo.SetQuantizationScale(qScale); |
| 270 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 271 | outputTensorInfo.SetQuantizationScale(qScale); |
| 272 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 273 | } |
| 274 | |
| 275 | std::vector<T> inputData( |
| 276 | QuantizedVector<T>({ |
| 277 | 1.0f, 2.0f, 5.0f, 6.0f, |
| 278 | 3.0f, 4.0f, 7.0f, 8.0f, |
| 279 | 9.0f, 10.0f, 13.0f, 14.0f, |
| 280 | 11.0f, 12.0f, 15.0f, 16.0f, |
| 281 | |
| 282 | 17.0f, 18.0f, 21.0f, 22.0f, |
| 283 | 19.0f, 20.0f, 23.0f, 24.0f, |
| 284 | 25.0f, 26.0f, 29.0f, 30.0f, |
| 285 | 27.0f, 28.0f, 31.0f, 32.0f, |
| 286 | |
| 287 | 33.0f, 34.0f, 37.0f, 38.0f, |
| 288 | 35.0f, 36.0f, 39.0f, 40.0f, |
| 289 | 41.0f, 42.0f, 45.0f, 46.0f, |
| 290 | 43.0f, 44.0f, 47.0f, 48.0f, |
| 291 | |
| 292 | 49.0f, 50.0f, 53.0f, 54.0f, |
| 293 | 51.0f, 52.0f, 55.0f, 56.0f, |
| 294 | 57.0f, 58.0f, 61.0f, 62.0f, |
| 295 | 59.0f, 60.0f, 63.0f, 64.0f, |
| 296 | }, |
| 297 | qScale, qOffset)); |
| 298 | |
| 299 | std::vector<T> outputData( |
| 300 | QuantizedVector<T>({ |
| 301 | 20.0f, 24.0f, |
| 302 | 28.0f, 32.0f, |
| 303 | |
| 304 | 52.0f, 56.0f, |
| 305 | 60.0f, 64.0f, |
| 306 | }, |
| 307 | qScale, qOffset)); |
| 308 | |
| 309 | const armnn::PermutationVector NCDHWToNDHWC = { 0, 4, 1, 2, 3 }; |
| 310 | if (dataLayout == armnn::DataLayout::NDHWC) |
| 311 | { |
| 312 | std::vector<T> tmp(inputData.size()); |
| 313 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCDHWToNDHWC, inputData.data(), tmp.data(), sizeof(T)); |
| 314 | inputData = tmp; |
| 315 | |
| 316 | std::vector<T> tmp1(outputData.size()); |
| 317 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCDHWToNDHWC, outputData.data(), tmp1.data(), sizeof(T)); |
| 318 | outputData = tmp1; |
| 319 | } |
| 320 | |
| 321 | return SimplePooling3dTestImpl<ArmnnType>( |
| 322 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 323 | inputData, outputData, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 324 | } |
| 325 | |
| 326 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 327 | LayerTestResult<T, 5> IgnorePaddingSimpleMaxPooling3dTestCommon( |
| 328 | armnn::IWorkloadFactory& workloadFactory, |
| 329 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 330 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 331 | float qScale = 1.0f, |
| 332 | int32_t qOffset = 0) |
| 333 | { |
| 334 | armnn::Pooling3dDescriptor descriptor; |
| 335 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 336 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 337 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 338 | descriptor.m_PadLeft = 1; |
| 339 | descriptor.m_PadRight = 1; |
| 340 | descriptor.m_PadTop = 1; |
| 341 | descriptor.m_PadBottom = 1; |
| 342 | descriptor.m_PadFront = 1; |
| 343 | descriptor.m_PadBack = 1; |
| 344 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 345 | |
| 346 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4, 4 }, ArmnnType); |
| 347 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3, 3 }, ArmnnType); |
| 348 | |
| 349 | // Set quantization parameters if the requested type is a quantized type. |
| 350 | if(armnn::IsQuantizedType<T>()) |
| 351 | { |
| 352 | inputTensorInfo.SetQuantizationScale(qScale); |
| 353 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 354 | outputTensorInfo.SetQuantizationScale(qScale); |
| 355 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 356 | } |
| 357 | |
| 358 | auto input = QuantizedVector<T>( |
| 359 | { |
| 360 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 361 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 362 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 363 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 364 | |
| 365 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 366 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 367 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 368 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 369 | |
| 370 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 371 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 372 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 373 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 374 | |
| 375 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 376 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 377 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 378 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 379 | }, |
| 380 | qScale, qOffset); |
| 381 | |
| 382 | auto outputExpected = QuantizedVector<T>( |
| 383 | { |
| 384 | -1.0f, 3.0f, 4.0f, |
| 385 | 1.0f, 3.0f, 4.0f, |
| 386 | 1.0f, 2.0f, -4.0f, |
| 387 | |
| 388 | -1.0f, 3.0f, 4.0f, |
| 389 | 1.0f, 3.0f, 4.0f, |
| 390 | 1.0f, 2.0f, -4.0f, |
| 391 | |
| 392 | -1.0f, 3.0f, 4.0f, |
| 393 | 1.0f, 3.0f, 4.0f, |
| 394 | 1.0f, 2.0f, -4.0f, |
| 395 | }, |
| 396 | qScale, qOffset); |
| 397 | |
| 398 | return SimplePooling3dTestImpl<ArmnnType>( |
| 399 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 400 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 401 | } |
| 402 | |
| 403 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 404 | LayerTestResult<T, 5> SimpleAveragePooling3dTestCommon( |
| 405 | armnn::IWorkloadFactory& workloadFactory, |
| 406 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 407 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 408 | armnn::DataLayout dataLayout = armnn::DataLayout::NCDHW, |
| 409 | float qScale = 1.0f, |
| 410 | int32_t qOffset = 0) |
| 411 | { |
| 412 | armnn::Pooling3dDescriptor descriptor; |
| 413 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 414 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 415 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 416 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 417 | descriptor.m_DataLayout = dataLayout; |
| 418 | |
| 419 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 4, 4, 4, dataLayout, ArmnnType); |
| 420 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 2, 2, 2, dataLayout, ArmnnType); |
| 421 | |
| 422 | // Set quantization parameters if the requested type is a quantized type. |
| 423 | if(armnn::IsQuantizedType<T>()) |
| 424 | { |
| 425 | inputTensorInfo.SetQuantizationScale(qScale); |
| 426 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 427 | outputTensorInfo.SetQuantizationScale(qScale); |
| 428 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 429 | } |
| 430 | |
| 431 | std::vector<T> inputData( |
| 432 | QuantizedVector<T>({ |
| 433 | 1.0f, 2.0f, 5.0f, 6.0f, |
| 434 | 3.0f, 4.0f, 7.0f, 8.0f, |
| 435 | 9.0f, 10.0f, 13.0f, 14.0f, |
| 436 | 11.0f, 12.0f, 15.0f, 16.0f, |
| 437 | |
| 438 | 17.0f, 18.0f, 21.0f, 22.0f, |
| 439 | 19.0f, 20.0f, 23.0f, 24.0f, |
| 440 | 25.0f, 26.0f, 29.0f, 30.0f, |
| 441 | 27.0f, 28.0f, 31.0f, 32.0f, |
| 442 | |
| 443 | 33.0f, 34.0f, 37.0f, 38.0f, |
| 444 | 35.0f, 36.0f, 39.0f, 40.0f, |
| 445 | 41.0f, 42.0f, 45.0f, 46.0f, |
| 446 | 43.0f, 44.0f, 47.0f, 48.0f, |
| 447 | |
| 448 | 49.0f, 50.0f, 53.0f, 54.0f, |
| 449 | 51.0f, 52.0f, 55.0f, 56.0f, |
| 450 | 57.0f, 58.0f, 61.0f, 62.0f, |
| 451 | 59.0f, 60.0f, 63.0f, 64.0f, |
| 452 | }, |
| 453 | qScale, qOffset)); |
| 454 | |
| 455 | std::vector<T> outputData( |
| 456 | QuantizedVector<T>({ |
| 457 | 10.5f, 14.5f, |
| 458 | 18.5f, 22.5f, |
| 459 | |
| 460 | 42.5f, 46.5f, |
| 461 | 50.5f, 54.5f, |
| 462 | }, |
| 463 | qScale, qOffset)); |
| 464 | |
| 465 | const armnn::PermutationVector NCDHWToNDHWC = { 0, 4, 1, 2, 3 }; |
| 466 | if (dataLayout == armnn::DataLayout::NDHWC) |
| 467 | { |
| 468 | std::vector<T> tmp(inputData.size()); |
| 469 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCDHWToNDHWC, inputData.data(), tmp.data(), sizeof(T)); |
| 470 | inputData = tmp; |
| 471 | |
| 472 | std::vector<T> tmp1(outputData.size()); |
| 473 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCDHWToNDHWC, outputData.data(), tmp1.data(), sizeof(T)); |
| 474 | outputData = tmp1; |
| 475 | } |
| 476 | |
| 477 | return SimplePooling3dTestImpl<ArmnnType>( |
| 478 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 479 | inputData, outputData, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 480 | } |
| 481 | |
| 482 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 483 | LayerTestResult<T, 5> LargeTensorsAveragePooling3dTestCommon( |
| 484 | armnn::IWorkloadFactory& workloadFactory, |
| 485 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 486 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 487 | float qScale = 1.0f, |
| 488 | int32_t qOffset = 0) |
| 489 | { |
| 490 | armnn::Pooling3dDescriptor descriptor; |
| 491 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 492 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 100; |
| 493 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 5; |
| 494 | descriptor.m_PadLeft = 50; |
| 495 | descriptor.m_PadRight = 50; |
| 496 | descriptor.m_PadTop = 50; |
| 497 | descriptor.m_PadBottom = 50; |
| 498 | descriptor.m_PadFront = 50; |
| 499 | descriptor.m_PadBack = 50; |
| 500 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 501 | |
| 502 | armnn::TensorInfo inputTensorInfo({ 5, 3, 52, 60, 68 }, ArmnnType); |
| 503 | armnn::TensorInfo outputTensorInfo({ 5, 3, 11, 13, 15 }, ArmnnType); |
| 504 | |
| 505 | // Set quantization parameters if the requested type is a quantized type. |
| 506 | if(armnn::IsQuantizedType<T>()) |
| 507 | { |
| 508 | inputTensorInfo.SetQuantizationScale(qScale); |
| 509 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 510 | outputTensorInfo.SetQuantizationScale(qScale); |
| 511 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 512 | } |
| 513 | |
| 514 | std::vector<T> input; |
| 515 | |
| 516 | for (unsigned int i = 0 ; i < inputTensorInfo.GetShape().GetNumElements(); ++i) |
| 517 | { |
| 518 | input.push_back(1); |
| 519 | } |
| 520 | |
| 521 | std::vector<T> outputExpected; |
| 522 | |
| 523 | for (unsigned int i = 0 ; i < outputTensorInfo.GetShape().GetNumElements(); ++i) |
| 524 | { |
| 525 | outputExpected.push_back(1); |
| 526 | } |
| 527 | |
| 528 | return SimplePooling3dTestImpl<ArmnnType>( |
| 529 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 530 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 531 | } |
| 532 | |
| 533 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 534 | LayerTestResult<T, 5> IgnorePaddingSimpleAveragePooling3dTestCommon( |
| 535 | armnn::IWorkloadFactory& workloadFactory, |
| 536 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 537 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 538 | float qScale = 1.0f, |
| 539 | int32_t qOffset = 0) |
| 540 | { |
| 541 | armnn::Pooling3dDescriptor descriptor; |
| 542 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 543 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 544 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 545 | descriptor.m_PadLeft = 1; |
| 546 | descriptor.m_PadRight = 1; |
| 547 | descriptor.m_PadTop = 1; |
| 548 | descriptor.m_PadBottom = 1; |
| 549 | descriptor.m_PadFront = 1; |
| 550 | descriptor.m_PadBack = 1; |
| 551 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 552 | |
| 553 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4, 4 }, ArmnnType); |
| 554 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3, 3 }, ArmnnType); |
| 555 | |
| 556 | // Set quantization parameters if the requested type is a quantized type. |
| 557 | if(armnn::IsQuantizedType<T>()) |
| 558 | { |
| 559 | inputTensorInfo.SetQuantizationScale(qScale); |
| 560 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 561 | outputTensorInfo.SetQuantizationScale(qScale); |
| 562 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 563 | } |
| 564 | |
| 565 | auto input = QuantizedVector<T>( |
| 566 | { |
| 567 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 568 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 569 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 570 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 571 | |
| 572 | 24.0f, 40.0f, 64.0f, 80.0f, |
| 573 | 24.0f, 40.0f, 64.0f, 80.0f, |
| 574 | 24.0f, 40.0f, 64.0f, 80.0f, |
| 575 | 24.0f, 40.0f, 64.0f, 80.0f, |
| 576 | |
| 577 | 36.0f, 60.0f, 96.0f, 120.0f, |
| 578 | 36.0f, 60.0f, 96.0f, 120.0f, |
| 579 | 36.0f, 60.0f, 96.0f, 120.0f, |
| 580 | 36.0f, 60.0f, 96.0f, 120.0f, |
| 581 | |
| 582 | 48.0f, 80.0f, 128.0f, 160.0f, |
| 583 | 48.0f, 80.0f, 128.0f, 160.0f, |
| 584 | 48.0f, 80.0f, 128.0f, 160.0f, |
| 585 | 48.0f, 80.0f, 128.0f, 160.0f, |
| 586 | }, |
| 587 | qScale, qOffset); |
| 588 | |
| 589 | auto outputExpected = QuantizedVector<T>( |
| 590 | { |
| 591 | 1.5f, 6.5f, 5.0f, |
| 592 | 3.0f, 13.0f, 10.0f, |
| 593 | 1.5f, 6.5f, 5.0f, |
| 594 | |
| 595 | 7.5f, 32.5f, 25.0f, |
| 596 | 15.0f, 65.0f, 50.0f, |
| 597 | 7.5f, 32.5f, 25.0f, |
| 598 | |
| 599 | 6.0f, 26.0f, 20.0f, |
| 600 | 12.0f, 52.0f, 40.0f, |
| 601 | 6.0f, 26.0f, 20.0f, |
| 602 | }, |
| 603 | qScale, qOffset); |
| 604 | |
| 605 | return SimplePooling3dTestImpl<ArmnnType>( |
| 606 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 607 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 608 | } |
| 609 | |
| 610 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 611 | LayerTestResult<T, 5> SimpleL2Pooling3dTestCommon( |
| 612 | armnn::IWorkloadFactory& workloadFactory, |
| 613 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 614 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 615 | armnn::DataLayout dataLayout = armnn::DataLayout::NCDHW, |
| 616 | float qScale = 1.0f, |
| 617 | int32_t qOffset = 0) |
| 618 | { |
| 619 | armnn::Pooling3dDescriptor descriptor; |
| 620 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 621 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 622 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 623 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 624 | descriptor.m_DataLayout = dataLayout; |
| 625 | |
| 626 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 4, 4, 4, dataLayout, ArmnnType); |
| 627 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 1, 2, 2, 2, dataLayout, ArmnnType); |
| 628 | |
| 629 | // Set quantization parameters if the requested type is a quantized type. |
| 630 | if(armnn::IsQuantizedType<T>()) |
| 631 | { |
| 632 | inputTensorInfo.SetQuantizationScale(qScale); |
| 633 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 634 | outputTensorInfo.SetQuantizationScale(qScale); |
| 635 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 636 | } |
| 637 | |
| 638 | std::vector<T> inputData( |
| 639 | QuantizedVector<T>({ |
| 640 | 1.0f, 2.0f, 5.0f, 6.0f, |
| 641 | 3.0f, 4.0f, 7.0f, 8.0f, |
| 642 | 9.0f, 10.0f, 13.0f, 14.0f, |
| 643 | 11.0f, 12.0f, 15.0f, 16.0f, |
| 644 | |
| 645 | 17.0f, 18.0f, 21.0f, 22.0f, |
| 646 | 19.0f, 20.0f, 23.0f, 24.0f, |
| 647 | 25.0f, 26.0f, 29.0f, 30.0f, |
| 648 | 27.0f, 28.0f, 31.0f, 32.0f, |
| 649 | |
| 650 | 33.0f, 34.0f, 37.0f, 38.0f, |
| 651 | 35.0f, 36.0f, 39.0f, 40.0f, |
| 652 | 41.0f, 42.0f, 45.0f, 46.0f, |
| 653 | 43.0f, 44.0f, 47.0f, 48.0f, |
| 654 | |
| 655 | 49.0f, 50.0f, 53.0f, 54.0f, |
| 656 | 51.0f, 52.0f, 55.0f, 56.0f, |
| 657 | 57.0f, 58.0f, 61.0f, 62.0f, |
| 658 | 59.0f, 60.0f, 63.0f, 64.0f, |
| 659 | }, |
| 660 | qScale, qOffset)); |
| 661 | |
| 662 | std::vector<T> outputData( |
| 663 | QuantizedVector<T>({ |
| 664 | 13.2476412995f, 16.5981926727f, |
| 665 | 20.1866292382f, 23.9060661758f, |
| 666 | |
| 667 | 43.2608367926f, 47.1963981677f, |
| 668 | 51.1419592898f, 55.0953718564f, |
| 669 | }, |
| 670 | qScale, qOffset)); |
| 671 | |
| 672 | const armnn::PermutationVector NCDHWToNDHWC = { 0, 4, 1, 2, 3 }; |
| 673 | if (dataLayout == armnn::DataLayout::NDHWC) |
| 674 | { |
| 675 | std::vector<T> tmp(inputData.size()); |
| 676 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCDHWToNDHWC, inputData.data(), tmp.data(), sizeof(T)); |
| 677 | inputData = tmp; |
| 678 | |
| 679 | std::vector<T> tmp1(outputData.size()); |
| 680 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCDHWToNDHWC, outputData.data(), tmp1.data(), sizeof(T)); |
| 681 | outputData = tmp1; |
| 682 | } |
| 683 | |
| 684 | return SimplePooling3dTestImpl<ArmnnType>( |
| 685 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 686 | inputData, outputData, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 687 | } |
| 688 | |
| 689 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 690 | LayerTestResult<T, 5> IgnorePaddingSimpleL2Pooling3dTestCommon( |
| 691 | armnn::IWorkloadFactory& workloadFactory, |
| 692 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 693 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 694 | float qScale = 1.0f, |
| 695 | int32_t qOffset = 0) |
| 696 | { |
| 697 | armnn::Pooling3dDescriptor descriptor; |
| 698 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 699 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = descriptor.m_PoolDepth = 2; |
| 700 | descriptor.m_StrideX = descriptor.m_StrideY = descriptor.m_StrideZ = 2; |
| 701 | descriptor.m_PadLeft = 1; |
| 702 | descriptor.m_PadRight = 1; |
| 703 | descriptor.m_PadTop = 1; |
| 704 | descriptor.m_PadBottom = 1; |
| 705 | descriptor.m_PadFront = 1; |
| 706 | descriptor.m_PadBack = 1; |
| 707 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 708 | |
| 709 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4, 4 }, ArmnnType); |
| 710 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3, 3 }, ArmnnType); |
| 711 | |
| 712 | // Set quantization parameters if the requested type is a quantized type. |
| 713 | if(armnn::IsQuantizedType<T>()) |
| 714 | { |
| 715 | inputTensorInfo.SetQuantizationScale(qScale); |
| 716 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 717 | outputTensorInfo.SetQuantizationScale(qScale); |
| 718 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 719 | } |
| 720 | |
| 721 | auto input = QuantizedVector<T>( |
| 722 | { |
| 723 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 724 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 725 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 726 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 727 | |
| 728 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 729 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 730 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 731 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 732 | |
| 733 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 734 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 735 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 736 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 737 | |
| 738 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 739 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 740 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 741 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 742 | }, |
| 743 | qScale, qOffset); |
| 744 | |
| 745 | float v111 = float(sqrt(pow(1,2)/8.0f)); |
| 746 | float v112 = float(sqrt((pow(2,2)+pow(3,2))/8.0f)); |
| 747 | float v113 = float(sqrt(pow(4,2)/8)); |
| 748 | |
| 749 | float v121 = float(sqrt((2*pow(1,2))/8.0f)); |
| 750 | float v122 = float(sqrt((2*pow(2,2)+2*pow(3,2))/8.0f)); |
| 751 | float v123 = float(sqrt((2*pow(4,2))/8.0f)); |
| 752 | |
| 753 | float v131 = v111; |
| 754 | float v132 = v112; |
| 755 | float v133 = v113; |
| 756 | |
| 757 | float v211 = float(sqrt((pow(2,2)+pow(3,2))/8.0f)); |
| 758 | float v212 = float(sqrt((pow(3,2)+2*pow(4,2)+pow(5,2))/8.0f)); |
| 759 | float v213 = float(sqrt((pow(5,2)+pow(6,2))/8.0f)); |
| 760 | |
| 761 | float v221 = float(sqrt((2*pow(2,2)+2*pow(3,2))/8.0f)); |
| 762 | float v222 = float(sqrt((2*pow(3,2)+4*pow(4,2)+2*pow(5,2))/8.0f)); |
| 763 | float v223 = float(sqrt((2*pow(5,2)+2*pow(6,2))/8.0f)); |
| 764 | |
| 765 | float v231 = v211; |
| 766 | float v232 = v212; |
| 767 | float v233 = v213; |
| 768 | |
| 769 | float v311 = float(sqrt(pow(4,2)/8.0f)); |
| 770 | float v312 = float(sqrt((pow(5,2)+pow(6,2))/8.0f)); |
| 771 | float v313 = float(sqrt(pow(7,2)/8)); |
| 772 | |
| 773 | float v321 = float(sqrt((2*pow(4,2))/8.0f)); |
| 774 | float v322 = float(sqrt((2*pow(5,2)+2*pow(6,2))/8.0f)); |
| 775 | float v323 = float(sqrt((2*pow(7,2))/8.0f)); |
| 776 | |
| 777 | float v331 = v311; |
| 778 | float v332 = v312; |
| 779 | float v333 = v313; |
| 780 | |
| 781 | auto outputExpected = QuantizedVector<T>( |
| 782 | { |
| 783 | v111, v112, v113, |
| 784 | v121, v122, v123, |
| 785 | v131, v132, v133, |
| 786 | |
| 787 | v211, v212, v213, |
| 788 | v221, v222, v223, |
| 789 | v231, v232, v233, |
| 790 | |
| 791 | v311, v312, v313, |
| 792 | v321, v322, v323, |
| 793 | v331, v332, v333, |
| 794 | }, |
| 795 | qScale, qOffset); |
| 796 | |
| 797 | return SimplePooling3dTestImpl<ArmnnType>( |
| 798 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 799 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 800 | } |
| 801 | |
| 802 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 803 | LayerTestResult<T, 5> AsymmetricNonSquareMaxPooling3dTestCommon( |
| 804 | armnn::IWorkloadFactory& workloadFactory, |
| 805 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 806 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 807 | float qScale = 1.0f, |
| 808 | int32_t qOffset = 0) |
| 809 | { |
| 810 | armnn::TensorInfo inputTensorInfo({ 1, 1, 1, 3, 1 }, ArmnnType); |
| 811 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2, 1 }, ArmnnType); |
| 812 | |
| 813 | armnn::Pooling3dDescriptor descriptor; |
| 814 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 815 | descriptor.m_PoolWidth = 1; |
| 816 | descriptor.m_PoolHeight = 2; |
| 817 | descriptor.m_PoolDepth = 3; |
| 818 | descriptor.m_StrideX = 0; |
| 819 | descriptor.m_StrideY = 2; |
| 820 | descriptor.m_StrideZ = 1; |
| 821 | descriptor.m_PadLeft = 0; |
| 822 | descriptor.m_PadRight = 0; |
| 823 | descriptor.m_PadTop = 2; |
| 824 | descriptor.m_PadBottom = 0; |
| 825 | descriptor.m_PadFront = 1; |
| 826 | descriptor.m_PadBack = 2; |
| 827 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 828 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 829 | |
| 830 | // Construct input data. |
| 831 | auto input = QuantizedVector<T>( |
| 832 | { |
| 833 | 1.0f, 3.0f, 4.0f, |
| 834 | }, |
| 835 | qScale, qOffset); |
| 836 | |
| 837 | // These were calculated manually. |
| 838 | auto outputExpected = QuantizedVector<T>( |
| 839 | { |
| 840 | 0.0f, 3.0f, 0.0f, 3.0f, |
| 841 | }, |
| 842 | qScale, qOffset); |
| 843 | |
| 844 | return SimplePooling3dTestImpl<ArmnnType>( |
| 845 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 846 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 847 | } |
| 848 | |
| 849 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 850 | LayerTestResult<T, 5> AsymmetricNonSquareAveragePooling3dTestCommon( |
| 851 | armnn::IWorkloadFactory& workloadFactory, |
| 852 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 853 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 854 | float qScale = 1.0f, |
| 855 | int32_t qOffset = 0) |
| 856 | { |
| 857 | armnn::TensorInfo inputTensorInfo({ 1, 1, 1, 3, 1 }, ArmnnType); |
| 858 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2, 1 }, ArmnnType); |
| 859 | |
| 860 | armnn::Pooling3dDescriptor descriptor; |
| 861 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 862 | descriptor.m_PoolWidth = 1; |
| 863 | descriptor.m_PoolHeight = 2; |
| 864 | descriptor.m_PoolDepth = 3; |
| 865 | descriptor.m_StrideX = 0; |
| 866 | descriptor.m_StrideY = 2; |
| 867 | descriptor.m_StrideZ = 1; |
| 868 | descriptor.m_PadLeft = 0; |
| 869 | descriptor.m_PadRight = 0; |
| 870 | descriptor.m_PadTop = 2; |
| 871 | descriptor.m_PadBottom = 0; |
| 872 | descriptor.m_PadFront = 1; |
| 873 | descriptor.m_PadBack = 2; |
| 874 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 875 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 876 | |
| 877 | // Construct input data. |
| 878 | auto input = QuantizedVector<T>( |
| 879 | { |
| 880 | 1.0f, 3.0f, 4.0f, |
| 881 | }, |
| 882 | qScale, qOffset); |
| 883 | |
| 884 | // These were calculated manually. |
| 885 | auto outputExpected = QuantizedVector<T>( |
| 886 | { |
| 887 | 0.0f, 2.0f, 0.0f, 2.0f, |
| 888 | }, |
| 889 | qScale, qOffset); |
| 890 | |
| 891 | return SimplePooling3dTestImpl<ArmnnType>( |
| 892 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 893 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 894 | } |
| 895 | |
| 896 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 897 | LayerTestResult<T, 5> AsymmetricNonSquareL2Pooling3dTestCommon( |
| 898 | armnn::IWorkloadFactory& workloadFactory, |
| 899 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 900 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 901 | float qScale = 1.0f, |
| 902 | int32_t qOffset = 0) |
| 903 | { |
| 904 | armnn::TensorInfo inputTensorInfo({ 1, 1, 1, 3, 1 }, ArmnnType); |
| 905 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2, 1 }, ArmnnType); |
| 906 | |
| 907 | armnn::Pooling3dDescriptor descriptor; |
| 908 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 909 | descriptor.m_PoolWidth = 1; |
| 910 | descriptor.m_PoolHeight = 2; |
| 911 | descriptor.m_PoolDepth = 3; |
| 912 | descriptor.m_StrideX = 0; |
| 913 | descriptor.m_StrideY = 2; |
| 914 | descriptor.m_StrideZ = 1; |
| 915 | descriptor.m_PadLeft = 0; |
| 916 | descriptor.m_PadRight = 0; |
| 917 | descriptor.m_PadTop = 2; |
| 918 | descriptor.m_PadBottom = 0; |
| 919 | descriptor.m_PadFront = 1; |
| 920 | descriptor.m_PadBack = 2; |
| 921 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 922 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 923 | |
| 924 | // Construct input data. |
| 925 | auto input = QuantizedVector<T>( |
| 926 | { |
| 927 | 1.0f, 3.0f, 4.0f, |
| 928 | }, |
| 929 | qScale, qOffset); |
| 930 | |
| 931 | // These were calculated manually. |
| 932 | auto outputExpected = QuantizedVector<T>( |
| 933 | { |
| 934 | 0.0f, 2.2360679775f, 0.0f, 2.2360679775f, |
| 935 | }, |
| 936 | qScale, qOffset); |
| 937 | |
| 938 | return SimplePooling3dTestImpl<ArmnnType>( |
| 939 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, |
| 940 | input, outputExpected, inputTensorInfo.GetShape(), outputTensorInfo.GetShape()); |
| 941 | } |
| 942 | |
| 943 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 944 | LayerTestResult<T, 5> ComparePooling3dTestCommon( |
| 945 | armnn::IWorkloadFactory& workloadFactory, |
| 946 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 947 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 948 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 949 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
| 950 | armnn::PoolingAlgorithm poolingType, |
| 951 | float qScale = 1.0f, |
| 952 | int32_t qOffset = 0) |
| 953 | { |
| 954 | IgnoreUnused(memoryManager); |
| 955 | const unsigned int inputWidth = 16; |
| 956 | const unsigned int inputHeight = 32; |
| 957 | const unsigned int inputDepth = 48; |
| 958 | const unsigned int channelCount = 2; |
| 959 | const unsigned int batchSize = 5; |
| 960 | |
| 961 | const unsigned int poolSize = 3; |
| 962 | const unsigned int strideX = 2; |
| 963 | const unsigned int strideY = 4; |
| 964 | const unsigned int strideZ = 6; |
| 965 | const unsigned int padX = 0; |
| 966 | const unsigned int padY = 0; |
| 967 | const unsigned int padZ = 0; |
| 968 | |
| 969 | const unsigned int outputWidth = (inputWidth + 2 * padX + strideX - poolSize) / strideX; |
| 970 | const unsigned int outputHeight = (inputHeight + 2 * padY + strideY - poolSize) / strideY; |
| 971 | const unsigned int outputDepth = (inputDepth + 2 * padZ + strideZ - poolSize) / strideZ; |
| 972 | |
| 973 | armnn::TensorInfo inputTensorInfo; |
| 974 | armnn::TensorInfo outputTensorInfo; |
| 975 | |
| 976 | unsigned int inputShape[] = { batchSize, channelCount, inputHeight, inputWidth, inputDepth }; |
| 977 | unsigned int outputShape[] = { batchSize, channelCount, outputHeight, outputWidth, outputDepth }; |
| 978 | |
| 979 | inputTensorInfo = armnn::TensorInfo(5, inputShape, ArmnnType); |
| 980 | outputTensorInfo = armnn::TensorInfo(5, outputShape, ArmnnType); |
| 981 | |
| 982 | // Set quantization parameters if the requested type is a quantized type. |
| 983 | if(armnn::IsQuantizedType<T>()) |
| 984 | { |
| 985 | inputTensorInfo.SetQuantizationScale(qScale); |
| 986 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 987 | outputTensorInfo.SetQuantizationScale(qScale); |
| 988 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 989 | } |
| 990 | |
| 991 | std::vector<T> input = MakeRandomTensor<T>(inputTensorInfo, 81715); |
| 992 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
| 993 | std::vector<T> expectedOutput(outputTensorInfo.GetNumElements()); |
| 994 | |
| 995 | LayerTestResult<T, 5> comparisonResult(outputTensorInfo); |
| 996 | |
| 997 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 998 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 999 | |
| 1000 | armnn::Pooling3dQueueDescriptor data; |
| 1001 | armnn::WorkloadInfo info; |
| 1002 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 1003 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1004 | data.m_Parameters.m_PoolType = poolingType; |
| 1005 | data.m_Parameters.m_PoolWidth = poolSize; |
| 1006 | data.m_Parameters.m_PoolHeight = poolSize; |
| 1007 | data.m_Parameters.m_PoolDepth = poolSize; |
| 1008 | data.m_Parameters.m_StrideX = strideX; |
| 1009 | data.m_Parameters.m_StrideY = strideY; |
| 1010 | data.m_Parameters.m_StrideZ = strideZ; |
| 1011 | data.m_Parameters.m_PadLeft = padX; |
| 1012 | data.m_Parameters.m_PadRight = padX; |
| 1013 | data.m_Parameters.m_PadTop = padY; |
| 1014 | data.m_Parameters.m_PadBottom = padY; |
| 1015 | data.m_Parameters.m_PadFront = padZ; |
| 1016 | data.m_Parameters.m_PadBack = padZ; |
| 1017 | data.m_Parameters.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 1018 | |
| 1019 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refTensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 1020 | std::unique_ptr<armnn::ITensorHandle> inputHandleRef = refTensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 1021 | |
| 1022 | // Don't execute if Pooling is not supported, as an exception will be raised. |
| 1023 | armnn::BackendId backend = workloadFactory.GetBackendId(); |
| 1024 | std::string reasonIfUnsupported; |
| 1025 | armnn::LayerSupportHandle handle = armnn::GetILayerSupportByBackendId(backend); |
| 1026 | comparisonResult.m_Supported = handle.IsPooling3dSupported(inputTensorInfo, |
| 1027 | outputTensorInfo, |
| 1028 | data.m_Parameters, |
| 1029 | reasonIfUnsupported); |
| 1030 | if (!comparisonResult.m_Supported) |
| 1031 | { |
| 1032 | return comparisonResult; |
| 1033 | } |
| 1034 | |
| 1035 | armnn::Pooling3dQueueDescriptor refData = data; |
| 1036 | armnn::WorkloadInfo refInfo = info; |
| 1037 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get()); |
| 1038 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 1039 | |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame^] | 1040 | std::unique_ptr<armnn::IWorkload> workload |
| 1041 | = workloadFactory.CreateWorkload(armnn::LayerType::Pooling3d, data, info); |
| 1042 | std::unique_ptr<armnn::IWorkload> workloadRef |
| 1043 | = refWorkloadFactory.CreateWorkload(armnn::LayerType::Pooling3d, refData, refInfo); |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 1044 | |
| 1045 | outputHandleRef->Allocate(); |
| 1046 | inputHandleRef->Allocate(); |
| 1047 | inputHandle->Allocate(); |
| 1048 | outputHandle->Allocate(); |
| 1049 | |
| 1050 | CopyDataToITensorHandle(inputHandle.get(), input.data()); |
| 1051 | CopyDataToITensorHandle(inputHandleRef.get(), input.data()); |
| 1052 | |
| 1053 | workload->Execute(); |
| 1054 | workloadRef->Execute(); |
| 1055 | |
| 1056 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
| 1057 | CopyDataFromITensorHandle(expectedOutput.data(), outputHandleRef.get()); |
| 1058 | |
| 1059 | comparisonResult.m_ActualData = actualOutput; |
| 1060 | comparisonResult.m_ExpectedData = expectedOutput; |
| 1061 | |
| 1062 | return comparisonResult; |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | } // anonymous namespace |
| 1067 | |
| 1068 | LayerTestResult<float, 5> SimpleMaxPooling3dSize2x2x2Stride1x1x1Test( |
| 1069 | armnn::IWorkloadFactory& workloadFactory, |
| 1070 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1071 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1072 | { |
| 1073 | return SimpleMaxPooling3dSize2x2x2Stride1x1x1TestCommon<armnn::DataType::Float32>( |
| 1074 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1075 | } |
| 1076 | |
| 1077 | LayerTestResult<uint8_t, 5> SimpleMaxPooling3dSize2x2x2Stride1x1x1Uint8Test( |
| 1078 | armnn::IWorkloadFactory& workloadFactory, |
| 1079 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1080 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1081 | { |
| 1082 | return SimpleMaxPooling3dSize2x2x2Stride1x1x1TestCommon<armnn::DataType::QAsymmU8>( |
| 1083 | workloadFactory, memoryManager, tensorHandleFactory, 0.1f, 128); |
| 1084 | } |
| 1085 | |
| 1086 | LayerTestResult<int16_t, 5> SimpleMaxPooling3dSize2x2x2Stride1x1x1Int16Test( |
| 1087 | armnn::IWorkloadFactory& workloadFactory, |
| 1088 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1089 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1090 | { |
| 1091 | return SimpleMaxPooling3dSize2x2x2Stride1x1x1TestCommon<armnn::DataType::QSymmS16>( |
| 1092 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1093 | } |
| 1094 | |
| 1095 | LayerTestResult<float, 5> SimpleMaxPooling3dTest( |
| 1096 | armnn::IWorkloadFactory& workloadFactory, |
| 1097 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1098 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1099 | const armnn::DataLayout dataLayout) |
| 1100 | { |
| 1101 | return SimpleMaxPooling3dTestCommon<armnn::DataType::Float32>( |
| 1102 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1103 | } |
| 1104 | |
| 1105 | LayerTestResult<uint8_t, 5> SimpleMaxPooling3dUint8Test( |
| 1106 | armnn::IWorkloadFactory& workloadFactory, |
| 1107 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1108 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1109 | const armnn::DataLayout dataLayout) |
| 1110 | { |
| 1111 | return SimpleMaxPooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1112 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1113 | } |
| 1114 | |
| 1115 | LayerTestResult<int16_t, 5> SimpleMaxPooling3dInt16Test( |
| 1116 | armnn::IWorkloadFactory& workloadFactory, |
| 1117 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1118 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1119 | const armnn::DataLayout dataLayout) |
| 1120 | { |
| 1121 | return SimpleMaxPooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1122 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1123 | } |
| 1124 | |
| 1125 | LayerTestResult<float, 5> IgnorePaddingSimpleMaxPooling3dTest( |
| 1126 | armnn::IWorkloadFactory& workloadFactory, |
| 1127 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1128 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1129 | { |
| 1130 | return IgnorePaddingSimpleMaxPooling3dTestCommon<armnn::DataType::Float32>( |
| 1131 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1132 | } |
| 1133 | |
| 1134 | LayerTestResult<uint8_t, 5> IgnorePaddingSimpleMaxPooling3dUint8Test( |
| 1135 | armnn::IWorkloadFactory& workloadFactory, |
| 1136 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1137 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1138 | { |
| 1139 | return IgnorePaddingSimpleMaxPooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1140 | workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -5); |
| 1141 | } |
| 1142 | |
| 1143 | LayerTestResult<int16_t, 5> IgnorePaddingSimpleMaxPooling3dInt16Test( |
| 1144 | armnn::IWorkloadFactory& workloadFactory, |
| 1145 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1146 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1147 | { |
| 1148 | return IgnorePaddingSimpleMaxPooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1149 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1150 | } |
| 1151 | |
| 1152 | LayerTestResult<float, 5> SimpleAveragePooling3dTest( |
| 1153 | armnn::IWorkloadFactory& workloadFactory, |
| 1154 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1155 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1156 | const armnn::DataLayout dataLayout) |
| 1157 | { |
| 1158 | return SimpleAveragePooling3dTestCommon<armnn::DataType::Float32>( |
| 1159 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1160 | } |
| 1161 | |
| 1162 | LayerTestResult<uint8_t, 5> SimpleAveragePooling3dUint8Test( |
| 1163 | armnn::IWorkloadFactory& workloadFactory, |
| 1164 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1165 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1166 | const armnn::DataLayout dataLayout) |
| 1167 | { |
| 1168 | return SimpleAveragePooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1169 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1170 | } |
| 1171 | |
| 1172 | LayerTestResult<int16_t, 5> SimpleAveragePooling3dInt16Test( |
| 1173 | armnn::IWorkloadFactory& workloadFactory, |
| 1174 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1175 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1176 | const armnn::DataLayout dataLayout) |
| 1177 | { |
| 1178 | return SimpleAveragePooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1179 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1180 | } |
| 1181 | |
| 1182 | LayerTestResult<float, 5> SimpleL2Pooling3dTest( |
| 1183 | armnn::IWorkloadFactory& workloadFactory, |
| 1184 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1185 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1186 | const armnn::DataLayout dataLayout) |
| 1187 | { |
| 1188 | return SimpleL2Pooling3dTestCommon<armnn::DataType::Float32>( |
| 1189 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1190 | } |
| 1191 | |
| 1192 | LayerTestResult<uint8_t, 5> SimpleL2Pooling3dUint8Test( |
| 1193 | armnn::IWorkloadFactory& workloadFactory, |
| 1194 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1195 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1196 | const armnn::DataLayout dataLayout) |
| 1197 | { |
| 1198 | return SimpleL2Pooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1199 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1200 | } |
| 1201 | |
| 1202 | LayerTestResult<int16_t, 5> SimpleL2Pooling3dInt16Test( |
| 1203 | armnn::IWorkloadFactory& workloadFactory, |
| 1204 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1205 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1206 | const armnn::DataLayout dataLayout) |
| 1207 | { |
| 1208 | return SimpleL2Pooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1209 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
| 1210 | } |
| 1211 | |
| 1212 | LayerTestResult<float, 5> LargeTensorsAveragePooling3dTest( |
| 1213 | armnn::IWorkloadFactory& workloadFactory, |
| 1214 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1215 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1216 | { |
| 1217 | return LargeTensorsAveragePooling3dTestCommon<armnn::DataType::Float32>( |
| 1218 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1219 | } |
| 1220 | |
| 1221 | LayerTestResult<uint8_t, 5> LargeTensorsAveragePooling3dUint8Test( |
| 1222 | armnn::IWorkloadFactory& workloadFactory, |
| 1223 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1224 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1225 | { |
| 1226 | return LargeTensorsAveragePooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1227 | workloadFactory, memoryManager, tensorHandleFactory, 0.5, -1); |
| 1228 | } |
| 1229 | |
| 1230 | LayerTestResult<int16_t, 5> LargeTensorsAveragePooling3dInt16Test( |
| 1231 | armnn::IWorkloadFactory& workloadFactory, |
| 1232 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1233 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1234 | { |
| 1235 | return LargeTensorsAveragePooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1236 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1237 | } |
| 1238 | |
| 1239 | LayerTestResult<float, 5> IgnorePaddingSimpleAveragePooling3dTest( |
| 1240 | armnn::IWorkloadFactory& workloadFactory, |
| 1241 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1242 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1243 | { |
| 1244 | return IgnorePaddingSimpleAveragePooling3dTestCommon<armnn::DataType::Float32>( |
| 1245 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1246 | } |
| 1247 | |
| 1248 | LayerTestResult<uint8_t, 5> IgnorePaddingSimpleAveragePooling3dUint8Test( |
| 1249 | armnn::IWorkloadFactory& workloadFactory, |
| 1250 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1251 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1252 | { |
| 1253 | return IgnorePaddingSimpleAveragePooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1254 | workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -5); |
| 1255 | } |
| 1256 | |
| 1257 | LayerTestResult<int16_t, 5> IgnorePaddingSimpleAveragePooling3dInt16Test( |
| 1258 | armnn::IWorkloadFactory& workloadFactory, |
| 1259 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1260 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1261 | { |
| 1262 | return IgnorePaddingSimpleAveragePooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1263 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1264 | } |
| 1265 | |
| 1266 | LayerTestResult<float, 5> IgnorePaddingSimpleL2Pooling3dTest( |
| 1267 | armnn::IWorkloadFactory& workloadFactory, |
| 1268 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1269 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1270 | { |
| 1271 | return IgnorePaddingSimpleL2Pooling3dTestCommon<armnn::DataType::Float32>( |
| 1272 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1273 | } |
| 1274 | |
| 1275 | LayerTestResult<uint8_t, 5> IgnorePaddingSimpleL2Pooling3dUint8Test( |
| 1276 | armnn::IWorkloadFactory& workloadFactory, |
| 1277 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1278 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1279 | { |
| 1280 | return IgnorePaddingSimpleL2Pooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1281 | workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -5); |
| 1282 | } |
| 1283 | |
| 1284 | LayerTestResult<int16_t, 5> IgnorePaddingSimpleL2Pooling3dInt16Test( |
| 1285 | armnn::IWorkloadFactory& workloadFactory, |
| 1286 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1287 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1288 | { |
| 1289 | return IgnorePaddingSimpleL2Pooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1290 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1291 | } |
| 1292 | |
| 1293 | LayerTestResult<float, 5> AsymmetricNonSquareMaxPooling3dTest( |
| 1294 | armnn::IWorkloadFactory& workloadFactory, |
| 1295 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1296 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1297 | { |
| 1298 | return AsymmetricNonSquareMaxPooling3dTestCommon<armnn::DataType::Float32>( |
| 1299 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1300 | } |
| 1301 | |
| 1302 | LayerTestResult<uint8_t, 5> AsymmetricNonSquareMaxPooling3dUint8Test( |
| 1303 | armnn::IWorkloadFactory& workloadFactory, |
| 1304 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1305 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1306 | { |
| 1307 | return AsymmetricNonSquareMaxPooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1308 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1309 | } |
| 1310 | |
| 1311 | LayerTestResult<int16_t, 5> AsymmetricNonSquareMaxPooling3dInt16Test( |
| 1312 | armnn::IWorkloadFactory& workloadFactory, |
| 1313 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1314 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1315 | { |
| 1316 | return AsymmetricNonSquareMaxPooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1317 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1318 | } |
| 1319 | |
| 1320 | LayerTestResult<float, 5> AsymmetricNonSquareAveragePooling3dTest( |
| 1321 | armnn::IWorkloadFactory& workloadFactory, |
| 1322 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1323 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1324 | { |
| 1325 | return AsymmetricNonSquareAveragePooling3dTestCommon<armnn::DataType::Float32>( |
| 1326 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1327 | } |
| 1328 | |
| 1329 | LayerTestResult<uint8_t, 5> AsymmetricNonSquareAveragePooling3dUint8Test( |
| 1330 | armnn::IWorkloadFactory& workloadFactory, |
| 1331 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1332 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1333 | { |
| 1334 | return AsymmetricNonSquareAveragePooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1335 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1336 | } |
| 1337 | |
| 1338 | LayerTestResult<int16_t, 5> AsymmetricNonSquareAveragePooling3dInt16Test( |
| 1339 | armnn::IWorkloadFactory& workloadFactory, |
| 1340 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1341 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1342 | { |
| 1343 | return AsymmetricNonSquareAveragePooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1344 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1345 | } |
| 1346 | |
| 1347 | LayerTestResult<float, 5> AsymmetricNonSquareL2Pooling3dTest( |
| 1348 | armnn::IWorkloadFactory& workloadFactory, |
| 1349 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1350 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1351 | { |
| 1352 | return AsymmetricNonSquareL2Pooling3dTestCommon<armnn::DataType::Float32>( |
| 1353 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1354 | } |
| 1355 | |
| 1356 | LayerTestResult<uint8_t, 5> AsymmetricNonSquareL2Pooling3dUint8Test( |
| 1357 | armnn::IWorkloadFactory& workloadFactory, |
| 1358 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1359 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1360 | { |
| 1361 | return AsymmetricNonSquareL2Pooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1362 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1363 | } |
| 1364 | |
| 1365 | LayerTestResult<int16_t, 5> AsymmetricNonSquareL2Pooling3dInt16Test( |
| 1366 | armnn::IWorkloadFactory& workloadFactory, |
| 1367 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1368 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
| 1369 | { |
| 1370 | return AsymmetricNonSquareL2Pooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1371 | workloadFactory, memoryManager, tensorHandleFactory); |
| 1372 | } |
| 1373 | |
| 1374 | LayerTestResult<float, 5> ComparePooling3dTest( |
| 1375 | armnn::IWorkloadFactory& workloadFactory, |
| 1376 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1377 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1378 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1379 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
| 1380 | armnn::PoolingAlgorithm poolingType) |
| 1381 | { |
| 1382 | return ComparePooling3dTestCommon<armnn::DataType::Float32>( |
| 1383 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, poolingType); |
| 1384 | } |
| 1385 | |
| 1386 | LayerTestResult<uint8_t, 5> ComparePooling3dUint8Test( |
| 1387 | armnn::IWorkloadFactory& workloadFactory, |
| 1388 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1389 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1390 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1391 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
| 1392 | armnn::PoolingAlgorithm poolingType) |
| 1393 | { |
| 1394 | return ComparePooling3dTestCommon<armnn::DataType::QAsymmU8>( |
| 1395 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, |
| 1396 | poolingType, 0.1f, 128); |
| 1397 | } |
| 1398 | |
| 1399 | LayerTestResult<int16_t, 5> ComparePooling3dInt16Test( |
| 1400 | armnn::IWorkloadFactory& workloadFactory, |
| 1401 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1402 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1403 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1404 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
| 1405 | armnn::PoolingAlgorithm poolingType) |
| 1406 | { |
| 1407 | return ComparePooling3dTestCommon<armnn::DataType::QSymmS16>( |
| 1408 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, poolingType); |
| 1409 | } |