telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | fbf0e5b | 2020-08-17 01:01:06 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 6 | #include "Pooling2dTestImpl.hpp" |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 8 | #include <QuantizeHelper.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 9 | #include <ResolveType.hpp> |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 10 | |
| 11 | #include <armnn/LayerSupport.hpp> |
| 12 | |
| 13 | #include <armnnUtils/TensorUtils.hpp> |
| 14 | #include <armnnUtils/DataLayoutIndexed.hpp> |
| 15 | #include <armnnUtils/Permute.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 16 | |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 17 | #include <armnn/utility/IgnoreUnused.hpp> |
| 18 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 19 | #include <backendsCommon/WorkloadInfo.hpp> |
| 20 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 21 | #include <backendsCommon/test/TensorCopyUtils.hpp> |
| 22 | #include <backendsCommon/test/WorkloadTestUtils.hpp> |
| 23 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 24 | #include <test/TensorHelpers.hpp> |
| 25 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 26 | #include <boost/numeric/conversion/cast.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 28 | namespace |
| 29 | { |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 30 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 31 | using namespace armnnUtils; |
| 32 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 33 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 34 | LayerTestResult<T, 4> SimplePooling2dTestImpl( |
| 35 | armnn::IWorkloadFactory& workloadFactory, |
| 36 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 37 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 38 | armnn::Pooling2dDescriptor descriptor, |
| 39 | float qScale, |
| 40 | int32_t qOffset, |
| 41 | const boost::multi_array<T, 4>& input, |
| 42 | const boost::multi_array<T, 4>& outputExpected) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 44 | IgnoreUnused(memoryManager); |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 45 | const armnn::DataLayout dataLayout = descriptor.m_DataLayout; |
Matteo Martincigh | 2135015 | 2018-11-28 16:22:22 +0000 | [diff] [blame] | 46 | const armnnUtils::DataLayoutIndexed dimensionIndices = dataLayout; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 47 | auto heightIndex = dimensionIndices.GetHeightIndex(); |
| 48 | auto widthIndex = dimensionIndices.GetWidthIndex(); |
| 49 | auto channelsIndex = dimensionIndices.GetChannelsIndex(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 51 | unsigned int inputHeight = boost::numeric_cast<unsigned int>(input.shape()[heightIndex]); |
| 52 | unsigned int inputWidth = boost::numeric_cast<unsigned int>(input.shape()[widthIndex]); |
| 53 | unsigned int inputChannels = boost::numeric_cast<unsigned int>(input.shape()[channelsIndex]); |
| 54 | unsigned int inputBatchSize = boost::numeric_cast<unsigned int>(input.shape()[0]); |
| 55 | |
| 56 | unsigned int outputHeight = boost::numeric_cast<unsigned int>(outputExpected.shape()[heightIndex]); |
| 57 | unsigned int outputWidth = boost::numeric_cast<unsigned int>(outputExpected.shape()[widthIndex]); |
| 58 | unsigned int outputChannels = boost::numeric_cast<unsigned int>(outputExpected.shape()[channelsIndex]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 59 | unsigned int outputBatchSize = boost::numeric_cast<unsigned int>(outputExpected.shape()[0]); |
| 60 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 61 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo( |
| 62 | inputBatchSize, inputChannels, inputHeight, inputWidth, dataLayout, ArmnnType); |
| 63 | |
| 64 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo( |
| 65 | outputBatchSize, outputChannels, outputHeight, outputWidth, dataLayout, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 66 | |
| 67 | // Set quantization parameters if the requested type is a quantized type. |
| 68 | if(armnn::IsQuantizedType<T>()) |
| 69 | { |
| 70 | inputTensorInfo.SetQuantizationScale(qScale); |
| 71 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 72 | outputTensorInfo.SetQuantizationScale(qScale); |
| 73 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 74 | } |
| 75 | |
| 76 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 77 | |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 78 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 79 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | |
| 81 | armnn::Pooling2dQueueDescriptor queueDescriptor; |
| 82 | queueDescriptor.m_Parameters = descriptor; |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 83 | queueDescriptor.m_Parameters.m_DataLayout = dataLayout; |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 84 | |
| 85 | armnn::WorkloadInfo workloadInfo; |
| 86 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get()); |
| 87 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 88 | |
| 89 | // Don't execute if Pooling is not supported, as an exception will be raised. |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 90 | armnn::BackendId backend = workloadFactory.GetBackendId(); |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 91 | const size_t reasonIfUnsupportedMaxLen = 255; |
| 92 | char reasonIfUnsupported[reasonIfUnsupportedMaxLen+1]; |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 93 | result.supported = armnn::IsPooling2dSupported(backend, inputTensorInfo, outputTensorInfo, |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 94 | queueDescriptor.m_Parameters, |
| 95 | reasonIfUnsupported, reasonIfUnsupportedMaxLen); |
| 96 | if (!result.supported) |
| 97 | { |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePooling2d(queueDescriptor, workloadInfo); |
| 102 | |
| 103 | inputHandle->Allocate(); |
| 104 | outputHandle->Allocate(); |
| 105 | |
| 106 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 107 | |
| 108 | workload->Execute(); |
| 109 | |
| 110 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 111 | |
| 112 | result.outputExpected = outputExpected; |
| 113 | |
| 114 | return result; |
| 115 | } |
| 116 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 117 | // |
| 118 | // Tests max pooling with the following parameters: |
| 119 | // |
| 120 | // Pooling size: 3x3 |
| 121 | // Stride: (2,4) |
| 122 | // input size: 8x13 |
| 123 | // channels: 2 |
| 124 | // batch size: 2 |
| 125 | // |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 126 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 127 | LayerTestResult<T, 4> SimpleMaxPooling2dSize3x3Stride2x4TestCommon( |
| 128 | armnn::IWorkloadFactory& workloadFactory, |
| 129 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 130 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 131 | bool forceNoPadding, |
| 132 | float qScale = 1.0f, |
| 133 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 134 | { |
| 135 | armnn::Pooling2dDescriptor descriptor; |
| 136 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 137 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 138 | descriptor.m_StrideX = 2; |
| 139 | descriptor.m_StrideY = 4; |
| 140 | // forceNoPadding is mainly used for compatibility with ARM Compute. |
| 141 | // As of 16/05/2017, it errors if padX or padY are equal to or greater than the pool size. |
| 142 | descriptor.m_PadLeft = descriptor.m_PadRight = forceNoPadding ? 0 : 3; |
| 143 | descriptor.m_PadTop = descriptor.m_PadBottom = 0; |
| 144 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 145 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 146 | |
| 147 | unsigned int inputWidth = 8; |
| 148 | unsigned int inputHeight = 13; |
| 149 | unsigned int outputWidth = |
| 150 | (inputWidth + descriptor.m_PadLeft + descriptor.m_PadRight + descriptor.m_StrideX - descriptor.m_PoolWidth) / |
| 151 | descriptor.m_StrideX; |
| 152 | unsigned int outputHeight = |
| 153 | (inputHeight + descriptor.m_PadTop + descriptor.m_PadBottom + descriptor.m_StrideY - descriptor.m_PoolHeight) / |
| 154 | descriptor.m_StrideY; |
| 155 | unsigned int channels = 2; |
| 156 | unsigned int batchSize = 2; |
| 157 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 158 | armnn::TensorInfo inputTensorInfo({ batchSize, channels, inputHeight, inputWidth }, ArmnnType); |
| 159 | armnn::TensorInfo outputTensorInfo({ batchSize, channels, outputHeight, outputWidth }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 160 | |
| 161 | // Set quantization parameters if the requested type is a quantized type. |
| 162 | if(armnn::IsQuantizedType<T>()) |
| 163 | { |
| 164 | inputTensorInfo.SetQuantizationScale(qScale); |
| 165 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 166 | outputTensorInfo.SetQuantizationScale(qScale); |
| 167 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 168 | } |
| 169 | |
| 170 | std::vector<float> singleChannelData({ |
| 171 | 0.0f, 4.0f, 8.0f, 1.0f, 6.0f, 4.0f, 5.0f, 8.0f, |
| 172 | 1.0f, 1.0f, 6.0f, 0.0f, 3.0f, 7.0f, 4.0f, 7.0f, |
| 173 | 8.0f, 5.0f, 0.0f, 0.0f, 8.0f, 3.0f, 4.0f, 3.0f, |
| 174 | 8.0f, 2.0f, 5.0f, 4.0f, 1.0f, 9.0f, 2.0f, 0.0f, |
| 175 | 5.0f, 4.0f, 5.0f, 0.0f, 0.0f, 0.0f, 7.0f, 2.0f, |
| 176 | 1.0f, 2.0f, 6.0f, 2.0f, 7.0f, 9.0f, 5.0f, 2.0f, |
| 177 | 9.0f, 7.0f, 3.0f, 1.0f, 3.0f, 4.0f, 8.0f, 3.0f, |
| 178 | 1.0f, 0.0f, 0.0f, 5.0f, 5.0f, 4.0f, 2.0f, 0.0f, |
| 179 | 6.0f, 4.0f, 3.0f, 6.0f, 9.0f, 5.0f, 5.0f, 6.0f, |
| 180 | 8.0f, 7.0f, 9.0f, 6.0f, 1.0f, 4.0f, 1.0f, 9.0f, |
| 181 | 7.0f, 1.0f, 9.0f, 2.0f, 9.0f, 9.0f, 8.0f, 1.0f, |
| 182 | 4.0f, 4.0f, 5.0f, 9.0f, 2.0f, 6.0f, 6.0f, 4.0f, |
| 183 | 3.0f, 5.0f, 4.0f, 0.0f, 1.0f, 5.0f, 9.0f, 7.0f, |
| 184 | }); |
| 185 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 186 | // Constructs input data. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 187 | std::vector<float> inputData; |
| 188 | auto negator = [](float f) { return -f; }; |
| 189 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 190 | // First image (two channels where the second channel is the negative of the first one). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 191 | inputData.insert(inputData.end(), singleChannelData.begin(), singleChannelData.end()); |
| 192 | std::transform(singleChannelData.begin(), singleChannelData.end(), std::back_inserter(inputData), negator); |
| 193 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 194 | // Second image (same as first image). |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 195 | inputData.insert(inputData.end(), singleChannelData.begin(), singleChannelData.end()); |
| 196 | std::transform(singleChannelData.begin(), singleChannelData.end(), std::back_inserter(inputData), negator); |
| 197 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 198 | auto input = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(inputData, qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 199 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 200 | // These were calculated manually. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 201 | auto shape(GetTensorShapeAsArray<4>(outputTensorInfo)); |
| 202 | boost::multi_array<T, 4> outputExpected(shape); |
| 203 | if (forceNoPadding) |
| 204 | { |
| 205 | outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 206 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 207 | 8.0f, 8.0f, 8.0f, |
| 208 | 9.0f, 7.0f, 9.0f, |
| 209 | 9.0f, 9.0f, 9.0f, |
| 210 | |
| 211 | 0.0f, 0.0f, -3.0f, |
| 212 | -1.0f, 0.0f, 0.0f, |
| 213 | -1.0f, -1.0f, -1.0f, |
| 214 | |
| 215 | 8.0f, 8.0f, 8.0f, |
| 216 | 9.0f, 7.0f, 9.0f, |
| 217 | 9.0f, 9.0f, 9.0f, |
| 218 | |
| 219 | 0.0f, 0.0f, -3.0f, |
| 220 | -1.0f, 0.0f, 0.0f, |
| 221 | -1.0f, -1.0f, -1.0f |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 222 | }, |
| 223 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 224 | } |
| 225 | else |
| 226 | { |
| 227 | outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 228 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 229 | 0.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, |
| 230 | 0.0f, 9.0f, 7.0f, 9.0f, 9.0f, 3.0f, |
| 231 | 0.0f, 8.0f, 9.0f, 9.0f, 9.0f, 9.0f, |
| 232 | |
Finn Williams | 70f609b | 2019-11-06 16:54:53 +0000 | [diff] [blame] | 233 | 0.0f, 0.0f, 0.0f, 0.0f,-3.0f,-3.0f, |
| 234 | 0.0f,-1.0f, 0.0f, 0.0f, 0.0f,-2.0f, |
| 235 | 0.0f,-1.0f,-1.0f,-1.0f,-1.0f,-1.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 236 | |
| 237 | 0.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, |
| 238 | 0.0f, 9.0f, 7.0f, 9.0f, 9.0f, 3.0f, |
| 239 | 0.0f, 8.0f, 9.0f, 9.0f, 9.0f, 9.0f, |
| 240 | |
Finn Williams | 70f609b | 2019-11-06 16:54:53 +0000 | [diff] [blame] | 241 | 0.0f, 0.0f, 0.0f, 0.0f,-3.0f,-3.0f, |
| 242 | 0.0f,-1.0f, 0.0f, 0.0f, 0.0f,-2.0f, |
| 243 | 0.0f,-1.0f,-1.0f,-1.0f,-1.0f,-1.0f |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 244 | }, |
| 245 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 248 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 249 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 252 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 253 | LayerTestResult<T, 4> SimpleMaxPooling2dTestCommon( |
| 254 | armnn::IWorkloadFactory& workloadFactory, |
| 255 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 256 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 257 | const armnn::DataLayout dataLayout = armnn::DataLayout::NCHW, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 258 | float qScale = 1.0f, |
| 259 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 260 | { |
| 261 | armnn::Pooling2dDescriptor descriptor; |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 262 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 263 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 264 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 265 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 266 | descriptor.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 268 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, ArmnnType); |
| 269 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 2, 2, dataLayout, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 270 | |
| 271 | // Set quantization parameters if the requested type is a quantized type. |
| 272 | if(armnn::IsQuantizedType<T>()) |
| 273 | { |
| 274 | inputTensorInfo.SetQuantizationScale(qScale); |
| 275 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 276 | outputTensorInfo.SetQuantizationScale(qScale); |
| 277 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 278 | } |
| 279 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 280 | std::vector<T> inputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 281 | QuantizedVector<T>({ |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 282 | 1.0f, 2.0f, 5.0f, 6.0f, |
| 283 | 3.0f, 4.0f, 7.0f, 8.0f, |
| 284 | 9.0f, 10.0f, 13.0f, 14.0f, |
| 285 | 11.0f, 12.0f, 15.0f, 16.0f, |
| 286 | |
| 287 | 17.0f, 18.0f, 21.0f, 22.0f, |
| 288 | 19.0f, 20.0f, 23.0f, 24.0f, |
| 289 | 25.0f, 26.0f, 29.0f, 30.0f, |
| 290 | 27.0f, 28.0f, 31.0f, 32.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 291 | }, |
| 292 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 293 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 294 | std::vector<T> outputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 295 | QuantizedVector<T>({ |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 296 | 4.0f, 8.0f, |
| 297 | 12.0f, 16.0f, |
| 298 | |
| 299 | 20.0f, 24.0f, |
| 300 | 28.0f, 32.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 301 | }, |
| 302 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 303 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 304 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 305 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 306 | { |
| 307 | std::vector<T> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 308 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 309 | inputData = tmp; |
| 310 | |
| 311 | std::vector<T> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 312 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 313 | outputData = tmp1; |
| 314 | } |
| 315 | |
| 316 | auto input = MakeTensor<T, 4>(inputTensorInfo, inputData); |
| 317 | |
| 318 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputData); |
| 319 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 320 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 321 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 324 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 325 | LayerTestResult<T, 4> SimpleAveragePooling2dTestCommon( |
| 326 | armnn::IWorkloadFactory& workloadFactory, |
| 327 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 328 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 329 | armnn::DataLayout dataLayout = armnn::DataLayout::NCHW, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 330 | float qScale = 1.0f, |
| 331 | int32_t qOffset = 0) |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 332 | { |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 333 | armnn::Pooling2dDescriptor descriptor; |
| 334 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 335 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 336 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 337 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 338 | descriptor.m_DataLayout = dataLayout; |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 339 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 340 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, ArmnnType); |
| 341 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 2, 2, dataLayout, ArmnnType); |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 342 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 343 | // Set quantization parameters if the requested type is a quantized type. |
| 344 | if(armnn::IsQuantizedType<T>()) |
| 345 | { |
| 346 | inputTensorInfo.SetQuantizationScale(qScale); |
| 347 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 348 | outputTensorInfo.SetQuantizationScale(qScale); |
| 349 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 350 | } |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 351 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 352 | std::vector<T> inputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 353 | QuantizedVector<T>({ |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 354 | 2.0f, 2.0f, 6.0f, 6.0f, |
| 355 | 4.0f, 4.0f, 8.0f, 8.0f, |
| 356 | 10.0f, 12.0f, 14.0f, 16.0f, |
| 357 | 10.0f, 12.0f, 16.0f, 14.0f, |
| 358 | |
| 359 | 18.0f, 20.0f, 24.0f, 22.0f, |
| 360 | 20.0f, 18.0f, 22.0f, 24.0f, |
| 361 | 26.0f, 28.0f, 0.0f, 0.0f, |
| 362 | 26.0f, 28.0f, 0.0f, 0.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 363 | }, |
| 364 | qScale, qOffset)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 365 | |
| 366 | std::vector<T> outputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 367 | QuantizedVector<T>({ |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 368 | 3.0f, 7.0f, |
| 369 | 11.0f, 15.0f, |
| 370 | |
| 371 | 19.0f, 23.0f, |
| 372 | 27.0f, 0.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 373 | }, |
| 374 | qScale, qOffset)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 375 | |
| 376 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 377 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 378 | { |
| 379 | std::vector<T> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 380 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 381 | inputData = tmp; |
| 382 | |
| 383 | std::vector<T> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 384 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 385 | outputData = tmp1; |
| 386 | } |
| 387 | |
| 388 | auto input = MakeTensor<T, 4>(inputTensorInfo, inputData); |
| 389 | |
| 390 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputData); |
| 391 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 392 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 393 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 394 | } |
| 395 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 396 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 397 | LayerTestResult<T, 4> LargeTensorsAveragePooling2dTestCommon( |
| 398 | armnn::IWorkloadFactory& workloadFactory, |
| 399 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 400 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 401 | float qScale = 1.0f, |
| 402 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 403 | { |
| 404 | armnn::Pooling2dDescriptor descriptor; |
| 405 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 406 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 100; |
| 407 | descriptor.m_StrideX = descriptor.m_StrideY = 5; |
| 408 | descriptor.m_PadLeft = 50; |
| 409 | descriptor.m_PadRight = 50; |
| 410 | descriptor.m_PadTop = 50; |
| 411 | descriptor.m_PadBottom = 50; |
| 412 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 413 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 414 | armnn::TensorInfo inputTensorInfo({ 5, 3, 52, 60 }, ArmnnType); |
| 415 | armnn::TensorInfo outputTensorInfo({ 5, 3, 11, 13 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 416 | |
| 417 | // Set quantization parameters if the requested type is a quantized type. |
| 418 | if(armnn::IsQuantizedType<T>()) |
| 419 | { |
| 420 | inputTensorInfo.SetQuantizationScale(qScale); |
| 421 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 422 | outputTensorInfo.SetQuantizationScale(qScale); |
| 423 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 424 | } |
| 425 | |
| 426 | std::vector<T> inputVec; |
| 427 | |
| 428 | for (unsigned int i = 0 ; i < inputTensorInfo.GetShape().GetNumElements(); ++i) |
| 429 | { |
| 430 | inputVec.push_back(1); |
| 431 | } |
| 432 | |
| 433 | auto input = MakeTensor<T, 4>(inputTensorInfo, inputVec); |
| 434 | |
| 435 | std::vector<T> outputVec; |
| 436 | |
| 437 | for (unsigned int i = 0 ; i < outputTensorInfo.GetShape().GetNumElements(); ++i) |
| 438 | { |
| 439 | outputVec.push_back(1); |
| 440 | } |
| 441 | |
| 442 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputVec); |
| 443 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 444 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 445 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 448 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 449 | LayerTestResult<T, 4> SimpleL2Pooling2dTestCommon( |
| 450 | armnn::IWorkloadFactory& workloadFactory, |
| 451 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 452 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 453 | armnn::DataLayout dataLayout = armnn::DataLayout::NCHW, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 454 | float qScale = 1.0f, |
| 455 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 456 | { |
| 457 | armnn::Pooling2dDescriptor descriptor; |
| 458 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 459 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 460 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 461 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 462 | descriptor.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 463 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 464 | armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, ArmnnType); |
| 465 | armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo(1, 2, 2, 2, dataLayout, ArmnnType); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 466 | |
| 467 | std::vector<T> inputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 468 | QuantizedVector<T>({ |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 469 | 1.0f, 7.0f, 5.0f, 5.0f, |
| 470 | 1.0f, 7.0f, 5.0f, 5.0f, |
| 471 | 3.0f, 3.0f, 1.0f, 1.0f, |
| 472 | 3.0f, 3.0f, 1.0f, 1.0f, |
| 473 | |
| 474 | 1.0f, 7.0f, 0.0f, 0.0f, |
| 475 | 1.0f, 7.0f, 2.0f, 0.0f, |
| 476 | 0.0f, 2.0f, 1.0f, 1.0f, |
| 477 | 0.0f, 0.0f, 1.0f, 1.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 478 | }, |
| 479 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 480 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 481 | std::vector<T> outputData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 482 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 483 | 5.0f, 5.0f, |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 484 | 3.0f, 1.0f, |
| 485 | |
| 486 | 5.0f, 1.0f, |
| 487 | 1.0f, 1.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 488 | }, |
| 489 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 490 | |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 491 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 492 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 493 | { |
| 494 | std::vector<T> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 495 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 496 | inputData = tmp; |
| 497 | |
| 498 | std::vector<T> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 499 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(T)); |
James Conroy | 45a9b77 | 2018-10-31 11:47:53 +0000 | [diff] [blame] | 500 | outputData = tmp1; |
| 501 | } |
| 502 | |
| 503 | auto input = MakeTensor<T, 4>(inputTensorInfo, inputData); |
| 504 | |
| 505 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputData); |
| 506 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 507 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 508 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 511 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 512 | LayerTestResult<T, 4> L2Pooling2dSize3Stride1TestCommon( |
| 513 | armnn::IWorkloadFactory& workloadFactory, |
| 514 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 515 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 516 | float qScale = 1.0f, |
| 517 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 518 | { |
| 519 | armnn::Pooling2dDescriptor descriptor; |
| 520 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 521 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 522 | descriptor.m_StrideX = descriptor.m_StrideY = 1; |
| 523 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 524 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 525 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 526 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 527 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 528 | 2.0f, 1.0f, 5.0f, 2.0f, |
| 529 | 1.0f, 2.0f, 2.0f, 1.0f, |
| 530 | 5.0f, 4.0f, 1.0f, 5.0f, |
| 531 | 2.0f, 1.0f, 5.0f, 2.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 532 | }, |
| 533 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 534 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 535 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 536 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 537 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 538 | 3.0f, 3.0f, |
| 539 | 3.0f, 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 540 | }, |
| 541 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 542 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 543 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 544 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 547 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 548 | LayerTestResult<T, 4> L2Pooling2dSize3Stride3TestCommon( |
| 549 | armnn::IWorkloadFactory& workloadFactory, |
| 550 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 551 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 552 | float qScale = 1.0f, |
| 553 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 554 | { |
| 555 | armnn::Pooling2dDescriptor descriptor; |
| 556 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 557 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 558 | descriptor.m_StrideX = descriptor.m_StrideY = 3; |
| 559 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 560 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 561 | armnn::TensorInfo inputTensorInfo({ 1, 1, 9, 9 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 562 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 563 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 564 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 565 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 566 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
| 567 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 568 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 569 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
| 570 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 571 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 572 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 573 | }, |
| 574 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 575 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 576 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 577 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 578 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 579 | 3.0f, 3.0f, 3.0f, |
| 580 | 3.0f, 3.0f, 3.0f, |
| 581 | 3.0f, 3.0f, 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 582 | }, |
| 583 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 584 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 585 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 586 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 587 | } |
| 588 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 589 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 590 | LayerTestResult<T, 4> L2Pooling2dSize3Stride4TestCommon( |
| 591 | armnn::IWorkloadFactory& workloadFactory, |
| 592 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 593 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 594 | float qScale = 1.0f, |
| 595 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 596 | { |
| 597 | armnn::Pooling2dDescriptor descriptor; |
| 598 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 599 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 600 | descriptor.m_StrideX = descriptor.m_StrideY = 4; |
| 601 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 602 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 603 | armnn::TensorInfo inputTensorInfo({ 1, 1, 7, 7 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 604 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 605 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 606 | 2.0f, 1.0f, 5.0f, 0.0f, 2.0f, 1.0f, 5.0f, |
| 607 | 1.0f, 2.0f, 2.0f, 0.0f, 1.0f, 2.0f, 2.0f, |
| 608 | 5.0f, 4.0f, 1.0f, 0.0f, 5.0f, 4.0f, 1.0f, |
| 609 | 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
| 610 | 2.0f, 1.0f, 5.0f, 0.0f, 2.0f, 1.0f, 5.0f, |
| 611 | 1.0f, 2.0f, 2.0f, 0.0f, 1.0f, 2.0f, 2.0f, |
| 612 | 5.0f, 4.0f, 1.0f, 0.0f, 5.0f, 4.0f, 1.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 613 | }, |
| 614 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 615 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 616 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 617 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 618 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 619 | 3.0f, 3.0f, |
| 620 | 3.0f, 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 621 | }, |
| 622 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 623 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 624 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 625 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 628 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 629 | LayerTestResult<T, 4> L2Pooling2dSize7TestCommon( |
| 630 | armnn::IWorkloadFactory& workloadFactory, |
| 631 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 632 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 633 | float qScale = 1.0f, |
| 634 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 635 | { |
| 636 | armnn::Pooling2dDescriptor descriptor; |
| 637 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 638 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 7; |
| 639 | descriptor.m_StrideX = descriptor.m_StrideY = 7; |
| 640 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 641 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 642 | armnn::TensorInfo inputTensorInfo({ 1, 1, 7, 7 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 643 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 644 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 645 | 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, |
| 646 | 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
| 647 | 0.0f, 5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, |
| 648 | 8.0f, 0.0f, 9.0f, 0.0f, 10.0f, 0.0f, 5.0f, |
| 649 | 0.0f, 5.0f, 0.0f, 2.0f, 0.0f, 1.0f, 1.0f, |
| 650 | 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
| 651 | 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 652 | }, |
| 653 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 654 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 655 | armnn::TensorInfo outputTensorInfo({ 1, 1, 1, 1 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 656 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 657 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 658 | 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 659 | }, |
| 660 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 661 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 662 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 663 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 666 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 667 | LayerTestResult<T, 4> L2Pooling2dSize9TestCommon( |
| 668 | armnn::IWorkloadFactory& workloadFactory, |
| 669 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 670 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 671 | float qScale = 1.0f, |
| 672 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 673 | { |
| 674 | armnn::Pooling2dDescriptor descriptor; |
| 675 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 676 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 9; |
| 677 | descriptor.m_StrideX = descriptor.m_StrideY = 9; |
| 678 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 679 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 680 | armnn::TensorInfo inputTensorInfo({ 1, 1, 9, 9 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 681 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 682 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 683 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 684 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 685 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
| 686 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 687 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 688 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
| 689 | 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, 2.0f, 1.0f, 5.0f, |
| 690 | 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, 1.0f, 2.0f, 2.0f, |
| 691 | 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, 5.0f, 4.0f, 1.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 692 | }, |
| 693 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 694 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 695 | armnn::TensorInfo outputTensorInfo({ 1, 1, 1, 1 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 696 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 697 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 698 | 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 699 | }, |
| 700 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 701 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 702 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 703 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 706 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 707 | LayerTestResult<T, 4> AsymmetricNonSquarePooling2dTestCommon( |
| 708 | armnn::IWorkloadFactory& workloadFactory, |
| 709 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 710 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 711 | float qScale = 1.0f, |
| 712 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 713 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 714 | armnn::TensorInfo inputTensorInfo({ 1, 1, 1, 3 }, ArmnnType); |
| 715 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 716 | |
| 717 | armnn::Pooling2dDescriptor descriptor; |
| 718 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 719 | descriptor.m_PoolWidth = 2; |
| 720 | descriptor.m_PoolHeight = 3; |
| 721 | descriptor.m_StrideX = 2; |
| 722 | descriptor.m_StrideY = 1; |
| 723 | descriptor.m_PadLeft = 2; |
| 724 | descriptor.m_PadRight = 0; |
| 725 | descriptor.m_PadTop = 1; |
| 726 | descriptor.m_PadBottom = 2; |
| 727 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 728 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 729 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 730 | // Construct input data. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 731 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 732 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 733 | 1.0f, 3.0f, 4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 734 | }, |
| 735 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 736 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 737 | // These were calculated manually. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 738 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 739 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 740 | 0.0f, 3.0f, 0.0f, 3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 741 | }, |
| 742 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 743 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 744 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 745 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 748 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 749 | LayerTestResult<T, 4> ComparePooling2dTestCommon( |
| 750 | armnn::IWorkloadFactory& workloadFactory, |
| 751 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 752 | armnn::IWorkloadFactory& refWorkloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 753 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 754 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 755 | armnn::PoolingAlgorithm poolingType, |
| 756 | float qScale = 1.0f, |
| 757 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 758 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 759 | IgnoreUnused(memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 760 | const unsigned int inputWidth = 16; |
| 761 | const unsigned int inputHeight = 32; |
| 762 | const unsigned int channelCount = 2; |
| 763 | const unsigned int batchSize = 5; |
| 764 | |
| 765 | const unsigned int poolSize = 3; |
| 766 | const unsigned int strideX = 2; |
| 767 | const unsigned int strideY = 4; |
| 768 | const unsigned int padX = 0; |
| 769 | const unsigned int padY = 0; |
| 770 | |
| 771 | const unsigned int outputWidth = (inputWidth + 2 * padX + strideX - poolSize) / strideX; |
| 772 | const unsigned int outputHeight = (inputHeight + 2 * padY + strideY - poolSize) / strideY; |
| 773 | |
| 774 | armnn::TensorInfo inputTensorInfo; |
| 775 | armnn::TensorInfo outputTensorInfo; |
| 776 | |
| 777 | unsigned int inputShape[] = { batchSize, channelCount, inputHeight, inputWidth }; |
| 778 | unsigned int outputShape[] = { batchSize, channelCount, outputHeight, outputWidth }; |
| 779 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 780 | inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType); |
| 781 | outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 782 | |
| 783 | // Set quantization parameters if the requested type is a quantized type. |
| 784 | if(armnn::IsQuantizedType<T>()) |
| 785 | { |
| 786 | inputTensorInfo.SetQuantizationScale(qScale); |
| 787 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 788 | outputTensorInfo.SetQuantizationScale(qScale); |
| 789 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 790 | } |
| 791 | |
| 792 | boost::multi_array<T, 4> input = MakeRandomTensor<T, 4>(inputTensorInfo, 81715); |
| 793 | |
| 794 | LayerTestResult<T, 4> comparisonResult(outputTensorInfo); |
| 795 | |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 796 | std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 797 | std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 798 | |
| 799 | armnn::Pooling2dQueueDescriptor data; |
| 800 | armnn::WorkloadInfo info; |
| 801 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 802 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 803 | data.m_Parameters.m_PoolType = poolingType; |
| 804 | data.m_Parameters.m_PoolWidth = poolSize; |
| 805 | data.m_Parameters.m_PoolHeight = poolSize; |
| 806 | data.m_Parameters.m_StrideX = strideX; |
| 807 | data.m_Parameters.m_StrideY = strideY; |
| 808 | data.m_Parameters.m_PadLeft = padX; |
| 809 | data.m_Parameters.m_PadRight = padX; |
| 810 | data.m_Parameters.m_PadTop = padY; |
| 811 | data.m_Parameters.m_PadBottom = padY; |
| 812 | data.m_Parameters.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 813 | |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 814 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refTensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 815 | std::unique_ptr<armnn::ITensorHandle> inputHandleRef = refTensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 816 | |
| 817 | // Don't execute if Pooling is not supported, as an exception will be raised. |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 818 | armnn::BackendId backend = workloadFactory.GetBackendId(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 819 | const size_t reasonIfUnsupportedMaxLen = 255; |
| 820 | char reasonIfUnsupported[reasonIfUnsupportedMaxLen+1]; |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 821 | comparisonResult.supported = armnn::IsPooling2dSupported(backend, inputTensorInfo, outputTensorInfo, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 822 | data.m_Parameters, |
| 823 | reasonIfUnsupported, reasonIfUnsupportedMaxLen); |
| 824 | if (!comparisonResult.supported) |
| 825 | { |
| 826 | return comparisonResult; |
| 827 | } |
| 828 | |
| 829 | armnn::Pooling2dQueueDescriptor refData = data; |
| 830 | armnn::WorkloadInfo refInfo = info; |
| 831 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get()); |
| 832 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 833 | |
| 834 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePooling2d(data, info); |
| 835 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreatePooling2d(refData, refInfo); |
| 836 | |
| 837 | outputHandleRef->Allocate(); |
| 838 | inputHandleRef->Allocate(); |
| 839 | inputHandle->Allocate(); |
| 840 | outputHandle->Allocate(); |
| 841 | |
| 842 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 843 | CopyDataToITensorHandle(inputHandleRef.get(), &input[0][0][0][0]); |
| 844 | |
| 845 | workload->Execute(); |
| 846 | workloadRef->Execute(); |
| 847 | |
| 848 | CopyDataFromITensorHandle(&comparisonResult.output[0][0][0][0], outputHandle.get()); |
| 849 | CopyDataFromITensorHandle(&comparisonResult.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 850 | |
| 851 | return comparisonResult; |
| 852 | } |
| 853 | |
| 854 | // |
| 855 | // Tests max pooling with the following parameters: |
| 856 | // |
| 857 | // Pooling size: 2x2 |
| 858 | // Stride: (2,2) |
| 859 | // input size: 4x4 |
| 860 | // channels: 1 |
| 861 | // batch size: 1 |
| 862 | // |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 863 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 864 | LayerTestResult<T, 4> SimpleMaxPooling2dSize2x2Stride2x2TestCommon( |
| 865 | armnn::IWorkloadFactory& workloadFactory, |
| 866 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 867 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 868 | bool forceNoPadding, |
| 869 | float qScale = 1.0f, |
| 870 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 871 | { |
| 872 | armnn::Pooling2dDescriptor descriptor; |
| 873 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 874 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 875 | descriptor.m_StrideX = 2; |
| 876 | descriptor.m_StrideY = 2; |
| 877 | descriptor.m_PadLeft = descriptor.m_PadRight = forceNoPadding ? 0 : 3; |
| 878 | descriptor.m_PadTop = descriptor.m_PadBottom = 0; |
| 879 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 880 | descriptor.m_PaddingMethod = armnn::PaddingMethod::Exclude; |
| 881 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 882 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 883 | unsigned int inputWidth = 4; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 884 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 885 | unsigned int inputHeight = 4; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 886 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 887 | unsigned int outputWidth = |
| 888 | (inputWidth + descriptor.m_PadLeft + descriptor.m_PadRight + descriptor.m_StrideX - descriptor.m_PoolWidth) / |
| 889 | descriptor.m_StrideX; |
| 890 | unsigned int outputHeight = |
| 891 | (inputHeight + descriptor.m_PadTop + descriptor.m_PadBottom + descriptor.m_StrideY - descriptor.m_PoolHeight) / |
| 892 | descriptor.m_StrideY; |
| 893 | unsigned int channels = 1; |
| 894 | unsigned int batchSize = 1; |
| 895 | |
| 896 | std::vector<float> inputData = { |
| 897 | 510.0f, 222.0f, 780.0f, 654.0f, |
| 898 | 141.0f, 276.0f, 15.0f, 546.0f, |
| 899 | 303.0f, 618.0f, 582.0f, 339.0f, |
| 900 | 438.0f, 564.0f, 573.0f, 402.0f |
| 901 | }; |
| 902 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 903 | // Note that left and right edges will be 0.f, due to the 2x2 max pooling only accessing zeros here. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 904 | std::vector<float> expectedOutputDataWithPadding = { |
| 905 | 0.0f, 510.0f, 780.0f, 654.0f, 0.0f, |
| 906 | 0.0f, 438.0f, 618.0f, 402.0f, 0.0f |
| 907 | }; |
| 908 | |
| 909 | std::vector<float> expectedOutputDataNoPadding = { |
| 910 | 510.0f, 780.0f, |
| 911 | 618.0f, 582.0f |
| 912 | }; |
| 913 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 914 | armnn::TensorInfo inputTensorInfo({ batchSize, channels, inputHeight, inputWidth }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 915 | |
| 916 | // Scale and offset should match input - we're just calculating maximum values. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 917 | armnn::TensorInfo outputTensorInfo({ batchSize, channels, outputHeight, outputWidth }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 918 | |
| 919 | // Set quantization parameters if the requested type is a quantized type. |
| 920 | if(armnn::IsQuantizedType<T>()) |
| 921 | { |
| 922 | inputTensorInfo.SetQuantizationScale(qScale); |
| 923 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 924 | outputTensorInfo.SetQuantizationScale(qScale); |
| 925 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 926 | } |
| 927 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 928 | auto input = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(inputData, qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 929 | |
| 930 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 931 | forceNoPadding ? QuantizedVector<T>(expectedOutputDataNoPadding, qScale, qOffset) : |
| 932 | QuantizedVector<T>(expectedOutputDataWithPadding, qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 933 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 934 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 935 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 936 | } |
| 937 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 938 | // |
| 939 | // Tests max pooling with the following parameters: |
| 940 | // |
| 941 | // Pooling size: 3x2 |
| 942 | // Stride: (2,2) |
| 943 | // input size: 3x2 |
| 944 | // channels: 1 |
| 945 | // batch size: 1 |
| 946 | // |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 947 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 948 | LayerTestResult<T, 4> IgnorePaddingAveragePooling2dSize3x2Stride2x2TestCommon( |
| 949 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 950 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 951 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 952 | bool forceNoPadding, |
| 953 | float qScale = 1.0f, |
| 954 | int32_t qOffset = 0) |
| 955 | { |
| 956 | armnn::Pooling2dDescriptor descriptor; |
| 957 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 958 | descriptor.m_PoolWidth = 3; |
| 959 | descriptor.m_PoolHeight = 2; |
| 960 | descriptor.m_StrideX = 2; |
| 961 | descriptor.m_StrideY = 2; |
| 962 | descriptor.m_PadLeft = (forceNoPadding) ? 0 : 1; |
| 963 | descriptor.m_PadRight = descriptor.m_PadLeft; |
| 964 | descriptor.m_PadTop = 0; |
| 965 | descriptor.m_PadBottom = 0; |
| 966 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Floor; |
| 967 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 968 | |
| 969 | unsigned int inputWidth = 3; |
| 970 | unsigned int inputHeight = 2; |
| 971 | unsigned int outputWidth = |
| 972 | (inputWidth + descriptor.m_PadLeft + descriptor.m_PadRight + descriptor.m_StrideX - descriptor.m_PoolWidth) / |
| 973 | descriptor.m_StrideX; |
| 974 | unsigned int outputHeight = |
| 975 | (inputHeight + descriptor.m_PadTop + descriptor.m_PadBottom + descriptor.m_StrideY - descriptor.m_PoolHeight) / |
| 976 | descriptor.m_StrideY; |
| 977 | unsigned int channels = 1; |
| 978 | unsigned int batchSize = 1; |
| 979 | |
| 980 | std::vector<float> inputData = { |
| 981 | 3.0f, 6.0f, 9.0f, |
| 982 | 12.0f, 15.0f, 18.0f, |
| 983 | }; |
| 984 | |
| 985 | std::vector<float> expectedOutputDataWithPadding = { |
| 986 | 6.0f, 8.0f, |
| 987 | }; |
| 988 | |
| 989 | std::vector<float> expectedOutputDataNoPadding = { |
| 990 | 10.5f, |
| 991 | }; |
| 992 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 993 | armnn::TensorInfo inputTensorInfo({ batchSize, channels, inputHeight, inputWidth }, ArmnnType); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 994 | |
| 995 | // Scale and offset should match input - we're just calculating average values. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 996 | armnn::TensorInfo outputTensorInfo({ batchSize, channels, outputHeight, outputWidth }, ArmnnType); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 997 | |
| 998 | // Set quantization parameters if the requested type is a quantized type. |
| 999 | if(armnn::IsQuantizedType<T>()) |
| 1000 | { |
| 1001 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1002 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1003 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1004 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1005 | } |
| 1006 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1007 | auto input = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(inputData, qScale, qOffset)); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1008 | |
| 1009 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1010 | forceNoPadding ? QuantizedVector<T>(expectedOutputDataNoPadding, qScale, qOffset) : |
| 1011 | QuantizedVector<T>(expectedOutputDataWithPadding, qScale, qOffset)); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1012 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1013 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1014 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1018 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1019 | LayerTestResult<T, 4> IgnorePaddingSimpleMaxPooling2dTestCommon( |
| 1020 | armnn::IWorkloadFactory& workloadFactory, |
| 1021 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1022 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1023 | float qScale = 1.0f, |
| 1024 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1025 | { |
| 1026 | armnn::Pooling2dDescriptor descriptor; |
| 1027 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 1028 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 1029 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 1030 | descriptor.m_PadLeft = 1; |
| 1031 | descriptor.m_PadRight = 1; |
| 1032 | descriptor.m_PadTop = 1; |
| 1033 | descriptor.m_PadBottom = 1; |
| 1034 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1035 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1036 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1037 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1038 | |
| 1039 | // Set quantization parameters if the requested type is a quantized type. |
| 1040 | if(armnn::IsQuantizedType<T>()) |
| 1041 | { |
| 1042 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1043 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1044 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1045 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1046 | } |
| 1047 | |
| 1048 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1049 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1050 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 1051 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 1052 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 1053 | 1.0f, 2.0f, -3.0f, -4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1054 | }, |
| 1055 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1056 | |
| 1057 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1058 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1059 | -1.0f, 3.0f, 4.0f, |
| 1060 | 1.0f, 3.0f, 4.0f, |
| 1061 | 1.0f, 2.0f, -4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1062 | }, |
| 1063 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1064 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1065 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1066 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1067 | } |
| 1068 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1069 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1070 | LayerTestResult<T, 4> IgnorePaddingMaxPooling2dSize3TestCommon( |
| 1071 | armnn::IWorkloadFactory& workloadFactory, |
| 1072 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1073 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1074 | float qScale = 1.0f, |
| 1075 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1076 | { |
| 1077 | armnn::Pooling2dDescriptor descriptor; |
| 1078 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 1079 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 1080 | descriptor.m_StrideX = descriptor.m_StrideY = 1; |
| 1081 | descriptor.m_PadLeft = 1; |
| 1082 | descriptor.m_PadRight = 1; |
| 1083 | descriptor.m_PadTop = 1; |
| 1084 | descriptor.m_PadBottom = 1; |
| 1085 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1086 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1087 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1088 | armnn::TensorInfo outputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1089 | |
| 1090 | // Set quantization parameters if the requested type is a quantized type. |
| 1091 | if(armnn::IsQuantizedType<T>()) |
| 1092 | { |
| 1093 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1094 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1095 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1096 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1097 | } |
| 1098 | |
| 1099 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1100 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1101 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 1102 | -1.0f, -2.0f, 3.0f, 4.0f, |
| 1103 | 1.0f, 2.0f, -3.0f, -4.0f, |
| 1104 | 1.0f, 2.0f, -3.0f, -4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1105 | }, |
| 1106 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1107 | |
| 1108 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1109 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1110 | -1.0f, 3.0f, 4.0f, 4.0f, |
| 1111 | 2.0f, 3.0f, 4.0f, 4.0f, |
| 1112 | 2.0f, 3.0f, 4.0f, 4.0f, |
| 1113 | 2.0f, 2.0f, 2.0f, -3.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1114 | }, |
| 1115 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1116 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1117 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1118 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1121 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1122 | LayerTestResult<T, 4> IgnorePaddingSimpleAveragePooling2dTestCommon( |
| 1123 | armnn::IWorkloadFactory& workloadFactory, |
| 1124 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1125 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1126 | float qScale = 1.0f, |
| 1127 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1128 | { |
| 1129 | armnn::Pooling2dDescriptor descriptor; |
| 1130 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 1131 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 1132 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 1133 | descriptor.m_PadLeft = 1; |
| 1134 | descriptor.m_PadRight = 1; |
| 1135 | descriptor.m_PadTop = 1; |
| 1136 | descriptor.m_PadBottom = 1; |
| 1137 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1138 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1139 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1140 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1141 | |
| 1142 | // Set quantization parameters if the requested type is a quantized type. |
| 1143 | if(armnn::IsQuantizedType<T>()) |
| 1144 | { |
| 1145 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1146 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1147 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1148 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1149 | } |
| 1150 | |
| 1151 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1152 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1153 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 1154 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 1155 | 12.0f, 20.0f, 32.0f, 40.0f, |
| 1156 | 12.0f, 20.0f, 32.0f, 40.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1157 | }, |
| 1158 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1159 | |
| 1160 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1161 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1162 | 3.0f, 13.0f, 10.0f, |
| 1163 | 6.0f, 26.0f, 20.0f, |
| 1164 | 3.0f, 13.0f, 10.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1165 | }, |
| 1166 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1167 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1168 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1169 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1172 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1173 | LayerTestResult<T, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon( |
| 1174 | armnn::IWorkloadFactory& workloadFactory, |
| 1175 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1176 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1177 | float qScale = 1.0f, |
| 1178 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1179 | { |
| 1180 | armnn::Pooling2dDescriptor descriptor; |
| 1181 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 1182 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 1183 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 1184 | descriptor.m_PadLeft = 0; |
| 1185 | descriptor.m_PadRight = 0; |
| 1186 | descriptor.m_PadTop = 0; |
| 1187 | descriptor.m_PadBottom = 0; |
| 1188 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1189 | descriptor.m_OutputShapeRounding = armnn::OutputShapeRounding::Ceiling; |
| 1190 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1191 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4}, ArmnnType); |
| 1192 | armnn::TensorInfo outputTensorInfo({ 1, 1, 2, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1193 | |
| 1194 | // Set quantization parameters if the requested type is a quantized type. |
| 1195 | if(armnn::IsQuantizedType<T>()) |
| 1196 | { |
| 1197 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1198 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1199 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1200 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1201 | } |
| 1202 | |
| 1203 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1204 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1205 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1206 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1207 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1208 | 1.0f, 2.0f, 3.0f, 4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1209 | }, |
| 1210 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1211 | |
| 1212 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1213 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1214 | 2.0f, 3.5f, |
| 1215 | 2.0f, 3.5f |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1216 | }, |
| 1217 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1218 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1219 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1220 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1223 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1224 | LayerTestResult<T, 4> IgnorePaddingAveragePooling2dSize3TestCommon( |
| 1225 | armnn::IWorkloadFactory& workloadFactory, |
| 1226 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1227 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1228 | float qScale = 1.0f, |
| 1229 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1230 | { |
| 1231 | armnn::Pooling2dDescriptor descriptor; |
| 1232 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Average; |
| 1233 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 1234 | descriptor.m_StrideX = descriptor.m_StrideY = 1; |
| 1235 | descriptor.m_PadLeft = 1; |
| 1236 | descriptor.m_PadRight = 1; |
| 1237 | descriptor.m_PadTop = 1; |
| 1238 | descriptor.m_PadBottom = 1; |
| 1239 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1240 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1241 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1242 | armnn::TensorInfo outputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1243 | |
| 1244 | // Set quantization parameters if the requested type is a quantized type. |
| 1245 | if(armnn::IsQuantizedType<T>()) |
| 1246 | { |
| 1247 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1248 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1249 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1250 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1251 | } |
| 1252 | |
| 1253 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1254 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1255 | 9.0f, 27.0f, 18.0f, 36.0f, |
| 1256 | 18.0f, 9.0f, 18.0f, 9.0f, |
| 1257 | 27.0f, 18.0f, 9.0f, 27.0f, |
| 1258 | 9.0f, 27.0f, 9.0f, 18.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1259 | }, |
| 1260 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1261 | |
| 1262 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1263 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1264 | 7.0f, 11.0f, 13.0f, 9.0f, |
| 1265 | 12.0f, 17.0f, 19.0f, 13.0f, |
| 1266 | 12.0f, 16.0f, 16.0f, 10.0f, |
| 1267 | 9.0f, 11.0f, 12.0f, 7.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1268 | }, |
| 1269 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1270 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1271 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1272 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1273 | } |
| 1274 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1275 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1276 | LayerTestResult<T, 4> IgnorePaddingSimpleL2Pooling2dTestCommon( |
| 1277 | armnn::IWorkloadFactory& workloadFactory, |
| 1278 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1279 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1280 | float qScale = 1.0f, |
| 1281 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1282 | { |
| 1283 | armnn::Pooling2dDescriptor descriptor; |
| 1284 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 1285 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 2; |
| 1286 | descriptor.m_StrideX = descriptor.m_StrideY = 2; |
| 1287 | descriptor.m_PadLeft = 1; |
| 1288 | descriptor.m_PadRight = 1; |
| 1289 | descriptor.m_PadTop = 1; |
| 1290 | descriptor.m_PadBottom = 1; |
| 1291 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1292 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1293 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1294 | armnn::TensorInfo outputTensorInfo({ 1, 1, 3, 3 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1295 | |
| 1296 | // Set quantization parameters if the requested type is a quantized type. |
| 1297 | if(armnn::IsQuantizedType<T>()) |
| 1298 | { |
| 1299 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1300 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1301 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1302 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1303 | } |
| 1304 | |
| 1305 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1306 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1307 | 2.0f, 4.0f, 8.0f, 16.0f, |
| 1308 | 4.0f, 2.0f, 2.0f, 4.0f, |
| 1309 | 8.0f, 2.0f, 4.0f, 2.0f, |
| 1310 | 16.0f, 2.0f, 2.0f, 8.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1311 | }, |
| 1312 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1313 | |
| 1314 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1315 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1316 | 1.0f, 4.4721f, 8.0f, |
| 1317 | 4.4721f, 2.6457f, 2.236f, |
| 1318 | 8.0f, 1.4142f, 4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1319 | }, |
| 1320 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1321 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1322 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1323 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1324 | } |
| 1325 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1326 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1327 | LayerTestResult<T, 4> IgnorePaddingL2Pooling2dSize3TestCommon( |
| 1328 | armnn::IWorkloadFactory& workloadFactory, |
| 1329 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1330 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1331 | float qScale = 1.0f, |
| 1332 | int32_t qOffset = 0) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1333 | { |
| 1334 | armnn::Pooling2dDescriptor descriptor; |
| 1335 | descriptor.m_PoolType = armnn::PoolingAlgorithm::L2; |
| 1336 | descriptor.m_PoolWidth = descriptor.m_PoolHeight = 3; |
| 1337 | descriptor.m_StrideX = descriptor.m_StrideY = 1; |
| 1338 | descriptor.m_PadLeft = 1; |
| 1339 | descriptor.m_PadRight = 1; |
| 1340 | descriptor.m_PadTop = 1; |
| 1341 | descriptor.m_PadBottom = 1; |
| 1342 | descriptor.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; |
| 1343 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1344 | armnn::TensorInfo inputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
| 1345 | armnn::TensorInfo outputTensorInfo({ 1, 1, 4, 4 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1346 | |
| 1347 | // Set quantization parameters if the requested type is a quantized type. |
| 1348 | if(armnn::IsQuantizedType<T>()) |
| 1349 | { |
| 1350 | inputTensorInfo.SetQuantizationScale(qScale); |
| 1351 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 1352 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1353 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1354 | } |
| 1355 | |
| 1356 | auto input = MakeTensor<T, 4>(inputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1357 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1358 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1359 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1360 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 1361 | 1.0f, 2.0f, 3.0f, 4.0f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1362 | }, |
| 1363 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1364 | |
| 1365 | auto outputExpected = MakeTensor<T, 4>(outputTensorInfo, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1366 | QuantizedVector<T>({ |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1367 | 1.0540f, 1.7638f, 2.5385f, 2.3570f, |
| 1368 | 1.2909f, 2.1602f, 3.1091f, 2.8867f, |
| 1369 | 1.2909f, 2.1602f, 3.1091f, 2.8867f, |
| 1370 | 1.0540f, 1.7638f, 2.5385f, 2.3570f, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1371 | }, |
| 1372 | qScale, qOffset)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1373 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1374 | return SimplePooling2dTestImpl<ArmnnType>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1375 | workloadFactory, memoryManager, tensorHandleFactory, descriptor, qScale, qOffset, input, outputExpected); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1376 | } |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1377 | |
| 1378 | } // anonymous namespace |
| 1379 | |
| 1380 | LayerTestResult<float, 4> SimpleMaxPooling2dSize2x2Stride2x2Test( |
| 1381 | armnn::IWorkloadFactory& workloadFactory, |
| 1382 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1383 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1384 | bool forceNoPadding) |
| 1385 | { |
| 1386 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<armnn::DataType::Float32>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1387 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize2x2Stride2x2Uint8Test( |
| 1391 | armnn::IWorkloadFactory& workloadFactory, |
| 1392 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1393 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1394 | bool forceNoPadding) |
| 1395 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1396 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1397 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding, 3.0f, -5); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | LayerTestResult<int16_t, 4> SimpleMaxPooling2dSize2x2Stride2x2Int16Test( |
| 1401 | armnn::IWorkloadFactory& workloadFactory, |
| 1402 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1403 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1404 | bool forceNoPadding) |
| 1405 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1406 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1407 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | LayerTestResult<float, 4> SimpleMaxPooling2dSize3x3Stride2x4Test( |
| 1411 | armnn::IWorkloadFactory& workloadFactory, |
| 1412 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1413 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1414 | bool forceNoPadding) |
| 1415 | { |
| 1416 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<armnn::DataType::Float32>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1417 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1418 | } |
| 1419 | |
| 1420 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize3x3Stride2x4Uint8Test( |
| 1421 | armnn::IWorkloadFactory& workloadFactory, |
| 1422 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1423 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1424 | bool forceNoPadding) |
| 1425 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1426 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1427 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding, 0.1f, 128); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | LayerTestResult<int16_t, 4> SimpleMaxPooling2dSize3x3Stride2x4Int16Test( |
| 1431 | armnn::IWorkloadFactory& workloadFactory, |
| 1432 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1433 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1434 | bool forceNoPadding) |
| 1435 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1436 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1437 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | LayerTestResult<float, 4> SimpleMaxPooling2dTest( |
| 1441 | armnn::IWorkloadFactory& workloadFactory, |
| 1442 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1443 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1444 | const armnn::DataLayout dataLayout) |
| 1445 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1446 | return SimpleMaxPooling2dTestCommon<armnn::DataType::Float32>( |
| 1447 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dUint8Test( |
| 1451 | armnn::IWorkloadFactory& workloadFactory, |
| 1452 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1453 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1454 | const armnn::DataLayout dataLayout) |
| 1455 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1456 | return SimpleMaxPooling2dTestCommon<armnn::DataType::QAsymmU8>( |
| 1457 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | LayerTestResult<int16_t, 4> SimpleMaxPooling2dInt16Test( |
| 1461 | armnn::IWorkloadFactory& workloadFactory, |
| 1462 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1463 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1464 | const armnn::DataLayout dataLayout) |
| 1465 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1466 | return SimpleMaxPooling2dTestCommon<armnn::DataType::QSymmS16>( |
| 1467 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1468 | } |
| 1469 | LayerTestResult<float, 4> IgnorePaddingSimpleMaxPooling2dTest( |
| 1470 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1471 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1472 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1473 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1474 | return IgnorePaddingSimpleMaxPooling2dTestCommon<armnn::DataType::Float32>( |
| 1475 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleMaxPooling2dUint8Test( |
| 1479 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1480 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1481 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1482 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1483 | return IgnorePaddingSimpleMaxPooling2dTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1484 | workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -5); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1485 | } |
| 1486 | |
| 1487 | LayerTestResult<int16_t, 4> IgnorePaddingSimpleMaxPooling2dInt16Test( |
| 1488 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1489 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1490 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1491 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1492 | return IgnorePaddingSimpleMaxPooling2dTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1493 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | LayerTestResult<float, 4> IgnorePaddingMaxPooling2dSize3Test( |
| 1497 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1498 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1499 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1500 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1501 | return IgnorePaddingMaxPooling2dSize3TestCommon<armnn::DataType::Float32>( |
| 1502 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | LayerTestResult<uint8_t, 4> IgnorePaddingMaxPooling2dSize3Uint8Test( |
| 1506 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1507 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1508 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1509 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1510 | return IgnorePaddingMaxPooling2dSize3TestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1511 | workloadFactory, memoryManager, tensorHandleFactory, 1.0f, -5); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1512 | } |
| 1513 | |
| 1514 | LayerTestResult<int16_t, 4> IgnorePaddingMaxPooling2dSize3Int16Test( |
| 1515 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1516 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1517 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1518 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1519 | return IgnorePaddingMaxPooling2dSize3TestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1520 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | LayerTestResult<float, 4> SimpleAveragePooling2dTest( |
| 1524 | armnn::IWorkloadFactory& workloadFactory, |
| 1525 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1526 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1527 | const armnn::DataLayout dataLayout) |
| 1528 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1529 | return SimpleAveragePooling2dTestCommon<armnn::DataType::Float32>( |
| 1530 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1531 | } |
| 1532 | |
| 1533 | LayerTestResult<uint8_t, 4> SimpleAveragePooling2dUint8Test( |
| 1534 | armnn::IWorkloadFactory& workloadFactory, |
| 1535 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1536 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1537 | const armnn::DataLayout dataLayout) |
| 1538 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1539 | return SimpleAveragePooling2dTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1540 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout, 0.5, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | LayerTestResult<int16_t, 4> SimpleAveragePooling2dInt16Test( |
| 1544 | armnn::IWorkloadFactory& workloadFactory, |
| 1545 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1546 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1547 | const armnn::DataLayout dataLayout) |
| 1548 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1549 | return SimpleAveragePooling2dTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1550 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3x2Stride2x2Test( |
| 1554 | armnn::IWorkloadFactory& workloadFactory, |
| 1555 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1556 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1557 | bool forceNoPadding) |
| 1558 | { |
| 1559 | return IgnorePaddingAveragePooling2dSize3x2Stride2x2TestCommon<armnn::DataType::Float32>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1560 | workloadFactory, memoryManager, tensorHandleFactory, forceNoPadding); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1561 | } |
| 1562 | |
| 1563 | LayerTestResult<float, 4> LargeTensorsAveragePooling2dTest( |
| 1564 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1565 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1566 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1567 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1568 | return LargeTensorsAveragePooling2dTestCommon<armnn::DataType::Float32>( |
| 1569 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | LayerTestResult<uint8_t, 4> LargeTensorsAveragePooling2dUint8Test( |
| 1573 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1574 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1575 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1576 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1577 | return LargeTensorsAveragePooling2dTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1578 | workloadFactory, memoryManager, tensorHandleFactory, 0.5, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | LayerTestResult<int16_t, 4> LargeTensorsAveragePooling2dInt16Test( |
| 1582 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1583 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1584 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1585 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1586 | return LargeTensorsAveragePooling2dTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1587 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1588 | } |
| 1589 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dTest( |
| 1590 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1591 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1592 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1593 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1594 | return IgnorePaddingSimpleAveragePooling2dTestCommon<armnn::DataType::Float32>( |
| 1595 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1596 | } |
| 1597 | |
| 1598 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dUint8Test( |
| 1599 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1600 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1601 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1602 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1603 | return IgnorePaddingSimpleAveragePooling2dTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1604 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | LayerTestResult<int16_t, 4> IgnorePaddingSimpleAveragePooling2dInt16Test( |
| 1608 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1609 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1610 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1611 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1612 | return IgnorePaddingSimpleAveragePooling2dTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1613 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingTest( |
| 1617 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1618 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1619 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1620 | { |
| 1621 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<armnn::DataType::Float32>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1622 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test( |
| 1626 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1627 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1628 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1629 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1630 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1631 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1632 | } |
| 1633 | |
| 1634 | LayerTestResult<int16_t, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingInt16Test( |
| 1635 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1636 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1637 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1638 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1639 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1640 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3Test( |
| 1644 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1645 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1646 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1647 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1648 | return IgnorePaddingAveragePooling2dSize3TestCommon<armnn::DataType::Float32>( |
| 1649 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | LayerTestResult<uint8_t, 4> IgnorePaddingAveragePooling2dSize3Uint8Test( |
| 1653 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1654 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1655 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1656 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1657 | return IgnorePaddingAveragePooling2dSize3TestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1658 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | LayerTestResult<int16_t, 4> IgnorePaddingAveragePooling2dSize3Int16Test( |
| 1662 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1663 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1664 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1665 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1666 | return IgnorePaddingAveragePooling2dSize3TestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1667 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | LayerTestResult<float, 4> SimpleL2Pooling2dTest( |
| 1671 | armnn::IWorkloadFactory& workloadFactory, |
| 1672 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1673 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1674 | const armnn::DataLayout dataLayout) |
| 1675 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1676 | return SimpleL2Pooling2dTestCommon<armnn::DataType::Float32>( |
| 1677 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1678 | } |
| 1679 | |
| 1680 | LayerTestResult<uint8_t, 4> SimpleL2Pooling2dUint8Test( |
| 1681 | armnn::IWorkloadFactory& workloadFactory, |
| 1682 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1683 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1684 | const armnn::DataLayout dataLayout) |
| 1685 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1686 | return SimpleL2Pooling2dTestCommon<armnn::DataType::QAsymmU8>( |
| 1687 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | LayerTestResult<int16_t, 4> SimpleL2Pooling2dInt16Test( |
| 1691 | armnn::IWorkloadFactory& workloadFactory, |
| 1692 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1693 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1694 | const armnn::DataLayout dataLayout) |
| 1695 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1696 | return SimpleL2Pooling2dTestCommon<armnn::DataType::QSymmS16>( |
| 1697 | workloadFactory, memoryManager, tensorHandleFactory, dataLayout); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1698 | } |
| 1699 | |
| 1700 | LayerTestResult<float, 4> L2Pooling2dSize3Stride1Test( |
| 1701 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1702 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1703 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1704 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1705 | return L2Pooling2dSize3Stride1TestCommon<armnn::DataType::Float32>( |
| 1706 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride1Uint8Test( |
| 1710 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1711 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1712 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1713 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1714 | return L2Pooling2dSize3Stride1TestCommon<armnn::DataType::QAsymmU8>( |
| 1715 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1716 | } |
| 1717 | |
| 1718 | LayerTestResult<int16_t, 4> L2Pooling2dSize3Stride1Int16Test( |
| 1719 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1720 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1721 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1722 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1723 | return L2Pooling2dSize3Stride1TestCommon<armnn::DataType::QSymmS16>( |
| 1724 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | LayerTestResult<float, 4> L2Pooling2dSize3Stride3Test( |
| 1728 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1729 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1730 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1731 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1732 | return L2Pooling2dSize3Stride3TestCommon<armnn::DataType::Float32>( |
| 1733 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1734 | } |
| 1735 | |
| 1736 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride3Uint8Test( |
| 1737 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1738 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1739 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1740 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1741 | return L2Pooling2dSize3Stride3TestCommon<armnn::DataType::QAsymmU8>( |
| 1742 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1743 | } |
| 1744 | |
| 1745 | LayerTestResult<int16_t, 4> L2Pooling2dSize3Stride3Int16Test( |
| 1746 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1747 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1748 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1749 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1750 | return L2Pooling2dSize3Stride3TestCommon<armnn::DataType::QSymmS16>( |
| 1751 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1752 | } |
| 1753 | LayerTestResult<float, 4> L2Pooling2dSize3Stride4Test( |
| 1754 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1755 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1756 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1757 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1758 | return L2Pooling2dSize3Stride4TestCommon<armnn::DataType::Float32>( |
| 1759 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride4Uint8Test( |
| 1763 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1764 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1765 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1766 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1767 | return L2Pooling2dSize3Stride4TestCommon<armnn::DataType::QAsymmU8>( |
| 1768 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1769 | } |
| 1770 | |
| 1771 | LayerTestResult<int16_t, 4> L2Pooling2dSize3Stride4Int16Test( |
| 1772 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1773 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1774 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1775 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1776 | return L2Pooling2dSize3Stride4TestCommon<armnn::DataType::QSymmS16>( |
| 1777 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | LayerTestResult<float, 4> L2Pooling2dSize7Test( |
| 1781 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1782 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1783 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1784 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1785 | return L2Pooling2dSize7TestCommon<armnn::DataType::Float32>( |
| 1786 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1787 | } |
| 1788 | |
| 1789 | LayerTestResult<uint8_t, 4> L2Pooling2dSize7Uint8Test( |
| 1790 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1791 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1792 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1793 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1794 | return L2Pooling2dSize7TestCommon<armnn::DataType::QAsymmU8>( |
| 1795 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1796 | } |
| 1797 | |
| 1798 | LayerTestResult<int16_t, 4> L2Pooling2dSize7Int16Test( |
| 1799 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1800 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1801 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1802 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1803 | return L2Pooling2dSize7TestCommon<armnn::DataType::QSymmS16>( |
| 1804 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1805 | } |
| 1806 | |
| 1807 | LayerTestResult<float, 4> L2Pooling2dSize9Test( |
| 1808 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1809 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1810 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1811 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1812 | return L2Pooling2dSize9TestCommon<armnn::DataType::Float32>( |
| 1813 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | LayerTestResult<uint8_t, 4> L2Pooling2dSize9Uint8Test( |
| 1817 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1818 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1819 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1820 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1821 | return L2Pooling2dSize9TestCommon<armnn::DataType::QAsymmU8>( |
| 1822 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1823 | } |
| 1824 | |
| 1825 | LayerTestResult<int16_t, 4> L2Pooling2dSize9Int16Test( |
| 1826 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1827 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1828 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1829 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1830 | return L2Pooling2dSize9TestCommon<armnn::DataType::QSymmS16>( |
| 1831 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1832 | } |
| 1833 | LayerTestResult<float, 4> IgnorePaddingSimpleL2Pooling2dTest( |
| 1834 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1835 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1836 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1837 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1838 | return IgnorePaddingSimpleL2Pooling2dTestCommon<armnn::DataType::Float32>( |
| 1839 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1840 | } |
| 1841 | |
| 1842 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleL2Pooling2dUint8Test( |
| 1843 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1844 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1845 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1846 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1847 | return IgnorePaddingSimpleL2Pooling2dTestCommon<armnn::DataType::QAsymmU8>( |
| 1848 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | LayerTestResult<int16_t, 4> IgnorePaddingSimpleL2Pooling2dInt16Test( |
| 1852 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1853 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1854 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1855 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1856 | return IgnorePaddingSimpleL2Pooling2dTestCommon<armnn::DataType::QSymmS16>( |
| 1857 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1858 | } |
| 1859 | |
| 1860 | LayerTestResult<float, 4> IgnorePaddingL2Pooling2dSize3Test( |
| 1861 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1862 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1863 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1864 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1865 | return IgnorePaddingL2Pooling2dSize3TestCommon<armnn::DataType::Float32>( |
| 1866 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1867 | } |
| 1868 | |
| 1869 | LayerTestResult<uint8_t, 4> IgnorePaddingL2Pooling2dSize3Uint8Test( |
| 1870 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1871 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1872 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1873 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1874 | return IgnorePaddingL2Pooling2dSize3TestCommon<armnn::DataType::QAsymmU8>( |
| 1875 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1876 | } |
| 1877 | |
| 1878 | LayerTestResult<int16_t, 4> IgnorePaddingL2Pooling2dSize3Int16Test( |
| 1879 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1880 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1881 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1882 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1883 | return IgnorePaddingL2Pooling2dSize3TestCommon<armnn::DataType::QSymmS16>( |
| 1884 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1885 | } |
| 1886 | |
| 1887 | LayerTestResult<float, 4> AsymmetricNonSquarePooling2dTest( |
| 1888 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1889 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1890 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1891 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1892 | return AsymmetricNonSquarePooling2dTestCommon<armnn::DataType::Float32>( |
| 1893 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1894 | } |
| 1895 | |
| 1896 | LayerTestResult<uint8_t, 4> AsymmetricNonSquarePooling2dUint8Test( |
| 1897 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1898 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1899 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1900 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1901 | return AsymmetricNonSquarePooling2dTestCommon<armnn::DataType::QAsymmU8>( |
| 1902 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1903 | } |
| 1904 | |
| 1905 | LayerTestResult<int16_t, 4> AsymmetricNonSquarePooling2dInt16Test( |
| 1906 | armnn::IWorkloadFactory& workloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1907 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1908 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1909 | { |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1910 | return AsymmetricNonSquarePooling2dTestCommon<armnn::DataType::QSymmS16>( |
| 1911 | workloadFactory, memoryManager, tensorHandleFactory); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1912 | } |
| 1913 | |
| 1914 | LayerTestResult<float, 4> ComparePooling2dTest( |
| 1915 | armnn::IWorkloadFactory& workloadFactory, |
| 1916 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1917 | armnn::IWorkloadFactory& refWorkloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1918 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1919 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1920 | armnn::PoolingAlgorithm poolingType) |
| 1921 | { |
| 1922 | return ComparePooling2dTestCommon<armnn::DataType::Float32>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1923 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, poolingType); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1924 | } |
| 1925 | |
| 1926 | LayerTestResult<uint8_t, 4> ComparePooling2dUint8Test( |
| 1927 | armnn::IWorkloadFactory& workloadFactory, |
| 1928 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1929 | armnn::IWorkloadFactory& refWorkloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1930 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1931 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1932 | armnn::PoolingAlgorithm poolingType) |
| 1933 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1934 | return ComparePooling2dTestCommon<armnn::DataType::QAsymmU8>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1935 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, |
| 1936 | poolingType, 0.1f, 128); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1937 | } |
| 1938 | |
| 1939 | LayerTestResult<int16_t, 4> ComparePooling2dInt16Test( |
| 1940 | armnn::IWorkloadFactory& workloadFactory, |
| 1941 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1942 | armnn::IWorkloadFactory& refWorkloadFactory, |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1943 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
| 1944 | const armnn::ITensorHandleFactory& refTensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1945 | armnn::PoolingAlgorithm poolingType) |
| 1946 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1947 | return ComparePooling2dTestCommon<armnn::DataType::QSymmS16>( |
Finn Williams | 826a543 | 2020-08-27 16:15:20 +0100 | [diff] [blame] | 1948 | workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, poolingType); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1949 | } |