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