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 | // |
| 5 | #include "LayerTests.hpp" |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6 | #include "WorkloadTestUtils.hpp" |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 7 | #include "TensorUtils.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
| 9 | #include "test/TensorHelpers.hpp" |
| 10 | #include "TensorCopyUtils.hpp" |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 11 | #include "Permute.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | #include <boost/test/unit_test.hpp> |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 14 | #include <boost/assert.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame] | 16 | #include <armnn/LayerSupport.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 18 | #include <backendsCommon/CpuTensorHandle.hpp> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 19 | #include <backendsCommon/IBackendInternal.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 20 | #include <backendsCommon/WorkloadFactory.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 21 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 22 | #include <reference/workloads/RefWorkloads.hpp> |
| 23 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | #include <algorithm> |
| 25 | #include <boost/cast.hpp> |
| 26 | |
| 27 | #include "WorkloadTestUtils.hpp" |
| 28 | #include "Conv2dTestImpl.hpp" |
| 29 | #include "BatchNormTestImpl.hpp" |
| 30 | #include "ActivationTestImpl.hpp" |
| 31 | #include "Pooling2dTestImpl.hpp" |
| 32 | #include "ReshapeTestImpl.hpp" |
| 33 | #include "FullyConnectedTestImpl.hpp" |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 34 | #include "SpaceToBatchNdTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 35 | #include "SplitterTestImpl.hpp" |
| 36 | #include "SoftmaxTestImpl.hpp" |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 37 | #include "StridedSliceTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 38 | #include "NormTestImpl.hpp" |
| 39 | #include "PermuteTestImpl.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | #include "LstmTestImpl.hpp" |
| 41 | #include "ConvertFp16ToFp32TestImpl.hpp" |
| 42 | #include "ConvertFp32ToFp16TestImpl.hpp" |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 43 | #include "DebugTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 45 | // 3-channel 16x8 image used as common input data for a number of Conv2d tests. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 46 | static std::vector<float> ConvInput3x8x16({ |
| 47 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 48 | 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
| 49 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 50 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 51 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 52 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 53 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 54 | 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, |
| 55 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 56 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 57 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 58 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 59 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 60 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 61 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 62 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 63 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 64 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 65 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 66 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 67 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 68 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 69 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 70 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 71 | }); |
| 72 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 73 | // 2-channel bias used by a number of Conv2d tests. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 74 | static std::vector<float> Bias2({0, 2}); |
| 75 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 76 | // Helper function that returns either Bias2 or an empty vector depending on whether bias is enabled. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 77 | template<typename T> |
| 78 | boost::multi_array<T, 1> GetBias2(bool biasEnabled, float qScale, int32_t qOffset) |
| 79 | { |
| 80 | if(biasEnabled) |
| 81 | { |
| 82 | armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias2.size())}, armnn::GetDataType<T>()); |
| 83 | boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(qScale, qOffset, Bias2)); |
| 84 | return bias; |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | return boost::multi_array<T, 1>(); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 93 | LayerTestResult<T, 4> SimpleConvolution2d3x5TestCommon( |
| 94 | armnn::IWorkloadFactory& workloadFactory, |
| 95 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 96 | float qScale, |
| 97 | int32_t qOffset, |
| 98 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 99 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 100 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 101 | // Use common single-batch 3-channel 16x8 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 102 | armnn::TensorInfo inputDesc({1, 3, 8, 16}, armnn::GetDataType<T>()); |
| 103 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16)); |
| 104 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 105 | // Use a 2-element batch with 3-channel 3x5 kernels. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 106 | armnn::TensorInfo kernelDesc({2, 3, 5, 3}, armnn::GetDataType<T>()); |
| 107 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 108 | QuantizedVector<T>(qScale, qOffset, { |
| 109 | 1, 1, 1, |
| 110 | 1, -1, 1, |
| 111 | 1, 1, 1, |
| 112 | 1, 1, 1, |
| 113 | 1, 1, 1, |
| 114 | |
| 115 | 0, 0, 0, |
| 116 | 0, 0, 0, |
| 117 | 0, 0, 0, |
| 118 | 0, 0, 0, |
| 119 | 0, 0, 0, |
| 120 | |
| 121 | 2, 2, 2, |
| 122 | 2, 2, 2, |
| 123 | 2, 2, 2, |
| 124 | 2, 2, 2, |
| 125 | 2, 2, 2, |
| 126 | |
| 127 | |
| 128 | 0, 0, 0, |
| 129 | 0, 0, 0, |
| 130 | 0, 0, 0, |
| 131 | 0, 0, 0, |
| 132 | 0, 0, 0, |
| 133 | |
| 134 | 1, 1, 1, |
| 135 | 1, 1, 1, |
| 136 | 1, 1, 1, |
| 137 | 1, 1, 1, |
| 138 | 1, 1, 1, |
| 139 | |
| 140 | 0, 0, 0, |
| 141 | 0, 0, 0, |
| 142 | 0, 0, 0, |
| 143 | 0, 0, 0, |
| 144 | 0, 0, 0 |
| 145 | }))); |
| 146 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 147 | // Expected output is 2 batch elements of a 1-channel 14x4 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 148 | armnn::TensorInfo outputDesc({1, 2, 4, 14}, armnn::GetDataType<T>()); |
| 149 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 150 | QuantizedVector<T>(qScale, qOffset, { |
| 151 | -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, |
| 152 | -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, |
| 153 | -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, |
| 154 | -23.5f, -23.5f, -23.5f, |
| 155 | -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, |
| 156 | -23.5f, -23.5f, -23.5f, |
| 157 | |
| 158 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 159 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 160 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 161 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 162 | }))); |
| 163 | |
| 164 | return SimpleConvolution2dTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 165 | memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 166 | input, |
| 167 | kernel, |
| 168 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset), |
| 169 | expectedOutput, |
| 170 | qScale, |
jimfly01 | 0a088a6 | 2018-10-25 17:05:05 +0100 | [diff] [blame] | 171 | qOffset, |
| 172 | layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 176 | LayerTestResult<T, 4> SimpleConvolution2d3x3TestCommon( |
| 177 | armnn::IWorkloadFactory& workloadFactory, |
| 178 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 179 | float qScale, |
| 180 | int32_t qOffset, |
| 181 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 182 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 183 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 184 | // Use a 3x3 kernel, which exercises ArmCompute's direct convolution path. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 185 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 186 | // Use common single-batch 3-channel 16x8 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 187 | armnn::TensorInfo inputDesc({1, 3, 8, 16}, armnn::GetDataType<T>()); |
| 188 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16)); |
| 189 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 190 | // Use a 2-element batch of 3-channel 3x3 kernels. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 191 | armnn::TensorInfo kernelDesc({2, 3, 3, 3}, armnn::GetDataType<T>()); |
| 192 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 193 | QuantizedVector<T>(qScale, qOffset, { |
| 194 | 1, 1, 1, |
| 195 | 1, -1, 1, |
| 196 | 1, 1, 1, |
| 197 | |
| 198 | 0, 0, 0, |
| 199 | 0, 0, 0, |
| 200 | 0, 0, 0, |
| 201 | |
| 202 | 2, 2, 2, |
| 203 | 2, 2, 2, |
| 204 | 2, 2, 2, |
| 205 | |
| 206 | |
| 207 | 0, 0, 0, |
| 208 | 0, 0, 0, |
| 209 | 0, 0, 0, |
| 210 | |
| 211 | 1, 1, 1, |
| 212 | 1, 1, 1, |
| 213 | 1, 1, 1, |
| 214 | |
| 215 | 0, 0, 0, |
| 216 | 0, 0, 0, |
| 217 | 0, 0, 0 |
| 218 | }))); |
| 219 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 220 | // Expected output is 1 batch of a 2-channel 14x6 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 221 | armnn::TensorInfo outputDesc({1, 2, 6, 14}, armnn::GetDataType<T>()); |
| 222 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 223 | QuantizedVector<T>(qScale, qOffset, { |
| 224 | -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, |
| 225 | -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, |
| 226 | -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f, |
| 227 | -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f, |
| 228 | -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f, |
| 229 | -14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f,-14.5f, |
| 230 | |
| 231 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 232 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 233 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 234 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 235 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 236 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 237 | }))); |
| 238 | |
| 239 | return SimpleConvolution2dTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 240 | memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 241 | input, |
| 242 | kernel, |
| 243 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset), |
| 244 | expectedOutput, |
| 245 | qScale, |
narpra01 | 5f70318 | 2018-10-26 16:24:58 +0100 | [diff] [blame] | 246 | qOffset, |
| 247 | layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 248 | } |
| 249 | |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 250 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 251 | LayerTestResult<T, 4> SimpleConvolution2d3x3NhwcTestCommon( |
| 252 | armnn::IWorkloadFactory& workloadFactory, |
| 253 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 254 | float qScale, |
| 255 | int32_t qOffset, |
| 256 | bool biasEnabled, |
| 257 | armnn::DataLayout dataLayout) |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 258 | { |
| 259 | // Use common single-batch 5x5 image. |
| 260 | |
| 261 | armnn::TensorInfo inputDesc({1, 3, 4, 1}, armnn::GetDataType<T>()); |
| 262 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, |
| 263 | { |
| 264 | 1, 5, 2, 3, |
| 265 | 8, 7, 3, 6, |
| 266 | 3, 3, 9, 1 |
| 267 | }); |
| 268 | |
| 269 | |
| 270 | // Use a 2-element batch of 3-channel 3x3 kernels. |
| 271 | armnn::TensorInfo kernelDesc({1, 3, 3, 1}, armnn::GetDataType<T>()); |
| 272 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, { |
| 273 | 4, 5, 6, |
| 274 | 0, 0, 0, |
| 275 | 3, 2, 1 |
| 276 | }); |
| 277 | |
| 278 | // Expected output is 1 batch of a 5x5 image. |
| 279 | armnn::TensorInfo outputDesc({1, 3, 4, 1}, armnn::GetDataType<T>()); |
| 280 | |
| 281 | const std::vector<float> outputData = |
| 282 | { |
| 283 | 23, 41, 33, 21, |
| 284 | 44, 65, 76, 52, |
| 285 | 82, 85, 79, 42 |
| 286 | }; |
| 287 | |
| 288 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData); |
| 289 | |
| 290 | return SimpleConvolution2dNhwcTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 291 | memoryManager, |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 292 | input, |
| 293 | kernel, |
| 294 | boost::multi_array<T, 1>(), |
| 295 | expectedOutput, |
| 296 | dataLayout, |
| 297 | qScale, |
| 298 | qOffset); |
| 299 | } |
| 300 | |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame^] | 301 | template<typename T> |
| 302 | LayerTestResult<T, 4> SimpleConvolution2d3x3Stride2x2TestCommon( |
| 303 | armnn::IWorkloadFactory& workloadFactory, |
| 304 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 305 | float qScale, |
| 306 | int32_t qOffset, |
| 307 | bool biasEnabled, |
| 308 | const armnn::DataLayout& dataLayout) |
| 309 | { |
| 310 | // Input is a single-batch, 1 channel, 5x5 image. |
| 311 | armnn::TensorInfo inputDesc({1, 5, 5, 1}, armnn::GetDataType<T>()); |
| 312 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, |
| 313 | { |
| 314 | 1, 5, 2, 3, 5, |
| 315 | 8, 7, 3, 6, 3, |
| 316 | 3, 3, 9, 1, 9, |
| 317 | 4, 1, 8, 1, 3, |
| 318 | 6, 8, 1, 9, 2 |
| 319 | }); |
| 320 | |
| 321 | // Use a 3x3 kernel. |
| 322 | armnn::TensorInfo kernelDesc({1, 3, 3, 1}, armnn::GetDataType<T>()); |
| 323 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, |
| 324 | { |
| 325 | 4, 5, 6, |
| 326 | 0, 0, 0, |
| 327 | 3, 2, 1 |
| 328 | }); |
| 329 | |
| 330 | // Expected output is a single-batch, 1 channel, 3x3 image. |
| 331 | armnn::TensorInfo outputDesc({1, 3, 3, 1}, armnn::GetDataType<T>()); |
| 332 | |
| 333 | const std::vector<T> outputData = |
| 334 | { |
| 335 | 23, 33, 24, |
| 336 | 91, 99, 48, |
| 337 | 26, 50, 19 |
| 338 | }; |
| 339 | |
| 340 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData); |
| 341 | |
| 342 | uint32_t padLeft = 1; |
| 343 | uint32_t padTop = 1; |
| 344 | uint32_t padRight = 1; |
| 345 | uint32_t padBottom = 1; |
| 346 | uint32_t strideX = 2; |
| 347 | uint32_t strideY = 2; |
| 348 | |
| 349 | return SimpleConvolution2dNhwcTestImpl<T>(workloadFactory, |
| 350 | memoryManager, |
| 351 | input, |
| 352 | kernel, |
| 353 | boost::multi_array<T, 1>(), |
| 354 | expectedOutput, |
| 355 | dataLayout, |
| 356 | qScale, |
| 357 | qOffset, |
| 358 | padLeft, |
| 359 | padTop, |
| 360 | padRight, |
| 361 | padBottom, |
| 362 | strideX, |
| 363 | strideY); |
| 364 | } |
| 365 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 366 | LayerTestResult<float, 4> SimpleConvolution2d3x5Test( |
| 367 | armnn::IWorkloadFactory& workloadFactory, |
| 368 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 369 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 370 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 371 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 372 | return SimpleConvolution2d3x5TestCommon<float>(workloadFactory, memoryManager, 0.f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 375 | LayerTestResult<uint8_t, 4> SimpleConvolution2d3x5Uint8Test( |
| 376 | armnn::IWorkloadFactory& workloadFactory, |
| 377 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 378 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 379 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 380 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 381 | return SimpleConvolution2d3x5TestCommon<uint8_t>(workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 384 | LayerTestResult<float, 4> SimpleConvolution2d3x3Test( |
| 385 | armnn::IWorkloadFactory& workloadFactory, |
| 386 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 387 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 388 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 389 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 390 | return SimpleConvolution2d3x3TestCommon<float>(workloadFactory, memoryManager, 0.f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 393 | LayerTestResult<float, 4> SimpleConvolution2d3x3NhwcTest( |
| 394 | armnn::IWorkloadFactory& workloadFactory, |
| 395 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 396 | bool biasEnabled) |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 397 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 398 | return SimpleConvolution2d3x3NhwcTestCommon<float>(workloadFactory, |
| 399 | memoryManager, |
| 400 | 0.f, |
| 401 | 0, |
| 402 | biasEnabled, |
| 403 | armnn::DataLayout::NHWC); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 404 | } |
| 405 | |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame^] | 406 | LayerTestResult<float, 4> SimpleConvolution2d3x3Stride2x2Test( |
| 407 | armnn::IWorkloadFactory& workloadFactory, |
| 408 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 409 | bool biasEnabled, |
| 410 | const armnn::DataLayout layout) |
| 411 | { |
| 412 | return SimpleConvolution2d3x3Stride2x2TestCommon<float>(workloadFactory, |
| 413 | memoryManager, |
| 414 | 0.f, |
| 415 | 0, |
| 416 | biasEnabled, |
| 417 | layout); |
| 418 | } |
| 419 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 420 | LayerTestResult<uint8_t, 4> SimpleConvolution2d3x3Uint8Test( |
| 421 | armnn::IWorkloadFactory& workloadFactory, |
| 422 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 423 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 424 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 425 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 426 | return SimpleConvolution2d3x3TestCommon<uint8_t>(workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | template<typename T> |
| 430 | LayerTestResult<T, 4> Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon( |
| 431 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 432 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 433 | const armnn::DataLayout layout, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 434 | float qScale, |
| 435 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 436 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 437 | // Use a single-batch 1-channel 3x3 image as input. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 438 | armnn::TensorInfo inputDesc({1, 1, 3, 3}, armnn::GetDataType<T>()); |
| 439 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>( |
| 440 | QuantizedVector<T>(qScale, qOffset, { |
| 441 | 11,21,31, |
| 442 | 12,22,32, |
| 443 | 13,23,33 |
| 444 | }))); |
| 445 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 446 | // Use 1 batch of a 1-channel 2x2 kernel. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 447 | armnn::TensorInfo kernelDesc({1, 1, 2, 2}, armnn::GetDataType<T>()); |
| 448 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 449 | QuantizedVector<T>(qScale, qOffset, { |
| 450 | -11,-21, |
| 451 | -12,-22, |
| 452 | }))); |
| 453 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 454 | // Expected output is 1 batch of a 1-channel 6x8 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 455 | // Manually calculated like this: |
| 456 | //[-11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ..] |
| 457 | //[-11*0 -21*0 -12*0 -22*11 ; -11*0 -21*0 -12*11 -22*21 ; -11*0 -21*0 -12*21 -22*31 ; -11*0 -21*0 -12*31 -22*0 ..] |
| 458 | //[-11*0 -21*11 -12*0 -22*12 ; -11*11 -21*21 -12*12 -22*22 ; -11*21 -21*31 -12*22 -22*32 ; -11*31 -21*0 -12*32 -22*0 ..] |
| 459 | //[-11*0 -21*12 -12*0 -22*13 ; -11*12 -21*22 -12*13 -22*23 ; -11*22 -21*32 -12*23 -22*33 ; -11*32 -21*0 -12*33 -22*0 ..] |
| 460 | //[-11*0 -21*13 -12*0 -22*0 ; -11*13 -21*23 -12*0 -22*0 ; -11*23 -21*33 -12*0 -22*0 ; -11*33 -21*0 -12*0 -22*0 ..] |
| 461 | //[-11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ; -11*0 -21*0 -12*0 -22*0 ..] |
| 462 | //[..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ..] |
| 463 | armnn::TensorInfo outputDesc({1, 1, 8, 6}, armnn::GetDataType<T>()); |
| 464 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 465 | QuantizedVector<T>(qScale, qOffset, { |
| 466 | 0, 0, 0, 0, 0, 0, |
| 467 | -242, -594, -934, -372, 0, 0, |
| 468 | -495, -1190, -1850, -725, 0, 0, |
| 469 | -538, -1256, -1916, -748, 0, 0, |
| 470 | -273, -626, -946, -363, 0, 0, |
| 471 | 0, 0, 0, 0, 0, 0, |
| 472 | 0, 0, 0, 0, 0, 0, |
| 473 | 0, 0, 0, 0, 0, 0 |
| 474 | }))); |
| 475 | |
| 476 | return SimpleConvolution2dTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 477 | memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 478 | input, |
| 479 | kernel, |
| 480 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(false, qScale, qOffset), |
| 481 | expectedOutput, |
| 482 | qScale, |
| 483 | qOffset, |
narpra01 | 5f70318 | 2018-10-26 16:24:58 +0100 | [diff] [blame] | 484 | layout, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 485 | 1, // Padding left. |
| 486 | 2, // Padding top. |
| 487 | 3, // Padding right. |
| 488 | 4); // Padding bottom. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 492 | LayerTestResult<T, 4> SimpleConvolution2dAsymmetricPaddingTestCommon( |
| 493 | armnn::IWorkloadFactory& workloadFactory, |
| 494 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 495 | const armnn::DataLayout layout, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 496 | float qScale, |
| 497 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 498 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 499 | // Use a single-batch 1-channel 5x5 image as input. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 500 | armnn::TensorInfo inputDesc({ 1, 1, 5, 5 }, armnn::GetDataType<T>()); |
| 501 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>( |
| 502 | QuantizedVector<T>(qScale, qOffset, { |
| 503 | 11,21,31,41,51, |
| 504 | 12,22,32,42,52, |
| 505 | 13,23,33,43,53, |
| 506 | 14,24,34,44,54, |
| 507 | 15,25,35,45,55, |
| 508 | }))); |
| 509 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 510 | // Use 1 batch of a 1-channel 4x4 kernel. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 511 | armnn::TensorInfo kernelDesc({ 1, 1, 4, 4 }, armnn::GetDataType<T>()); |
| 512 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 513 | QuantizedVector<T>(qScale, qOffset, { |
| 514 | -11,-21,-31,-41, |
| 515 | -12,-22,-32,-42, |
| 516 | -13,-23,-33,-43, |
| 517 | -14,-24,-34,-44, |
| 518 | }))); |
| 519 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 520 | // Expected output is 1 batch of a 1-channel 5x5 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 521 | armnn::TensorInfo outputDesc({ 1, 1, 5, 5 }, armnn::GetDataType<T>()); |
| 522 | std::vector<T> myVec(outputDesc.GetNumElements(), 0); |
| 523 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 524 | QuantizedVector<T>(qScale, qOffset, { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 525 | -7140, -10580, -13940, -9300, -5230, |
| 526 | -9590, -14120, -18520, -12290, -6860, |
| 527 | -9980, -14560, -18960, -12560, -7000, |
| 528 | -7518, -10904, -14144, -9318, -5152, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 529 | -5032, -7256, -9376, -6142, -3368, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 530 | }))); |
| 531 | |
| 532 | return SimpleConvolution2dTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 533 | memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 534 | input, |
| 535 | kernel, |
| 536 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(false, qScale, qOffset), |
| 537 | expectedOutput, |
| 538 | qScale, |
| 539 | qOffset, |
narpra01 | 5f70318 | 2018-10-26 16:24:58 +0100 | [diff] [blame] | 540 | layout, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 541 | 1, // Padding left. |
| 542 | 1, // Padding top. |
| 543 | 2, // Padding right. |
| 544 | 2); // Padding bottom. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 548 | LayerTestResult<T, 4> DepthwiseConvolution2dAsymmetricTestCommon( |
| 549 | armnn::IWorkloadFactory& workloadFactory, |
| 550 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 551 | float qScale, |
| 552 | int32_t qOffset, |
| 553 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 554 | const armnn::DataLayout layout) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 555 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 556 | // Use a single-batch 2-channel 5x5 image as input. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 557 | armnn::TensorInfo inputTensorInfo({ 1, 2, 5, 5 }, armnn::GetDataType<T>()); |
| 558 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 559 | QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), { |
| 560 | 0, 1, 2, 3, 4, |
| 561 | 5, 6, 7, 8, 9, |
| 562 | 10, 11, 12, 13, 14, |
| 563 | 15, 16, 17, 18, 19, |
| 564 | 20, 21, 22, 23, 24, |
| 565 | |
| 566 | 25, 26, 27, 28, 29, |
| 567 | 30, 31, 32, 33, 34, |
| 568 | 35, 36, 37, 38, 39, |
| 569 | 40, 41, 42, 43, 44, |
| 570 | 45, 46, 47, 48, 49 |
| 571 | }))); |
| 572 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 573 | // Use a depth multiplier of 1 on a 2-channel 4x4 kernel. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 574 | armnn::TensorInfo kernelTensorInfo({ 1, 2, 4, 4 }, armnn::GetDataType<T>()); |
| 575 | auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>( |
| 576 | QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), { |
| 577 | 32, 31, 30, 29, |
| 578 | 28, 27, 26, 25, |
| 579 | 24, 23, 22, 21, |
| 580 | 20, 19, 18, 17, |
| 581 | |
| 582 | 16, 15, 14, 13, |
| 583 | 12, 11, 10, 9, |
| 584 | 8, 7, 6, 5, |
| 585 | 4, 3, 2, 1 |
| 586 | }))); |
| 587 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 588 | // Expected output is 1 batch of a 2-channel 5x5 image. |
| 589 | // Calculated using the python tensorflow library with strideX=1, strideY=1. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 590 | armnn::TensorInfo outputTensorInfo({ 1, 2, 5, 5 }, armnn::GetDataType<T>()); |
| 591 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>( |
| 592 | QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), { |
| 593 | 1062, 1580, 1850, 1530, 1117, |
| 594 | 2140, 3108, 3500, 2842, 2042, |
| 595 | 3580, 5068, 5460, 4342, 3062, |
| 596 | 3618, 5072, 5390, 4248, 2971, |
| 597 | 3074, 4282, 4510, 3533, 2457, |
| 598 | 1550, 2284, 2362, 1955, 1428, |
| 599 | 2910, 4206, 4342, 3528, 2536, |
| 600 | 3390, 4886, 5022, 4068, 2916, |
| 601 | 3566, 5056, 5182, 4133, 2922, |
| 602 | 3100, 4352, 4452, 3517, 2465 |
| 603 | }))); |
| 604 | |
| 605 | return DepthwiseConvolution2dAsymmetricTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 606 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 607 | input, |
| 608 | kernel, |
| 609 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset), |
| 610 | expectedOutput, |
| 611 | qScale, |
| 612 | qOffset, |
jimfly01 | 382a91d | 2018-10-26 15:55:50 +0100 | [diff] [blame] | 613 | layout, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 614 | 1, // Padding left. |
| 615 | 1, // Padding top. |
| 616 | 2, // Padding right. |
| 617 | 2, // Padding bottom. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 618 | 1, // strideX |
| 619 | 1); // strideY |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 622 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 623 | LayerTestResult<T, 4> DepthwiseConvolution2dNhwcTestCommon( |
| 624 | armnn::IWorkloadFactory& workloadFactory, |
| 625 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 626 | float qScale, |
| 627 | int32_t qOffset, |
| 628 | bool biasEnabled) |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 629 | { |
| 630 | armnn::TensorInfo inputTensorInfo({ 1, 5, 5, 2}, armnn::GetDataType<T>()); |
| 631 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 632 | QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), { |
| 633 | 0, 25, |
| 634 | 1, 26, |
| 635 | 2, 27, |
| 636 | 3, 28, |
| 637 | 4, 29, |
| 638 | |
| 639 | 5, 30, |
| 640 | 6, 31, |
| 641 | 7, 32, |
| 642 | 8, 33, |
| 643 | 9, 34, |
| 644 | |
| 645 | 10, 35, |
| 646 | 11, 36, |
| 647 | 12, 37, |
| 648 | 13, 38, |
| 649 | 14, 39, |
| 650 | |
| 651 | 15, 40, |
| 652 | 16, 41, |
| 653 | 17, 42, |
| 654 | 18, 43, |
| 655 | 19, 44, |
| 656 | |
| 657 | 20, 45, |
| 658 | 21, 46, |
| 659 | 22, 47, |
| 660 | 23, 48, |
| 661 | 24, 49 |
| 662 | }))); |
| 663 | |
| 664 | armnn::TensorInfo kernelTensorInfo({ 1, 4, 4, 2}, armnn::GetDataType<T>()); |
| 665 | auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>( |
| 666 | QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), { |
| 667 | 32, 16, |
| 668 | 31, 15, |
| 669 | 30, 14, |
| 670 | 29, 13, |
| 671 | |
| 672 | 28, 12, |
| 673 | 27, 11, |
| 674 | 26, 10, |
| 675 | 25, 9, |
| 676 | |
| 677 | 24, 8, |
| 678 | 23, 7, |
| 679 | 22, 6, |
| 680 | 21, 5, |
| 681 | |
| 682 | 20, 4, |
| 683 | 19, 3, |
| 684 | 18, 2, |
| 685 | 17, 1 |
| 686 | }))); |
| 687 | |
| 688 | armnn::TensorInfo outputTensorInfo({ 1, 5, 5, 2}, armnn::GetDataType<T>()); |
| 689 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>( |
| 690 | QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), { |
| 691 | 1062, 1550, |
| 692 | 1580, 2284, |
| 693 | 1850, 2362, |
| 694 | 1530, 1955, |
| 695 | 1117, 1428, |
| 696 | |
| 697 | 2140, 2910, |
| 698 | 3108, 4206, |
| 699 | 3500, 4342, |
| 700 | 2842, 3528, |
| 701 | 2042, 2536, |
| 702 | |
| 703 | 3580, 3390, |
| 704 | 5068, 4886, |
| 705 | 5460, 5022, |
| 706 | 4342, 4068, |
| 707 | 3062, 2916, |
| 708 | |
| 709 | 3618, 3566, |
| 710 | 5072, 5056, |
| 711 | 5390, 5182, |
| 712 | 4248, 4133, |
| 713 | 2971, 2922, |
| 714 | |
| 715 | 3074, 3100, |
| 716 | 4282, 4352, |
| 717 | 4510, 4452, |
| 718 | 3533, 3517, |
| 719 | 2457, 2465 |
| 720 | }))); |
| 721 | |
| 722 | return DepthwiseConvolution2dNhwcTestImpl<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 723 | memoryManager, |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 724 | input, |
| 725 | kernel, |
| 726 | GetBias2<typename FullyConnectedBiasTypeForInputType<T>::Type>(biasEnabled, qScale, qOffset), |
| 727 | expectedOutput, |
| 728 | qScale, |
| 729 | qOffset, |
| 730 | 1, // Padding left. |
| 731 | 1, // Padding top. |
| 732 | 2, // Padding right. |
| 733 | 2, // Padding bottom. |
| 734 | 1, // strideX |
| 735 | 1); // strideY |
| 736 | } |
| 737 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 738 | LayerTestResult<float, 4> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 739 | Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTest( |
| 740 | armnn::IWorkloadFactory& workloadFactory, |
| 741 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 742 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 743 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 744 | return Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon<float>( |
| 745 | workloadFactory, memoryManager, layout, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 748 | LayerTestResult<float, 4> Convolution2dAsymmetricPaddingTest( |
| 749 | armnn::IWorkloadFactory& workloadFactory, |
| 750 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 751 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 752 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 753 | return SimpleConvolution2dAsymmetricPaddingTestCommon<float>( |
| 754 | workloadFactory, memoryManager, layout, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 757 | LayerTestResult<float, 4> DepthwiseConvolution2dTest( |
| 758 | armnn::IWorkloadFactory& workloadFactory, |
| 759 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 760 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 761 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 762 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 763 | return DepthwiseConvolution2dTestImpl<float, float>( |
| 764 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 765 | } |
| 766 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 767 | LayerTestResult<float, 4> DepthwiseConvolution2dDepthNhwcTest( |
| 768 | armnn::IWorkloadFactory& workloadFactory, |
| 769 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 770 | bool biasEnabled) |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 771 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 772 | return DepthwiseConvolution2dNhwcTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0, biasEnabled); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 773 | } |
| 774 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 775 | LayerTestResult<float, 4> DepthwiseConvolution2dDepthMul1Test( |
| 776 | armnn::IWorkloadFactory& workloadFactory, |
| 777 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 778 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 779 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 780 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 781 | return DepthwiseConvolution2dDepthMul1TestImpl<float, float>( |
| 782 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 783 | } |
| 784 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 785 | LayerTestResult<float, 4> DepthwiseConvolution2dAsymmetricTest( |
| 786 | armnn::IWorkloadFactory& workloadFactory, |
| 787 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 788 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 789 | const armnn::DataLayout layout) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 790 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 791 | return DepthwiseConvolution2dAsymmetricTestCommon<float>( |
| 792 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 793 | } |
| 794 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 795 | LayerTestResult<uint8_t, 4> DepthwiseConvolution2dUint8Test( |
| 796 | armnn::IWorkloadFactory& workloadFactory, |
| 797 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 798 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 799 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 800 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 801 | return DepthwiseConvolution2dTestImpl<uint8_t, int32_t>( |
| 802 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 805 | LayerTestResult<uint8_t, 4> DepthwiseConvolution2dDepthMul1Uint8Test( |
| 806 | armnn::IWorkloadFactory& workloadFactory, |
| 807 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 808 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 809 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 810 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 811 | return DepthwiseConvolution2dDepthMul1TestImpl<uint8_t, int32_t>( |
| 812 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 815 | LayerTestResult<float, 4> Convolution1dTest( |
| 816 | armnn::IWorkloadFactory& workloadFactory, |
| 817 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 818 | bool biasEnabled) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 819 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 820 | return Convolution1dTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, biasEnabled); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 821 | } |
| 822 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 823 | LayerTestResult<uint8_t, 4> Convolution1dUint8Test( |
| 824 | armnn::IWorkloadFactory& workloadFactory, |
| 825 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 826 | bool biasEnabled) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 827 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 828 | return Convolution1dTestImpl<uint8_t>(workloadFactory, memoryManager, 0.1f, 128, biasEnabled); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 829 | } |
| 830 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 831 | LayerTestResult<float,4> CompareConvolution2dTest( |
| 832 | armnn::IWorkloadFactory& workloadFactory, |
| 833 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 834 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 835 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 836 | return CompareConvolution2dTestImpl<float>(workloadFactory, memoryManager, refWorkloadFactory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 840 | LayerTestResult<T,4> CompareDepthwiseConvolution2dTest( |
| 841 | armnn::IWorkloadFactory& workloadFactory, |
| 842 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 843 | armnn::IWorkloadFactory& refWorkloadFactory, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 844 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 845 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 846 | return CompareDepthwiseConvolution2dTestImpl<T>(workloadFactory, memoryManager, refWorkloadFactory, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | template LayerTestResult<float, 4> CompareDepthwiseConvolution2dTest<float>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 850 | armnn::IWorkloadFactory&, |
| 851 | const armnn::IBackendInternal::IMemoryManagerSharedPtr&, |
| 852 | armnn::IWorkloadFactory&, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 853 | const armnn::DataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 854 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 855 | template LayerTestResult<uint8_t, 4> CompareDepthwiseConvolution2dTest<uint8_t>( |
| 856 | armnn::IWorkloadFactory&, |
| 857 | const armnn::IBackendInternal::IMemoryManagerSharedPtr&, |
| 858 | armnn::IWorkloadFactory&, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 859 | const armnn::DataLayout); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 860 | |
| 861 | LayerTestResult<float,4> SimpleNormalizationAcrossTest( |
| 862 | armnn::IWorkloadFactory& workloadFactory, |
| 863 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 864 | { |
| 865 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 866 | auto normChannel = armnn::NormalizationAlgorithmChannel::Across; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 867 | return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 868 | } |
| 869 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 870 | LayerTestResult<float,4> SimpleNormalizationWithinTest( |
| 871 | armnn::IWorkloadFactory& workloadFactory, |
| 872 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 873 | { |
| 874 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 875 | auto normChannel = armnn::NormalizationAlgorithmChannel::Within; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 876 | return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 877 | } |
| 878 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 879 | LayerTestResult<float,4> SimpleNormalizationAcrossNhwcTest( |
| 880 | armnn::IWorkloadFactory& workloadFactory, |
| 881 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 882 | { |
| 883 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 884 | auto normChannel = armnn::NormalizationAlgorithmChannel::Across; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 885 | return SimpleNormalizationNhwcTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 886 | } |
| 887 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 888 | LayerTestResult<float,2> SimpleSoftmaxTest( |
| 889 | armnn::IWorkloadFactory& workloadFactory, |
| 890 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 891 | float beta) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 892 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 893 | return SimpleSoftmaxTestImpl<float>(workloadFactory, memoryManager, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 894 | } |
| 895 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 896 | LayerTestResult<uint8_t,2> SimpleSoftmaxUint8Test( |
| 897 | armnn::IWorkloadFactory& workloadFactory, |
| 898 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 899 | float beta) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 900 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 901 | return SimpleSoftmaxTestImpl<uint8_t>(workloadFactory, memoryManager, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 904 | LayerTestResult<float,4> CompareNormalizationTest( |
| 905 | armnn::IWorkloadFactory& workloadFactory, |
| 906 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 907 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 908 | armnn::NormalizationAlgorithmChannel normChannel, |
| 909 | armnn::NormalizationAlgorithmMethod normMethod) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 910 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 911 | return CompareNormalizationTestImpl(workloadFactory, memoryManager, refWorkloadFactory, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 912 | } |
| 913 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 914 | LayerTestResult<float,2> CompareSoftmaxTest( |
| 915 | armnn::IWorkloadFactory& workloadFactory, |
| 916 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 917 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 918 | float beta) |
| 919 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 920 | return CompareSoftmaxTestImpl<float>(workloadFactory, memoryManager, refWorkloadFactory, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 921 | } |
| 922 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 923 | LayerTestResult<uint8_t,2> CompareSoftmaxUint8Test( |
| 924 | armnn::IWorkloadFactory& workloadFactory, |
| 925 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 926 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 927 | float beta) |
| 928 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 929 | return CompareSoftmaxTestImpl<uint8_t>(workloadFactory, memoryManager, refWorkloadFactory, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 930 | } |
| 931 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 932 | std::vector<LayerTestResult<float,3>> SplitterTest( |
| 933 | armnn::IWorkloadFactory& workloadFactory, |
| 934 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 935 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 936 | return SplitterTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 937 | } |
| 938 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 939 | std::vector<LayerTestResult<uint8_t,3>> SplitterUint8Test( |
| 940 | armnn::IWorkloadFactory& workloadFactory, |
| 941 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 942 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 943 | return SplitterTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 944 | } |
| 945 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 946 | LayerTestResult<float, 3> CopyViaSplitterTest( |
| 947 | armnn::IWorkloadFactory& workloadFactory, |
| 948 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 949 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 950 | return CopyViaSplitterTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 951 | } |
| 952 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 953 | LayerTestResult<uint8_t, 3> CopyViaSplitterUint8Test( |
| 954 | armnn::IWorkloadFactory& workloadFactory, |
| 955 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 956 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 957 | return CopyViaSplitterTestImpl<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 958 | } |
| 959 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 960 | LayerTestResult<float, 2> LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 961 | armnn::IWorkloadFactory& workloadFactory, |
| 962 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 963 | { |
| 964 | armnn::TensorInfo inputDesc({ 2, 2 }, armnn::GetDataType<float>()); |
| 965 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 966 | { 2., 3., 3., 4. })); |
| 967 | |
| 968 | armnn::TensorInfo outputDesc({ 2, 4 }, armnn::GetDataType<float>()); |
| 969 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 970 | {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f, |
| 971 | -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f})); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 972 | return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl( |
| 973 | workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | LayerTestResult<float, 2> LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 977 | armnn::IWorkloadFactory& workloadFactory, |
| 978 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 979 | { |
| 980 | armnn::TensorInfo inputDesc({ 2, 5 }, armnn::GetDataType<float>()); |
| 981 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 982 | {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f, |
| 983 | 0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f})); |
| 984 | |
| 985 | armnn::TensorInfo outputDesc({ 2, 16 }, armnn::GetDataType<float>()); |
| 986 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 987 | {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f, |
| 988 | -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f, |
| 989 | -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f, |
| 990 | 0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f, |
| 991 | -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f, |
| 992 | 0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f, |
| 993 | 0.02168f})); |
Matteo Martincigh | a65b7ae | 2018-11-14 12:39:55 +0000 | [diff] [blame] | 994 | return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl(workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 995 | } |
| 996 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 997 | LayerTestResult<float, 2> LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest( |
| 998 | armnn::IWorkloadFactory& workloadFactory, |
| 999 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1000 | { |
| 1001 | armnn::TensorInfo inputDesc({2, 2}, armnn::GetDataType<float>()); |
| 1002 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 1003 | {2., 3., 3., 4.})); |
| 1004 | |
| 1005 | |
| 1006 | armnn::TensorInfo outputDesc({2, 4}, armnn::GetDataType<float>()); |
| 1007 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 1008 | {{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f, |
| 1009 | -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}})); |
| 1010 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1011 | return LstmNoCifgNoPeepholeNoProjectionTestImpl( |
| 1012 | workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1013 | } |
| 1014 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1015 | LayerTestResult<float,3> MergerTest( |
| 1016 | armnn::IWorkloadFactory& workloadFactory, |
| 1017 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1018 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1019 | unsigned int outputWidth = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1020 | unsigned int outputHeight = 6; |
| 1021 | unsigned int outputChannels = 3; |
| 1022 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1023 | unsigned int inputWidth1 = 3; |
| 1024 | unsigned int inputHeight1 = 6; |
| 1025 | unsigned int inputChannels1 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1026 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1027 | unsigned int inputWidth2 = 3; |
| 1028 | unsigned int inputHeight2 = 6; |
| 1029 | unsigned int inputChannels2 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1030 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1031 | // Define the tensor descriptors. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1032 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::Float32); |
| 1033 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::Float32); |
| 1034 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1035 | |
| 1036 | LayerTestResult<float,3> ret(outputTensorInfo); |
| 1037 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1038 | ret.outputExpected = MakeTensor<float, 3>(outputTensorInfo, std::vector<float>( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1039 | { |
| 1040 | 1.0f, 2.0f, 3.0f, |
| 1041 | 4.0f, 5.0f, 6.0f, |
| 1042 | 7.0f, 8.0f, 9.0f, |
| 1043 | 10.0f, 11.0f, 12.0f, |
| 1044 | 13.0f, 14.0f, 15.0f, |
| 1045 | 16.0f, 17.0f, 18.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1046 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1047 | 19.0f, 20.0f, 21.0f, |
| 1048 | 22.0f, 23.0f, 24.0f, |
| 1049 | 25.0f, 26.0f, 27.0f, |
| 1050 | 28.0f, 29.0f, 30.0f, |
| 1051 | 31.0f, 32.0f, 33.0f, |
| 1052 | 34.0f, 35.0f, 36.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1053 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1054 | 37.0f, 38.0f, 39.0f, |
| 1055 | 40.0f, 41.0f, 42.0f, |
| 1056 | 43.0f, 44.0f, 45.0f, |
| 1057 | 46.0f, 47.0f, 48.0f, |
| 1058 | 49.0f, 50.0f, 51.0f, |
| 1059 | 52.0f, 53.0f, 54.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1060 | }) |
| 1061 | ); |
| 1062 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1063 | auto input1 = MakeTensor<float, 3>(inputTensorInfo1, std::vector<float>( |
| 1064 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1065 | 1.0f, 2.0f, 3.0f, |
| 1066 | 4.0f, 5.0f, 6.0f, |
| 1067 | 7.0f, 8.0f, 9.0f, |
| 1068 | 10.0f, 11.0f, 12.0f, |
| 1069 | 13.0f, 14.0f, 15.0f, |
| 1070 | 16.0f, 17.0f, 18.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1071 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1072 | 19.0f, 20.0f, 21.0f, |
| 1073 | 22.0f, 23.0f, 24.0f, |
| 1074 | 25.0f, 26.0f, 27.0f, |
| 1075 | 28.0f, 29.0f, 30.0f, |
| 1076 | 31.0f, 32.0f, 33.0f, |
| 1077 | 34.0f, 35.0f, 36.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1078 | }) |
| 1079 | ); |
| 1080 | |
| 1081 | auto input2 = MakeTensor<float, 3>(inputTensorInfo2, std::vector<float>( |
| 1082 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1083 | 37.0f, 38.0f, 39.0f, |
| 1084 | 40.0f, 41.0f, 42.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1085 | 43.0f, 44.0f, 45.0f, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1086 | 46.0f, 47.0f, 48.0f, |
| 1087 | 49.0f, 50.0f, 51.0f, |
| 1088 | 52.0f, 53.0f, 54.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1089 | }) |
| 1090 | ); |
| 1091 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1092 | std::vector<unsigned int> wOrigin1 = {0, 0, 0}; //Extent of the window is defined by size of input[0]. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1093 | armnn::MergerQueueDescriptor::ViewOrigin window1(wOrigin1); |
| 1094 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1095 | std::vector<unsigned int> wOrigin2 = {2, 0, 0}; //Extent of the window is defined by size of input[1]. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1096 | armnn::MergerQueueDescriptor::ViewOrigin window2(wOrigin2); |
| 1097 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1098 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1099 | |
| 1100 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 1101 | |
| 1102 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 1103 | subTensorsSupported ? |
| 1104 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 1105 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1106 | |
| 1107 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 1108 | subTensorsSupported ? |
| 1109 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 1110 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1111 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1112 | armnn::MergerQueueDescriptor data; |
| 1113 | armnn::WorkloadInfo info; |
| 1114 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1115 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1116 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1117 | |
| 1118 | data.m_ViewOrigins.push_back(window1); |
| 1119 | data.m_ViewOrigins.push_back(window2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1120 | |
| 1121 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(data, info); |
| 1122 | |
| 1123 | inputHandle1->Allocate(); |
| 1124 | inputHandle2->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1125 | outputHandle->Allocate(); |
| 1126 | |
| 1127 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 1128 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1129 | |
| 1130 | workload->Execute(); |
| 1131 | |
| 1132 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 1133 | |
| 1134 | return ret; |
| 1135 | } |
| 1136 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1137 | LayerTestResult<float,4> AdditionTest( |
| 1138 | armnn::IWorkloadFactory& workloadFactory, |
| 1139 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1140 | { |
| 1141 | unsigned int batchSize = 2; |
| 1142 | unsigned int channels = 2; |
| 1143 | unsigned int height = 2; |
| 1144 | unsigned int width = 3; |
| 1145 | |
| 1146 | armnn::TensorInfo inputTensorInfo1, inputTensorInfo2; |
| 1147 | armnn::TensorInfo outputTensorInfo; |
| 1148 | |
| 1149 | unsigned int shape[] = {batchSize, channels, height, width}; |
| 1150 | |
| 1151 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1152 | inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1153 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1154 | |
| 1155 | |
| 1156 | auto input1 = MakeTensor<float, 4>(inputTensorInfo1, std::vector<float>( |
| 1157 | { |
| 1158 | 0.0f, 2.0f, 1.0f, |
| 1159 | 0.2f, 1.0f, 2.0f, |
| 1160 | |
| 1161 | 1.0f, 2.0f, 1.0f, |
| 1162 | 0.2f, 1.0f, 2.0f, |
| 1163 | |
| 1164 | 0.0f, 2.0f, 1.0f, |
| 1165 | 4.2f, 1.0f, 2.0f, |
| 1166 | |
| 1167 | 0.0f, 0.0f, 1.0f, |
| 1168 | 0.2f, 1.0f, 2.0f, |
| 1169 | })); |
| 1170 | |
| 1171 | auto input2 = MakeTensor<float, 4>(inputTensorInfo2, std::vector<float>( |
| 1172 | { |
| 1173 | 1.0f, 2.0f, 1.0f, |
| 1174 | 0.0f, 1.0f, 2.0f, |
| 1175 | |
| 1176 | 1.0f, 2.0f, -2.0f, |
| 1177 | 0.2f, 1.0f, 2.0f, |
| 1178 | |
| 1179 | 0.0f, 2.0f, 1.0f, |
| 1180 | 4.2f, 0.0f, -3.0f, |
| 1181 | |
| 1182 | 0.0f, 0.0f, 1.0f, |
| 1183 | 0.7f, 1.0f, 5.0f, |
| 1184 | })); |
| 1185 | |
| 1186 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 1187 | ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, std::vector<float>( |
| 1188 | { |
| 1189 | 1.0f, 4.0f, 2.0f, |
| 1190 | 0.2f, 2.0f, 4.0f, |
| 1191 | |
| 1192 | 2.0f, 4.0f, -1.0f, |
| 1193 | 0.4f, 2.0f, 4.0f, |
| 1194 | |
| 1195 | 0.0f, 4.0f, 2.0f, |
| 1196 | 8.4f, 1.0f, -1.0f, |
| 1197 | |
| 1198 | 0.0f, 0.0f, 2.0f, |
| 1199 | 0.9f, 2.0f, 7.0f, |
| 1200 | })); |
| 1201 | |
| 1202 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1203 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1204 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1205 | |
| 1206 | armnn::AdditionQueueDescriptor data; |
| 1207 | armnn::WorkloadInfo info; |
| 1208 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1209 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1210 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1211 | |
| 1212 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1213 | |
| 1214 | inputHandle1->Allocate(); |
| 1215 | inputHandle2->Allocate(); |
| 1216 | outputHandle->Allocate(); |
| 1217 | |
| 1218 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1219 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1220 | |
| 1221 | workload->Execute(); |
| 1222 | |
| 1223 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1224 | |
| 1225 | return ret; |
| 1226 | } |
| 1227 | |
| 1228 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1229 | LayerTestResult<T, 4> AdditionBroadcastTestImpl( |
| 1230 | armnn::IWorkloadFactory& workloadFactory, |
| 1231 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1232 | float qScale, |
| 1233 | int32_t qOffset) |
| 1234 | { |
| 1235 | armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 1}, armnn::GetDataType<T>()); |
| 1236 | armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 2, 3}, armnn::GetDataType<T>()); |
| 1237 | armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>()); |
| 1238 | |
| 1239 | if (armnn::IsQuantizedType<T>()) |
| 1240 | { |
| 1241 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 1242 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
| 1243 | inputTensorInfo2.SetQuantizationScale(qScale); |
| 1244 | inputTensorInfo2.SetQuantizationOffset(qOffset); |
| 1245 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1246 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1247 | } |
| 1248 | |
| 1249 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, |
| 1250 | { |
| 1251 | 0.0f, |
| 1252 | 1.0f, |
| 1253 | |
| 1254 | 2.0f, |
| 1255 | 3.0f, |
| 1256 | |
| 1257 | 4.0f, |
| 1258 | 5.0f, |
| 1259 | })); |
| 1260 | |
| 1261 | auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset, |
| 1262 | { |
| 1263 | 0.5f, 1.5f, 2.5f, |
| 1264 | 3.5f, 4.5f, 5.5f, |
| 1265 | })); |
| 1266 | |
| 1267 | LayerTestResult<T,4> ret(outputTensorInfo); |
| 1268 | ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, |
| 1269 | { |
| 1270 | 0.5f, 1.5f, 2.5f, |
| 1271 | 4.5f, 5.5f, 6.5f, |
| 1272 | |
| 1273 | 2.5f, 3.5f, 4.5f, |
| 1274 | 6.5f, 7.5f, 8.5f, |
| 1275 | |
| 1276 | 4.5f, 5.5f, 6.5f, |
| 1277 | 8.5f, 9.5f, 10.5f, |
| 1278 | })); |
| 1279 | |
| 1280 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1281 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1282 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1283 | |
| 1284 | armnn::AdditionQueueDescriptor data; |
| 1285 | armnn::WorkloadInfo info; |
| 1286 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1287 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1288 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1289 | |
| 1290 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1291 | |
| 1292 | inputHandle1->Allocate(); |
| 1293 | inputHandle2->Allocate(); |
| 1294 | outputHandle->Allocate(); |
| 1295 | |
| 1296 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1297 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1298 | |
| 1299 | workload->Execute(); |
| 1300 | |
| 1301 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1302 | |
| 1303 | return ret; |
| 1304 | } |
| 1305 | |
| 1306 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1307 | LayerTestResult<T, 4> AdditionBroadcast1ElementTestImpl( |
| 1308 | armnn::IWorkloadFactory& workloadFactory, |
| 1309 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1310 | float qScale, |
| 1311 | int32_t qOffset) |
| 1312 | { |
| 1313 | armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>()); |
| 1314 | armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 1, 1}, armnn::GetDataType<T>()); |
| 1315 | armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, armnn::GetDataType<T>()); |
| 1316 | |
| 1317 | if (armnn::IsQuantizedType<T>()) |
| 1318 | { |
| 1319 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 1320 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
| 1321 | inputTensorInfo2.SetQuantizationScale(qScale); |
| 1322 | inputTensorInfo2.SetQuantizationOffset(qOffset); |
| 1323 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1324 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1325 | } |
| 1326 | |
| 1327 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, |
| 1328 | { |
| 1329 | 0.0f, 1.0f, 2.0f, |
| 1330 | 3.0f, 4.0f, 5.0f, |
| 1331 | 6.0f, 7.0f, 8.0f, |
| 1332 | 9.0f, 10.0f, 11.0f, |
| 1333 | 12.0f, 13.0f, 14.0f, |
| 1334 | 15.0f, 16.0f, 17.0f, |
| 1335 | })); |
| 1336 | |
| 1337 | auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset, |
| 1338 | { |
| 1339 | 0.5f, |
| 1340 | })); |
| 1341 | |
| 1342 | LayerTestResult<T,4> ret(outputTensorInfo); |
| 1343 | ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, |
| 1344 | { |
| 1345 | 0.5f, 1.5f, 2.5f, |
| 1346 | 3.5f, 4.5f, 5.5f, |
| 1347 | 6.5f, 7.5f, 8.5f, |
| 1348 | 9.5f, 10.5f, 11.5f, |
| 1349 | 12.5f, 13.5f, 14.5f, |
| 1350 | 15.5f, 16.5f, 17.5f, |
| 1351 | })); |
| 1352 | |
| 1353 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1354 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1355 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1356 | |
| 1357 | armnn::AdditionQueueDescriptor data; |
| 1358 | armnn::WorkloadInfo info; |
| 1359 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1360 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1361 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1362 | |
| 1363 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1364 | |
| 1365 | inputHandle1->Allocate(); |
| 1366 | inputHandle2->Allocate(); |
| 1367 | outputHandle->Allocate(); |
| 1368 | |
| 1369 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1370 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1371 | |
| 1372 | workload->Execute(); |
| 1373 | |
| 1374 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1375 | |
| 1376 | return ret; |
| 1377 | } |
| 1378 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1379 | LayerTestResult<float, 4> AdditionBroadcastTest( |
| 1380 | armnn::IWorkloadFactory& workloadFactory, |
| 1381 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1382 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1383 | return AdditionBroadcastTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1384 | } |
| 1385 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1386 | LayerTestResult<uint8_t, 4> AdditionBroadcastUint8Test( |
| 1387 | armnn::IWorkloadFactory& workloadFactory, |
| 1388 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1389 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1390 | return AdditionBroadcastTestImpl<uint8_t>(workloadFactory, memoryManager, 2.f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1391 | } |
| 1392 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1393 | LayerTestResult<float, 4> AdditionBroadcast1ElementTest( |
| 1394 | armnn::IWorkloadFactory& workloadFactory, |
| 1395 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1396 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1397 | return AdditionBroadcast1ElementTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1398 | } |
| 1399 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1400 | LayerTestResult<uint8_t, 4> AdditionBroadcast1ElementUint8Test( |
| 1401 | armnn::IWorkloadFactory& workloadFactory, |
| 1402 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1403 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1404 | return AdditionBroadcast1ElementTestImpl<uint8_t>(workloadFactory, memoryManager, 0.1333333f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1405 | } |
| 1406 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1407 | LayerTestResult<float,4> CompareAdditionTest( |
| 1408 | armnn::IWorkloadFactory& workloadFactory, |
| 1409 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1410 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1411 | { |
| 1412 | unsigned int batchSize = 4; |
| 1413 | unsigned int channels = 1; |
| 1414 | unsigned int height = 2; |
| 1415 | unsigned int width = 3; |
| 1416 | |
| 1417 | armnn::TensorInfo inputTensorInfo1, inputTensorInfo2; |
| 1418 | armnn::TensorInfo outputTensorInfo; |
| 1419 | |
| 1420 | unsigned int shape[] = {batchSize, channels, height, width}; |
| 1421 | |
| 1422 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1423 | inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1424 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1425 | |
| 1426 | auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 1232); |
| 1427 | auto input2 = MakeRandomTensor<float, 4>(inputTensorInfo2, 456); |
| 1428 | |
| 1429 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 1430 | |
| 1431 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1432 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1433 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1434 | |
| 1435 | std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1436 | std::unique_ptr<armnn::ITensorHandle> inputHandle2Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1437 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1438 | |
| 1439 | armnn::AdditionQueueDescriptor data; |
| 1440 | armnn::WorkloadInfo info; |
| 1441 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1442 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1443 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1444 | |
| 1445 | armnn::AdditionQueueDescriptor refData = data; |
| 1446 | armnn::WorkloadInfo refInfo = info; |
| 1447 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo1, inputHandle1Ref.get()); |
| 1448 | SetWorkloadInput(refData, refInfo, 1, inputTensorInfo2, inputHandle2Ref.get()); |
| 1449 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 1450 | |
| 1451 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1452 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateAddition(refData, refInfo); |
| 1453 | |
| 1454 | inputHandle1->Allocate(); |
| 1455 | inputHandle2->Allocate(); |
| 1456 | outputHandle->Allocate(); |
| 1457 | inputHandle1Ref->Allocate(); |
| 1458 | inputHandle2Ref->Allocate(); |
| 1459 | outputHandleRef->Allocate(); |
| 1460 | |
| 1461 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1462 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1463 | CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]); |
| 1464 | CopyDataToITensorHandle(inputHandle2Ref.get(), &input2[0][0][0][0]); |
| 1465 | |
| 1466 | workload->Execute(); |
| 1467 | workloadRef->Execute(); |
| 1468 | |
| 1469 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1470 | CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 1471 | |
| 1472 | return ret; |
| 1473 | } |
| 1474 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1475 | namespace { |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1476 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1477 | LayerTestResult<T, 4> DivisionTestHelper( |
| 1478 | armnn::IWorkloadFactory& workloadFactory, |
| 1479 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1480 | const unsigned int shape0[4], |
| 1481 | const std::vector<T>& values0, |
| 1482 | float scale0, |
| 1483 | int32_t offset0, |
| 1484 | const unsigned int shape1[4], |
| 1485 | const std::vector<T> & values1, |
| 1486 | float scale1, |
| 1487 | int32_t offset1, |
| 1488 | const unsigned int outShape[4], |
| 1489 | const std::vector<T> & outValues, |
| 1490 | float outScale, |
| 1491 | int32_t outOffset) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1492 | { |
| 1493 | auto dataType = (std::is_same<T, uint8_t>::value ? |
| 1494 | armnn::DataType::QuantisedAsymm8 : |
| 1495 | armnn::DataType::Float32); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1496 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1497 | armnn::TensorInfo inputTensorInfo0(4, shape0, dataType); |
| 1498 | armnn::TensorInfo inputTensorInfo1(4, shape1, dataType); |
| 1499 | armnn::TensorInfo outputTensorInfo(4, outShape, dataType); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1500 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1501 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 1502 | inputTensorInfo0.SetQuantizationOffset(offset0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1503 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1504 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 1505 | inputTensorInfo1.SetQuantizationOffset(offset1); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1506 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1507 | outputTensorInfo.SetQuantizationScale(outScale); |
| 1508 | outputTensorInfo.SetQuantizationOffset(outOffset); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1509 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1510 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 1511 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1512 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1513 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1514 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1515 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1516 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 1517 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1518 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1519 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1520 | armnn::DivisionQueueDescriptor data; |
| 1521 | armnn::WorkloadInfo info; |
| 1522 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 1523 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1524 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1525 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1526 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateDivision(data, info); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1527 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1528 | inputHandle0->Allocate(); |
| 1529 | inputHandle1->Allocate(); |
| 1530 | outputHandle->Allocate(); |
| 1531 | |
| 1532 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 1533 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1534 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1535 | workload->Execute(); |
| 1536 | |
| 1537 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 1538 | |
| 1539 | return result; |
| 1540 | } |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1541 | } // anonymous namespace |
| 1542 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1543 | LayerTestResult<float,4> DivisionByZeroTest( |
| 1544 | armnn::IWorkloadFactory& workloadFactory, |
| 1545 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | 8c5e3dc | 2018-08-30 17:18:37 +0100 | [diff] [blame] | 1546 | { |
| 1547 | const unsigned int width = 2; |
| 1548 | const unsigned int height = 2; |
| 1549 | const unsigned int channelCount = 2; |
| 1550 | const unsigned int batchSize = 2; |
| 1551 | |
| 1552 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1553 | |
| 1554 | std::vector<float> input0({ |
| 1555 | 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, |
| 1556 | -1.f, -1.f, -1.f, -1.f, 5.f, 5.f, 5.f, 5.f }); |
| 1557 | |
| 1558 | std::vector<float> input1({ |
| 1559 | 0.f, 0.f, -0.f, -0.f, 0.f, 0.f, -0.f, -0.f, |
| 1560 | 0.f, 0.f, -0.f, -0.f, 5.f, 5.f, 5.f, 5.f }); |
| 1561 | |
| 1562 | std::vector<float> output({ |
| 1563 | INFINITY, INFINITY, -INFINITY, -INFINITY, NAN, NAN, -NAN, -NAN, |
| 1564 | -INFINITY, -INFINITY, INFINITY, INFINITY, 1, 1, 1, 1 }); |
| 1565 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1566 | return DivisionTestHelper<float>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1567 | memoryManager, |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1568 | shape, input0, 1.0f, 0, |
| 1569 | shape, input1, 1.0f, 0, |
| 1570 | shape, output, 1.0f, 0); |
Francis Murtagh | 8c5e3dc | 2018-08-30 17:18:37 +0100 | [diff] [blame] | 1571 | } |
| 1572 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1573 | LayerTestResult<float,4> DivisionTest( |
| 1574 | armnn::IWorkloadFactory& workloadFactory, |
| 1575 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1576 | { |
| 1577 | const unsigned int width = 2; |
| 1578 | const unsigned int height = 2; |
| 1579 | const unsigned int channelCount = 2; |
| 1580 | const unsigned int batchSize = 2; |
| 1581 | |
| 1582 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1583 | |
| 1584 | std::vector<float> input0({ |
| 1585 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 1586 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 1587 | |
| 1588 | std::vector<float> input1({ |
| 1589 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 1590 | 4, 4, 4, 4, 4, 4, 4, 4 }); |
| 1591 | |
| 1592 | std::vector<float> output({ |
| 1593 | 2, 2, 2, 2, 1.5, 1.5, 1.5, 1.5, |
| 1594 | 1, 1, 1, 1, 1.25, 1.25, 1.25, 1.25 }); |
| 1595 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1596 | |
| 1597 | return DivisionTestHelper<float>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1598 | memoryManager, |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1599 | shape, input0, 1.0f, 0, |
| 1600 | shape, input1, 1.0f, 0, |
| 1601 | shape, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1602 | } |
| 1603 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1604 | LayerTestResult<float, 4> DivisionBroadcast1ElementTest( |
| 1605 | armnn::IWorkloadFactory& workloadFactory, |
| 1606 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1607 | { |
| 1608 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 1609 | std::vector<float> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 1610 | |
| 1611 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 1612 | std::vector<float> input1({ 2 }); |
| 1613 | |
| 1614 | std::vector<float> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 1615 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1616 | |
| 1617 | return DivisionTestHelper<float>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1618 | memoryManager, |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1619 | shape0, input0, 1.0f, 0, |
| 1620 | shape1, input1, 1.0f, 0, |
| 1621 | shape0, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1622 | } |
| 1623 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1624 | LayerTestResult<float, 4> DivisionBroadcast1DVectorTest( |
| 1625 | armnn::IWorkloadFactory& workloadFactory, |
| 1626 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1627 | { |
| 1628 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 1629 | std::vector<float> input0({ |
| 1630 | 1, 4, 3, 8, 5, 12, |
| 1631 | 7, 16, 9, 20, 11, 24, |
| 1632 | 13, 28, 15, 32, 17, 36}); |
| 1633 | |
| 1634 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 1635 | std::vector<float> input1({ 1, 2 }); |
| 1636 | |
| 1637 | std::vector<float> output({ |
| 1638 | 1, 2, 3, 4, 5, 6, |
| 1639 | 7, 8, 9, 10, 11, 12, |
| 1640 | 13, 14, 15, 16, 17, 18}); |
| 1641 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1642 | return DivisionTestHelper<float>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1643 | memoryManager, |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1644 | shape0, input0, 1.0f, 0, |
| 1645 | shape1, input1, 1.0f, 0, |
| 1646 | shape0, output, 1.0f, 0); |
| 1647 | } |
| 1648 | |
| 1649 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1650 | LayerTestResult<uint8_t,4> DivisionUint8Test( |
| 1651 | armnn::IWorkloadFactory& workloadFactory, |
| 1652 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1653 | { |
| 1654 | const unsigned int width = 2; |
| 1655 | const unsigned int height = 2; |
| 1656 | const unsigned int channelCount = 2; |
| 1657 | const unsigned int batchSize = 2; |
| 1658 | |
| 1659 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1660 | |
| 1661 | std::vector<uint8_t> input0({2, 2, 2, 2, 3, 3, 3, 3, |
| 1662 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 1663 | |
| 1664 | std::vector<uint8_t> input1({1, 1, 1, 1, 2, 2, 2, 2, |
| 1665 | 4, 4, 4, 4, 4, 4, 4, 4 }); |
| 1666 | |
| 1667 | std::vector<uint8_t> output({8, 8, 8, 8, 6, 6, 6, 6, |
| 1668 | 4, 4, 4, 4, 5, 5, 5, 5}); |
| 1669 | |
| 1670 | |
| 1671 | return DivisionTestHelper<uint8_t>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1672 | memoryManager, |
| 1673 | shape, input0, 1.0f, 0, |
| 1674 | shape, input1, 1.0f, 0, |
| 1675 | shape, output, 0.25f, 0); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1676 | } |
| 1677 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1678 | LayerTestResult<uint8_t, 4> DivisionBroadcast1ElementUint8Test( |
| 1679 | armnn::IWorkloadFactory& workloadFactory, |
| 1680 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1681 | { |
| 1682 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 1683 | std::vector<uint8_t> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 1684 | |
| 1685 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 1686 | std::vector<uint8_t> input1({ 2 }); |
| 1687 | |
| 1688 | std::vector<uint8_t> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 1689 | |
| 1690 | return DivisionTestHelper<uint8_t>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1691 | memoryManager, |
| 1692 | shape0, input0, 1.0f, 0, |
| 1693 | shape1, input1, 1.0f, 0, |
| 1694 | shape0, output, 1.0f, 0); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1695 | } |
| 1696 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1697 | LayerTestResult<uint8_t, 4> DivisionBroadcast1DVectorUint8Test( |
| 1698 | armnn::IWorkloadFactory& workloadFactory, |
| 1699 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1700 | { |
| 1701 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 1702 | std::vector<uint8_t> input0({1, 4, 3, 8, 5, 12, |
| 1703 | 7, 16, 9, 20, 11, 24, |
| 1704 | 13, 28, 15, 32, 17, 36}); |
| 1705 | |
| 1706 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 1707 | std::vector<uint8_t> input1({ 1, 2 }); |
| 1708 | |
| 1709 | std::vector<uint8_t> output({1, 2, 3, 4, 5, 6, |
| 1710 | 7, 8, 9, 10, 11, 12, |
| 1711 | 13, 14, 15, 16, 17, 18}); |
| 1712 | |
| 1713 | return DivisionTestHelper<uint8_t>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1714 | memoryManager, |
| 1715 | shape0, input0, 1.0f, 0, |
| 1716 | shape1, input1, 1.0f, 0, |
| 1717 | shape0, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1718 | } |
| 1719 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 1720 | template<typename DescriptorType> |
| 1721 | std::unique_ptr<armnn::IWorkload> CreateWorkload( |
| 1722 | const armnn::IWorkloadFactory& workloadFactory, |
| 1723 | const armnn::WorkloadInfo& info, |
| 1724 | const DescriptorType& descriptor) |
| 1725 | { |
| 1726 | return CreateWorkload(workloadFactory, info, descriptor); |
| 1727 | }; |
| 1728 | |
| 1729 | template<> |
| 1730 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MaximumQueueDescriptor>( |
| 1731 | const armnn::IWorkloadFactory& workloadFactory, |
| 1732 | const armnn::WorkloadInfo& info, |
| 1733 | const armnn::MaximumQueueDescriptor& descriptor) |
| 1734 | { |
| 1735 | return workloadFactory.CreateMaximum(descriptor, info); |
| 1736 | } |
| 1737 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1738 | template<> |
| 1739 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>( |
| 1740 | const armnn::IWorkloadFactory& workloadFactory, |
| 1741 | const armnn::WorkloadInfo& info, |
| 1742 | const armnn::MinimumQueueDescriptor& descriptor) |
| 1743 | { |
| 1744 | return workloadFactory.CreateMinimum(descriptor, info); |
| 1745 | } |
| 1746 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 1747 | template<> |
| 1748 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::EqualQueueDescriptor>( |
| 1749 | const armnn::IWorkloadFactory& workloadFactory, |
| 1750 | const armnn::WorkloadInfo& info, |
| 1751 | const armnn::EqualQueueDescriptor& descriptor) |
| 1752 | { |
| 1753 | return workloadFactory.CreateEqual(descriptor, info); |
| 1754 | } |
| 1755 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1756 | template<> |
| 1757 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::GreaterQueueDescriptor>( |
| 1758 | const armnn::IWorkloadFactory& workloadFactory, |
| 1759 | const armnn::WorkloadInfo& info, |
| 1760 | const armnn::GreaterQueueDescriptor& descriptor) |
| 1761 | { |
| 1762 | return workloadFactory.CreateGreater(descriptor, info); |
| 1763 | } |
| 1764 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 1765 | namespace { |
| 1766 | template <typename Descriptor, typename dataType> |
| 1767 | LayerTestResult<dataType, 4> ElementwiseTestHelper |
| 1768 | (armnn::IWorkloadFactory & workloadFactory, |
| 1769 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager, |
| 1770 | const unsigned int shape0[4], std::vector<dataType> values0, |
| 1771 | const unsigned int shape1[4], std::vector<dataType> values1, |
| 1772 | const unsigned int outShape[4], std::vector<dataType> outValues, |
| 1773 | float qScale = 0.0f, int qOffset = 0) |
| 1774 | { |
| 1775 | const size_t dimensionCount = 4; |
| 1776 | armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::GetDataType<dataType>()}; |
| 1777 | armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::GetDataType<dataType>()}; |
| 1778 | armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::GetDataType<dataType>()}; |
| 1779 | |
| 1780 | auto input0 = MakeTensor<dataType, 4>(inputTensorInfo0, values0); |
| 1781 | auto input1 = MakeTensor<dataType, 4>(inputTensorInfo1, values1); |
| 1782 | |
| 1783 | if (armnn::IsQuantizedType<dataType>()) |
| 1784 | { |
| 1785 | inputTensorInfo0.SetQuantizationScale(qScale); |
| 1786 | inputTensorInfo0.SetQuantizationOffset(qOffset); |
| 1787 | |
| 1788 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 1789 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
| 1790 | |
| 1791 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1792 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1793 | } |
| 1794 | |
| 1795 | LayerTestResult<dataType,4> ret(outputTensorInfo); |
| 1796 | |
| 1797 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 1798 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1799 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1800 | |
| 1801 | Descriptor data; |
| 1802 | armnn::WorkloadInfo info; |
| 1803 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 1804 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1805 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1806 | auto workload = CreateWorkload<Descriptor>(workloadFactory, info, data); |
| 1807 | |
| 1808 | inputHandle0->Allocate(); |
| 1809 | inputHandle1->Allocate(); |
| 1810 | outputHandle->Allocate(); |
| 1811 | |
| 1812 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 1813 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1814 | |
| 1815 | ExecuteWorkload(*workload, memoryManager); |
| 1816 | |
| 1817 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1818 | |
| 1819 | ret.outputExpected = MakeTensor<dataType, 4>(outputTensorInfo, outValues); |
| 1820 | return ret; |
| 1821 | } |
| 1822 | } |
| 1823 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 1824 | LayerTestResult<float, 4> EqualSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
| 1825 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1826 | { |
| 1827 | const unsigned int width = 2; |
| 1828 | const unsigned int height = 2; |
| 1829 | const unsigned int channelCount = 2; |
| 1830 | const unsigned int batchSize = 2; |
| 1831 | |
| 1832 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1833 | |
| 1834 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 1835 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 1836 | |
| 1837 | std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3, |
| 1838 | 5, 5, 5, 5, 4, 4, 4, 4 }); |
| 1839 | |
| 1840 | std::vector<float> output({ 1, 1, 1, 1, 0, 0, 0, 0, |
| 1841 | 0, 0, 0, 0, 1, 1, 1, 1 }); |
| 1842 | |
| 1843 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float> |
| 1844 | (workloadFactory, |
| 1845 | memoryManager, |
| 1846 | shape, |
| 1847 | input0, |
| 1848 | shape, |
| 1849 | input1, |
| 1850 | shape, |
| 1851 | output); |
| 1852 | } |
| 1853 | |
| 1854 | LayerTestResult<float, 4> EqualBroadcast1ElementTest( |
| 1855 | armnn::IWorkloadFactory& workloadFactory, |
| 1856 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1857 | { |
| 1858 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 1859 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 1860 | |
| 1861 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 1862 | std::vector<float> input1({ 1 }); |
| 1863 | |
| 1864 | std::vector<float> output({ 1, 0, 0, 0, 0, 0, 0, 0}); |
| 1865 | |
| 1866 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float> |
| 1867 | (workloadFactory, |
| 1868 | memoryManager, |
| 1869 | shape0, |
| 1870 | input0, |
| 1871 | shape1, |
| 1872 | input1, |
| 1873 | shape0, |
| 1874 | output); |
| 1875 | } |
| 1876 | |
| 1877 | LayerTestResult<float, 4> EqualBroadcast1DVectorTest( |
| 1878 | armnn::IWorkloadFactory& workloadFactory, |
| 1879 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1880 | { |
| 1881 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 1882 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 1883 | |
| 1884 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, |
| 1885 | 7, 8, 9, 10, 11, 12 }); |
| 1886 | |
| 1887 | std::vector<float> input1({ 1, 2, 3}); |
| 1888 | |
| 1889 | std::vector<float> output({ 1, 1, 1, 0, 0, 0, |
| 1890 | 0, 0, 0, 0, 0, 0 }); |
| 1891 | |
| 1892 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, float> |
| 1893 | (workloadFactory, |
| 1894 | memoryManager, |
| 1895 | shape0, |
| 1896 | input0, |
| 1897 | shape1, |
| 1898 | input1, |
| 1899 | shape0, |
| 1900 | output); |
| 1901 | } |
| 1902 | |
| 1903 | LayerTestResult<uint8_t, 4> EqualUint8Test( |
| 1904 | armnn::IWorkloadFactory& workloadFactory, |
| 1905 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1906 | { |
| 1907 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 1908 | |
| 1909 | // See dequantized values to the right. |
| 1910 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 1911 | 3, 3, 3, 3, 5, 5, 5, 5 }); |
| 1912 | |
| 1913 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 1914 | 3, 3, 3, 3, 5, 5, 5, 5 }); |
| 1915 | |
| 1916 | std::vector<uint8_t> output({ 0, 0, 0, 0, 1, 1, 1, 1, |
| 1917 | 1, 1, 1, 1, 0, 0, 0, 0 }); |
| 1918 | |
| 1919 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t > |
| 1920 | (workloadFactory, |
| 1921 | memoryManager, |
| 1922 | shape, |
| 1923 | input0, |
| 1924 | shape, |
| 1925 | input1, |
| 1926 | shape, |
| 1927 | output, |
| 1928 | 1.0f, |
| 1929 | 0); |
| 1930 | } |
| 1931 | |
| 1932 | LayerTestResult<uint8_t, 4> EqualBroadcast1ElementUint8Test( |
| 1933 | armnn::IWorkloadFactory& workloadFactory, |
| 1934 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1935 | { |
| 1936 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 1937 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 1938 | |
| 1939 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 1940 | 7, 8, 9, 10, 11, 12 }); |
| 1941 | |
| 1942 | std::vector<uint8_t> input1({ 1 }); |
| 1943 | |
| 1944 | std::vector<uint8_t> output({ 1, 0, 0, 0, 0, 0, |
| 1945 | 0, 0, 0, 0, 0, 0 }); |
| 1946 | |
| 1947 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t > |
| 1948 | (workloadFactory, |
| 1949 | memoryManager, |
| 1950 | shape0, |
| 1951 | input0, |
| 1952 | shape1, |
| 1953 | input1, |
| 1954 | shape0, |
| 1955 | output, |
| 1956 | 1.0f, |
| 1957 | 0); |
| 1958 | } |
| 1959 | |
| 1960 | LayerTestResult<uint8_t, 4> EqualBroadcast1DVectorUint8Test( |
| 1961 | armnn::IWorkloadFactory& workloadFactory, |
| 1962 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1963 | { |
| 1964 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 1965 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 1966 | |
| 1967 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 1968 | 7, 8, 9, 10, 11, 12 }); |
| 1969 | |
| 1970 | std::vector<uint8_t> input1({ 1, 1, 3}); |
| 1971 | |
| 1972 | std::vector<uint8_t> output({ 1, 0, 1, 0, 0, 0, |
| 1973 | 0, 0, 0, 0, 0, 0 }); |
| 1974 | |
| 1975 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, uint8_t> |
| 1976 | (workloadFactory, |
| 1977 | memoryManager, |
| 1978 | shape0, |
| 1979 | input0, |
| 1980 | shape1, |
| 1981 | input1, |
| 1982 | shape0, |
| 1983 | output, |
| 1984 | 1.0f, |
| 1985 | 0); |
| 1986 | } |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 1987 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 1988 | LayerTestResult<float, 4> GreaterSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
| 1989 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1990 | { |
| 1991 | const unsigned int width = 2; |
| 1992 | const unsigned int height = 2; |
| 1993 | const unsigned int channelCount = 2; |
| 1994 | const unsigned int batchSize = 2; |
| 1995 | |
| 1996 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1997 | |
| 1998 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 1999 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2000 | |
| 2001 | std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3, |
| 2002 | 5, 5, 5, 5, 4, 4, 4, 4 }); |
| 2003 | |
| 2004 | std::vector<float> output({ 0, 0, 0, 0, 1, 1, 1, 1, |
| 2005 | 0, 0, 0, 0, 0, 0, 0, 0 }); |
| 2006 | |
| 2007 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float> |
| 2008 | (workloadFactory, |
| 2009 | memoryManager, |
| 2010 | shape, |
| 2011 | input0, |
| 2012 | shape, |
| 2013 | input1, |
| 2014 | shape, |
| 2015 | output); |
| 2016 | } |
| 2017 | |
| 2018 | LayerTestResult<float, 4> GreaterBroadcast1ElementTest( |
| 2019 | armnn::IWorkloadFactory& workloadFactory, |
| 2020 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2021 | { |
| 2022 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2023 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2024 | |
| 2025 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2026 | std::vector<float> input1({ 1 }); |
| 2027 | |
| 2028 | std::vector<float> output({ 0, 1, 1, 1, 1, 1, 1, 1}); |
| 2029 | |
| 2030 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float> |
| 2031 | (workloadFactory, |
| 2032 | memoryManager, |
| 2033 | shape0, |
| 2034 | input0, |
| 2035 | shape1, |
| 2036 | input1, |
| 2037 | shape0, |
| 2038 | output); |
| 2039 | } |
| 2040 | |
| 2041 | LayerTestResult<float, 4> GreaterBroadcast1DVectorTest( |
| 2042 | armnn::IWorkloadFactory& workloadFactory, |
| 2043 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2044 | { |
| 2045 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2046 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2047 | |
| 2048 | std::vector<float> input0({ 1, 2.9f, 2.1f, 4, 5, 6, |
| 2049 | 7, 8, 9, 10, 11, 12 }); |
| 2050 | |
| 2051 | std::vector<float> input1({ 1, 3, 2}); |
| 2052 | |
| 2053 | std::vector<float> output({ 0, 0, 1, 1, 1, 1, |
| 2054 | 1, 1, 1, 1, 1, 1 }); |
| 2055 | |
| 2056 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, float> |
| 2057 | (workloadFactory, |
| 2058 | memoryManager, |
| 2059 | shape0, |
| 2060 | input0, |
| 2061 | shape1, |
| 2062 | input1, |
| 2063 | shape0, |
| 2064 | output); |
| 2065 | } |
| 2066 | |
| 2067 | LayerTestResult<uint8_t, 4> GreaterUint8Test( |
| 2068 | armnn::IWorkloadFactory& workloadFactory, |
| 2069 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2070 | { |
| 2071 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2072 | |
| 2073 | // See dequantized values to the right. |
| 2074 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2075 | 3, 3, 3, 3, 5, 5, 5, 5 }); |
| 2076 | |
| 2077 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2078 | 2, 2, 2, 2, 5, 5, 5, 5 }); |
| 2079 | |
| 2080 | std::vector<uint8_t> output({ 0, 0, 0, 0, 0, 0, 0, 0, |
| 2081 | 1, 1, 1, 1, 0, 0, 0, 0 }); |
| 2082 | |
| 2083 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t > |
| 2084 | (workloadFactory, |
| 2085 | memoryManager, |
| 2086 | shape, |
| 2087 | input0, |
| 2088 | shape, |
| 2089 | input1, |
| 2090 | shape, |
| 2091 | output, |
| 2092 | 1.0f, |
| 2093 | 0); |
| 2094 | } |
| 2095 | |
| 2096 | LayerTestResult<uint8_t, 4> GreaterBroadcast1ElementUint8Test( |
| 2097 | armnn::IWorkloadFactory& workloadFactory, |
| 2098 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2099 | { |
| 2100 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2101 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2102 | |
| 2103 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2104 | 7, 8, 9, 10, 11, 12 }); |
| 2105 | |
| 2106 | std::vector<uint8_t> input1({ 1 }); |
| 2107 | |
| 2108 | std::vector<uint8_t> output({ 0, 1, 1, 1, 1, 1, |
| 2109 | 1, 1, 1, 1, 1, 1 }); |
| 2110 | |
| 2111 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t > |
| 2112 | (workloadFactory, |
| 2113 | memoryManager, |
| 2114 | shape0, |
| 2115 | input0, |
| 2116 | shape1, |
| 2117 | input1, |
| 2118 | shape0, |
| 2119 | output, |
| 2120 | 1.0f, |
| 2121 | 0); |
| 2122 | } |
| 2123 | |
| 2124 | LayerTestResult<uint8_t, 4> GreaterBroadcast1DVectorUint8Test( |
| 2125 | armnn::IWorkloadFactory& workloadFactory, |
| 2126 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2127 | { |
| 2128 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2129 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2130 | |
| 2131 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2132 | 7, 8, 9, 10, 11, 12 }); |
| 2133 | |
| 2134 | std::vector<uint8_t> input1({ 1, 1, 3}); |
| 2135 | |
| 2136 | std::vector<uint8_t> output({ 0, 1, 0, 1, 1, 1, |
| 2137 | 1, 1, 1, 1, 1, 1 }); |
| 2138 | |
| 2139 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, uint8_t> |
| 2140 | (workloadFactory, |
| 2141 | memoryManager, |
| 2142 | shape0, |
| 2143 | input0, |
| 2144 | shape1, |
| 2145 | input1, |
| 2146 | shape0, |
| 2147 | output, |
| 2148 | 1.0f, |
| 2149 | 0); |
| 2150 | } |
| 2151 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2152 | LayerTestResult<float, 4> MaximumSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
| 2153 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2154 | { |
| 2155 | const unsigned int width = 2; |
| 2156 | const unsigned int height = 2; |
| 2157 | const unsigned int channelCount = 2; |
| 2158 | const unsigned int batchSize = 2; |
| 2159 | |
| 2160 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2161 | |
| 2162 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 2163 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2164 | |
| 2165 | std::vector<float> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2166 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2167 | |
| 2168 | std::vector<float> output({ 2, 2, 2, 2, 5, 5, 5, 5, |
| 2169 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2170 | |
| 2171 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float> |
| 2172 | (workloadFactory, |
| 2173 | memoryManager, |
| 2174 | shape, |
| 2175 | input0, |
| 2176 | shape, |
| 2177 | input1, |
| 2178 | shape, |
| 2179 | output); |
| 2180 | } |
| 2181 | |
| 2182 | LayerTestResult<float, 4> MaximumBroadcast1ElementTest( |
| 2183 | armnn::IWorkloadFactory& workloadFactory, |
| 2184 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2185 | { |
| 2186 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2187 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2188 | |
| 2189 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2190 | std::vector<float> input1({ 2 }); |
| 2191 | |
| 2192 | std::vector<float> output({ 2, 2, 3, 4, 5, 6, 7, 8}); |
| 2193 | |
| 2194 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float> |
| 2195 | (workloadFactory, |
| 2196 | memoryManager, |
| 2197 | shape0, |
| 2198 | input0, |
| 2199 | shape1, |
| 2200 | input1, |
| 2201 | shape0, |
| 2202 | output); |
| 2203 | } |
| 2204 | |
| 2205 | LayerTestResult<float, 4> MaximumBroadcast1DVectorTest( |
| 2206 | armnn::IWorkloadFactory& workloadFactory, |
| 2207 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2208 | { |
| 2209 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2210 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2211 | |
| 2212 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, |
| 2213 | 7, 8, 9, 10, 11, 12 }); |
| 2214 | |
| 2215 | std::vector<float> input1({ 1, 2, 3}); |
| 2216 | |
| 2217 | std::vector<float> output({ 1, 2, 3, 4, 5, 6, |
| 2218 | 7, 8, 9, 10, 11, 12 }); |
| 2219 | |
| 2220 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, float> |
| 2221 | (workloadFactory, |
| 2222 | memoryManager, |
| 2223 | shape0, |
| 2224 | input0, |
| 2225 | shape1, |
| 2226 | input1, |
| 2227 | shape0, |
| 2228 | output); |
| 2229 | } |
| 2230 | |
| 2231 | LayerTestResult<uint8_t, 4> MaximumUint8Test( |
| 2232 | armnn::IWorkloadFactory& workloadFactory, |
| 2233 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2234 | { |
| 2235 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2236 | |
| 2237 | // See dequantized values to the right. |
| 2238 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2239 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2240 | |
| 2241 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2242 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2243 | |
| 2244 | std::vector<uint8_t> output({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2245 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2246 | |
| 2247 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t > |
| 2248 | (workloadFactory, |
| 2249 | memoryManager, |
| 2250 | shape, |
| 2251 | input0, |
| 2252 | shape, |
| 2253 | input1, |
| 2254 | shape, |
| 2255 | output, |
| 2256 | 1.0f, |
| 2257 | 0); |
| 2258 | } |
| 2259 | |
| 2260 | LayerTestResult<uint8_t, 4> MaximumBroadcast1ElementUint8Test( |
| 2261 | armnn::IWorkloadFactory& workloadFactory, |
| 2262 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2263 | { |
| 2264 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2265 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2266 | |
| 2267 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2268 | 7, 8, 9, 10, 11, 12 }); |
| 2269 | |
| 2270 | std::vector<uint8_t> input1({2}); |
| 2271 | |
| 2272 | std::vector<uint8_t> output({ 2, 2, 3, 4, 5, 6, |
| 2273 | 7, 8, 9, 10, 11, 12 }); |
| 2274 | |
| 2275 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t > |
| 2276 | (workloadFactory, |
| 2277 | memoryManager, |
| 2278 | shape0, |
| 2279 | input0, |
| 2280 | shape1, |
| 2281 | input1, |
| 2282 | shape0, |
| 2283 | output, |
| 2284 | 1.0f, |
| 2285 | 0); |
| 2286 | } |
| 2287 | |
| 2288 | LayerTestResult<uint8_t, 4> MaximumBroadcast1DVectorUint8Test( |
| 2289 | armnn::IWorkloadFactory& workloadFactory, |
| 2290 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2291 | { |
| 2292 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2293 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2294 | |
| 2295 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2296 | 7, 8, 9, 10, 11, 12 }); |
| 2297 | |
| 2298 | std::vector<uint8_t> input1({ 1, 10, 3}); |
| 2299 | |
| 2300 | std::vector<uint8_t> output({ 1, 10, 3, 4, 10, 6, |
| 2301 | 7, 10, 9, 10, 11, 12 }); |
| 2302 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2303 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, uint8_t> |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2304 | (workloadFactory, |
| 2305 | memoryManager, |
| 2306 | shape0, |
| 2307 | input0, |
| 2308 | shape1, |
| 2309 | input1, |
| 2310 | shape0, |
| 2311 | output, |
| 2312 | 1.0f, |
| 2313 | 0); |
| 2314 | } |
| 2315 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2316 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest1( |
| 2317 | armnn::IWorkloadFactory& workloadFactory, |
| 2318 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2319 | { |
| 2320 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2321 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2322 | |
| 2323 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2324 | std::vector<float> input1({ 2 }); |
| 2325 | |
| 2326 | std::vector<float> output({ 1, 2, 2, 2, 2, 2, 2, 2}); |
| 2327 | |
| 2328 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, float>(workloadFactory, |
| 2329 | memoryManager, |
| 2330 | shape0, |
| 2331 | input0, |
| 2332 | shape1, |
| 2333 | input1, |
| 2334 | shape0, |
| 2335 | output); |
| 2336 | } |
| 2337 | |
| 2338 | |
| 2339 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest2( |
| 2340 | armnn::IWorkloadFactory& workloadFactory, |
| 2341 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2342 | { |
| 2343 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2344 | std::vector<float> input0({ 1, 6, 3, 2, 8, 9, 1, 10}); |
| 2345 | |
| 2346 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2347 | std::vector<float> input1({ 5 }); |
| 2348 | |
| 2349 | std::vector<float> output({ 1, 5, 3, 2, 5, 5, 1, 5}); |
| 2350 | |
| 2351 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, float>(workloadFactory, |
| 2352 | memoryManager, |
| 2353 | shape0, |
| 2354 | input0, |
| 2355 | shape1, |
| 2356 | input1, |
| 2357 | shape0, |
| 2358 | output); |
| 2359 | } |
| 2360 | |
| 2361 | LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test( |
| 2362 | armnn::IWorkloadFactory & workloadFactory, |
| 2363 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager) |
| 2364 | { |
| 2365 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2366 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2367 | |
| 2368 | std::vector<uint8_t> input0({ 1, 2, 3, 3, 2, 1, |
| 2369 | 7, 1, 2, 3, 4, 5 }); |
| 2370 | |
| 2371 | std::vector<uint8_t> input1({ 1, 2, 3}); |
| 2372 | |
| 2373 | std::vector<uint8_t> output({ 1, 2, 3, 1, 2, 1, |
| 2374 | 1, 1, 2, 1, 2, 3 }); |
| 2375 | |
| 2376 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, uint8_t>(workloadFactory, |
| 2377 | memoryManager, |
| 2378 | shape0, |
| 2379 | input0, |
| 2380 | shape1, |
| 2381 | input1, |
| 2382 | shape0, |
| 2383 | output, |
| 2384 | 1.0f, |
| 2385 | 0); |
| 2386 | } |
| 2387 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 2388 | namespace { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2389 | LayerTestResult<float,4> MultiplicationTestHelper( |
| 2390 | armnn::IWorkloadFactory& workloadFactory, |
| 2391 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2392 | const unsigned int shape0[4], |
| 2393 | const std::vector<float> & values0, |
| 2394 | const unsigned int shape1[4], |
| 2395 | const std::vector<float> & values1, |
| 2396 | const unsigned int outShape[4], |
| 2397 | const std::vector<float> & outValues) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2398 | { |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2399 | const size_t dimensionCount = 4; |
| 2400 | armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::DataType::Float32}; |
| 2401 | armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::DataType::Float32}; |
| 2402 | armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::DataType::Float32}; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2403 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2404 | auto input0 = MakeTensor<float, 4>(inputTensorInfo0, values0); |
| 2405 | auto input1 = MakeTensor<float, 4>(inputTensorInfo1, values1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2406 | |
| 2407 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 2408 | |
| 2409 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 2410 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 2411 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2412 | |
| 2413 | armnn::MultiplicationQueueDescriptor data; |
| 2414 | armnn::WorkloadInfo info; |
| 2415 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 2416 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2417 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2418 | |
| 2419 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 2420 | |
| 2421 | inputHandle0->Allocate(); |
| 2422 | inputHandle1->Allocate(); |
| 2423 | outputHandle->Allocate(); |
| 2424 | |
| 2425 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 2426 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 2427 | |
| 2428 | workload->Execute(); |
| 2429 | |
| 2430 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 2431 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2432 | ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outValues); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2433 | return ret; |
| 2434 | } |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2435 | } // anonymous namespace |
| 2436 | |
| 2437 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2438 | LayerTestResult<float,4> MultiplicationTest( |
| 2439 | armnn::IWorkloadFactory& workloadFactory, |
| 2440 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2441 | { |
| 2442 | const unsigned int width = 2; |
| 2443 | const unsigned int height = 2; |
| 2444 | const unsigned int channelCount = 2; |
| 2445 | const unsigned int batchSize = 2; |
| 2446 | |
| 2447 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2448 | |
| 2449 | std::vector<float> input0({ |
| 2450 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 2451 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2452 | |
| 2453 | std::vector<float> input1({ |
| 2454 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 2455 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2456 | |
| 2457 | std::vector<float> output({ |
| 2458 | 2, 2, 2, 2, 6, 6, 6, 6, |
| 2459 | 12, 12, 12, 12, 20, 20, 20, 20 }); |
| 2460 | |
| 2461 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2462 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2463 | shape, |
| 2464 | input0, |
| 2465 | shape, |
| 2466 | input1, |
| 2467 | shape, |
| 2468 | output); |
| 2469 | } |
| 2470 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2471 | LayerTestResult<float, 4> MultiplicationBroadcast1ElementTest( |
| 2472 | armnn::IWorkloadFactory& workloadFactory, |
| 2473 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2474 | { |
| 2475 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2476 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2477 | |
| 2478 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2479 | std::vector<float> input1({ 2 }); |
| 2480 | |
| 2481 | std::vector<float> output({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 2482 | |
| 2483 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2484 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2485 | shape0, |
| 2486 | input0, |
| 2487 | shape1, |
| 2488 | input1, |
| 2489 | shape0, |
| 2490 | output); |
| 2491 | } |
| 2492 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2493 | LayerTestResult<float, 4> MultiplicationBroadcast1DVectorTest( |
| 2494 | armnn::IWorkloadFactory& workloadFactory, |
| 2495 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2496 | { |
| 2497 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 2498 | std::vector<float> input0({ |
| 2499 | 1, 2, 3, 4, 5, 6, |
| 2500 | 7, 8, 9, 10, 11, 12, |
| 2501 | 13, 14, 15, 16, 17, 18}); |
| 2502 | |
| 2503 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 2504 | std::vector<float> input1({ 1, 2 }); |
| 2505 | |
| 2506 | std::vector<float> output({ |
| 2507 | 1, 4, 3, 8, 5, 12, |
| 2508 | 7, 16, 9, 20, 11, 24, |
| 2509 | 13, 28, 15, 32, 17, 36}); |
| 2510 | |
| 2511 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2512 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 2513 | shape0, |
| 2514 | input0, |
| 2515 | shape1, |
| 2516 | input1, |
| 2517 | shape0, |
| 2518 | output); |
| 2519 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2520 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2521 | LayerTestResult<float,4> CompareMultiplicationTest( |
| 2522 | armnn::IWorkloadFactory& workloadFactory, |
| 2523 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2524 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2525 | { |
| 2526 | const unsigned int width = 16; |
| 2527 | const unsigned int height = 32; |
| 2528 | const unsigned int channelCount = 2; |
| 2529 | const unsigned int batchSize = 5; |
| 2530 | |
| 2531 | armnn::TensorInfo inputTensorInfo0; |
| 2532 | armnn::TensorInfo inputTensorInfo1; |
| 2533 | armnn::TensorInfo outputTensorInfo; |
| 2534 | |
| 2535 | constexpr unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2536 | |
| 2537 | inputTensorInfo0 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 2538 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 2539 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 2540 | |
| 2541 | LayerTestResult<float,4> comparisonResult(outputTensorInfo); |
| 2542 | |
| 2543 | auto input0 = MakeRandomTensor<float, 4>(inputTensorInfo0, 803506992); |
| 2544 | auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 54902257); |
| 2545 | |
| 2546 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 2547 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 2548 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2549 | |
| 2550 | std::unique_ptr<armnn::ITensorHandle> inputHandle0Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 2551 | std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 2552 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2553 | |
| 2554 | armnn::MultiplicationQueueDescriptor data; |
| 2555 | armnn::WorkloadInfo info; |
| 2556 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 2557 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2558 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2559 | |
| 2560 | armnn::MultiplicationQueueDescriptor refData = data; |
| 2561 | armnn::WorkloadInfo refInfo = info; |
| 2562 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo0, inputHandle0Ref.get()); |
| 2563 | SetWorkloadInput(refData, refInfo, 1, inputTensorInfo1, inputHandle1Ref.get()); |
| 2564 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 2565 | |
| 2566 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 2567 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateMultiplication(refData, refInfo); |
| 2568 | |
| 2569 | inputHandle0->Allocate(); |
| 2570 | inputHandle1->Allocate(); |
| 2571 | outputHandle->Allocate(); |
| 2572 | inputHandle0Ref->Allocate(); |
| 2573 | inputHandle1Ref->Allocate(); |
| 2574 | outputHandleRef->Allocate(); |
| 2575 | |
| 2576 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 2577 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 2578 | CopyDataToITensorHandle(inputHandle0Ref.get(), &input0[0][0][0][0]); |
| 2579 | CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]); |
| 2580 | |
| 2581 | workload->Execute(); |
| 2582 | workloadRef->Execute(); |
| 2583 | |
| 2584 | CopyDataFromITensorHandle(&comparisonResult.output[0][0][0][0], outputHandle.get()); |
| 2585 | CopyDataFromITensorHandle(&comparisonResult.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 2586 | |
| 2587 | return comparisonResult; |
| 2588 | } |
| 2589 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2590 | LayerTestResult<float,4> CompareBatchNormTest( |
| 2591 | armnn::IWorkloadFactory& workloadFactory, |
| 2592 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2593 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2594 | { |
| 2595 | const unsigned int width = 2; |
| 2596 | const unsigned int height = 3; |
| 2597 | const unsigned int channels = 5; |
| 2598 | const unsigned int batchSize = 3; |
| 2599 | |
| 2600 | armnn::TensorInfo inputTensorInfo; |
| 2601 | armnn::TensorInfo outputTensorInfo; |
| 2602 | armnn::TensorInfo tensorInfo; |
| 2603 | |
| 2604 | constexpr unsigned int shape[] = {batchSize, channels, height, width}; |
| 2605 | constexpr unsigned int tensorShape[] = {channels}; |
| 2606 | |
| 2607 | inputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 2608 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 2609 | tensorInfo = armnn::TensorInfo(1, tensorShape, armnn::DataType::Float32); |
| 2610 | |
| 2611 | auto input = MakeRandomTensor<float, 4>(inputTensorInfo, 21312); |
| 2612 | |
| 2613 | auto mean = MakeRandomTensor<float, 1>(tensorInfo, 123); |
| 2614 | auto variance = MakeRandomTensor<float, 1>(tensorInfo, 234, 0.0f); |
| 2615 | auto beta = MakeRandomTensor<float, 1>(tensorInfo, 123); |
| 2616 | auto gamma = MakeRandomTensor<float, 1>(tensorInfo, 345); |
| 2617 | |
| 2618 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 2619 | |
| 2620 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 2621 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2622 | |
| 2623 | std::unique_ptr<armnn::ITensorHandle> inputHandleRef = refWorkloadFactory.CreateTensorHandle(inputTensorInfo); |
| 2624 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2625 | |
| 2626 | armnn::BatchNormalizationQueueDescriptor data; |
| 2627 | armnn::WorkloadInfo info; |
| 2628 | armnn::ScopedCpuTensorHandle meanTensor(tensorInfo); |
| 2629 | armnn::ScopedCpuTensorHandle varianceTensor(tensorInfo); |
| 2630 | armnn::ScopedCpuTensorHandle betaTensor(tensorInfo); |
| 2631 | armnn::ScopedCpuTensorHandle gammaTensor(tensorInfo); |
| 2632 | |
| 2633 | AllocateAndCopyDataToITensorHandle(&meanTensor, &mean[0]); |
| 2634 | AllocateAndCopyDataToITensorHandle(&varianceTensor, &variance[0]); |
| 2635 | AllocateAndCopyDataToITensorHandle(&betaTensor, &beta[0]); |
| 2636 | AllocateAndCopyDataToITensorHandle(&gammaTensor, &gamma[0]); |
| 2637 | |
| 2638 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 2639 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2640 | data.m_Mean = &meanTensor; |
| 2641 | data.m_Variance = &varianceTensor; |
| 2642 | data.m_Beta = &betaTensor; |
| 2643 | data.m_Gamma = &gammaTensor; |
| 2644 | data.m_Parameters.m_Eps = 0.01f; |
| 2645 | |
| 2646 | armnn::BatchNormalizationQueueDescriptor refData = data; |
| 2647 | armnn::WorkloadInfo refInfo = info; |
| 2648 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get()); |
| 2649 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 2650 | |
| 2651 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchNormalization(data, info); |
| 2652 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateBatchNormalization(refData, refInfo); |
| 2653 | |
| 2654 | inputHandle->Allocate(); |
| 2655 | outputHandle->Allocate(); |
| 2656 | inputHandleRef->Allocate(); |
| 2657 | outputHandleRef->Allocate(); |
| 2658 | |
| 2659 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 2660 | CopyDataToITensorHandle(inputHandleRef.get(), &input[0][0][0][0]); |
| 2661 | |
| 2662 | workload->Execute(); |
| 2663 | workloadRef->Execute(); |
| 2664 | |
| 2665 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 2666 | CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 2667 | |
| 2668 | return ret; |
| 2669 | } |
| 2670 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2671 | template<typename T> |
| 2672 | void PermuteTensorData( |
| 2673 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2674 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2675 | const armnn::PermutationVector& mappings, |
| 2676 | armnn::TensorInfo & inputTensorInfo, |
| 2677 | const T * inputData, |
| 2678 | std::vector<T>& outputData) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2679 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2680 | BOOST_ASSERT_MSG(inputData != nullptr, "inputData must not be null"); |
| 2681 | if (inputData == nullptr) |
| 2682 | { |
| 2683 | // Nullptr is an error in the test. By returning without doing the concatenation |
| 2684 | // I expect the caller to fail the test. It still makes sense to report this as |
| 2685 | // an assert for Debug builds. |
| 2686 | return; |
| 2687 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2688 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2689 | armnn::TensorInfo outputTensorInfo = armnnUtils::Permuted(inputTensorInfo, mappings); |
| 2690 | |
| 2691 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 2692 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2693 | |
| 2694 | armnn::PermuteQueueDescriptor queueDescriptor; |
| 2695 | queueDescriptor.m_Parameters = armnn::PermuteDescriptor{mappings}; |
| 2696 | armnn::WorkloadInfo workloadInfo; |
| 2697 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get()); |
| 2698 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 2699 | |
| 2700 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePermute(queueDescriptor, workloadInfo); |
| 2701 | |
| 2702 | inputHandle->Allocate(); |
| 2703 | outputHandle->Allocate(); |
| 2704 | |
| 2705 | CopyDataToITensorHandle(inputHandle.get(), inputData); |
| 2706 | |
| 2707 | workload->Execute(); |
| 2708 | |
| 2709 | outputData.resize(outputTensorInfo.GetNumElements()); |
| 2710 | CopyDataFromITensorHandle(&outputData[0], outputHandle.get()); |
| 2711 | inputTensorInfo = outputTensorInfo; |
| 2712 | } |
| 2713 | |
| 2714 | armnn::OriginsDescriptor CreateMergerDescriptorForConcatenation( |
| 2715 | const std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 2716 | unsigned int concatDim) |
| 2717 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2718 | std::vector<armnn::TensorShape> shapes; |
| 2719 | shapes.reserve(inputTensorInfos.size()); |
| 2720 | for (const armnn::TensorInfo& it: inputTensorInfos) |
| 2721 | { |
| 2722 | shapes.push_back(it.GetShape()); |
| 2723 | } |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2724 | |
| 2725 | return armnn::CreateMergerDescriptorForConcatenation(shapes.begin(), |
| 2726 | shapes.end(), |
| 2727 | concatDim); |
| 2728 | } |
| 2729 | |
| 2730 | // |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2731 | // Concatenation is only supported for N and C dimensions for NCHW and the inner most dimension |
| 2732 | // In case of <4 dimensions we need to make sure that the concat dimensions are at least |
| 2733 | // the 3rd slowest iterating one or the inner most dimension. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2734 | // |
| 2735 | |
| 2736 | bool NeedPermuteForConcat( |
| 2737 | const std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 2738 | unsigned int concatDim) |
| 2739 | { |
| 2740 | // See note above. Additionally we expect the input shapes to have the |
| 2741 | // same number of dimensions. |
| 2742 | unsigned int nDimensions = 0; |
| 2743 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2744 | // Determine the number of dimensions as well as sanity check them |
| 2745 | // agains test implementation issues. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2746 | for (auto && tensorInfo : inputTensorInfos) |
| 2747 | { |
| 2748 | if (!nDimensions) |
| 2749 | { |
| 2750 | nDimensions = tensorInfo.GetShape().GetNumDimensions(); |
| 2751 | } |
| 2752 | else |
| 2753 | { |
| 2754 | BOOST_ASSERT_MSG(nDimensions == tensorInfo.GetShape().GetNumDimensions(), |
| 2755 | "Input shapes must have the same number of dimensions"); |
| 2756 | } |
| 2757 | } |
| 2758 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2759 | return (nDimensions < 3 || (nDimensions == 3 && (nDimensions-concatDim) < 3 && (nDimensions-concatDim) != 1)); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2760 | } |
| 2761 | |
| 2762 | armnn::TensorShape ExpandTensorShapeTo3dForPermute(const armnn::TensorShape & inputShape) |
| 2763 | { |
| 2764 | unsigned int numDims = inputShape.GetNumDimensions(); |
| 2765 | if (numDims >= 3) |
| 2766 | { |
| 2767 | // Nothing to do if the inputShape has at least 3 dimensions. |
| 2768 | return inputShape; |
| 2769 | } |
| 2770 | |
| 2771 | std::vector<unsigned int> newDims(size_t(3), 1u); |
| 2772 | unsigned int expandedBy = 3 - numDims; |
| 2773 | for (unsigned int i=0; i<numDims; ++i) |
| 2774 | { |
| 2775 | newDims[expandedBy+i] = inputShape[i]; |
| 2776 | } |
| 2777 | return armnn::TensorShape(3u, &newDims[0]); |
| 2778 | } |
| 2779 | |
| 2780 | void Generate3dPermuteVectorForConcat( |
| 2781 | unsigned int numDimensions, |
| 2782 | unsigned int & concatDim, |
| 2783 | std::pair<armnn::PermutationVector, armnn::PermutationVector> & permutations) |
| 2784 | { |
| 2785 | BOOST_ASSERT_MSG(numDimensions <= 3, |
| 2786 | "Only dimensions 1,2 and 3 are supported by this helper"); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2787 | unsigned int expandedBy = 3 - numDimensions; |
| 2788 | unsigned int expandedConcatAxis = concatDim + expandedBy; |
| 2789 | |
| 2790 | if (expandedConcatAxis == 2) |
| 2791 | { |
| 2792 | concatDim = 0; |
| 2793 | armnn::PermutationVector forwardPermutation({1, 2, 0}); |
| 2794 | armnn::PermutationVector reversePermutation({2, 0, 1}); |
| 2795 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 2796 | } |
| 2797 | else if (expandedConcatAxis == 1) |
| 2798 | { |
| 2799 | concatDim = 0; |
| 2800 | armnn::PermutationVector forwardPermutation({2, 0, 1}); |
| 2801 | armnn::PermutationVector reversePermutation({1, 2, 0}); |
| 2802 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 2803 | } |
| 2804 | else |
| 2805 | { |
| 2806 | BOOST_ASSERT(expandedConcatAxis == 0); |
| 2807 | concatDim = 0; |
| 2808 | } |
| 2809 | } |
| 2810 | |
| 2811 | // |
| 2812 | // Permute the input tensors so we can do a supported concatenation. |
| 2813 | // Also treat lower than 3d tensors as 3d by adding dummy 1 dimensions |
| 2814 | // at the front. Finally this function tells what the output shape |
| 2815 | // of the permuted concatenated tensor is going to be. |
| 2816 | // |
| 2817 | template <typename T> |
| 2818 | void PermuteInputsForConcat( |
| 2819 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2820 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2821 | std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 2822 | std::vector<T *> & inputData, |
| 2823 | std::vector<std::vector<T>> & inputDataStorage, |
| 2824 | armnn::PermutationVector & permuteVector, |
| 2825 | unsigned int & concatDim, |
| 2826 | armnn::TensorInfo & outputTensorInfo) |
| 2827 | { |
| 2828 | BOOST_ASSERT_MSG(inputTensorInfos.size() > 1, |
| 2829 | "Expecting more than one tensor to be concatenated here"); |
| 2830 | |
| 2831 | unsigned int numDims = 0; |
| 2832 | unsigned int nthInput = 0; |
| 2833 | const armnn::PermutationVector identity({0, 1, 2}); |
| 2834 | |
| 2835 | std::pair<armnn::PermutationVector, armnn::PermutationVector> permutations = |
| 2836 | std::make_pair(identity, identity); |
| 2837 | |
| 2838 | inputDataStorage.resize(inputData.size()); |
| 2839 | |
| 2840 | for (auto && tensorInfo : inputTensorInfos) |
| 2841 | { |
| 2842 | if (numDims == 0) |
| 2843 | { |
| 2844 | numDims = tensorInfo.GetShape().GetNumDimensions(); |
| 2845 | Generate3dPermuteVectorForConcat(numDims, concatDim, permutations); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2846 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2847 | // Store the reverese permutation. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2848 | permuteVector = permutations.second; |
| 2849 | BOOST_ASSERT_MSG(!permuteVector.IsEqual(identity), |
| 2850 | "Test logic error, we don't need permutation, so we shouldn't arrive here"); |
| 2851 | } |
| 2852 | else |
| 2853 | { |
| 2854 | BOOST_ASSERT_MSG(numDims == tensorInfo.GetShape().GetNumDimensions(), |
| 2855 | "All inputs must have the same number of dimensions"); |
| 2856 | } |
| 2857 | |
| 2858 | armnn::TensorInfo newTensorInfo = tensorInfo; |
| 2859 | newTensorInfo.SetShape(ExpandTensorShapeTo3dForPermute(tensorInfo.GetShape())); |
| 2860 | |
| 2861 | PermuteTensorData<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2862 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2863 | permutations.first, |
| 2864 | newTensorInfo, |
| 2865 | inputData[nthInput], |
| 2866 | inputDataStorage[nthInput]); |
| 2867 | |
| 2868 | inputData[nthInput] = inputDataStorage[nthInput].data(); |
| 2869 | inputTensorInfos[nthInput] = newTensorInfo; |
| 2870 | |
| 2871 | ++nthInput; |
| 2872 | } |
| 2873 | |
| 2874 | outputTensorInfo.SetShape( |
| 2875 | armnnUtils::Permuted( |
| 2876 | ExpandTensorShapeTo3dForPermute(outputTensorInfo.GetShape()), |
| 2877 | permutations.first)); |
| 2878 | } |
| 2879 | |
| 2880 | |
| 2881 | // |
| 2882 | // This is the pair of PermuteInputsForConcat(...) which permutes back |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2883 | // the output of the concatenation so we can check it against an expected |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2884 | // output. |
| 2885 | // |
| 2886 | template <typename T> |
| 2887 | void PermuteOutputForConcat( |
| 2888 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2889 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2890 | const armnn::TensorInfo & tensorInfo, |
| 2891 | const armnn::PermutationVector & permuteVector, |
| 2892 | std::unique_ptr<armnn::ITensorHandle> && inputDataHandle, |
| 2893 | T * data) |
| 2894 | { |
| 2895 | BOOST_ASSERT_MSG(data != nullptr, "data must not be null"); |
| 2896 | if (data == nullptr) |
| 2897 | { |
| 2898 | // Nullptr is an error in the test. By returning without doing the permutation |
| 2899 | // I expect the caller to fail the test. It still makes sense to report this as |
| 2900 | // an assert for Debug builds. |
| 2901 | return; |
| 2902 | } |
| 2903 | |
| 2904 | armnn::TensorInfo resultTensorInfo = tensorInfo; |
| 2905 | std::vector<T> inputData(tensorInfo.GetNumElements()); |
| 2906 | std::vector<T> outputData; |
| 2907 | |
| 2908 | CopyDataFromITensorHandle(&inputData[0], inputDataHandle.get()); |
| 2909 | |
| 2910 | PermuteTensorData<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2911 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2912 | permuteVector, |
| 2913 | resultTensorInfo, |
| 2914 | &inputData[0], |
| 2915 | outputData); |
| 2916 | |
| 2917 | ::memcpy(data, &outputData[0], sizeof(T)*outputData.size()); |
| 2918 | } |
| 2919 | |
| 2920 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2921 | void Concatenate( |
| 2922 | armnn::IWorkloadFactory& workloadFactory, |
| 2923 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2924 | std::initializer_list<const armnn::TensorInfo> inputTensorInfosOrig, |
| 2925 | std::initializer_list<T *> inputsOrig, |
| 2926 | const armnn::TensorInfo& outputTensorInfoOrig, |
| 2927 | T * output, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2928 | unsigned int concatDim, |
| 2929 | bool useSubtensor) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2930 | { |
| 2931 | BOOST_ASSERT_MSG(output != nullptr, "output must not be null"); |
| 2932 | if (output == nullptr) |
| 2933 | { |
| 2934 | // Nullptr is an error in the test. By returning without doing the permutation |
| 2935 | // I expect the caller to fail the test. It still makes sense to report this as |
| 2936 | // an assert for Debug builds. |
| 2937 | return; |
| 2938 | } |
| 2939 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2940 | // Saves a copy of the parameters which we might need to change. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2941 | std::vector<armnn::TensorInfo> inputTensorInfos(inputTensorInfosOrig.begin(), inputTensorInfosOrig.end()); |
| 2942 | std::vector<T *> inputs = inputsOrig; |
| 2943 | armnn::TensorInfo outputTensorInfo = outputTensorInfoOrig; |
| 2944 | |
| 2945 | armnn::PermutationVector permuteVector{0, 1, 2}; |
| 2946 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2947 | // Holds and automatically releases memory for the reshaped input data. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2948 | std::vector<std::vector<T>> tmpInputDataStorage; |
| 2949 | |
| 2950 | const size_t inputCount = inputTensorInfos.size(); |
| 2951 | |
| 2952 | bool needPermuteForConcat = NeedPermuteForConcat(inputTensorInfos, concatDim); |
| 2953 | |
| 2954 | if (needPermuteForConcat) |
| 2955 | { |
| 2956 | // |
| 2957 | // We need to permute the inputs, because concatenation along |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2958 | // the requested axis is not supported. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2959 | // |
| 2960 | PermuteInputsForConcat<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2961 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 2962 | inputTensorInfos, |
| 2963 | inputs, |
| 2964 | tmpInputDataStorage, |
| 2965 | permuteVector, |
| 2966 | concatDim, |
| 2967 | outputTensorInfo); |
| 2968 | } |
| 2969 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2970 | armnn::WorkloadInfo workloadInfo; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2971 | |
| 2972 | std::vector<std::unique_ptr<armnn::ITensorHandle>> inputHandles; |
| 2973 | inputHandles.reserve(inputCount); |
| 2974 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2975 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2976 | |
| 2977 | armnn::MergerQueueDescriptor queueDescriptor; |
| 2978 | armnn::OriginsDescriptor viewsDescriptor = CreateMergerDescriptorForConcatenation(inputTensorInfos, concatDim); |
| 2979 | queueDescriptor.m_Parameters = viewsDescriptor; |
| 2980 | |
| 2981 | if (useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2982 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2983 | queueDescriptor.m_ViewOrigins.reserve(viewsDescriptor.GetNumViews()); |
| 2984 | for (unsigned int i = 0; i < viewsDescriptor.GetNumViews(); ++i) |
| 2985 | { |
| 2986 | queueDescriptor.m_ViewOrigins.emplace_back(std::vector<unsigned int>(viewsDescriptor.GetViewOrigin(i), |
| 2987 | viewsDescriptor.GetViewOrigin(i) + viewsDescriptor.GetNumDimensions())); |
| 2988 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2989 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2990 | outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2991 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 2992 | const bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 2993 | for (unsigned int i = 0; i < inputCount; ++i) |
| 2994 | { |
| 2995 | const armnn::TensorInfo& inputTensorInfo = inputTensorInfos[i]; |
| 2996 | std::unique_ptr<armnn::ITensorHandle> inputHandle = |
| 2997 | subTensorsSupported ? |
| 2998 | workloadFactory.CreateSubTensorHandle(*outputHandle, |
| 2999 | inputTensorInfo.GetShape(), |
| 3000 | queueDescriptor.m_ViewOrigins[i].m_Origin.data()) : |
| 3001 | workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 3002 | |
| 3003 | inputHandles.emplace_back(std::move(inputHandle)); |
| 3004 | } |
| 3005 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3006 | } |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3007 | else |
| 3008 | { |
| 3009 | for (unsigned int i = 0; i < inputCount; ++i) |
| 3010 | { |
| 3011 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfos[i]); |
| 3012 | inputHandles.emplace_back(std::move(inputHandle)); |
| 3013 | } |
| 3014 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3015 | |
| 3016 | for (unsigned int i = 0; i < inputCount; ++i) |
| 3017 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3018 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfos[i], inputHandles[i].get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3019 | } |
| 3020 | |
| 3021 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 3022 | |
| 3023 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(queueDescriptor, workloadInfo); |
| 3024 | |
| 3025 | for (auto& inputHandle : inputHandles) |
| 3026 | { |
| 3027 | inputHandle->Allocate(); |
| 3028 | } |
| 3029 | |
| 3030 | outputHandle->Allocate(); |
| 3031 | |
| 3032 | unsigned int nextInputId = 0; |
| 3033 | for (auto& inputHandle : inputHandles) |
| 3034 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3035 | CopyDataToITensorHandle(inputHandle.get(), inputs[nextInputId]); |
| 3036 | ++nextInputId; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3037 | } |
| 3038 | |
| 3039 | workload->Execute(); |
| 3040 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3041 | if (needPermuteForConcat) |
| 3042 | { |
| 3043 | PermuteOutputForConcat<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3044 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3045 | outputTensorInfo, |
| 3046 | permuteVector, |
| 3047 | std::move(outputHandle), |
| 3048 | output); |
| 3049 | } |
| 3050 | else |
| 3051 | { |
| 3052 | CopyDataFromITensorHandle(output, outputHandle.get()); |
| 3053 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3054 | } |
| 3055 | |
| 3056 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3057 | LayerTestResult<T, 1> Concatenation1dTestImpl( |
| 3058 | armnn::IWorkloadFactory& workloadFactory, |
| 3059 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3060 | float qScale, |
| 3061 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3062 | { |
| 3063 | armnn::TensorInfo inputTensorInfo({ 3 }, armnn::GetDataType<T>()); |
| 3064 | |
| 3065 | auto input0 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 1.0f, 2.0f, 3.0f })); |
| 3066 | auto input1 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 4.0f, 5.0f, 6.0f })); |
| 3067 | auto input2 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 7.0f, 8.0f, 9.0f })); |
| 3068 | |
| 3069 | armnn::TensorInfo outputTensorInfo({ 9 }, armnn::GetDataType<T>()); |
| 3070 | |
| 3071 | LayerTestResult<T, 1> result(outputTensorInfo); |
| 3072 | |
| 3073 | std::vector<T> output; |
| 3074 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3075 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3076 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 3077 | { input0.data(), input1.data(), input2.data() }, |
| 3078 | outputTensorInfo, |
| 3079 | output.data(), |
| 3080 | 0, |
| 3081 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3082 | |
| 3083 | result.output = MakeTensor<T, 1>(outputTensorInfo, output); |
| 3084 | result.outputExpected = MakeTensor<T, 1>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3085 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f |
| 3086 | })); |
| 3087 | |
| 3088 | return result; |
| 3089 | } |
| 3090 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3091 | LayerTestResult<float, 1> Concatenation1dTest( |
| 3092 | armnn::IWorkloadFactory& workloadFactory, |
| 3093 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3094 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3095 | return Concatenation1dTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3096 | } |
| 3097 | |
| 3098 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3099 | LayerTestResult<T, 2> Concatenation2dTestImpl( |
| 3100 | armnn::IWorkloadFactory& workloadFactory, |
| 3101 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3102 | const armnn::TensorInfo& outputTensorInfo, |
| 3103 | unsigned int dimension, |
| 3104 | const float qScale, |
| 3105 | const int32_t qOffset) |
| 3106 | { |
| 3107 | armnn::TensorInfo inputTensorInfo({ 2, 3 }, armnn::GetDataType<T>()); |
| 3108 | |
| 3109 | auto input0 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3110 | // Batch 0 |
| 3111 | 1.0f, 2.0f, 3.0f, |
| 3112 | |
| 3113 | // Batch 1 |
| 3114 | 10.0f, 11.0f, 12.0f, |
| 3115 | })); |
| 3116 | |
| 3117 | auto input1 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3118 | // Batch 0 |
| 3119 | 4.0f, 5.0f, 6.0f, |
| 3120 | |
| 3121 | // Batch 1 |
| 3122 | 13.0f, 14.0f, 15.0f, |
| 3123 | })); |
| 3124 | |
| 3125 | auto input2 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3126 | // Batch 0 |
| 3127 | 7.0f, 8.0f, 9.0f, |
| 3128 | |
| 3129 | // Batch 1 |
| 3130 | 16.0f, 17.0f, 18.0f, |
| 3131 | })); |
| 3132 | |
| 3133 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3134 | |
| 3135 | std::vector<T> output; |
| 3136 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3137 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3138 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 3139 | { input0.data(), input1.data(), input2.data() }, |
| 3140 | outputTensorInfo, |
| 3141 | output.data(), |
| 3142 | dimension, |
| 3143 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3144 | |
| 3145 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3146 | return result; |
| 3147 | } |
| 3148 | |
| 3149 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3150 | LayerTestResult<T, 2> Concatenation2dDim0TestImpl( |
| 3151 | armnn::IWorkloadFactory& workloadFactory, |
| 3152 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3153 | float qScale, |
| 3154 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3155 | { |
| 3156 | armnn::TensorInfo outputTensorInfo({ 6, 3 }, armnn::GetDataType<T>()); |
| 3157 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3158 | LayerTestResult<T, 2> result = |
| 3159 | Concatenation2dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3160 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3161 | // Batch 0 |
| 3162 | 1.0f, 2.0f, 3.0f, |
| 3163 | |
| 3164 | // Batch 1 |
| 3165 | 10.0f, 11.0f, 12.0f, |
| 3166 | |
| 3167 | // Batch 2 |
| 3168 | 4.0f, 5.0f, 6.0f, |
| 3169 | |
| 3170 | // Batch 3 |
| 3171 | 13.0f, 14.0f, 15.0f, |
| 3172 | |
| 3173 | // Batch 4 |
| 3174 | 7.0f, 8.0f, 9.0f, |
| 3175 | |
| 3176 | // Batch 5 |
| 3177 | 16.0f, 17.0f, 18.0f, |
| 3178 | })); |
| 3179 | |
| 3180 | return result; |
| 3181 | } |
| 3182 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3183 | LayerTestResult<float, 2> Concatenation2dDim0Test( |
| 3184 | armnn::IWorkloadFactory& workloadFactory, |
| 3185 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3186 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3187 | return Concatenation2dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3188 | } |
| 3189 | |
| 3190 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3191 | LayerTestResult<T, 2> Concatenation2dDim1TestImpl( |
| 3192 | armnn::IWorkloadFactory& workloadFactory, |
| 3193 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3194 | float qScale, |
| 3195 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3196 | { |
| 3197 | armnn::TensorInfo outputTensorInfo({ 2, 9 }, armnn::GetDataType<T>()); |
| 3198 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3199 | LayerTestResult<T, 2> result = |
| 3200 | Concatenation2dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3201 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3202 | // Batch 0 |
| 3203 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
| 3204 | |
| 3205 | // Batch 1 |
| 3206 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f |
| 3207 | })); |
| 3208 | |
| 3209 | return result; |
| 3210 | } |
| 3211 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3212 | LayerTestResult<float, 2> Concatenation2dDim1Test( |
| 3213 | armnn::IWorkloadFactory& workloadFactory, |
| 3214 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3215 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3216 | return Concatenation2dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
| 3219 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3220 | LayerTestResult<T, 2> Concatenation2dDim0DiffInputDimsTestImpl( |
| 3221 | armnn::IWorkloadFactory& workloadFactory, |
| 3222 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3223 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3224 | int32_t qOffset) |
| 3225 | { |
| 3226 | armnn::TensorInfo input0TensorInfo({ 2, 3 }, armnn::GetDataType<T>()); |
| 3227 | auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3228 | // Batch 0 |
| 3229 | 1.0f, 2.0f, 3.0f, |
| 3230 | |
| 3231 | // Batch 1 |
| 3232 | 10.0f, 11.0f, 12.0f, |
| 3233 | })); |
| 3234 | |
| 3235 | armnn::TensorInfo input1TensorInfo({ 3, 3 }, armnn::GetDataType<T>()); |
| 3236 | auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3237 | // Batch 0 |
| 3238 | 4.0f, 5.0f, 6.0f, |
| 3239 | |
| 3240 | // Batch 1 |
| 3241 | 13.0f, 14.0f, 15.0f, |
| 3242 | |
| 3243 | // Batch 0 |
| 3244 | 7.0f, 8.0f, 9.0f, |
| 3245 | })); |
| 3246 | |
| 3247 | armnn::TensorInfo input2TensorInfo({ 1, 3 }, armnn::GetDataType<T>()); |
| 3248 | auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3249 | // Batch 1 |
| 3250 | 16.0f, 17.0f, 18.0f, |
| 3251 | })); |
| 3252 | |
| 3253 | armnn::TensorInfo outputTensorInfo({ 6, 3 }, armnn::GetDataType<T>()); |
| 3254 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3255 | |
| 3256 | std::vector<T> output; |
| 3257 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3258 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3259 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3260 | { input0.data(), input1.data(), input2.data() }, |
| 3261 | outputTensorInfo, |
| 3262 | output.data(), |
| 3263 | 0, |
| 3264 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3265 | |
| 3266 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3267 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3268 | // Batch 0 |
| 3269 | 1.0f, 2.0f, 3.0f, |
| 3270 | |
| 3271 | // Batch 1 |
| 3272 | 10.0f, 11.0f, 12.0f, |
| 3273 | |
| 3274 | // Batch 2 |
| 3275 | 4.0f, 5.0f, 6.0f, |
| 3276 | |
| 3277 | // Batch 3 |
| 3278 | 13.0f, 14.0f, 15.0f, |
| 3279 | |
| 3280 | // Batch 4 |
| 3281 | 7.0f, 8.0f, 9.0f, |
| 3282 | |
| 3283 | // Batch 5 |
| 3284 | 16.0f, 17.0f, 18.0f, |
| 3285 | })); |
| 3286 | |
| 3287 | return result; |
| 3288 | } |
| 3289 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3290 | LayerTestResult<float, 2> Concatenation2dDim0DiffInputDimsTest( |
| 3291 | armnn::IWorkloadFactory& workloadFactory, |
| 3292 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3293 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3294 | return Concatenation2dDim0DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3295 | } |
| 3296 | |
| 3297 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3298 | LayerTestResult<T, 2> Concatenation2dDim1DiffInputDimsTestImpl( |
| 3299 | armnn::IWorkloadFactory& workloadFactory, |
| 3300 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3301 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3302 | int32_t qOffset) |
| 3303 | { |
| 3304 | armnn::TensorInfo input0TensorInfo({ 2, 3 }, armnn::GetDataType<T>()); |
| 3305 | auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3306 | // Batch 0 |
| 3307 | 1.0f, 2.0f, 3.0f, |
| 3308 | |
| 3309 | // Batch 1 |
| 3310 | 10.0f, 11.0f, 12.0f, |
| 3311 | })); |
| 3312 | |
| 3313 | armnn::TensorInfo input1TensorInfo({ 2, 5 }, armnn::GetDataType<T>()); |
| 3314 | auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3315 | // Batch 0 |
| 3316 | 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, |
| 3317 | |
| 3318 | // Batch 1 |
| 3319 | 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, |
| 3320 | })); |
| 3321 | |
| 3322 | armnn::TensorInfo input2TensorInfo({ 2, 1 }, armnn::GetDataType<T>()); |
| 3323 | auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3324 | // Batch 0 |
| 3325 | 9.0f, |
| 3326 | |
| 3327 | // Batch 1 |
| 3328 | 18.0f |
| 3329 | })); |
| 3330 | |
| 3331 | armnn::TensorInfo outputTensorInfo({ 2, 9 }, armnn::GetDataType<T>()); |
| 3332 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3333 | |
| 3334 | std::vector<T> output; |
| 3335 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3336 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3337 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3338 | { input0.data(), input1.data(), input2.data() }, |
| 3339 | outputTensorInfo, |
| 3340 | output.data(), |
| 3341 | 1, |
| 3342 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3343 | |
| 3344 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3345 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3346 | // Batch 0 |
| 3347 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
| 3348 | |
| 3349 | // Batch 1 |
| 3350 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, |
| 3351 | })); |
| 3352 | |
| 3353 | return result; |
| 3354 | } |
| 3355 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3356 | LayerTestResult<float, 2> Concatenation2dDim1DiffInputDimsTest( |
| 3357 | armnn::IWorkloadFactory& workloadFactory, |
| 3358 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3359 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3360 | return Concatenation2dDim1DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3364 | LayerTestResult<T, 3> Concatenation3dTestImpl( |
| 3365 | armnn::IWorkloadFactory& workloadFactory, |
| 3366 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3367 | const armnn::TensorInfo& outputTensorInfo, |
| 3368 | unsigned int dimension, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3369 | bool useSubtensor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3370 | float qScale, |
| 3371 | int32_t qOffset) |
| 3372 | { |
| 3373 | armnn::TensorInfo inputTensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>()); |
| 3374 | |
| 3375 | auto input0 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3376 | // Batch 0, Channel 0 |
| 3377 | 1.0f, 2.0f, |
| 3378 | |
| 3379 | // Batch 0, Channel 1 |
| 3380 | 3.0f, 4.0f, |
| 3381 | |
| 3382 | // Batch 0, Channel 2 |
| 3383 | 5.0f, 6.0f, |
| 3384 | |
| 3385 | // Batch 1, Channel 0 |
| 3386 | 19.0f, 20.0f, |
| 3387 | |
| 3388 | // Batch 1, Channel 1 |
| 3389 | 21.0f, 22.0f, |
| 3390 | |
| 3391 | // Batch 1, Channel 2 |
| 3392 | 23.0f, 24.0f |
| 3393 | })); |
| 3394 | |
| 3395 | auto input1 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3396 | // Batch 0, Channel 0 |
| 3397 | 7.0f, 8.0f, |
| 3398 | |
| 3399 | // Batch 0, Channel 1 |
| 3400 | 9.0f, 10.0f, |
| 3401 | |
| 3402 | // Batch 0, Channel 2 |
| 3403 | 11.0f, 12.0f, |
| 3404 | |
| 3405 | // Batch 1, Channel 0 |
| 3406 | 25.0f, 26.0f, |
| 3407 | |
| 3408 | // Batch 1, Channel 1 |
| 3409 | 27.0f, 28.0f, |
| 3410 | |
| 3411 | // Batch 1, Channel 2 |
| 3412 | 29.0f, 30.0f |
| 3413 | })); |
| 3414 | |
| 3415 | auto input2 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3416 | // Batch 0, Channel 0 |
| 3417 | 13.0f, 14.0f, |
| 3418 | |
| 3419 | // Batch 0, Channel 1 |
| 3420 | 15.0f, 16.0f, |
| 3421 | |
| 3422 | // Batch 0, Channel 2 |
| 3423 | 17.0f, 18.0f, |
| 3424 | |
| 3425 | // Batch 1, Channel 0 |
| 3426 | 31.0f, 32.0f, |
| 3427 | |
| 3428 | // Batch 1, Channel 1 |
| 3429 | 33.0f, 34.0f, |
| 3430 | |
| 3431 | // Batch 1, Channel 2 |
| 3432 | 35.0f, 36.0f |
| 3433 | })); |
| 3434 | |
| 3435 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 3436 | |
| 3437 | std::vector<T> output; |
| 3438 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3439 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3440 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 3441 | { input0.data(), input1.data(), input2.data() }, |
| 3442 | outputTensorInfo, |
| 3443 | output.data(), |
| 3444 | dimension, |
| 3445 | useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3446 | |
| 3447 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 3448 | return result; |
| 3449 | } |
| 3450 | |
| 3451 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3452 | LayerTestResult<T, 3> Concatenation3dDim0TestImpl( |
| 3453 | armnn::IWorkloadFactory& workloadFactory, |
| 3454 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3455 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3456 | int32_t qOffset) |
| 3457 | { |
| 3458 | armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, armnn::GetDataType<T>()); |
| 3459 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3460 | LayerTestResult<T, 3> result = |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3461 | Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0, true, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3462 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3463 | // Batch 0, Channel 0 |
| 3464 | 1.0f, 2.0f, |
| 3465 | |
| 3466 | // Batch 0, Channel 1 |
| 3467 | 3.0f, 4.0f, |
| 3468 | |
| 3469 | // Batch 0, Channel 2 |
| 3470 | 5.0f, 6.0f, |
| 3471 | |
| 3472 | // Batch 1, Channel 0 |
| 3473 | 19.0f, 20.0f, |
| 3474 | |
| 3475 | // Batch 1, Channel 1 |
| 3476 | 21.0f, 22.0f, |
| 3477 | |
| 3478 | // Batch 1, Channel 2 |
| 3479 | 23.0f, 24.0f, |
| 3480 | |
| 3481 | // Batch 2, Channel 0 |
| 3482 | 7.0f, 8.0f, |
| 3483 | |
| 3484 | // Batch 2, Channel 1 |
| 3485 | 9.0f, 10.0f, |
| 3486 | |
| 3487 | // Batch 2, Channel 2 |
| 3488 | 11.0f, 12.0f, |
| 3489 | |
| 3490 | // Batch 3, Channel 0 |
| 3491 | 25.0f, 26.0f, |
| 3492 | |
| 3493 | // Batch 3, Channel 1 |
| 3494 | 27.0f, 28.0f, |
| 3495 | |
| 3496 | // Batch 3, Channel 2 |
| 3497 | 29.0f, 30.0f, |
| 3498 | |
| 3499 | // Batch 4, Channel 0 |
| 3500 | 13.0f, 14.0f, |
| 3501 | |
| 3502 | // Batch 4, Channel 1 |
| 3503 | 15.0f, 16.0f, |
| 3504 | |
| 3505 | // Batch 4, Channel 2 |
| 3506 | 17.0f, 18.0f, |
| 3507 | |
| 3508 | // Batch 5, Channel 0 |
| 3509 | 31.0f, 32.0f, |
| 3510 | |
| 3511 | // Batch 5, Channel 1 |
| 3512 | 33.0f, 34.0f, |
| 3513 | |
| 3514 | // Batch 5, Channel 2 |
| 3515 | 35.0f, 36.0f |
| 3516 | })); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3517 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3518 | return result; |
| 3519 | } |
| 3520 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3521 | LayerTestResult<float, 3> Concatenation3dDim0Test( |
| 3522 | armnn::IWorkloadFactory& workloadFactory, |
| 3523 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3524 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3525 | return Concatenation3dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3526 | } |
| 3527 | |
| 3528 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3529 | LayerTestResult<T, 3> Concatenation3dDim1TestImpl( |
| 3530 | armnn::IWorkloadFactory& workloadFactory, |
| 3531 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3532 | float qScale, |
| 3533 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3534 | { |
| 3535 | armnn::TensorInfo outputTensorInfo({ 2, 9, 2 }, armnn::GetDataType<T>()); |
| 3536 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3537 | LayerTestResult<T, 3> result = |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3538 | Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1, true, qScale, qOffset); |
| 3539 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3540 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3541 | // Batch 0, Channel 0 |
| 3542 | 1.0f, 2.0f, |
| 3543 | |
| 3544 | // Batch 0, Channel 1 |
| 3545 | 3.0f, 4.0f, |
| 3546 | |
| 3547 | // Batch 0, Channel 2 |
| 3548 | 5.0f, 6.0f, |
| 3549 | |
| 3550 | // Batch 0, Channel 3 |
| 3551 | 7.0f, 8.0f, |
| 3552 | |
| 3553 | // Batch 0, Channel 4 |
| 3554 | 9.0f, 10.0f, |
| 3555 | |
| 3556 | // Batch 0, Channel 5 |
| 3557 | 11.0f, 12.0f, |
| 3558 | |
| 3559 | // Batch 0, Channel 6 |
| 3560 | 13.0f, 14.0f, |
| 3561 | |
| 3562 | // Batch 0, Channel 7 |
| 3563 | 15.0f, 16.0f, |
| 3564 | |
| 3565 | // Batch 0, Channel 8 |
| 3566 | 17.0f, 18.0f, |
| 3567 | |
| 3568 | // Batch 1, Channel 0 |
| 3569 | 19.0f, 20.0f, |
| 3570 | |
| 3571 | // Batch 1, Channel 1 |
| 3572 | 21.0f, 22.0f, |
| 3573 | |
| 3574 | // Batch 1, Channel 2 |
| 3575 | 23.0f, 24.0f, |
| 3576 | |
| 3577 | // Batch 1, Channel 3 |
| 3578 | 25.0f, 26.0f, |
| 3579 | |
| 3580 | // Batch 1, Channel 4 |
| 3581 | 27.0f, 28.0f, |
| 3582 | |
| 3583 | // Batch 1, Channel 5 |
| 3584 | 29.0f, 30.0f, |
| 3585 | |
| 3586 | // Batch 1, Channel 6 |
| 3587 | 31.0f, 32.0f, |
| 3588 | |
| 3589 | // Batch 1, Channel 7 |
| 3590 | 33.0f, 34.0f, |
| 3591 | |
| 3592 | // Batch 1, Channel 8 |
| 3593 | 35.0f, 36.0f |
| 3594 | })); |
| 3595 | |
| 3596 | return result; |
| 3597 | } |
| 3598 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3599 | LayerTestResult<float, 3> Concatenation3dDim1Test( |
| 3600 | armnn::IWorkloadFactory& workloadFactory, |
| 3601 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3602 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3603 | return Concatenation3dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3604 | } |
| 3605 | |
| 3606 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3607 | LayerTestResult<T, 3> Concatenation3dDim2TestImpl( |
| 3608 | armnn::IWorkloadFactory& workloadFactory, |
| 3609 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3610 | bool useSubtensor, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3611 | float qScale, |
| 3612 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3613 | { |
| 3614 | armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, armnn::GetDataType<T>()); |
| 3615 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3616 | LayerTestResult<T, 3> result = |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3617 | Concatenation3dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 2, useSubtensor, qScale, qOffset); |
| 3618 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3619 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3620 | // Batch 0, Channel 0 |
| 3621 | 1.0f, 2.0f, 7.0f, 8.0f, 13.0f, 14.0f, |
| 3622 | |
| 3623 | // Batch 0, Channel 1 |
| 3624 | 3.0f, 4.0f, 9.0f, 10.0f, 15.0f, 16.0f, |
| 3625 | |
| 3626 | // Batch 0, Channel 2 |
| 3627 | 5.0f, 6.0f, 11.0f, 12.0f, 17.0f, 18.0f, |
| 3628 | |
| 3629 | // Batch 1, Channel 0 |
| 3630 | 19.0f, 20.0f, 25.0f, 26.0f, 31.0f, 32.0f, |
| 3631 | |
| 3632 | // Batch 1, Channel 1 |
| 3633 | 21.0f, 22.0f, 27.0f, 28.0f, 33.0f, 34.0f, |
| 3634 | |
| 3635 | // Batch 1, Channel 2 |
| 3636 | 23.0f, 24.0f, 29.0f, 30.0f, 35.0f, 36.0f, |
| 3637 | })); |
| 3638 | |
| 3639 | return result; |
| 3640 | } |
| 3641 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3642 | LayerTestResult<float, 3> Concatenation3dDim2Test( |
| 3643 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3644 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3645 | bool useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3646 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3647 | return Concatenation3dDim2TestImpl<float>(workloadFactory, memoryManager, useSubtensor, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3651 | LayerTestResult<T, 3> Concatenation3dDim0DiffInputDimsTestImpl( |
| 3652 | armnn::IWorkloadFactory& workloadFactory, |
| 3653 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3654 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3655 | int32_t qOffset) |
| 3656 | { |
| 3657 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>()); |
| 3658 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3659 | // Batch 0, Channel 0 |
| 3660 | 1.0f, 2.0f, |
| 3661 | |
| 3662 | // Batch 0, Channel 1 |
| 3663 | 3.0f, 4.0f, |
| 3664 | |
| 3665 | // Batch 0, Channel 2 |
| 3666 | 5.0f, 6.0f, |
| 3667 | |
| 3668 | // Batch 1, Channel 0 |
| 3669 | 19.0f, 20.0f, |
| 3670 | |
| 3671 | // Batch 1, Channel 1 |
| 3672 | 21.0f, 22.0f, |
| 3673 | |
| 3674 | // Batch 1, Channel 2 |
| 3675 | 23.0f, 24.0f |
| 3676 | })); |
| 3677 | |
| 3678 | armnn::TensorInfo input1TensorInfo({ 1, 3, 2 }, armnn::GetDataType<T>()); |
| 3679 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3680 | // Batch 0, Channel 0 |
| 3681 | 7.0f, 8.0f, |
| 3682 | |
| 3683 | // Batch 0, Channel 1 |
| 3684 | 9.0f, 10.0f, |
| 3685 | |
| 3686 | // Batch 0, Channel 2 |
| 3687 | 11.0f, 12.0f, |
| 3688 | })); |
| 3689 | |
| 3690 | armnn::TensorInfo input2TensorInfo({ 3, 3, 2 }, armnn::GetDataType<T>()); |
| 3691 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3692 | // Batch 0, Channel 0 |
| 3693 | 25.0f, 26.0f, |
| 3694 | |
| 3695 | // Batch 0, Channel 1 |
| 3696 | 27.0f, 28.0f, |
| 3697 | |
| 3698 | // Batch 0, Channel 2 |
| 3699 | 29.0f, 30.0f, |
| 3700 | |
| 3701 | // Batch 1, Channel 0 |
| 3702 | 13.0f, 14.0f, |
| 3703 | |
| 3704 | // Batch 1, Channel 1 |
| 3705 | 15.0f, 16.0f, |
| 3706 | |
| 3707 | // Batch 1, Channel 2 |
| 3708 | 17.0f, 18.0f, |
| 3709 | |
| 3710 | // Batch 2, Channel 0 |
| 3711 | 31.0f, 32.0f, |
| 3712 | |
| 3713 | // Batch 2, Channel 1 |
| 3714 | 33.0f, 34.0f, |
| 3715 | |
| 3716 | // Batch 2, Channel 2 |
| 3717 | 35.0f, 36.0f |
| 3718 | })); |
| 3719 | |
| 3720 | armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, armnn::GetDataType<T>()); |
| 3721 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 3722 | |
| 3723 | std::vector<T> output; |
| 3724 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3725 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3726 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3727 | { input0.data(), input1.data(), input2.data() }, |
| 3728 | outputTensorInfo, |
| 3729 | output.data(), |
| 3730 | 0, |
| 3731 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3732 | |
| 3733 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 3734 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3735 | // Batch 0, Channel 0 |
| 3736 | 1.0f, 2.0f, |
| 3737 | |
| 3738 | // Batch 0, Channel 1 |
| 3739 | 3.0f, 4.0f, |
| 3740 | |
| 3741 | // Batch 0, Channel 2 |
| 3742 | 5.0f, 6.0f, |
| 3743 | |
| 3744 | // Batch 1, Channel 0 |
| 3745 | 19.0f, 20.0f, |
| 3746 | |
| 3747 | // Batch 1, Channel 1 |
| 3748 | 21.0f, 22.0f, |
| 3749 | |
| 3750 | // Batch 1, Channel 2 |
| 3751 | 23.0f, 24.0f, |
| 3752 | |
| 3753 | // Batch 2, Channel 0 |
| 3754 | 7.0f, 8.0f, |
| 3755 | |
| 3756 | // Batch 2, Channel 1 |
| 3757 | 9.0f, 10.0f, |
| 3758 | |
| 3759 | // Batch 2, Channel 2 |
| 3760 | 11.0f, 12.0f, |
| 3761 | |
| 3762 | // Batch 3, Channel 0 |
| 3763 | 25.0f, 26.0f, |
| 3764 | |
| 3765 | // Batch 3, Channel 1 |
| 3766 | 27.0f, 28.0f, |
| 3767 | |
| 3768 | // Batch 3, Channel 2 |
| 3769 | 29.0f, 30.0f, |
| 3770 | |
| 3771 | // Batch 4, Channel 0 |
| 3772 | 13.0f, 14.0f, |
| 3773 | |
| 3774 | // Batch 4, Channel 1 |
| 3775 | 15.0f, 16.0f, |
| 3776 | |
| 3777 | // Batch 4, Channel 2 |
| 3778 | 17.0f, 18.0f, |
| 3779 | |
| 3780 | // Batch 5, Channel 0 |
| 3781 | 31.0f, 32.0f, |
| 3782 | |
| 3783 | // Batch 5, Channel 1 |
| 3784 | 33.0f, 34.0f, |
| 3785 | |
| 3786 | // Batch 5, Channel 2 |
| 3787 | 35.0f, 36.0f |
| 3788 | })); |
| 3789 | |
| 3790 | return result; |
| 3791 | } |
| 3792 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3793 | LayerTestResult<float, 3> Concatenation3dDim0DiffInputDimsTest( |
| 3794 | armnn::IWorkloadFactory& workloadFactory, |
| 3795 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3796 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3797 | return Concatenation3dDim0DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3798 | } |
| 3799 | |
| 3800 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3801 | LayerTestResult<T, 3> Concatenation3dDim1DiffInputDimsTestImpl( |
| 3802 | armnn::IWorkloadFactory& workloadFactory, |
| 3803 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3804 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3805 | int32_t qOffset) |
| 3806 | { |
| 3807 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>()); |
| 3808 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3809 | // Batch 0, Channel 0 |
| 3810 | 1.0f, 2.0f, |
| 3811 | |
| 3812 | // Batch 0, Channel 1 |
| 3813 | 3.0f, 4.0f, |
| 3814 | |
| 3815 | // Batch 0, Channel 2 |
| 3816 | 5.0f, 6.0f, |
| 3817 | |
| 3818 | // Batch 1, Channel 0 |
| 3819 | 19.0f, 20.0f, |
| 3820 | |
| 3821 | // Batch 1, Channel 1 |
| 3822 | 21.0f, 22.0f, |
| 3823 | |
| 3824 | // Batch 1, Channel 2 |
| 3825 | 23.0f, 24.0f |
| 3826 | })); |
| 3827 | |
| 3828 | armnn::TensorInfo input1TensorInfo({ 2, 4, 2 }, armnn::GetDataType<T>()); |
| 3829 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3830 | // Batch 0, Channel 0 |
| 3831 | 7.0f, 8.0f, |
| 3832 | |
| 3833 | // Batch 0, Channel 1 |
| 3834 | 9.0f, 10.0f, |
| 3835 | |
| 3836 | // Batch 0, Channel 2 |
| 3837 | 11.0f, 12.0f, |
| 3838 | |
| 3839 | // Batch 0, Channel 3 |
| 3840 | 25.0f, 26.0f, |
| 3841 | |
| 3842 | // Batch 1, Channel 0 |
| 3843 | 27.0f, 28.0f, |
| 3844 | |
| 3845 | // Batch 1, Channel 1 |
| 3846 | 29.0f, 30.0f, |
| 3847 | |
| 3848 | // Batch 1, Channel 2 |
| 3849 | 13.0f, 14.0f, |
| 3850 | |
| 3851 | // Batch 1, Channel 3 |
| 3852 | 15.0f, 16.0f, |
| 3853 | })); |
| 3854 | |
| 3855 | armnn::TensorInfo input2TensorInfo({ 2, 1, 2 }, armnn::GetDataType<T>()); |
| 3856 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3857 | // Batch 0, Channel 0 |
| 3858 | 17.0f, 18.0f, |
| 3859 | |
| 3860 | // Batch 1, Channel 0 |
| 3861 | 31.0f, 32.0f, |
| 3862 | })); |
| 3863 | |
| 3864 | armnn::TensorInfo outputTensorInfo({ 2, 8, 2 }, armnn::GetDataType<T>()); |
| 3865 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 3866 | |
| 3867 | std::vector<T> output; |
| 3868 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3869 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3870 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3871 | { input0.data(), input1.data(), input2.data() }, |
| 3872 | outputTensorInfo, |
| 3873 | output.data(), |
| 3874 | 1, |
| 3875 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3876 | |
| 3877 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 3878 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3879 | // Batch 0, Channel 0 |
| 3880 | 1.0f, 2.0f, |
| 3881 | |
| 3882 | // Batch 0, Channel 1 |
| 3883 | 3.0f, 4.0f, |
| 3884 | |
| 3885 | // Batch 0, Channel 2 |
| 3886 | 5.0f, 6.0f, |
| 3887 | |
| 3888 | // Batch 0, Channel 3 |
| 3889 | 7.0f, 8.0f, |
| 3890 | |
| 3891 | // Batch 0, Channel 4 |
| 3892 | 9.0f, 10.0f, |
| 3893 | |
| 3894 | // Batch 0, Channel 5 |
| 3895 | 11.0f, 12.0f, |
| 3896 | |
| 3897 | // Batch 0, Channel 6 |
| 3898 | 25.0f, 26.0f, |
| 3899 | |
| 3900 | // Batch 0, Channel 7 |
| 3901 | 17.0f, 18.0f, |
| 3902 | |
| 3903 | // Batch 1, Channel 0 |
| 3904 | 19.0f, 20.0f, |
| 3905 | |
| 3906 | // Batch 1, Channel 1 |
| 3907 | 21.0f, 22.0f, |
| 3908 | |
| 3909 | // Batch 1, Channel 2 |
| 3910 | 23.0f, 24.0f, |
| 3911 | |
| 3912 | // Batch 1, Channel 3 |
| 3913 | 27.0f, 28.0f, |
| 3914 | |
| 3915 | // Batch 1, Channel 4 |
| 3916 | 29.0f, 30.0f, |
| 3917 | |
| 3918 | // Batch 1, Channel 5 |
| 3919 | 13.0f, 14.0f, |
| 3920 | |
| 3921 | // Batch 1, Channel 6 |
| 3922 | 15.0f, 16.0f, |
| 3923 | |
| 3924 | // Batch 1, Channel 7 |
| 3925 | 31.0f, 32.0f, |
| 3926 | })); |
| 3927 | |
| 3928 | return result; |
| 3929 | } |
| 3930 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3931 | LayerTestResult<float, 3> Concatenation3dDim1DiffInputDimsTest( |
| 3932 | armnn::IWorkloadFactory& workloadFactory, |
| 3933 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3934 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3935 | return Concatenation3dDim1DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3936 | } |
| 3937 | |
| 3938 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3939 | LayerTestResult<T, 3> Concatenation3dDim2DiffInputDimsTestImpl( |
| 3940 | armnn::IWorkloadFactory& workloadFactory, |
| 3941 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3942 | bool useSubtensor, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3943 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3944 | int32_t qOffset) |
| 3945 | { |
| 3946 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, armnn::GetDataType<T>()); |
| 3947 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3948 | // Batch 0, Channel 0 |
| 3949 | 1.0f, 2.0f, |
| 3950 | |
| 3951 | // Batch 0, Channel 1 |
| 3952 | 3.0f, 4.0f, |
| 3953 | |
| 3954 | // Batch 0, Channel 2 |
| 3955 | 5.0f, 6.0f, |
| 3956 | |
| 3957 | // Batch 1, Channel 0 |
| 3958 | 19.0f, 20.0f, |
| 3959 | |
| 3960 | // Batch 1, Channel 1 |
| 3961 | 21.0f, 22.0f, |
| 3962 | |
| 3963 | // Batch 1, Channel 2 |
| 3964 | 23.0f, 24.0f |
| 3965 | })); |
| 3966 | |
| 3967 | armnn::TensorInfo input1TensorInfo({ 2, 3, 1 }, armnn::GetDataType<T>()); |
| 3968 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3969 | // Batch 0, Channel 0 |
| 3970 | 7.0f, |
| 3971 | |
| 3972 | // Batch 0, Channel 1 |
| 3973 | 9.0f, |
| 3974 | |
| 3975 | // Batch 0, Channel 2 |
| 3976 | 11.0f, |
| 3977 | |
| 3978 | // Batch 1, Channel 0 |
| 3979 | 25.0f, |
| 3980 | |
| 3981 | // Batch 1, Channel 1 |
| 3982 | 27.0f, |
| 3983 | |
| 3984 | // Batch 1, Channel 2 |
| 3985 | 29.0f |
| 3986 | })); |
| 3987 | |
| 3988 | armnn::TensorInfo input2TensorInfo({ 2, 3, 3 }, armnn::GetDataType<T>()); |
| 3989 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3990 | // Batch 0, Channel 0 |
| 3991 | 13.0f, 14.0f, 50.0f, |
| 3992 | |
| 3993 | // Batch 0, Channel 1 |
| 3994 | 15.0f, 16.0f, 51.0f, |
| 3995 | |
| 3996 | // Batch 0, Channel 2 |
| 3997 | 17.0f, 18.0f, 52.0f, |
| 3998 | |
| 3999 | // Batch 1, Channel 0 |
| 4000 | 31.0f, 32.0f, 53.0f, |
| 4001 | |
| 4002 | // Batch 1, Channel 1 |
| 4003 | 33.0f, 34.0f, 54.0f, |
| 4004 | |
| 4005 | // Batch 1, Channel 2 |
| 4006 | 35.0f, 36.0f, 55.0f, |
| 4007 | })); |
| 4008 | |
| 4009 | armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, armnn::GetDataType<T>()); |
| 4010 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 4011 | |
| 4012 | std::vector<T> output; |
| 4013 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4014 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4015 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 4016 | { input0.data(), input1.data(), input2.data() }, |
| 4017 | outputTensorInfo, |
| 4018 | output.data(), |
| 4019 | 2, |
| 4020 | useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4021 | |
| 4022 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 4023 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4024 | // Batch 0, Channel 0 |
| 4025 | 1.0f, 2.0f, 7.0f, 13.0f, 14.0f, 50.0f, |
| 4026 | |
| 4027 | // Batch 0, Channel 1 |
| 4028 | 3.0f, 4.0f, 9.0f, 15.0f, 16.0f, 51.0f, |
| 4029 | |
| 4030 | // Batch 0, Channel 2 |
| 4031 | 5.0f, 6.0f, 11.0f, 17.0f, 18.0f, 52.0f, |
| 4032 | |
| 4033 | // Batch 1, Channel 0 |
| 4034 | 19.0f, 20.0f, 25.0f, 31.0f, 32.0f, 53.0f, |
| 4035 | |
| 4036 | // Batch 1, Channel 1 |
| 4037 | 21.0f, 22.0f, 27.0f, 33.0f, 34.0f, 54.0f, |
| 4038 | |
| 4039 | // Batch 1, Channel 2 |
| 4040 | 23.0f, 24.0f, 29.0f, 35.0f, 36.0f, 55.0f, |
| 4041 | })); |
| 4042 | |
| 4043 | return result; |
| 4044 | } |
| 4045 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4046 | LayerTestResult<float, 3> Concatenation3dDim2DiffInputDimsTest( |
| 4047 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4048 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4049 | bool useSubtensor) |
| 4050 | { |
| 4051 | return Concatenation3dDim2DiffInputDimsTestImpl<float>(workloadFactory, memoryManager, useSubtensor, 0.0f, 0); |
| 4052 | } |
| 4053 | |
| 4054 | template <typename T> |
| 4055 | LayerTestResult<T, 4> Concatenation4dTestImpl( |
| 4056 | armnn::IWorkloadFactory& workloadFactory, |
| 4057 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4058 | const armnn::TensorInfo& outputTensorInfo, |
| 4059 | unsigned int dimension, |
| 4060 | bool useSubtensor, |
| 4061 | float qScale, |
| 4062 | int32_t qOffset) |
| 4063 | { |
| 4064 | armnn::TensorInfo inputTensorInfo({ 1, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4065 | |
| 4066 | auto input0 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4067 | 1.0f, 2.0f, |
| 4068 | 3.0f, 4.0f, |
| 4069 | 5.0f, 6.0f, |
| 4070 | 7.0f, 8.0f, |
| 4071 | 9.0f, 10.0f, |
| 4072 | 11.0f, 12.0f |
| 4073 | })); |
| 4074 | |
| 4075 | auto input1 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4076 | 11.0f, 12.0f, |
| 4077 | 13.0f, 14.0f, |
| 4078 | 15.0f, 16.0f, |
| 4079 | 17.0f, 18.0f, |
| 4080 | 19.0f, 20.0f, |
| 4081 | 21.0f, 22.0f |
| 4082 | })); |
| 4083 | |
| 4084 | auto input2 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4085 | 21.0f, 22.0f, |
| 4086 | 23.0f, 24.0f, |
| 4087 | 25.0f, 26.0f, |
| 4088 | 27.0f, 28.0f, |
| 4089 | 29.0f, 30.0f, |
| 4090 | 31.0f, 32.0f |
| 4091 | })); |
| 4092 | |
| 4093 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4094 | |
| 4095 | std::vector<T> output; |
| 4096 | output.resize(outputTensorInfo.GetNumElements()); |
| 4097 | |
| 4098 | Concatenate<T>(workloadFactory, |
| 4099 | memoryManager, |
| 4100 | {inputTensorInfo, inputTensorInfo, inputTensorInfo}, |
| 4101 | {input0.data(), input1.data(), input2.data()}, |
| 4102 | outputTensorInfo, |
| 4103 | output.data(), |
| 4104 | dimension, |
| 4105 | useSubtensor); |
| 4106 | |
| 4107 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4108 | return result; |
| 4109 | } |
| 4110 | |
| 4111 | template <typename T> |
| 4112 | LayerTestResult<T, 4> Concatenation4dDim0TestImpl( |
| 4113 | armnn::IWorkloadFactory& workloadFactory, |
| 4114 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4115 | float qScale, |
| 4116 | int32_t qOffset) |
| 4117 | { |
| 4118 | armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4119 | |
| 4120 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 0, |
| 4121 | true, qScale, qOffset); |
| 4122 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4123 | 1.0f, 2.0f, |
| 4124 | 3.0f, 4.0f, |
| 4125 | 5.0f, 6.0f, |
| 4126 | 7.0f, 8.0f, |
| 4127 | 9.0f, 10.0f, |
| 4128 | 11.0f, 12.0f, |
| 4129 | |
| 4130 | 11.0f, 12.0f, |
| 4131 | 13.0f, 14.0f, |
| 4132 | 15.0f, 16.0f, |
| 4133 | 17.0f, 18.0f, |
| 4134 | 19.0f, 20.0f, |
| 4135 | 21.0f, 22.0f, |
| 4136 | |
| 4137 | 21.0f, 22.0f, |
| 4138 | 23.0f, 24.0f, |
| 4139 | 25.0f, 26.0f, |
| 4140 | 27.0f, 28.0f, |
| 4141 | 29.0f, 30.0f, |
| 4142 | 31.0f, 32.0f |
| 4143 | })); |
| 4144 | return result; |
| 4145 | } |
| 4146 | |
| 4147 | LayerTestResult<float, 4> Concatenation4dDim0Test( |
| 4148 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4149 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4150 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4151 | return Concatenation4dDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4152 | } |
| 4153 | |
| 4154 | template <typename T> |
| 4155 | LayerTestResult<T, 4> Concatenation4dDim1TestImpl( |
| 4156 | armnn::IWorkloadFactory& workloadFactory, |
| 4157 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4158 | float qScale, |
| 4159 | int32_t qOffset) |
| 4160 | { |
| 4161 | armnn::TensorInfo outputTensorInfo({ 1, 9, 2, 2 }, armnn::GetDataType<T>()); |
| 4162 | |
| 4163 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 1, |
| 4164 | true, qScale, qOffset); |
| 4165 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4166 | 1.0f, 2.0f, |
| 4167 | 3.0f, 4.0f, |
| 4168 | 5.0f, 6.0f, |
| 4169 | 7.0f, 8.0f, |
| 4170 | 9.0f, 10.0f, |
| 4171 | 11.0f, 12.0f, |
| 4172 | |
| 4173 | 11.0f, 12.0f, |
| 4174 | 13.0f, 14.0f, |
| 4175 | 15.0f, 16.0f, |
| 4176 | 17.0f, 18.0f, |
| 4177 | 19.0f, 20.0f, |
| 4178 | 21.0f, 22.0f, |
| 4179 | |
| 4180 | 21.0f, 22.0f, |
| 4181 | 23.0f, 24.0f, |
| 4182 | 25.0f, 26.0f, |
| 4183 | 27.0f, 28.0f, |
| 4184 | 29.0f, 30.0f, |
| 4185 | 31.0f, 32.0f |
| 4186 | })); |
| 4187 | |
| 4188 | return result; |
| 4189 | } |
| 4190 | |
| 4191 | LayerTestResult<float, 4> Concatenation4dDim1Test( |
| 4192 | armnn::IWorkloadFactory& workloadFactory, |
| 4193 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4194 | { |
| 4195 | return Concatenation4dDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4196 | } |
| 4197 | |
| 4198 | template <typename T> |
| 4199 | LayerTestResult<T, 4> Concatenation4dDim2TestImpl( |
| 4200 | armnn::IWorkloadFactory& workloadFactory, |
| 4201 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4202 | float qScale, |
| 4203 | int32_t qOffset) |
| 4204 | { |
| 4205 | armnn::TensorInfo outputTensorInfo({ 1, 3, 6, 2 }, armnn::GetDataType<T>()); |
| 4206 | |
| 4207 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 2, |
| 4208 | true, qScale, qOffset); |
| 4209 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4210 | 1.0f, 2.0f, |
| 4211 | 3.0f, 4.0f, |
| 4212 | 11.0f, 12.0f, |
| 4213 | 13.0f, 14.0f, |
| 4214 | 21.0f, 22.0f, |
| 4215 | 23.0f, 24.0f, |
| 4216 | |
| 4217 | 5.0f, 6.0f, |
| 4218 | 7.0f, 8.0f, |
| 4219 | 15.0f, 16.0f, |
| 4220 | 17.0f, 18.0f, |
| 4221 | 25.0f, 26.0f, |
| 4222 | 27.0f, 28.0f, |
| 4223 | |
| 4224 | 9.0f, 10.0f, |
| 4225 | 11.0f, 12.0f, |
| 4226 | 19.0f, 20.0f, |
| 4227 | 21.0f, 22.0f, |
| 4228 | 29.0f, 30.0f, |
| 4229 | 31.0f, 32.0f |
| 4230 | })); |
| 4231 | |
| 4232 | return result; |
| 4233 | } |
| 4234 | |
| 4235 | LayerTestResult<float, 4> Concatenation4dDim2Test( |
| 4236 | armnn::IWorkloadFactory& workloadFactory, |
| 4237 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4238 | { |
| 4239 | return Concatenation4dDim2TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4240 | } |
| 4241 | |
| 4242 | template <typename T> |
| 4243 | LayerTestResult<T, 4> Concatenation4dDim3TestImpl( |
| 4244 | armnn::IWorkloadFactory& workloadFactory, |
| 4245 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4246 | float qScale, |
| 4247 | int32_t qOffset, |
| 4248 | bool useSubtensor) |
| 4249 | { |
| 4250 | armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 6 }, armnn::GetDataType<T>()); |
| 4251 | |
| 4252 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<T>(workloadFactory, memoryManager, outputTensorInfo, 3, |
| 4253 | useSubtensor, qScale, qOffset); |
| 4254 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4255 | 1.0f, 2.0f, |
| 4256 | 11.0f, 12.0f, |
| 4257 | 21.0f, 22.0f, |
| 4258 | 3.0f, 4.0f, |
| 4259 | 13.0f, 14.0f, |
| 4260 | 23.0f, 24.0f, |
| 4261 | |
| 4262 | 5.0f, 6.0f, |
| 4263 | 15.0f, 16.0f, |
| 4264 | 25.0f, 26.0f, |
| 4265 | 7.0f, 8.0f, |
| 4266 | 17.0f, 18.0f, |
| 4267 | 27.0f, 28.0f, |
| 4268 | |
| 4269 | 9.0f, 10.0f, |
| 4270 | 19.0f, 20.0f, |
| 4271 | 29.0f, 30.0f, |
| 4272 | 11.0f, 12.0f, |
| 4273 | 21.0f, 22.0f, |
| 4274 | 31.0f, 32.0f |
| 4275 | })); |
| 4276 | |
| 4277 | return result; |
| 4278 | } |
| 4279 | |
| 4280 | LayerTestResult<float, 4> Concatenation4dDim3Test( |
| 4281 | armnn::IWorkloadFactory& workloadFactory, |
| 4282 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4283 | bool useSubtensor) |
| 4284 | { |
| 4285 | return Concatenation4dDim3TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, useSubtensor); |
| 4286 | } |
| 4287 | |
| 4288 | template <typename T> |
| 4289 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim0TestImpl( |
| 4290 | armnn::IWorkloadFactory& workloadFactory, |
| 4291 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4292 | float qScale, |
| 4293 | int32_t qOffset) |
| 4294 | { |
| 4295 | unsigned int dimension = 0; |
| 4296 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4297 | |
| 4298 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 4299 | 1.0f, 2.0f, |
| 4300 | 3.0f, 4.0f, |
| 4301 | 5.0f, 6.0f, |
| 4302 | 7.0f, 8.0f, |
| 4303 | 9.0f, 10.0f, |
| 4304 | 11.0f, 12.0f |
| 4305 | })); |
| 4306 | |
| 4307 | armnn::TensorInfo inputTensorInfo1({ 2, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4308 | |
| 4309 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 4310 | 11.0f, 12.0f, |
| 4311 | 13.0f, 14.0f, |
| 4312 | 15.0f, 16.0f, |
| 4313 | 17.0f, 18.0f, |
| 4314 | 19.0f, 20.0f, |
| 4315 | 21.0f, 22.0f, |
| 4316 | |
| 4317 | 21.0f, 22.0f, |
| 4318 | 23.0f, 24.0f, |
| 4319 | 25.0f, 26.0f, |
| 4320 | 27.0f, 28.0f, |
| 4321 | 29.0f, 30.0f, |
| 4322 | 31.0f, 32.0f |
| 4323 | |
| 4324 | })); |
| 4325 | |
| 4326 | armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4327 | |
| 4328 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4329 | |
| 4330 | std::vector<T> output; |
| 4331 | output.resize(outputTensorInfo.GetNumElements()); |
| 4332 | Concatenate<T>(workloadFactory, |
| 4333 | memoryManager, |
| 4334 | {inputTensorInfo0, inputTensorInfo1}, |
| 4335 | {input0.data(), input1.data()}, |
| 4336 | outputTensorInfo, |
| 4337 | output.data(), |
| 4338 | dimension, |
| 4339 | true); |
| 4340 | |
| 4341 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4342 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4343 | 1.0f, 2.0f, |
| 4344 | 3.0f, 4.0f, |
| 4345 | 5.0f, 6.0f, |
| 4346 | 7.0f, 8.0f, |
| 4347 | 9.0f, 10.0f, |
| 4348 | 11.0f, 12.0f, |
| 4349 | |
| 4350 | 11.0f, 12.0f, |
| 4351 | 13.0f, 14.0f, |
| 4352 | 15.0f, 16.0f, |
| 4353 | 17.0f, 18.0f, |
| 4354 | 19.0f, 20.0f, |
| 4355 | 21.0f, 22.0f, |
| 4356 | |
| 4357 | 21.0f, 22.0f, |
| 4358 | 23.0f, 24.0f, |
| 4359 | 25.0f, 26.0f, |
| 4360 | 27.0f, 28.0f, |
| 4361 | 29.0f, 30.0f, |
| 4362 | 31.0f, 32.0f |
| 4363 | })); |
| 4364 | |
| 4365 | return result; |
| 4366 | } |
| 4367 | |
| 4368 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim0Test( |
| 4369 | armnn::IWorkloadFactory& workloadFactory, |
| 4370 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4371 | { |
| 4372 | return Concatenation4dDiffShapeDim0TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4373 | } |
| 4374 | |
| 4375 | template <typename T> |
| 4376 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim1TestImpl( |
| 4377 | armnn::IWorkloadFactory& workloadFactory, |
| 4378 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4379 | float qScale, |
| 4380 | int32_t qOffset) |
| 4381 | { |
| 4382 | unsigned int dimension = 1; |
| 4383 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4384 | |
| 4385 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 4386 | 1.0f, 2.0f, |
| 4387 | 3.0f, 4.0f, |
| 4388 | 5.0f, 6.0f, |
| 4389 | 7.0f, 8.0f, |
| 4390 | 9.0f, 10.0f, |
| 4391 | 11.0f, 12.0f |
| 4392 | })); |
| 4393 | |
| 4394 | armnn::TensorInfo inputTensorInfo1({ 1, 2, 2, 2 }, armnn::GetDataType<T>()); |
| 4395 | |
| 4396 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 4397 | 11.0f, 12.0f, |
| 4398 | 13.0f, 14.0f, |
| 4399 | 15.0f, 16.0f, |
| 4400 | 17.0f, 18.0f, |
| 4401 | |
| 4402 | })); |
| 4403 | |
| 4404 | armnn::TensorInfo outputTensorInfo({ 1, 5, 2, 2 }, armnn::GetDataType<T>()); |
| 4405 | |
| 4406 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4407 | |
| 4408 | std::vector<T> output; |
| 4409 | output.resize(outputTensorInfo.GetNumElements()); |
| 4410 | Concatenate<T>(workloadFactory, |
| 4411 | memoryManager, |
| 4412 | {inputTensorInfo0, inputTensorInfo1}, |
| 4413 | {input0.data(), input1.data()}, |
| 4414 | outputTensorInfo, |
| 4415 | output.data(), |
| 4416 | dimension, |
| 4417 | true); |
| 4418 | |
| 4419 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4420 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4421 | 1.0f, 2.0f, |
| 4422 | 3.0f, 4.0f, |
| 4423 | 5.0f, 6.0f, |
| 4424 | 7.0f, 8.0f, |
| 4425 | 9.0f, 10.0f, |
| 4426 | 11.0f, 12.0f, |
| 4427 | 11.0f, 12.0f, |
| 4428 | 13.0f, 14.0f, |
| 4429 | 15.0f, 16.0f, |
| 4430 | 17.0f, 18.0f |
| 4431 | })); |
| 4432 | |
| 4433 | return result; |
| 4434 | } |
| 4435 | |
| 4436 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim1Test( |
| 4437 | armnn::IWorkloadFactory& workloadFactory, |
| 4438 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4439 | { |
| 4440 | return Concatenation4dDiffShapeDim1TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4441 | } |
| 4442 | |
| 4443 | template <typename T> |
| 4444 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim2TestImpl( |
| 4445 | armnn::IWorkloadFactory& workloadFactory, |
| 4446 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4447 | float qScale, |
| 4448 | int32_t qOffset) |
| 4449 | { |
| 4450 | unsigned int dimension = 2; |
| 4451 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4452 | |
| 4453 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 4454 | 1.0f, 2.0f, |
| 4455 | 3.0f, 4.0f, |
| 4456 | 5.0f, 6.0f, |
| 4457 | 7.0f, 8.0f, |
| 4458 | 9.0f, 10.0f, |
| 4459 | 11.0f, 12.0f |
| 4460 | })); |
| 4461 | |
| 4462 | armnn::TensorInfo inputTensorInfo1({ 1, 3, 3, 2 }, armnn::GetDataType<T>()); |
| 4463 | |
| 4464 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 4465 | 11.0f, 12.0f, |
| 4466 | 13.0f, 14.0f, |
| 4467 | 15.0f, 16.0f, |
| 4468 | 17.0f, 18.0f, |
| 4469 | 19.0f, 20.0f, |
| 4470 | 21.0f, 22.0f, |
| 4471 | 23.0f, 24.0f, |
| 4472 | 25.0f, 26.0f, |
| 4473 | 27.0f, 28.0f |
| 4474 | })); |
| 4475 | |
| 4476 | armnn::TensorInfo outputTensorInfo({ 1, 3, 5, 2 }, armnn::GetDataType<T>()); |
| 4477 | |
| 4478 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4479 | |
| 4480 | std::vector<T> output; |
| 4481 | output.resize(outputTensorInfo.GetNumElements()); |
| 4482 | Concatenate<T>(workloadFactory, |
| 4483 | memoryManager, |
| 4484 | {inputTensorInfo0, inputTensorInfo1}, |
| 4485 | {input0.data(), input1.data()}, |
| 4486 | outputTensorInfo, |
| 4487 | output.data(), |
| 4488 | dimension, |
| 4489 | true); |
| 4490 | |
| 4491 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4492 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4493 | 1.0f, 2.0f, |
| 4494 | 3.0f, 4.0f, |
| 4495 | 11.0f, 12.0f, |
| 4496 | 13.0f, 14.0f, |
| 4497 | 15.0f, 16.0f, |
| 4498 | |
| 4499 | 5.0f, 6.0f, |
| 4500 | 7.0f, 8.0f, |
| 4501 | 17.0f, 18.0f, |
| 4502 | 19.0f, 20.0f, |
| 4503 | 21.0f, 22.0f, |
| 4504 | |
| 4505 | 9.0f, 10.0f, |
| 4506 | 11.0f, 12.0f, |
| 4507 | 23.0f, 24.0f, |
| 4508 | 25.0f, 26.0f, |
| 4509 | 27.0f, 28.0f |
| 4510 | })); |
| 4511 | |
| 4512 | return result; |
| 4513 | } |
| 4514 | |
| 4515 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim2Test( |
| 4516 | armnn::IWorkloadFactory& workloadFactory, |
| 4517 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4518 | { |
| 4519 | return Concatenation4dDiffShapeDim2TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
| 4520 | } |
| 4521 | |
| 4522 | template <typename T> |
| 4523 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim3TestImpl( |
| 4524 | armnn::IWorkloadFactory& workloadFactory, |
| 4525 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4526 | float qScale, |
| 4527 | int32_t qOffset, |
| 4528 | bool useSubtensor) |
| 4529 | { |
| 4530 | unsigned int dimension = 3; |
| 4531 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, armnn::GetDataType<T>()); |
| 4532 | |
| 4533 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 4534 | 1.0f, 2.0f, |
| 4535 | 3.0f, 4.0f, |
| 4536 | 5.0f, 6.0f, |
| 4537 | 7.0f, 8.0f, |
| 4538 | 9.0f, 10.0f, |
| 4539 | 11.0f, 12.0f |
| 4540 | })); |
| 4541 | |
| 4542 | armnn::TensorInfo inputTensorInfo1({ 1, 3, 2, 3 }, armnn::GetDataType<T>()); |
| 4543 | |
| 4544 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 4545 | 11.0f, 12.0f, 13.0f, |
| 4546 | 14.0f, 15.0f, 16.0f, |
| 4547 | |
| 4548 | 17.0f, 18.0f, 19.0f, |
| 4549 | 20.0f, 21.0f, 22.0f, |
| 4550 | |
| 4551 | 23.0f, 24.0f, 25.0f, |
| 4552 | 26.0f, 27.0f, 28.0f |
| 4553 | })); |
| 4554 | |
| 4555 | armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 5 }, armnn::GetDataType<T>()); |
| 4556 | |
| 4557 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4558 | |
| 4559 | std::vector<T> output; |
| 4560 | output.resize(outputTensorInfo.GetNumElements()); |
| 4561 | Concatenate<T>(workloadFactory, |
| 4562 | memoryManager, |
| 4563 | {inputTensorInfo0, inputTensorInfo1}, |
| 4564 | {input0.data(), input1.data()}, |
| 4565 | outputTensorInfo, |
| 4566 | output.data(), |
| 4567 | dimension, |
| 4568 | useSubtensor); |
| 4569 | |
| 4570 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4571 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4572 | 1.0f, 2.0f, 11.0f, 12.0f, 13.0f, |
| 4573 | 3.0f, 4.0f, 14.0f, 15.0f, 16.0f, |
| 4574 | 5.0f, 6.0f, 17.0f, 18.0f, 19.0f, |
| 4575 | 7.0f, 8.0f, 20.0f, 21.0f, 22.0f, |
| 4576 | 9.0f, 10.0f, 23.0f, 24.0f, 25.0f, |
| 4577 | 11.0f, 12.0f, 26.0f, 27.0f, 28.0f |
| 4578 | })); |
| 4579 | |
| 4580 | return result; |
| 4581 | } |
| 4582 | |
| 4583 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim3Test( |
| 4584 | armnn::IWorkloadFactory& workloadFactory, |
| 4585 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4586 | bool useSubtensor) |
| 4587 | { |
| 4588 | return Concatenation4dDiffShapeDim3TestImpl<float>(workloadFactory, memoryManager, 0.0f, 0, useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4589 | } |
| 4590 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4591 | LayerTestResult<float, 4> ResizeBilinearNopTest( |
| 4592 | armnn::IWorkloadFactory& workloadFactory, |
| 4593 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4594 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4595 | { |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 4596 | const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout); |
| 4597 | const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4598 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4599 | std::vector<float> inputData({ |
| 4600 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 4601 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 4602 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 4603 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 4604 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4605 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 4606 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 4607 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 4608 | 4.0f, 5.0f, 6.0f, 7.0f |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4609 | }); |
| 4610 | |
| 4611 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4612 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4613 | { |
| 4614 | std::vector<float> tmp(inputData.size()); |
| 4615 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4616 | inputData = tmp; |
| 4617 | } |
| 4618 | |
| 4619 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4620 | |
| 4621 | LayerTestResult<float, 4> result(outputTensorInfo); |
| 4622 | result.outputExpected = input; |
| 4623 | |
| 4624 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 4625 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 4626 | |
| 4627 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4628 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
| 4629 | armnn::WorkloadInfo info; |
| 4630 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 4631 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 4632 | |
| 4633 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 4634 | |
| 4635 | inputHandle->Allocate(); |
| 4636 | outputHandle->Allocate(); |
| 4637 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 4638 | |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4639 | workload->Execute(); |
| 4640 | |
| 4641 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 4642 | return result; |
| 4643 | } |
| 4644 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4645 | LayerTestResult<float, 4> SimpleResizeBilinearTest( |
| 4646 | armnn::IWorkloadFactory& workloadFactory, |
| 4647 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4648 | const armnn::DataLayout dataLayout) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4649 | { |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 4650 | const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 2, dataLayout); |
| 4651 | const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 1, 1, dataLayout); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4652 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4653 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4654 | 1.0f, 255.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4655 | 200.0f, 250.0f, |
| 4656 | |
| 4657 | 250.0f, 200.0f, |
| 4658 | 250.0f, 1.0f |
| 4659 | }); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4660 | |
| 4661 | // The 'resize bilinear' operation projects the top-left corner of output texels into the input image, |
| 4662 | // then figures out the interpolants and weights. Note this is different to projecting the centre of the |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4663 | // output texel. Thus, for a input matrix of 2x2, we'll expect the output 1x1 matrix to contain, as |
| 4664 | // its single element, the value that was at position (0,0) of the input matrix (rather than an average, |
| 4665 | // which we would expect if projecting the centre). |
| 4666 | |
| 4667 | std::vector<float> outputData({ |
| 4668 | 1.0f, |
| 4669 | |
| 4670 | 250.0f |
| 4671 | }); |
| 4672 | |
| 4673 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4674 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4675 | { |
| 4676 | std::vector<float> tmp(inputData.size()); |
| 4677 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4678 | inputData = tmp; |
| 4679 | |
| 4680 | std::vector<float> tmp1(outputData.size()); |
| 4681 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data()); |
| 4682 | outputData = tmp1; |
| 4683 | } |
| 4684 | |
| 4685 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
| 4686 | |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4687 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4688 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4689 | |
| 4690 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 4691 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 4692 | |
| 4693 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 4694 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4695 | armnn::WorkloadInfo info; |
| 4696 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 4697 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 4698 | |
| 4699 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 4700 | |
| 4701 | inputHandle->Allocate(); |
| 4702 | outputHandle->Allocate(); |
| 4703 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 4704 | |
| 4705 | workload->Execute(); |
| 4706 | |
| 4707 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 4708 | return result; |
| 4709 | } |
| 4710 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4711 | LayerTestResult<float, 4> ResizeBilinearSqMinTest( |
| 4712 | armnn::IWorkloadFactory& workloadFactory, |
| 4713 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4714 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4715 | { |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 4716 | const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 4, 4, dataLayout); |
| 4717 | const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 2, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4718 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4719 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4720 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 4721 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 4722 | 3.0f, 4.0f, 5.0f, 6.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4723 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 4724 | |
| 4725 | 7.0f, 6.0f, 5.0f, 4.0f, |
| 4726 | 6.0f, 5.0f, 4.0f, 3.0f, |
| 4727 | 5.0f, 4.0f, 3.0f, 2.0f, |
| 4728 | 4.0f, 3.0f, 2.0f, 1.0f |
| 4729 | }); |
| 4730 | |
| 4731 | std::vector<float> outputData({ |
| 4732 | 1.0f, 3.0f, |
| 4733 | 3.0f, 5.0f, |
| 4734 | |
| 4735 | 7.0f, 5.0f, |
| 4736 | 5.0f, 3.0f |
| 4737 | }); |
| 4738 | |
| 4739 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4740 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4741 | { |
| 4742 | std::vector<float> tmp(inputData.size()); |
| 4743 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4744 | inputData = tmp; |
| 4745 | |
| 4746 | std::vector<float> tmp1(outputData.size()); |
| 4747 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data()); |
| 4748 | outputData = tmp1; |
| 4749 | } |
| 4750 | |
| 4751 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4752 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4753 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4754 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4755 | |
| 4756 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 4757 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 4758 | |
| 4759 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4760 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4761 | armnn::WorkloadInfo info; |
| 4762 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 4763 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 4764 | |
| 4765 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 4766 | |
| 4767 | inputHandle->Allocate(); |
| 4768 | outputHandle->Allocate(); |
| 4769 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 4770 | |
| 4771 | workload->Execute(); |
| 4772 | |
| 4773 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 4774 | return result; |
| 4775 | } |
| 4776 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4777 | LayerTestResult<float, 4> ResizeBilinearMinTest( |
| 4778 | armnn::IWorkloadFactory& workloadFactory, |
| 4779 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4780 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4781 | { |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 4782 | const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 5, dataLayout); |
| 4783 | const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 2, 3, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4784 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4785 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4786 | 1.0f, 2.0f, 3.0f, 5.0f, 8.0f, |
| 4787 | 13.0f, 21.0f, 34.0f, 55.0f, 89.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4788 | 144.0f, 233.0f, 377.0f, 610.0f, 987.0f, |
| 4789 | |
| 4790 | 987.0f, 610.0f, 377.0f, 233.0f, 144.0f, |
| 4791 | 89.0f, 55.0f, 34.0f, 21.0f, 13.0f, |
| 4792 | 8.0f, 5.0f, 3.0f, 2.0f, 1.0f |
| 4793 | }); |
| 4794 | |
| 4795 | std::vector<float> outputData({ |
| 4796 | 1.0f, 2.6666f, 6.00f, |
| 4797 | 78.5f, 179.3333f, 401.00f, |
| 4798 | |
| 4799 | 987.0f, 454.6670f, 203.33f, |
| 4800 | 48.5f, 22.3333f, 10.00f |
| 4801 | }); |
| 4802 | |
| 4803 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4804 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4805 | { |
| 4806 | std::vector<float> tmp(inputData.size()); |
| 4807 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4808 | inputData = tmp; |
| 4809 | |
| 4810 | std::vector<float> tmp1(outputData.size()); |
| 4811 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data()); |
| 4812 | outputData = tmp1; |
| 4813 | } |
| 4814 | |
| 4815 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4816 | |
| 4817 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4818 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4819 | |
| 4820 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 4821 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 4822 | |
| 4823 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4824 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4825 | armnn::WorkloadInfo info; |
| 4826 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 4827 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 4828 | |
| 4829 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 4830 | |
| 4831 | inputHandle->Allocate(); |
| 4832 | outputHandle->Allocate(); |
| 4833 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 4834 | |
| 4835 | workload->Execute(); |
| 4836 | |
| 4837 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 4838 | return result; |
| 4839 | } |
| 4840 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4841 | LayerTestResult<float, 4> ResizeBilinearMagTest( |
| 4842 | armnn::IWorkloadFactory& workloadFactory, |
| 4843 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4844 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4845 | { |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 4846 | const armnn::TensorInfo inputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 2, dataLayout); |
| 4847 | const armnn::TensorInfo outputTensorInfo = armnnUtils::GetTensorInfo<float>(1, 2, 3, 5, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4848 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4849 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4850 | 1.0f, 2.0f, |
| 4851 | 13.0f, 21.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4852 | 144.0f, 233.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4853 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4854 | 233.0f, 144.0f, |
| 4855 | 21.0f, 13.0f, |
| 4856 | 2.0f, 1.0f |
| 4857 | }); |
| 4858 | |
| 4859 | std::vector<float> outputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4860 | 1.0f, 1.4f, 1.8f, 2.0f, 2.0f, |
| 4861 | 13.0f, 16.2f, 19.4f, 21.0f, 21.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4862 | 144.0f, 179.6f, 215.2f, 233.0f, 233.0f, |
| 4863 | |
| 4864 | 233.0f, 197.4f, 161.8f, 144.0f, 144.0f, |
| 4865 | 21.0f, 17.8f, 14.6f, 13.0f, 13.0f, |
| 4866 | 2.0f, 1.6f, 1.2f, 1.0f, 1.0f |
| 4867 | }); |
| 4868 | |
| 4869 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4870 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 4871 | { |
| 4872 | std::vector<float> tmp(inputData.size()); |
| 4873 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4874 | inputData = tmp; |
| 4875 | |
| 4876 | std::vector<float> tmp1(outputData.size()); |
| 4877 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data()); |
| 4878 | outputData = tmp1; |
| 4879 | } |
| 4880 | |
| 4881 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
| 4882 | |
| 4883 | LayerTestResult<float, 4> result(outputTensorInfo); |
| 4884 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4885 | |
| 4886 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 4887 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 4888 | |
| 4889 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 4890 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4891 | armnn::WorkloadInfo info; |
| 4892 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 4893 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 4894 | |
| 4895 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 4896 | |
| 4897 | inputHandle->Allocate(); |
| 4898 | outputHandle->Allocate(); |
| 4899 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 4900 | |
| 4901 | workload->Execute(); |
| 4902 | |
| 4903 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 4904 | return result; |
| 4905 | } |
| 4906 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4907 | LayerTestResult<float, 2> FakeQuantizationTest( |
| 4908 | armnn::IWorkloadFactory& workloadFactory, |
| 4909 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4910 | { |
| 4911 | constexpr unsigned int width = 2; |
| 4912 | constexpr unsigned int height = 3; |
| 4913 | |
| 4914 | const armnn::TensorInfo tensorInfo({height, width }, |
| 4915 | armnn::DataType::Float32); |
| 4916 | auto input = MakeTensor<float, 2>(tensorInfo, std::vector<float>({ |
| 4917 | -10.0f, -5.0f, |
| 4918 | 0.0f, 5.0f, |
| 4919 | 10.0f, 10.0f |
| 4920 | })); |
| 4921 | |
| 4922 | LayerTestResult<float, 2> ret(tensorInfo); |
| 4923 | |
| 4924 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(tensorInfo); |
| 4925 | |
| 4926 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(tensorInfo); |
| 4927 | |
| 4928 | armnn::FakeQuantizationQueueDescriptor data; |
| 4929 | armnn::WorkloadInfo info; |
| 4930 | |
| 4931 | AddInputToWorkload(data, info, tensorInfo, inputHandle.get()); |
| 4932 | AddOutputToWorkload(data, info, tensorInfo, outputHandle.get()); |
| 4933 | float min = -10.f; |
| 4934 | float max = 10.f; |
| 4935 | |
| 4936 | data.m_Parameters.m_Min = min; |
| 4937 | data.m_Parameters.m_Max = max; |
| 4938 | |
| 4939 | armnn::PassthroughCpuTensorHandle refHandle(tensorInfo, &ret.outputExpected[0][0]); |
| 4940 | armnn::FakeQuantizationQueueDescriptor refData = data; |
| 4941 | armnn::WorkloadInfo refInfo = info; |
| 4942 | SetWorkloadOutput(refData, refInfo, 0, tensorInfo, &refHandle); |
| 4943 | |
| 4944 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateFakeQuantization(data, info); |
| 4945 | |
| 4946 | inputHandle->Allocate(); |
| 4947 | outputHandle->Allocate(); |
| 4948 | |
| 4949 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0]); |
| 4950 | |
| 4951 | workload->Execute(); |
| 4952 | |
| 4953 | CopyDataFromITensorHandle(&ret.output[0][0], outputHandle.get()); |
| 4954 | |
| 4955 | ret.outputExpected = MakeTensor<float, 2>(tensorInfo, std::vector<float>({ |
| 4956 | 0.0f, 63.0f, |
| 4957 | 128.0f, 191.0f, |
| 4958 | 255.0f, 255.0f |
| 4959 | })); |
| 4960 | return ret; |
| 4961 | } |
| 4962 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 4963 | namespace |
| 4964 | { |
| 4965 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4966 | LayerTestResult<float, 4> L2NormalizationTestImpl( |
| 4967 | armnn::IWorkloadFactory& workloadFactory, |
| 4968 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4969 | const armnn::TensorShape& inputOutputTensorShape, |
| 4970 | const std::vector<float>& inputValues, |
| 4971 | const std::vector<float>& expectedOutputValues, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4972 | const armnn::DataLayout layout) |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 4973 | { |
| 4974 | const armnn::TensorInfo inputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32); |
| 4975 | const armnn::TensorInfo outputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32); |
| 4976 | |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 4977 | // at this point if we require it permute the input data |
| 4978 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
| 4979 | std::vector<float> inputData = inputValues; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4980 | if (layout == armnn::DataLayout::NHWC) |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 4981 | { |
| 4982 | std::vector<float> tmp(inputData.size()); |
| 4983 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data()); |
| 4984 | inputData = tmp; |
| 4985 | } |
| 4986 | |
| 4987 | auto inputTensor = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(inputData)); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 4988 | |
| 4989 | LayerTestResult<float, 4> result(outputTensorInfo); |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 4990 | std::vector<float> expectedOutputData = expectedOutputValues; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 4991 | if (layout == armnn::DataLayout::NHWC) |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 4992 | { |
| 4993 | std::vector<float> tmp(expectedOutputData.size()); |
| 4994 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, expectedOutputData.data(), tmp.data()); |
| 4995 | expectedOutputData = tmp; |
| 4996 | } |
| 4997 | result.outputExpected = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(expectedOutputData)); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 4998 | |
| 4999 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5000 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5001 | |
| 5002 | armnn::L2NormalizationQueueDescriptor descriptor; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5003 | descriptor.m_Parameters.m_DataLayout = layout; |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5004 | armnn::WorkloadInfo info; |
| 5005 | |
| 5006 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5007 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5008 | |
| 5009 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateL2Normalization(descriptor, info); |
| 5010 | |
| 5011 | inputHandle->Allocate(); |
| 5012 | outputHandle->Allocate(); |
| 5013 | |
| 5014 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]); |
| 5015 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5016 | ExecuteWorkload(*workload, memoryManager); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5017 | |
| 5018 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5019 | |
| 5020 | return result; |
| 5021 | } |
| 5022 | |
| 5023 | float CalcInvL2Norm(std::initializer_list<float> elements) |
| 5024 | { |
| 5025 | const float reduction = std::accumulate(elements.begin(), elements.end(), 0.0f, |
| 5026 | [](float acc, float element) { return acc + element * element; }); |
| 5027 | return 1.0f / sqrtf(reduction); |
| 5028 | } |
| 5029 | |
| 5030 | } // anonymous namespace |
| 5031 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5032 | template<typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5033 | LayerTestResult<T, 2> Pad2dTestCommon( |
| 5034 | armnn::IWorkloadFactory& workloadFactory, |
| 5035 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5036 | float qScale, |
| 5037 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5038 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5039 | const armnn::TensorShape inputShape{ 3, 3 }; |
| 5040 | const armnn::TensorShape outputShape{ 7, 7 }; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5041 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5042 | const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>()); |
| 5043 | const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5044 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5045 | std::vector<T> inputValues( |
| 5046 | QuantizedVector<T>(qScale, qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5047 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5048 | // Height (3) x Width (3) |
| 5049 | 4, 8, 6, |
| 5050 | 7, 4, 4, |
| 5051 | 3, 2, 4 |
| 5052 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5053 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5054 | std::vector<T> expectedOutputValues( |
| 5055 | QuantizedVector<T>(qScale, qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5056 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5057 | 0, 0, 0, 0, 0, 0, 0, |
| 5058 | 0, 0, 0, 0, 0, 0, 0, |
| 5059 | 0, 0, 4, 8, 6, 0, 0, |
| 5060 | 0, 0, 7, 4, 4, 0, 0, |
| 5061 | 0, 0, 3, 2, 4, 0, 0, |
| 5062 | 0, 0, 0, 0, 0, 0, 0, |
| 5063 | 0, 0, 0, 0, 0, 0, 0 |
| 5064 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5065 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5066 | auto inputTensor = MakeTensor<T, 2>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5067 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5068 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 5069 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5070 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5071 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5072 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5073 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5074 | armnn::PadQueueDescriptor descriptor; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5075 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5076 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 5077 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
| 5078 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5079 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5080 | descriptor.m_Parameters.m_PadList = PadList; |
| 5081 | armnn::WorkloadInfo info; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5082 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5083 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5084 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5085 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5086 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5087 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5088 | inputHandle->Allocate(); |
| 5089 | outputHandle->Allocate(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5090 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5091 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0]); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5092 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5093 | workload->Execute(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5094 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5095 | CopyDataFromITensorHandle(&result.output[0][0], outputHandle.get()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5096 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5097 | return result; |
| 5098 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5099 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5100 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5101 | LayerTestResult<T, 3> Pad3dTestCommon( |
| 5102 | armnn::IWorkloadFactory& workloadFactory, |
| 5103 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5104 | float qScale, |
| 5105 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5106 | { |
| 5107 | const armnn::TensorShape inputShape{ 2, 2, 2 }; |
| 5108 | const armnn::TensorShape outputShape{ 3, 5, 6 }; |
| 5109 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5110 | const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>()); |
| 5111 | const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5112 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5113 | std::vector<T> inputValues( |
| 5114 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5115 | { |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5116 | // Channel 0, Height (2) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5117 | 0, 4, |
| 5118 | 2, 5, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5119 | |
| 5120 | // Channel 1, Height (2) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5121 | 6, 1, |
| 5122 | 5, 2 |
| 5123 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5124 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5125 | std::vector<T> expectedOutputValues( |
| 5126 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5127 | { |
| 5128 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5129 | 0, 0, 0, 0, 0, 0, |
| 5130 | 0, 0, 0, 0, 0, 0, |
| 5131 | 0, 0, 0, 4, 0, 0, |
| 5132 | 0, 0, 2, 5, 0, 0, |
| 5133 | 0, 0, 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5134 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5135 | 0, 0, 0, 0, 0, 0, |
| 5136 | 0, 0, 0, 0, 0, 0, |
| 5137 | 0, 0, 6, 1, 0, 0, |
| 5138 | 0, 0, 5, 2, 0, 0, |
| 5139 | 0, 0, 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5140 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5141 | 0, 0, 0, 0, 0, 0, |
| 5142 | 0, 0, 0, 0, 0, 0, |
| 5143 | 0, 0, 0, 0, 0, 0, |
| 5144 | 0, 0, 0, 0, 0, 0, |
| 5145 | 0, 0, 0, 0, 0, 0 |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5146 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5147 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5148 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5149 | auto inputTensor = MakeTensor<T, 3>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5150 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5151 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 5152 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5153 | |
| 5154 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5155 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5156 | |
| 5157 | armnn::PadQueueDescriptor descriptor; |
| 5158 | |
| 5159 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 5160 | PadList.push_back(std::pair<unsigned int, unsigned int>(0,1)); |
| 5161 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,1)); |
| 5162 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
| 5163 | |
| 5164 | descriptor.m_Parameters.m_PadList = PadList; |
| 5165 | armnn::WorkloadInfo info; |
| 5166 | |
| 5167 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5168 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5169 | |
| 5170 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
| 5171 | |
| 5172 | inputHandle->Allocate(); |
| 5173 | outputHandle->Allocate(); |
| 5174 | |
| 5175 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0]); |
| 5176 | |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5177 | workload->Execute(); |
| 5178 | |
| 5179 | CopyDataFromITensorHandle(&result.output[0][0][0], outputHandle.get()); |
| 5180 | |
| 5181 | return result; |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5182 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5183 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5184 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5185 | LayerTestResult<T, 4> Pad4dTestCommon( |
| 5186 | armnn::IWorkloadFactory& workloadFactory, |
| 5187 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5188 | float qScale, |
| 5189 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5190 | { |
| 5191 | const armnn::TensorShape inputShape{ 2, 2, 3, 2 }; |
| 5192 | const armnn::TensorShape outputShape{ 4, 5, 7, 4 }; |
| 5193 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5194 | const armnn::TensorInfo inputTensorInfo(inputShape, armnn::GetDataType<T>()); |
| 5195 | const armnn::TensorInfo outputTensorInfo(outputShape, armnn::GetDataType<T>()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5196 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5197 | std::vector<T> inputValues( |
| 5198 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5199 | { |
| 5200 | // Batch 0, Channel 0, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5201 | 0, 1, |
| 5202 | 2, 3, |
| 5203 | 4, 5, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5204 | |
| 5205 | // Batch 0, Channel 1, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5206 | 6, 7, |
| 5207 | 8, 9, |
| 5208 | 10, 11, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5209 | |
| 5210 | // Batch 1, Channel 0, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5211 | 12, 13, |
| 5212 | 14, 15, |
| 5213 | 16, 17, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5214 | |
| 5215 | // Batch 1, Channel 1, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5216 | 18, 19, |
| 5217 | 20, 21, |
| 5218 | 22, 23 |
| 5219 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5220 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5221 | std::vector<T> expectedOutputValues( |
| 5222 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5223 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5224 | 0, 0, 0, 0, |
| 5225 | 0, 0, 0, 0, |
| 5226 | 0, 0, 0, 0, |
| 5227 | 0, 0, 0, 0, |
| 5228 | 0, 0, 0, 0, |
| 5229 | 0, 0, 0, 0, |
| 5230 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5231 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5232 | 0, 0, 0, 0, |
| 5233 | 0, 0, 0, 0, |
| 5234 | 0, 0, 0, 0, |
| 5235 | 0, 0, 0, 0, |
| 5236 | 0, 0, 0, 0, |
| 5237 | 0, 0, 0, 0, |
| 5238 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5239 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5240 | 0, 0, 0, 0, |
| 5241 | 0, 0, 0, 0, |
| 5242 | 0, 0, 0, 0, |
| 5243 | 0, 0, 0, 0, |
| 5244 | 0, 0, 0, 0, |
| 5245 | 0, 0, 0, 0, |
| 5246 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5247 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5248 | 0, 0, 0, 0, |
| 5249 | 0, 0, 0, 0, |
| 5250 | 0, 0, 0, 0, |
| 5251 | 0, 0, 0, 0, |
| 5252 | 0, 0, 0, 0, |
| 5253 | 0, 0, 0, 0, |
| 5254 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5255 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5256 | 0, 0, 0, 0, |
| 5257 | 0, 0, 0, 0, |
| 5258 | 0, 0, 0, 0, |
| 5259 | 0, 0, 0, 0, |
| 5260 | 0, 0, 0, 0, |
| 5261 | 0, 0, 0, 0, |
| 5262 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5263 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5264 | 0, 0, 0, 0, |
| 5265 | 0, 0, 0, 0, |
| 5266 | 0, 0, 0, 0, |
| 5267 | 0, 0, 0, 0, |
| 5268 | 0, 0, 0, 0, |
| 5269 | 0, 0, 0, 0, |
| 5270 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5271 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5272 | 0, 0, 0, 0, |
| 5273 | 0, 0, 0, 0, |
| 5274 | 0, 0, 0, 0, |
| 5275 | 0, 0, 0, 0, |
| 5276 | 0, 0, 0, 0, |
| 5277 | 0, 0, 0, 0, |
| 5278 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5279 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5280 | 0, 0, 0, 0, |
| 5281 | 0, 0, 0, 0, |
| 5282 | 0, 0, 0, 0, |
| 5283 | 0, 0, 1, 0, |
| 5284 | 0, 2, 3, 0, |
| 5285 | 0, 4, 5, 0, |
| 5286 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5287 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5288 | 0, 0, 0, 0, |
| 5289 | 0, 0, 0, 0, |
| 5290 | 0, 0, 0, 0, |
| 5291 | 0, 6, 7, 0, |
| 5292 | 0, 8, 9, 0, |
| 5293 | 0, 10, 11, 0, |
| 5294 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5295 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5296 | 0, 0, 0, 0, |
| 5297 | 0, 0, 0, 0, |
| 5298 | 0, 0, 0, 0, |
| 5299 | 0, 0, 0, 0, |
| 5300 | 0, 0, 0, 0, |
| 5301 | 0, 0, 0, 0, |
| 5302 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5303 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5304 | 0, 0, 0, 0, |
| 5305 | 0, 0, 0, 0, |
| 5306 | 0, 0, 0, 0, |
| 5307 | 0, 0, 0, 0, |
| 5308 | 0, 0, 0, 0, |
| 5309 | 0, 0, 0, 0, |
| 5310 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5311 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5312 | 0, 0, 0, 0, |
| 5313 | 0, 0, 0, 0, |
| 5314 | 0, 0, 0, 0, |
| 5315 | 0, 0, 0, 0, |
| 5316 | 0, 0, 0, 0, |
| 5317 | 0, 0, 0, 0, |
| 5318 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5319 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5320 | 0, 0, 0, 0, |
| 5321 | 0, 0, 0, 0, |
| 5322 | 0, 0, 0, 0, |
| 5323 | 0, 12, 13, 0, |
| 5324 | 0, 14, 15, 0, |
| 5325 | 0, 16, 17, 0, |
| 5326 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5327 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5328 | 0, 0, 0, 0, |
| 5329 | 0, 0, 0, 0, |
| 5330 | 0, 0, 0, 0, |
| 5331 | 0, 18, 19, 0, |
| 5332 | 0, 20, 21, 0, |
| 5333 | 0, 22, 23, 0, |
| 5334 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5335 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5336 | 0, 0, 0, 0, |
| 5337 | 0, 0, 0, 0, |
| 5338 | 0, 0, 0, 0, |
| 5339 | 0, 0, 0, 0, |
| 5340 | 0, 0, 0, 0, |
| 5341 | 0, 0, 0, 0, |
| 5342 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5343 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5344 | 0, 0, 0, 0, |
| 5345 | 0, 0, 0, 0, |
| 5346 | 0, 0, 0, 0, |
| 5347 | 0, 0, 0, 0, |
| 5348 | 0, 0, 0, 0, |
| 5349 | 0, 0, 0, 0, |
| 5350 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5351 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5352 | 0, 0, 0, 0, |
| 5353 | 0, 0, 0, 0, |
| 5354 | 0, 0, 0, 0, |
| 5355 | 0, 0, 0, 0, |
| 5356 | 0, 0, 0, 0, |
| 5357 | 0, 0, 0, 0, |
| 5358 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5359 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5360 | 0, 0, 0, 0, |
| 5361 | 0, 0, 0, 0, |
| 5362 | 0, 0, 0, 0, |
| 5363 | 0, 0, 0, 0, |
| 5364 | 0, 0, 0, 0, |
| 5365 | 0, 0, 0, 0, |
| 5366 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5367 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5368 | 0, 0, 0, 0, |
| 5369 | 0, 0, 0, 0, |
| 5370 | 0, 0, 0, 0, |
| 5371 | 0, 0, 0, 0, |
| 5372 | 0, 0, 0, 0, |
| 5373 | 0, 0, 0, 0, |
| 5374 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5375 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5376 | 0, 0, 0, 0, |
| 5377 | 0, 0, 0, 0, |
| 5378 | 0, 0, 0, 0, |
| 5379 | 0, 0, 0, 0, |
| 5380 | 0, 0, 0, 0, |
| 5381 | 0, 0, 0, 0, |
| 5382 | 0, 0, 0, 0 |
| 5383 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5384 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5385 | auto inputTensor = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5386 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5387 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 5388 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5389 | |
| 5390 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5391 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5392 | |
| 5393 | armnn::PadQueueDescriptor descriptor; |
| 5394 | |
| 5395 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 5396 | PadList.push_back(std::pair<unsigned int, unsigned int>(1,1)); |
| 5397 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,1)); |
| 5398 | PadList.push_back(std::pair<unsigned int, unsigned int>(3,1)); |
| 5399 | PadList.push_back(std::pair<unsigned int, unsigned int>(1,1)); |
| 5400 | |
| 5401 | descriptor.m_Parameters.m_PadList = PadList; |
| 5402 | armnn::WorkloadInfo info; |
| 5403 | |
| 5404 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5405 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5406 | |
| 5407 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
| 5408 | |
| 5409 | inputHandle->Allocate(); |
| 5410 | outputHandle->Allocate(); |
| 5411 | |
| 5412 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]); |
| 5413 | |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5414 | workload->Execute(); |
| 5415 | |
| 5416 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5417 | |
| 5418 | return result; |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5419 | } |
| 5420 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5421 | LayerTestResult<uint8_t, 2> PadUint82dTest( |
| 5422 | armnn::IWorkloadFactory& workloadFactory, |
| 5423 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5424 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5425 | return Pad2dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5426 | } |
| 5427 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5428 | LayerTestResult<uint8_t, 3> PadUint83dTest( |
| 5429 | armnn::IWorkloadFactory& workloadFactory, |
| 5430 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5431 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5432 | return Pad3dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5433 | } |
| 5434 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5435 | LayerTestResult<uint8_t, 4> PadUint84dTest( |
| 5436 | armnn::IWorkloadFactory& workloadFactory, |
| 5437 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5438 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5439 | return Pad4dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5440 | } |
| 5441 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5442 | LayerTestResult<float, 2> PadFloat322dTest( |
| 5443 | armnn::IWorkloadFactory& workloadFactory, |
| 5444 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5445 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5446 | return Pad2dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5447 | } |
| 5448 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5449 | LayerTestResult<float, 3> PadFloat323dTest( |
| 5450 | armnn::IWorkloadFactory& workloadFactory, |
| 5451 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5452 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5453 | return Pad3dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5454 | } |
| 5455 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5456 | LayerTestResult<float, 4> PadFloat324dTest( |
| 5457 | armnn::IWorkloadFactory& workloadFactory, |
| 5458 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5459 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5460 | return Pad4dTestCommon<float>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5461 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5462 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5463 | LayerTestResult<float, 4> L2Normalization1dTest( |
| 5464 | armnn::IWorkloadFactory& workloadFactory, |
| 5465 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5466 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5467 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5468 | // Width: 1 |
| 5469 | // Height: 1 |
| 5470 | // Channels: 10 |
| 5471 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5472 | unsigned int numberOfBatches = 1; |
| 5473 | unsigned int numberOfChannels = 10; |
| 5474 | unsigned int height = 1; |
| 5475 | unsigned int width = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5476 | |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5477 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 5478 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5479 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5480 | std::vector<float> inputValues |
| 5481 | { |
| 5482 | // Batch 0, Channel 0, Height (1) x Width (1) |
| 5483 | 1.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5484 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5485 | // Batch 0, Channel 1, Height (1) x Width (1) |
| 5486 | 2.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5487 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5488 | // Batch 0, Channel 2, Height (1) x Width (1) |
| 5489 | 3.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5490 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5491 | // Batch 0, Channel 3, Height (1) x Width (1) |
| 5492 | 4.0f, |
| 5493 | |
| 5494 | // Batch 0, Channel 4, Height (1) x Width (1) |
| 5495 | 5.0f, |
| 5496 | |
| 5497 | // Batch 0, Channel 5, Height (1) x Width (1) |
| 5498 | 6.0f, |
| 5499 | |
| 5500 | // Batch 0, Channel 6, Height (1) x Width (1) |
| 5501 | 7.0f, |
| 5502 | |
| 5503 | // Batch 0, Channel 7, Height (1) x Width (1) |
| 5504 | 8.0f, |
| 5505 | |
| 5506 | // Batch 0, Channel 8, Height (1) x Width (1) |
| 5507 | 9.0f, |
| 5508 | |
| 5509 | // Batch 0, Channel 9, Height (1) x Width (1) |
| 5510 | 10.0f |
| 5511 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5512 | const float approxInvL2Norm = 0.050964719f; |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5513 | std::vector<float> expectedOutputValues |
| 5514 | { |
| 5515 | // Batch 0, Channel 0, Height (1) x Width (1) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5516 | 1.0f * approxInvL2Norm, |
| 5517 | 2.0f * approxInvL2Norm, |
| 5518 | 3.0f * approxInvL2Norm, |
| 5519 | 4.0f * approxInvL2Norm, |
| 5520 | 5.0f * approxInvL2Norm, |
| 5521 | 6.0f * approxInvL2Norm, |
| 5522 | 7.0f * approxInvL2Norm, |
| 5523 | 8.0f * approxInvL2Norm, |
| 5524 | 9.0f * approxInvL2Norm, |
| 5525 | 10.0f * approxInvL2Norm |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5526 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5527 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5528 | |
| 5529 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5530 | inputValues, expectedOutputValues, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5531 | } |
| 5532 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5533 | LayerTestResult<float, 4> L2Normalization2dTest( |
| 5534 | armnn::IWorkloadFactory& workloadFactory, |
| 5535 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5536 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5537 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5538 | // Width: 5 |
| 5539 | // Height: 1 |
| 5540 | // Channels: 2 |
| 5541 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5542 | unsigned int numberOfBatches = 1; |
| 5543 | unsigned int numberOfChannels = 2; |
| 5544 | unsigned int height = 1; |
| 5545 | unsigned int width = 5; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5546 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 5547 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5548 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5549 | std::vector<float> inputValues |
| 5550 | { |
| 5551 | // Batch 0, Channel 0, Height (1) x Width (5) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5552 | 1.0f, 3.0f, 5.0f, 7.0f, 9.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5553 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5554 | // Batch 0, Channel 1, Height (1) x Width (5) |
| 5555 | 2.0f, 4.0f, 6.0f, 8.0f, 10.0f |
| 5556 | }; |
| 5557 | std::vector<float> expectedOutputValues |
| 5558 | { |
| 5559 | // Batch 0, Channel 0, Height (1) x Width (5) |
| 5560 | 1.0f * CalcInvL2Norm({ 1.0f, 2.0f }), |
| 5561 | 3.0f * CalcInvL2Norm({ 3.0f, 4.0f }), |
| 5562 | 5.0f * CalcInvL2Norm({ 5.0f, 6.0f }), |
| 5563 | 7.0f * CalcInvL2Norm({ 7.0f, 8.0f }), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5564 | 9.0f * CalcInvL2Norm({ 9.0f, 10.0f }), |
| 5565 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5566 | // Batch 0, Channel 1, Height (1) x Width (5) |
| 5567 | 2.0f * CalcInvL2Norm({ 1.0f, 2.0f }), |
| 5568 | 4.0f * CalcInvL2Norm({ 3.0f, 4.0f }), |
| 5569 | 6.0f * CalcInvL2Norm({ 5.0f, 6.0f }), |
| 5570 | 8.0f * CalcInvL2Norm({ 7.0f, 8.0f }), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5571 | 10.0f * CalcInvL2Norm({ 9.0f, 10.0f }) |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5572 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5573 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5574 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5575 | inputValues, expectedOutputValues, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5576 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5577 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5578 | LayerTestResult<float, 4> L2Normalization3dTest( |
| 5579 | armnn::IWorkloadFactory& workloadFactory, |
| 5580 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5581 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5582 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5583 | // Width: 3 |
| 5584 | // Height: 4 |
| 5585 | // Channels: 2 |
| 5586 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5587 | unsigned int numberOfBatches = 1; |
| 5588 | unsigned int numberOfChannels = 2; |
| 5589 | unsigned int height = 4; |
| 5590 | unsigned int width = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5591 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 5592 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5593 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5594 | std::vector<float> inputValues |
| 5595 | { |
| 5596 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5597 | 119.0f, 21.0f, 150.0f, |
| 5598 | 149.0f, 32.0f, 179.0f, |
| 5599 | 15.0f, 227.0f, 141.0f, |
| 5600 | 147.0f, 199.0f, 220.0f, |
| 5601 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5602 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5603 | 110.0f, 140.0f, 73.0f, |
| 5604 | 211.0f, 212.0f, 89.0f, |
| 5605 | 24.0f, 138.0f, 188.0f, |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5606 | 162.0f, 12.0f, 161.0f |
| 5607 | }; |
| 5608 | std::vector<float> expectedOutputValues |
| 5609 | { |
| 5610 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5611 | 119.0f * CalcInvL2Norm({ 119.0f, 110.0f }), |
| 5612 | 21.0f * CalcInvL2Norm({ 21.0f, 140.0f }), |
| 5613 | 150.0f * CalcInvL2Norm({ 150.0f, 73.0f }), |
| 5614 | 149.0f * CalcInvL2Norm({ 149.0f, 211.0f }), |
| 5615 | 32.0f * CalcInvL2Norm({ 32.0f, 212.0f }), |
| 5616 | 179.0f * CalcInvL2Norm({ 179.0f, 89.0f }), |
| 5617 | 15.0f * CalcInvL2Norm({ 15.0f, 24.0f }), |
| 5618 | 227.0f * CalcInvL2Norm({ 227.0f, 138.0f }), |
| 5619 | 141.0f * CalcInvL2Norm({ 141.0f, 188.0f }), |
| 5620 | 147.0f * CalcInvL2Norm({ 147.0f, 162.0f }), |
| 5621 | 199.0f * CalcInvL2Norm({ 199.0f, 12.0f }), |
| 5622 | 220.0f * CalcInvL2Norm({ 220.0f, 161.0f }), |
| 5623 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5624 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5625 | 110.0f * CalcInvL2Norm({ 119.0f, 110.0f }), |
| 5626 | 140.0f * CalcInvL2Norm({ 21.0f, 140.0f }), |
| 5627 | 73.0f * CalcInvL2Norm({ 150.0f, 73.0f }), |
| 5628 | 211.0f * CalcInvL2Norm({ 149.0f, 211.0f }), |
| 5629 | 212.0f * CalcInvL2Norm({ 32.0f, 212.0f }), |
| 5630 | 89.0f * CalcInvL2Norm({ 179.0f, 89.0f }), |
| 5631 | 24.0f * CalcInvL2Norm({ 15.0f, 24.0f }), |
| 5632 | 138.0f * CalcInvL2Norm({ 227.0f, 138.0f }), |
| 5633 | 188.0f * CalcInvL2Norm({ 141.0f, 188.0f }), |
| 5634 | 162.0f * CalcInvL2Norm({ 147.0f, 162.0f }), |
| 5635 | 12.0f * CalcInvL2Norm({ 199.0f, 12.0f }), |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5636 | 161.0f * CalcInvL2Norm({ 220.0f, 161.0f }) |
| 5637 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5638 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5639 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5640 | inputValues, expectedOutputValues, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5641 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5642 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5643 | LayerTestResult<float, 4> L2Normalization4dTest( |
| 5644 | armnn::IWorkloadFactory& workloadFactory, |
| 5645 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5646 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5647 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5648 | // Width: 3 |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5649 | // Height: 4 |
| 5650 | // Channels: 3 |
| 5651 | // BatchSize: 2 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5652 | unsigned int numberOfBatches = 2; |
| 5653 | unsigned int numberOfChannels = 3; |
| 5654 | unsigned int height = 4; |
| 5655 | unsigned int width = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5656 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 5657 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5658 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5659 | std::vector<float> inputValues |
| 5660 | { |
| 5661 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5662 | 235.0f, 46.0f, 178.0f, |
| 5663 | 100.0f, 123.0f, 19.0f, |
| 5664 | 172.0f, 74.0f, 250.0f, |
| 5665 | 6.0f, 195.0f, 80.0f, |
| 5666 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5667 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5668 | 113.0f, 95.0f, 202.0f, |
| 5669 | 77.0f, 114.0f, 71.0f, |
| 5670 | 122.0f, 246.0f, 166.0f, |
| 5671 | 82.0f, 28.0f, 37.0f, |
| 5672 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5673 | // Batch 0, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5674 | 56.0f, 170.0f, 162.0f, |
| 5675 | 194.0f, 89.0f, 254.0f, |
| 5676 | 12.0f, 209.0f, 200.0f, |
| 5677 | 1.0f, 64.0f, 54.0f, |
| 5678 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5679 | // Batch 1, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5680 | 67.0f, 90.0f, 49.0f, |
| 5681 | 7.0f, 163.0f, 18.0f, |
| 5682 | 25.0f, 117.0f, 103.0f, |
| 5683 | 247.0f, 59.0f, 189.0f, |
| 5684 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5685 | // Batch 1, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5686 | 239.0f, 104.0f, 199.0f, |
| 5687 | 17.0f, 124.0f, 153.0f, |
| 5688 | 222.0f, 217.0f, 75.0f, |
| 5689 | 32.0f, 126.0f, 21.0f, |
| 5690 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5691 | // Batch 1, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5692 | 97.0f, 145.0f, 215.0f, |
| 5693 | 115.0f, 116.0f, 238.0f, |
| 5694 | 226.0f, 16.0f, 132.0f, |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5695 | 92.0f, 125.0f, 88.0f |
| 5696 | }; |
| 5697 | std::vector<float> expectedOutputValues |
| 5698 | { |
| 5699 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5700 | 235.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 5701 | 46.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 5702 | 178.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 5703 | 100.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 5704 | 123.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 5705 | 19.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 5706 | 172.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 5707 | 74.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 5708 | 250.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 5709 | 6.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 5710 | 195.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 5711 | 80.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 5712 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5713 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5714 | 113.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 5715 | 95.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 5716 | 202.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 5717 | 77.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 5718 | 114.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 5719 | 71.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 5720 | 122.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 5721 | 246.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 5722 | 166.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 5723 | 82.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 5724 | 28.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 5725 | 37.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 5726 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5727 | // Batch 0, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5728 | 56.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 5729 | 170.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 5730 | 162.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 5731 | 194.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 5732 | 89.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 5733 | 254.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 5734 | 12.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 5735 | 209.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 5736 | 200.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 5737 | 1.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 5738 | 64.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 5739 | 54.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 5740 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5741 | // Batch 1, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5742 | 67.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 5743 | 90.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 5744 | 49.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 5745 | 7.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 5746 | 163.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 5747 | 18.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 5748 | 25.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 5749 | 117.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 5750 | 103.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 5751 | 247.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 5752 | 59.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
| 5753 | 189.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }), |
| 5754 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5755 | // Batch 1, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5756 | 239.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 5757 | 104.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 5758 | 199.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 5759 | 17.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 5760 | 124.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 5761 | 153.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 5762 | 222.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 5763 | 217.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 5764 | 75.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 5765 | 32.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 5766 | 126.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
| 5767 | 21.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }), |
| 5768 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5769 | // Batch 1, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5770 | 97.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 5771 | 145.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 5772 | 215.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 5773 | 115.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 5774 | 116.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 5775 | 238.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 5776 | 226.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 5777 | 16.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 5778 | 132.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 5779 | 92.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 5780 | 125.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5781 | 88.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }) |
| 5782 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5783 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5784 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5785 | inputValues, expectedOutputValues, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5786 | } |
| 5787 | |
| 5788 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5789 | LayerTestResult<T, 4> ConstantTestImpl( |
| 5790 | armnn::IWorkloadFactory& workloadFactory, |
| 5791 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5792 | float qScale, |
| 5793 | int32_t qOffset) |
| 5794 | { |
| 5795 | constexpr unsigned int inputWidth = 3; |
| 5796 | constexpr unsigned int inputHeight = 4; |
| 5797 | constexpr unsigned int inputChannels = 3; |
| 5798 | constexpr unsigned int inputBatchSize = 2; |
| 5799 | |
| 5800 | constexpr unsigned int outputWidth = inputWidth; |
| 5801 | constexpr unsigned int outputHeight = inputHeight; |
| 5802 | constexpr unsigned int outputChannels = inputChannels; |
| 5803 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 5804 | |
| 5805 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 5806 | armnn::GetDataType<T>()); |
| 5807 | |
| 5808 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 5809 | armnn::GetDataType<T>()); |
| 5810 | |
| 5811 | // Set quantization parameters if the requested type is a quantized type. |
| 5812 | if(armnn::IsQuantizedType<T>()) |
| 5813 | { |
| 5814 | inputTensorInfo.SetQuantizationScale(qScale); |
| 5815 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 5816 | outputTensorInfo.SetQuantizationScale(qScale); |
| 5817 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 5818 | } |
| 5819 | |
| 5820 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 5821 | QuantizedVector<T>(qScale, qOffset, { |
| 5822 | // Batch 0, Channel 0 |
| 5823 | 235.0f, 46.0f, 178.0f, |
| 5824 | 100.0f, 123.0f, 19.0f, |
| 5825 | 172.0f, 74.0f, 250.0f, |
| 5826 | 6.0f, 195.0f, 80.0f, |
| 5827 | |
| 5828 | // Batch 0, Channel 1 |
| 5829 | 113.0f, 95.0f, 202.0f, |
| 5830 | 77.0f, 114.0f, 71.0f, |
| 5831 | 122.0f, 246.0f, 166.0f, |
| 5832 | 82.0f, 28.0f, 37.0f, |
| 5833 | |
| 5834 | // Batch 0, Channel 2 |
| 5835 | 56.0f, 170.0f, 162.0f, |
| 5836 | 194.0f, 89.0f, 254.0f, |
| 5837 | 12.0f, 209.0f, 200.0f, |
| 5838 | 1.0f, 64.0f, 54.0f, |
| 5839 | |
| 5840 | // Batch 1, Channel 0 |
| 5841 | 67.0f, 90.0f, 49.0f, |
| 5842 | 7.0f, 163.0f, 18.0f, |
| 5843 | 25.0f, 117.0f, 103.0f, |
| 5844 | 247.0f, 59.0f, 189.0f, |
| 5845 | |
| 5846 | // Batch 1, Channel 1 |
| 5847 | 239.0f, 104.0f, 199.0f, |
| 5848 | 17.0f, 124.0f, 153.0f, |
| 5849 | 222.0f, 217.0f, 75.0f, |
| 5850 | 32.0f, 126.0f, 21.0f, |
| 5851 | |
| 5852 | // Batch 1, Channel 2 |
| 5853 | 97.0f, 145.0f, 215.0f, |
| 5854 | 115.0f, 116.0f, 238.0f, |
| 5855 | 226.0f, 16.0f, 132.0f, |
| 5856 | 92.0f, 125.0f, 88.0f, |
| 5857 | }))); |
| 5858 | |
| 5859 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 5860 | result.outputExpected = input; |
| 5861 | |
| 5862 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5863 | |
| 5864 | armnn::ScopedCpuTensorHandle constantTensor(inputTensorInfo); |
| 5865 | AllocateAndCopyDataToITensorHandle(&constantTensor, &input[0][0][0][0]); |
| 5866 | |
| 5867 | armnn::ConstantQueueDescriptor descriptor; |
| 5868 | descriptor.m_LayerOutput = &constantTensor; |
| 5869 | |
| 5870 | armnn::WorkloadInfo info; |
| 5871 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5872 | |
| 5873 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConstant(descriptor, info); |
| 5874 | |
| 5875 | outputHandle->Allocate(); |
| 5876 | |
| 5877 | workload->Execute(); |
| 5878 | |
| 5879 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5880 | return result; |
| 5881 | } |
| 5882 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5883 | LayerTestResult<float, 4> ConstantTest( |
| 5884 | armnn::IWorkloadFactory& workloadFactory, |
| 5885 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5886 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5887 | return ConstantTestImpl<float>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5888 | } |
| 5889 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5890 | LayerTestResult<uint8_t, 4> ConstantTestUint8( |
| 5891 | armnn::IWorkloadFactory& workloadFactory, |
| 5892 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5893 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5894 | return ConstantTestImpl<uint8_t>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5895 | } |
| 5896 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5897 | LayerTestResult<uint8_t, 3> MergerUint8Test( |
| 5898 | armnn::IWorkloadFactory& workloadFactory, |
| 5899 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5900 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5901 | unsigned int outputWidth = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5902 | unsigned int outputHeight = 6; |
| 5903 | unsigned int outputChannels = 3; |
| 5904 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5905 | unsigned int inputWidth1 = 3; |
| 5906 | unsigned int inputHeight1 = 6; |
| 5907 | unsigned int inputChannels1 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5908 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5909 | unsigned int inputWidth2 = 3; |
| 5910 | unsigned int inputHeight2 = 6; |
| 5911 | unsigned int inputChannels2 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5912 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 5913 | // Defines the tensor descriptors. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5914 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::QuantisedAsymm8); |
| 5915 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::QuantisedAsymm8); |
| 5916 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::QuantisedAsymm8); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5917 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 5918 | // Arbitrary scale and offsets. They don't really matter as the merger operator doesn't dequantize/quantize them. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5919 | const float scale = 0.13497836f; |
| 5920 | const int32_t offset = -7; |
| 5921 | |
| 5922 | outputTensorInfo.SetQuantizationScale(scale); |
| 5923 | outputTensorInfo.SetQuantizationOffset(offset); |
| 5924 | inputTensorInfo1.SetQuantizationScale(scale); |
| 5925 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 5926 | inputTensorInfo2.SetQuantizationScale(scale); |
| 5927 | inputTensorInfo2.SetQuantizationOffset(offset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5928 | |
| 5929 | LayerTestResult<uint8_t, 3> ret(outputTensorInfo); |
| 5930 | |
| 5931 | ret.outputExpected = MakeTensor<uint8_t, 3>(outputTensorInfo, std::vector<uint8_t>( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5932 | { |
| 5933 | 1, 2, 3, |
| 5934 | 4, 5, 6, |
| 5935 | 7, 8, 9, |
| 5936 | 10, 11, 12, |
| 5937 | 13, 14, 15, |
| 5938 | 16, 17, 18, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5939 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5940 | 19, 20, 21, |
| 5941 | 22, 23, 24, |
| 5942 | 25, 26, 27, |
| 5943 | 28, 29, 30, |
| 5944 | 31, 32, 33, |
| 5945 | 34, 35, 36, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5946 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5947 | 37, 38, 39, |
| 5948 | 40, 41, 42, |
| 5949 | 43, 44, 45, |
| 5950 | 46, 47, 48, |
| 5951 | 49, 50, 51, |
| 5952 | 52, 53, 54, |
| 5953 | }) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5954 | ); |
| 5955 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5956 | auto input1 = MakeTensor<uint8_t, 3>(inputTensorInfo1, std::vector<uint8_t>( |
| 5957 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5958 | 1, 2, 3, |
| 5959 | 4, 5, 6, |
| 5960 | 7, 8, 9, |
| 5961 | 10, 11, 12, |
| 5962 | 13, 14, 15, |
| 5963 | 16, 17, 18, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5964 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5965 | 19, 20, 21, |
| 5966 | 22, 23, 24, |
| 5967 | 25, 26, 27, |
| 5968 | 28, 29, 30, |
| 5969 | 31, 32, 33, |
| 5970 | 34, 35, 36, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5971 | }) |
| 5972 | ); |
| 5973 | |
| 5974 | auto input2 = MakeTensor<uint8_t, 3>(inputTensorInfo2, std::vector<uint8_t>( |
| 5975 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5976 | 37, 38, 39, |
| 5977 | 40, 41, 42, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5978 | 43, 44, 45, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 5979 | 46, 47, 48, |
| 5980 | 49, 50, 51, |
| 5981 | 52, 53, 54, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5982 | }) |
| 5983 | ); |
| 5984 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 5985 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5986 | armnn::MergerQueueDescriptor::ViewOrigin window1(wOrigin1); |
| 5987 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 5988 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5989 | armnn::MergerQueueDescriptor::ViewOrigin window2(wOrigin2); |
| 5990 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5991 | |
| 5992 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5993 | |
| 5994 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 5995 | |
| 5996 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 5997 | subTensorsSupported ? |
| 5998 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 5999 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6000 | |
| 6001 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 6002 | subTensorsSupported ? |
| 6003 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 6004 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 6005 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6006 | |
| 6007 | armnn::MergerQueueDescriptor data; |
| 6008 | armnn::WorkloadInfo info; |
| 6009 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6010 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6011 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6012 | |
| 6013 | data.m_ViewOrigins.push_back(window1); |
| 6014 | data.m_ViewOrigins.push_back(window2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6015 | |
| 6016 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMerger(data, info); |
| 6017 | |
| 6018 | inputHandle1->Allocate(); |
| 6019 | inputHandle2->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6020 | outputHandle->Allocate(); |
| 6021 | |
| 6022 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 6023 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6024 | |
| 6025 | workload->Execute(); |
| 6026 | |
| 6027 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 6028 | |
| 6029 | return ret; |
| 6030 | } |
| 6031 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6032 | LayerTestResult<uint8_t, 4> AdditionUint8Test( |
| 6033 | armnn::IWorkloadFactory& workloadFactory, |
| 6034 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6035 | { |
| 6036 | unsigned int batchSize = 1; |
| 6037 | unsigned int channels = 2; |
| 6038 | unsigned int height = 2; |
| 6039 | unsigned int width = 3; |
| 6040 | |
| 6041 | const float scale = 7.0f; |
| 6042 | const int32_t offset = 3; |
| 6043 | |
| 6044 | armnn::TensorInfo inputTensorInfo1, inputTensorInfo2; |
| 6045 | armnn::TensorInfo outputTensorInfo; |
| 6046 | |
| 6047 | const unsigned int shape[] = { batchSize, channels, height, width }; |
| 6048 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8); |
| 6049 | inputTensorInfo1.SetQuantizationScale(scale); |
| 6050 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 6051 | |
| 6052 | inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8); |
| 6053 | inputTensorInfo2.SetQuantizationScale(scale); |
| 6054 | inputTensorInfo2.SetQuantizationOffset(offset); |
| 6055 | |
| 6056 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::QuantisedAsymm8); |
| 6057 | outputTensorInfo.SetQuantizationScale(scale); |
| 6058 | outputTensorInfo.SetQuantizationOffset(offset); |
| 6059 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6060 | // See dequantized values to the right. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6061 | auto input1 = MakeTensor<uint8_t, 4>(inputTensorInfo1, std::vector<uint8_t>( |
| 6062 | { |
| 6063 | 63, 35, 77, 70, 56, 112, // 420, 224, 518, 469, 371, 763 |
| 6064 | 203, 28, 252, 168, 245, 91 // 1400, 175, 1743, 1155, 1694, 616 |
| 6065 | })); |
| 6066 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6067 | // See dequantized values to the right. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6068 | auto input2 = MakeTensor<uint8_t, 4>(inputTensorInfo1, std::vector<uint8_t>( |
| 6069 | { |
| 6070 | 21, 7, 175, 231, 175, 210, // 126, 28, 1204, 1596, 1204, 1449 |
| 6071 | 126, 161, 63, 21, 105, 126 // 861, 1106, 420, 126, 714, 861 |
| 6072 | })); |
| 6073 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6074 | // See dequantized values to the right. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6075 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6076 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>( |
| 6077 | { |
| 6078 | 81, 39, 249, 255, 228, 255, // 546, 252, 1722, 2065(clamped), 1575, 2212(clamped) |
| 6079 | 255, 186, 255, 186, 255, 214, // 2261(clamped), 1281, 2163(clamped), 1281, 2408(clamped), 1477 |
| 6080 | })); |
| 6081 | |
| 6082 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6083 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 6084 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6085 | |
| 6086 | armnn::AdditionQueueDescriptor data; |
| 6087 | armnn::WorkloadInfo info; |
| 6088 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6089 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 6090 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6091 | |
| 6092 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 6093 | |
| 6094 | inputHandle1->Allocate(); |
| 6095 | inputHandle2->Allocate(); |
| 6096 | outputHandle->Allocate(); |
| 6097 | |
| 6098 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 6099 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 6100 | |
| 6101 | workload->Execute(); |
| 6102 | |
| 6103 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6104 | |
| 6105 | return result; |
| 6106 | } |
| 6107 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6108 | namespace |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6109 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6110 | LayerTestResult<uint8_t, 4> MultiplicationUint8TestHelper( |
| 6111 | armnn::IWorkloadFactory& workloadFactory, |
| 6112 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 6113 | const unsigned int shape0[4], |
| 6114 | const std::vector<uint8_t> & values0, |
| 6115 | float scale0, |
| 6116 | int32_t offset0, |
| 6117 | const unsigned int shape1[4], |
| 6118 | const std::vector<uint8_t> & values1, |
| 6119 | float scale1, |
| 6120 | int32_t offset1, |
| 6121 | const unsigned int outShape[4], |
| 6122 | const std::vector<uint8_t> & outValues, |
| 6123 | float outScale, |
| 6124 | int32_t outOffset) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6125 | { |
| 6126 | armnn::TensorInfo inputTensorInfo0(4, shape0, armnn::DataType::QuantisedAsymm8); |
| 6127 | armnn::TensorInfo inputTensorInfo1(4, shape1, armnn::DataType::QuantisedAsymm8); |
| 6128 | armnn::TensorInfo outputTensorInfo(4, outShape, armnn::DataType::QuantisedAsymm8); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6129 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6130 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 6131 | inputTensorInfo0.SetQuantizationOffset(offset0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6132 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6133 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 6134 | inputTensorInfo1.SetQuantizationOffset(offset1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6135 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6136 | outputTensorInfo.SetQuantizationScale(outScale); |
| 6137 | outputTensorInfo.SetQuantizationOffset(outOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6138 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6139 | auto input0 = MakeTensor<uint8_t, 4>(inputTensorInfo0, values0); |
| 6140 | auto input1 = MakeTensor<uint8_t, 4>(inputTensorInfo1, values1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6141 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6142 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6143 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, outValues); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6144 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6145 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6146 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6147 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6148 | |
| 6149 | armnn::MultiplicationQueueDescriptor data; |
| 6150 | armnn::WorkloadInfo info; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6151 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 6152 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6153 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6154 | |
| 6155 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 6156 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6157 | inputHandle0->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6158 | inputHandle1->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6159 | outputHandle->Allocate(); |
| 6160 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6161 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6162 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6163 | |
| 6164 | workload->Execute(); |
| 6165 | |
| 6166 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6167 | |
| 6168 | return result; |
| 6169 | } |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6170 | } // anonymous namespace |
| 6171 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6172 | LayerTestResult<uint8_t, 4> MultiplicationUint8Test( |
| 6173 | armnn::IWorkloadFactory& workloadFactory, |
| 6174 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6175 | { |
| 6176 | unsigned int batchSize = 1; |
| 6177 | unsigned int channels = 2; |
| 6178 | unsigned int height = 2; |
| 6179 | unsigned int width = 3; |
| 6180 | const unsigned int shape[] = { batchSize, channels, height, width }; |
| 6181 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6182 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6183 | std::vector<uint8_t> input0({ |
| 6184 | 62, 37, 3, 172, 13, 111, // 244, 144, 8, 684, 48, 440, |
| 6185 | 188, 20, 73, 31, 23, 31 // 748, 76, 288, 120, 88, 120 |
| 6186 | }); |
| 6187 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6188 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6189 | std::vector<uint8_t> input1({ |
| 6190 | 126, 240, 252, 183, 121, 247, // 384, 726, 762, 555, 369, 747, |
| 6191 | 48, 115, 151, 79, 78, 97 // 150, 351, 459, 243, 240, 297 |
| 6192 | }); |
| 6193 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6194 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6195 | std::vector<uint8_t> output( |
| 6196 | { |
| 6197 | 64, 72, 0, 255, 8, 236, // 93696, 104544, 6096(clamped), 379620(clamped), 17712, 328680, |
| 6198 | 77, 15, 92, 16, 10, 21, // 112200, 26676, 132192, 29160, 21120, 35640 |
| 6199 | }); |
| 6200 | |
| 6201 | return MultiplicationUint8TestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6202 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6203 | shape, |
| 6204 | input0, |
| 6205 | 4.0f, |
| 6206 | 1, |
| 6207 | shape, |
| 6208 | input1, |
| 6209 | 3.0f, |
| 6210 | -2, |
| 6211 | shape, |
| 6212 | output, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6213 | 1366.255f, // Scale/offset chosen to have output values out of range. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6214 | -5); |
| 6215 | } |
| 6216 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6217 | LayerTestResult<uint8_t, 4> MultiplicationBroadcast1ElementUint8Test( |
| 6218 | armnn::IWorkloadFactory& workloadFactory, |
| 6219 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6220 | { |
| 6221 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 6222 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 6223 | |
| 6224 | std::vector<uint8_t> input0({ |
| 6225 | 1, 2, 3, 4, 5, 6, |
| 6226 | 7, 8, 9, 10, 11, 12 |
| 6227 | }); |
| 6228 | |
| 6229 | std::vector<uint8_t> input1({2}); |
| 6230 | |
| 6231 | std::vector<uint8_t> output({ |
| 6232 | 2, 4, 6, 8, 10, 12, |
| 6233 | 14, 16, 18, 20, 22, 24 |
| 6234 | }); |
| 6235 | |
| 6236 | return MultiplicationUint8TestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6237 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6238 | shape0, |
| 6239 | input0, |
| 6240 | 1.0f, |
| 6241 | 0, |
| 6242 | shape1, |
| 6243 | input1, |
| 6244 | 1.0f, |
| 6245 | 0, |
| 6246 | shape0, |
| 6247 | output, |
| 6248 | 1.0f, |
| 6249 | 0); |
| 6250 | } |
| 6251 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6252 | LayerTestResult<uint8_t, 4> MultiplicationBroadcast1DVectorUint8Test( |
| 6253 | armnn::IWorkloadFactory& workloadFactory, |
| 6254 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6255 | { |
| 6256 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 6257 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 6258 | |
| 6259 | std::vector<uint8_t> input0({ |
| 6260 | 1, 2, 3, 4, 5, 6, |
| 6261 | 7, 8, 9, 10, 11, 12 |
| 6262 | }); |
| 6263 | |
| 6264 | std::vector<uint8_t> input1({1, 2, 3}); |
| 6265 | |
| 6266 | std::vector<uint8_t> output({ |
| 6267 | 1, 4, 9, 4, 10, 18, |
| 6268 | 7, 16, 27, 10, 22, 36 |
| 6269 | }); |
| 6270 | |
| 6271 | return MultiplicationUint8TestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6272 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6273 | shape0, |
| 6274 | input0, |
| 6275 | 1.0f, |
| 6276 | 0, |
| 6277 | shape1, |
| 6278 | input1, |
| 6279 | 1.0f, |
| 6280 | 0, |
| 6281 | shape0, |
| 6282 | output, |
| 6283 | 1.0f, |
| 6284 | 0); |
| 6285 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6286 | |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6287 | namespace |
| 6288 | { |
| 6289 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6290 | LayerTestResult<T, 4> SubtractionTestHelper( |
| 6291 | armnn::IWorkloadFactory& workloadFactory, |
| 6292 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 6293 | const unsigned int shape0[4], |
| 6294 | const std::vector<T>& values0, |
| 6295 | float scale0, |
| 6296 | int32_t offset0, |
| 6297 | const unsigned int shape1[4], |
| 6298 | const std::vector<T> & values1, |
| 6299 | float scale1, |
| 6300 | int32_t offset1, |
| 6301 | const unsigned int outShape[4], |
| 6302 | const std::vector<T> & outValues, |
| 6303 | float outScale, |
| 6304 | int32_t outOffset) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6305 | { |
| 6306 | auto dataType = (std::is_same<T, uint8_t>::value ? |
| 6307 | armnn::DataType::QuantisedAsymm8 : |
| 6308 | armnn::DataType::Float32); |
| 6309 | |
| 6310 | armnn::TensorInfo inputTensorInfo0(4, shape0, dataType); |
| 6311 | armnn::TensorInfo inputTensorInfo1(4, shape1, dataType); |
| 6312 | armnn::TensorInfo outputTensorInfo(4, outShape, dataType); |
| 6313 | |
| 6314 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 6315 | inputTensorInfo0.SetQuantizationOffset(offset0); |
| 6316 | |
| 6317 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 6318 | inputTensorInfo1.SetQuantizationOffset(offset1); |
| 6319 | |
| 6320 | outputTensorInfo.SetQuantizationScale(outScale); |
| 6321 | outputTensorInfo.SetQuantizationOffset(outOffset); |
| 6322 | |
| 6323 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 6324 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
| 6325 | |
| 6326 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 6327 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
| 6328 | |
| 6329 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 6330 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6331 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6332 | |
| 6333 | armnn::SubtractionQueueDescriptor data; |
| 6334 | armnn::WorkloadInfo info; |
| 6335 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 6336 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6337 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6338 | |
| 6339 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateSubtraction(data, info); |
| 6340 | |
| 6341 | inputHandle0->Allocate(); |
| 6342 | inputHandle1->Allocate(); |
| 6343 | outputHandle->Allocate(); |
| 6344 | |
| 6345 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 6346 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 6347 | |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6348 | workload->Execute(); |
| 6349 | |
| 6350 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6351 | |
| 6352 | return result; |
| 6353 | } |
| 6354 | } // anonymous namespace |
| 6355 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6356 | LayerTestResult<uint8_t, 4> SubtractionUint8Test( |
| 6357 | armnn::IWorkloadFactory& workloadFactory, |
| 6358 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6359 | { |
| 6360 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6361 | const unsigned int shape1[] = { 1, 1, 2, 2 }; |
| 6362 | |
| 6363 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 6364 | std::vector<uint8_t> input1({ 1, 2, 1, 2 }); |
| 6365 | std::vector<uint8_t> output({ 3, 3, 5, 5 }); |
| 6366 | |
| 6367 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6368 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6369 | shape0, input0, 0.5f, 2, |
| 6370 | shape1, input1, 1.0f, 0, |
| 6371 | shape0, output, 1.0f, 0); |
| 6372 | } |
| 6373 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6374 | LayerTestResult<uint8_t, 4> SubtractionBroadcast1ElementUint8Test( |
| 6375 | armnn::IWorkloadFactory& workloadFactory, |
| 6376 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6377 | { |
| 6378 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6379 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 6380 | |
| 6381 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 6382 | std::vector<uint8_t> input1({ 2 }); |
| 6383 | std::vector<uint8_t> output({ 5, 6, 7, 8 }); |
| 6384 | |
| 6385 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6386 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6387 | shape0, input0, 0.5f, 2, |
| 6388 | shape1, input1, 1.0f, 0, |
| 6389 | shape0, output, 1.0f, 3); |
| 6390 | } |
| 6391 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6392 | LayerTestResult<uint8_t, 4> SubtractionBroadcastUint8Test( |
| 6393 | armnn::IWorkloadFactory& workloadFactory, |
| 6394 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6395 | { |
| 6396 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6397 | const unsigned int shape1[] = { 1, 1, 2, 1 }; |
| 6398 | |
| 6399 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 6400 | std::vector<uint8_t> input1({ 2, 1 }); |
| 6401 | std::vector<uint8_t> output({ 8, 11, 12, 15 }); |
| 6402 | |
| 6403 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6404 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6405 | shape0, input0, 1.0f, 0, |
| 6406 | shape1, input1, 1.0f, 0, |
| 6407 | shape0, output, 1.0f, 0); |
| 6408 | } |
| 6409 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6410 | LayerTestResult<float, 4> SubtractionTest( |
| 6411 | armnn::IWorkloadFactory& workloadFactory, |
| 6412 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6413 | { |
| 6414 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6415 | const unsigned int shape1[] = { 1, 1, 2, 2 }; |
| 6416 | |
| 6417 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 6418 | std::vector<float> input1({ 1, -1, 0, 2 }); |
| 6419 | std::vector<float> output({ 0, 3, 3, 2 }); |
| 6420 | |
| 6421 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6422 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6423 | shape0, input0, 1.0f, 0, |
| 6424 | shape1, input1, 1.0f, 0, |
| 6425 | shape0, output, 1.0f, 0); |
| 6426 | } |
| 6427 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6428 | LayerTestResult<float, 4> SubtractionBroadcast1ElementTest( |
| 6429 | armnn::IWorkloadFactory& workloadFactory, |
| 6430 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6431 | { |
| 6432 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6433 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 6434 | |
| 6435 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 6436 | std::vector<float> input1({ 10 }); |
| 6437 | std::vector<float> output({ -9, -8, -7, -6 }); |
| 6438 | |
| 6439 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6440 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6441 | shape0, input0, 1.0f, 0, |
| 6442 | shape1, input1, 1.0f, 0, |
| 6443 | shape0, output, 1.0f, 0); |
| 6444 | } |
| 6445 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6446 | LayerTestResult<float, 4> SubtractionBroadcastTest( |
| 6447 | armnn::IWorkloadFactory& workloadFactory, |
| 6448 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6449 | { |
| 6450 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 6451 | const unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 6452 | |
| 6453 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 6454 | std::vector<float> input1({ 10, -5 }); |
| 6455 | std::vector<float> output({ -9, 7, -7, 9 }); |
| 6456 | |
| 6457 | return SubtractionTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6458 | memoryManager, |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 6459 | shape0, input0, 1.0f, 0, |
| 6460 | shape1, input1, 1.0f, 0, |
| 6461 | shape0, output, 1.0f, 0); |
| 6462 | } |
| 6463 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6464 | LayerTestResult<uint8_t, 4> ResizeBilinearNopUint8Test( |
| 6465 | armnn::IWorkloadFactory& workloadFactory, |
| 6466 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6467 | { |
| 6468 | constexpr unsigned int inputWidth = 4; |
| 6469 | constexpr unsigned int inputHeight = 4; |
| 6470 | constexpr unsigned int inputChannels = 1; |
| 6471 | constexpr unsigned int inputBatchSize = 1; |
| 6472 | |
| 6473 | constexpr unsigned int outputWidth = inputWidth; |
| 6474 | constexpr unsigned int outputHeight = inputHeight; |
| 6475 | constexpr unsigned int outputChannels = inputChannels; |
| 6476 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6477 | |
| 6478 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6479 | armnn::DataType::QuantisedAsymm8); |
| 6480 | inputTensorInfo.SetQuantizationScale(1.5f); |
| 6481 | inputTensorInfo.SetQuantizationOffset(-3); |
| 6482 | |
| 6483 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6484 | armnn::DataType::QuantisedAsymm8); |
| 6485 | outputTensorInfo.SetQuantizationScale(1.5f); |
| 6486 | outputTensorInfo.SetQuantizationOffset(-3); |
| 6487 | |
| 6488 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 6489 | 1, 2, 3, 4, |
| 6490 | 2, 3, 4, 5, |
| 6491 | 3, 4, 5, 6, |
| 6492 | 4, 5, 6, 7 |
| 6493 | })); |
| 6494 | |
| 6495 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6496 | result.outputExpected = input; |
| 6497 | |
| 6498 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6499 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6500 | |
| 6501 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 6502 | armnn::WorkloadInfo info; |
| 6503 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6504 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6505 | |
| 6506 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 6507 | |
| 6508 | inputHandle->Allocate(); |
| 6509 | outputHandle->Allocate(); |
| 6510 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 6511 | |
| 6512 | workload->Execute(); |
| 6513 | |
| 6514 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6515 | return result; |
| 6516 | } |
| 6517 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6518 | LayerTestResult<uint8_t, 4> SimpleResizeBilinearUint8Test( |
| 6519 | armnn::IWorkloadFactory& workloadFactory, |
| 6520 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6521 | { |
| 6522 | constexpr unsigned int inputWidth = 2; |
| 6523 | constexpr unsigned int inputHeight = 2; |
| 6524 | constexpr unsigned int inputChannels = 1; |
| 6525 | constexpr unsigned int inputBatchSize = 1; |
| 6526 | |
| 6527 | constexpr unsigned int outputWidth = inputWidth / 2; |
| 6528 | constexpr unsigned int outputHeight = inputHeight / 2; |
| 6529 | constexpr unsigned int outputChannels = inputChannels; |
| 6530 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6531 | |
| 6532 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6533 | armnn::DataType::QuantisedAsymm8); |
| 6534 | inputTensorInfo.SetQuantizationScale(0.1567f); |
| 6535 | inputTensorInfo.SetQuantizationOffset(1); |
| 6536 | |
| 6537 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6538 | armnn::DataType::QuantisedAsymm8); |
| 6539 | outputTensorInfo.SetQuantizationScale(0.1567f); |
| 6540 | outputTensorInfo.SetQuantizationOffset(1); |
| 6541 | |
| 6542 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 6543 | 1, 255, |
| 6544 | 200, 250 |
| 6545 | })); |
| 6546 | |
| 6547 | // The 'resize bilinear' operation projects the top-left corner of output texels into the input image, |
| 6548 | // then figures out the interpolants and weights. Note this is different to projecting the centre of the |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6549 | // output texel - and thus we'll expect the output 1x1 matrix to contain, as its single element, the value |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6550 | // that was at position (0,0) of the input matrix (rather than an average, which we would expect if projecting |
| 6551 | // the centre). |
| 6552 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6553 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 6554 | 1 |
| 6555 | })); |
| 6556 | |
| 6557 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6558 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6559 | |
| 6560 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 6561 | armnn::WorkloadInfo info; |
| 6562 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6563 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6564 | |
| 6565 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 6566 | |
| 6567 | inputHandle->Allocate(); |
| 6568 | outputHandle->Allocate(); |
| 6569 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 6570 | |
| 6571 | workload->Execute(); |
| 6572 | |
| 6573 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6574 | return result; |
| 6575 | } |
| 6576 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6577 | LayerTestResult<uint8_t, 4> ResizeBilinearSqMinUint8Test( |
| 6578 | armnn::IWorkloadFactory& workloadFactory, |
| 6579 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6580 | { |
| 6581 | constexpr unsigned int inputWidth = 4; |
| 6582 | constexpr unsigned int inputHeight = 4; |
| 6583 | constexpr unsigned int inputChannels = 1; |
| 6584 | constexpr unsigned int inputBatchSize = 1; |
| 6585 | |
| 6586 | constexpr unsigned int outputWidth = inputWidth / 2; |
| 6587 | constexpr unsigned int outputHeight = inputHeight / 2; |
| 6588 | constexpr unsigned int outputChannels = inputChannels; |
| 6589 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6590 | |
| 6591 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6592 | armnn::DataType::QuantisedAsymm8); |
| 6593 | inputTensorInfo.SetQuantizationScale(3.141592f); |
| 6594 | inputTensorInfo.SetQuantizationOffset(3); |
| 6595 | |
| 6596 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6597 | armnn::DataType::QuantisedAsymm8); |
| 6598 | outputTensorInfo.SetQuantizationScale(3.141592f); |
| 6599 | outputTensorInfo.SetQuantizationOffset(3); |
| 6600 | |
| 6601 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 6602 | 1, 2, 3, 4, |
| 6603 | 2, 3, 4, 5, |
| 6604 | 3, 4, 5, 6, |
| 6605 | 4, 5, 6, 7 |
| 6606 | })); |
| 6607 | |
| 6608 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6609 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 6610 | 1, 3, |
| 6611 | 3, 5 |
| 6612 | })); |
| 6613 | |
| 6614 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6615 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6616 | |
| 6617 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 6618 | armnn::WorkloadInfo info; |
| 6619 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6620 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6621 | |
| 6622 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 6623 | |
| 6624 | inputHandle->Allocate(); |
| 6625 | outputHandle->Allocate(); |
| 6626 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 6627 | |
| 6628 | workload->Execute(); |
| 6629 | |
| 6630 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6631 | return result; |
| 6632 | } |
| 6633 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6634 | LayerTestResult<uint8_t, 4> ResizeBilinearMinUint8Test( |
| 6635 | armnn::IWorkloadFactory& workloadFactory, |
| 6636 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6637 | { |
| 6638 | constexpr unsigned int inputWidth = 3; |
| 6639 | constexpr unsigned int inputHeight = 2; |
| 6640 | constexpr unsigned int inputChannels = 1; |
| 6641 | constexpr unsigned int inputBatchSize = 1; |
| 6642 | |
| 6643 | constexpr unsigned int outputWidth = 2; |
| 6644 | constexpr unsigned int outputHeight = 1; |
| 6645 | constexpr unsigned int outputChannels = inputChannels; |
| 6646 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6647 | |
| 6648 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6649 | armnn::DataType::QuantisedAsymm8); |
| 6650 | inputTensorInfo.SetQuantizationScale(1.5f); |
| 6651 | inputTensorInfo.SetQuantizationOffset(-1); |
| 6652 | |
| 6653 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6654 | armnn::DataType::QuantisedAsymm8); |
| 6655 | outputTensorInfo.SetQuantizationScale(1.5f); |
| 6656 | outputTensorInfo.SetQuantizationOffset(-1); |
| 6657 | |
| 6658 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 6659 | 1, 2, 3, // 3.0, 4.5, 6.0 |
| 6660 | 5, 8, 13 // 9.0, 13.5, 21.0 |
| 6661 | })); |
| 6662 | |
| 6663 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6664 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 6665 | 1, 3 // 3.0, 5.25 |
| 6666 | })); |
| 6667 | |
| 6668 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6669 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6670 | |
| 6671 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 6672 | armnn::WorkloadInfo info; |
| 6673 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6674 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6675 | |
| 6676 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 6677 | |
| 6678 | inputHandle->Allocate(); |
| 6679 | outputHandle->Allocate(); |
| 6680 | |
| 6681 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 6682 | |
| 6683 | workload->Execute(); |
| 6684 | |
| 6685 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6686 | return result; |
| 6687 | } |
| 6688 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6689 | LayerTestResult<uint8_t, 4> ResizeBilinearMagUint8Test( |
| 6690 | armnn::IWorkloadFactory& workloadFactory, |
| 6691 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6692 | { |
| 6693 | constexpr unsigned int inputWidth = 2; |
| 6694 | constexpr unsigned int inputHeight = 3; |
| 6695 | constexpr unsigned int inputChannels = 1; |
| 6696 | constexpr unsigned int inputBatchSize = 1; |
| 6697 | |
| 6698 | constexpr unsigned int outputWidth = 5; |
| 6699 | constexpr unsigned int outputHeight = 3; |
| 6700 | constexpr unsigned int outputChannels = inputChannels; |
| 6701 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6702 | |
| 6703 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6704 | armnn::DataType::QuantisedAsymm8); |
| 6705 | inputTensorInfo.SetQuantizationScale(0.010765f); |
| 6706 | inputTensorInfo.SetQuantizationOffset(7); |
| 6707 | |
| 6708 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6709 | armnn::DataType::QuantisedAsymm8); |
| 6710 | outputTensorInfo.SetQuantizationScale(0.010132f); |
| 6711 | outputTensorInfo.SetQuantizationOffset(-18); |
| 6712 | |
| 6713 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 6714 | 24, 228, // 0.183005, 2.379065, |
| 6715 | 105, 128, // 1.05497, 1.302565 |
| 6716 | 230, 71 // 2.400595, 0.68896 |
| 6717 | })); |
| 6718 | |
| 6719 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 6720 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 6721 | 0, 87, 173, 217, 217, // 0.18300501, 1.06142902, 1.93985295, 2.37906504, 2.37906504 |
| 6722 | 86, 96, 106, 111, 111, // 1.05497003, 1.15400803, 1.25304604, 1.30256498, 1.30256498 |
| 6723 | 219, 151, 84, 50, 50 // 2.40059495, 1.71594095, 1.03128707, 0.68896002, 0.68896002 |
| 6724 | })); |
| 6725 | |
| 6726 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6727 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6728 | |
| 6729 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 6730 | armnn::WorkloadInfo info; |
| 6731 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6732 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6733 | |
| 6734 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 6735 | |
| 6736 | inputHandle->Allocate(); |
| 6737 | outputHandle->Allocate(); |
| 6738 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 6739 | |
| 6740 | workload->Execute(); |
| 6741 | |
| 6742 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6743 | return result; |
| 6744 | } |
| 6745 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6746 | LayerTestResult<float, 4> BatchNormTest( |
| 6747 | armnn::IWorkloadFactory& workloadFactory, |
| 6748 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6749 | { |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6750 | // BatchSize: 1 |
| 6751 | // Channels: 2 |
| 6752 | // Height: 3 |
| 6753 | // Width: 2 |
| 6754 | |
| 6755 | const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; |
| 6756 | std::vector<float> inputValues |
| 6757 | { |
| 6758 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 6759 | 1.f, 4.f, |
| 6760 | 4.f, 2.f, |
| 6761 | 1.f, 6.f, |
| 6762 | |
| 6763 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 6764 | 1.f, 1.f, |
| 6765 | 4.f, 1.f, |
| 6766 | -2.f, 4.f |
| 6767 | }; |
| 6768 | std::vector<float> expectedOutputValues |
| 6769 | { |
| 6770 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 6771 | 1.f, 4.f, |
| 6772 | 4.f, 2.f, |
| 6773 | 1.f, 6.f, |
| 6774 | |
| 6775 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 6776 | 3.f, 3.f, |
| 6777 | 4.f, 3.f, |
| 6778 | 2.f, 4.f |
| 6779 | }; |
| 6780 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6781 | return BatchNormTestImpl<float>(workloadFactory, memoryManager, |
| 6782 | inputOutputShape, inputValues, expectedOutputValues, |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6783 | 0.f, 0, armnn::DataLayout::NCHW); |
| 6784 | } |
| 6785 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6786 | LayerTestResult<float, 4> BatchNormNhwcTest( |
| 6787 | armnn::IWorkloadFactory& workloadFactory, |
| 6788 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6789 | { |
| 6790 | // BatchSize: 1 |
| 6791 | // Height: 3 |
| 6792 | // Width: 2 |
| 6793 | // Channels: 2 |
| 6794 | |
| 6795 | const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; |
| 6796 | std::vector<float> inputValues |
| 6797 | { |
| 6798 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 6799 | 1.f, 1.f, |
| 6800 | 4.f, 1.f, |
| 6801 | |
| 6802 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 6803 | 4.f, 4.f, |
| 6804 | 2.f, 1.f, |
| 6805 | |
| 6806 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 6807 | 1.f, -2.f, |
| 6808 | 6.f, 4.f |
| 6809 | }; |
| 6810 | std::vector<float> expectedOutputValues |
| 6811 | { |
| 6812 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 6813 | 1.f, 3.f, |
| 6814 | 4.f, 3.f, |
| 6815 | |
| 6816 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 6817 | 4.f, 4.f, |
| 6818 | 2.f, 3.f, |
| 6819 | |
| 6820 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 6821 | 1.f, 2.f, |
| 6822 | 6.f, 4.f |
| 6823 | }; |
| 6824 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6825 | return BatchNormTestImpl<float>(workloadFactory, memoryManager, |
| 6826 | inputOutputShape, inputValues, expectedOutputValues, |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6827 | 0.f, 0, armnn::DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6828 | } |
| 6829 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6830 | LayerTestResult<uint8_t, 4> BatchNormUint8Test( |
| 6831 | armnn::IWorkloadFactory& workloadFactory, |
| 6832 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6833 | { |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6834 | // BatchSize: 1 |
| 6835 | // Channels: 2 |
| 6836 | // Height: 3 |
| 6837 | // Width: 2 |
| 6838 | |
| 6839 | const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; |
| 6840 | std::vector<float> inputValues |
| 6841 | { |
| 6842 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 6843 | 1.f, 4.f, |
| 6844 | 4.f, 2.f, |
| 6845 | 1.f, 6.f, |
| 6846 | |
| 6847 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 6848 | 1.f, 1.f, |
| 6849 | 4.f, 1.f, |
| 6850 | -2.f, 4.f |
| 6851 | }; |
| 6852 | std::vector<float> expectedOutputValues |
| 6853 | { |
| 6854 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 6855 | 1.f, 4.f, |
| 6856 | 4.f, 2.f, |
| 6857 | 1.f, 6.f, |
| 6858 | |
| 6859 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 6860 | 3.f, 3.f, |
| 6861 | 4.f, 3.f, |
| 6862 | 2.f, 4.f |
| 6863 | }; |
| 6864 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6865 | return BatchNormTestImpl<uint8_t>(workloadFactory, memoryManager, |
| 6866 | inputOutputShape, inputValues, expectedOutputValues, |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6867 | 1.f/20.f, 50, armnn::DataLayout::NCHW); |
| 6868 | } |
| 6869 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6870 | LayerTestResult<uint8_t, 4> BatchNormUint8NhwcTest( |
| 6871 | armnn::IWorkloadFactory& workloadFactory, |
| 6872 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6873 | { |
| 6874 | // BatchSize: 1 |
| 6875 | // Height: 3 |
| 6876 | // Width: 2 |
| 6877 | // Channels: 2 |
| 6878 | |
| 6879 | const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; |
| 6880 | std::vector<float> inputValues |
| 6881 | { |
| 6882 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 6883 | 1.f, 1.f, |
| 6884 | 4.f, 1.f, |
| 6885 | |
| 6886 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 6887 | 4.f, 4.f, |
| 6888 | 2.f, 1.f, |
| 6889 | |
| 6890 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 6891 | 1.f, -2.f, |
| 6892 | 6.f, 4.f |
| 6893 | }; |
| 6894 | std::vector<float> expectedOutputValues |
| 6895 | { |
| 6896 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 6897 | 1.f, 3.f, |
| 6898 | 4.f, 3.f, |
| 6899 | |
| 6900 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 6901 | 4.f, 4.f, |
| 6902 | 2.f, 3.f, |
| 6903 | |
| 6904 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 6905 | 1.f, 2.f, |
| 6906 | 6.f, 4.f |
| 6907 | }; |
| 6908 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6909 | return BatchNormTestImpl<uint8_t>(workloadFactory, memoryManager, |
| 6910 | inputOutputShape, inputValues, expectedOutputValues, |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 6911 | 1.f/20.f, 50, armnn::DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6912 | } |
| 6913 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6914 | LayerTestResult<uint8_t, 4> ConstantUint8Test( |
| 6915 | armnn::IWorkloadFactory& workloadFactory, |
| 6916 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6917 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6918 | return ConstantTestImpl<uint8_t>(workloadFactory, memoryManager, 2e-6f, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6919 | } |
| 6920 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6921 | LayerTestResult<uint8_t, 1> Concatenation1dUint8Test( |
| 6922 | armnn::IWorkloadFactory& workloadFactory, |
| 6923 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6924 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6925 | return Concatenation1dTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6926 | } |
| 6927 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6928 | LayerTestResult<uint8_t, 2> Concatenation2dDim0Uint8Test( |
| 6929 | armnn::IWorkloadFactory& workloadFactory, |
| 6930 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6931 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6932 | return Concatenation2dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6933 | } |
| 6934 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6935 | LayerTestResult<uint8_t, 2> Concatenation2dDim1Uint8Test( |
| 6936 | armnn::IWorkloadFactory& workloadFactory, |
| 6937 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6938 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6939 | return Concatenation2dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6940 | } |
| 6941 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6942 | LayerTestResult<uint8_t, 2> Concatenation2dDim0DiffInputDimsUint8Test( |
| 6943 | armnn::IWorkloadFactory& workloadFactory, |
| 6944 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6945 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6946 | return Concatenation2dDim0DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6947 | } |
| 6948 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6949 | LayerTestResult<uint8_t, 2> Concatenation2dDim1DiffInputDimsUint8Test( |
| 6950 | armnn::IWorkloadFactory& workloadFactory, |
| 6951 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6952 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6953 | return Concatenation2dDim1DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6954 | } |
| 6955 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6956 | LayerTestResult<uint8_t, 3> Concatenation3dDim0Uint8Test( |
| 6957 | armnn::IWorkloadFactory& workloadFactory, |
| 6958 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6959 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6960 | return Concatenation3dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6961 | } |
| 6962 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6963 | LayerTestResult<uint8_t, 3> Concatenation3dDim1Uint8Test( |
| 6964 | armnn::IWorkloadFactory& workloadFactory, |
| 6965 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6966 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6967 | return Concatenation3dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6968 | } |
| 6969 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6970 | LayerTestResult<uint8_t, 3> Concatenation3dDim2Uint8Test( |
| 6971 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 6972 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 6973 | bool useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6974 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 6975 | return Concatenation3dDim2TestImpl<uint8_t>(workloadFactory, memoryManager, useSubtensor, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6976 | } |
| 6977 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6978 | LayerTestResult<uint8_t, 3> Concatenation3dDim0DiffInputDimsUint8Test( |
| 6979 | armnn::IWorkloadFactory& workloadFactory, |
| 6980 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6981 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6982 | return Concatenation3dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6983 | } |
| 6984 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6985 | LayerTestResult<uint8_t, 3> Concatenation3dDim1DiffInputDimsUint8Test( |
| 6986 | armnn::IWorkloadFactory& workloadFactory, |
| 6987 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6988 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6989 | return Concatenation3dDim1DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6990 | } |
| 6991 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6992 | LayerTestResult<uint8_t, 3> Concatenation3dDim2DiffInputDimsUint8Test( |
| 6993 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 6994 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 6995 | bool useSubtensor) |
| 6996 | { |
| 6997 | return Concatenation3dDim2DiffInputDimsTestImpl<uint8_t>(workloadFactory, memoryManager, useSubtensor, 0.5f, -1); |
| 6998 | } |
| 6999 | |
| 7000 | LayerTestResult<uint8_t, 4> Concatenation4dDim0Uint8Test( |
| 7001 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7002 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7003 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 7004 | return Concatenation4dDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7005 | } |
| 7006 | |
| 7007 | LayerTestResult<uint8_t, 4> Concatenation4dDim1Uint8Test( |
| 7008 | armnn::IWorkloadFactory& workloadFactory, |
| 7009 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7010 | { |
| 7011 | return Concatenation4dDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7012 | } |
| 7013 | |
| 7014 | LayerTestResult<uint8_t, 4> Concatenation4dDim2Uint8Test( |
| 7015 | armnn::IWorkloadFactory& workloadFactory, |
| 7016 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7017 | { |
| 7018 | return Concatenation4dDim2TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7019 | } |
| 7020 | |
| 7021 | LayerTestResult<uint8_t, 4> Concatenation4dDim3Uint8Test( |
| 7022 | armnn::IWorkloadFactory& workloadFactory, |
| 7023 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, bool useSubtensor) |
| 7024 | { |
| 7025 | return Concatenation4dDim3TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1, useSubtensor); |
| 7026 | } |
| 7027 | |
| 7028 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim0Uint8Test( |
| 7029 | armnn::IWorkloadFactory& workloadFactory, |
| 7030 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7031 | { |
| 7032 | return Concatenation4dDiffShapeDim0TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7033 | } |
| 7034 | |
| 7035 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim1Uint8Test( |
| 7036 | armnn::IWorkloadFactory& workloadFactory, |
| 7037 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7038 | { |
| 7039 | return Concatenation4dDiffShapeDim1TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7040 | } |
| 7041 | |
| 7042 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim2Uint8Test( |
| 7043 | armnn::IWorkloadFactory& workloadFactory, |
| 7044 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7045 | { |
| 7046 | return Concatenation4dDiffShapeDim2TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1); |
| 7047 | } |
| 7048 | |
| 7049 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim3Uint8Test( |
| 7050 | armnn::IWorkloadFactory& workloadFactory, |
| 7051 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7052 | bool useSubtensor) |
| 7053 | { |
| 7054 | return Concatenation4dDiffShapeDim3TestImpl<uint8_t>(workloadFactory, memoryManager, 0.5f, -1, useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7055 | } |
| 7056 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7057 | LayerTestResult<float, 4> SimpleMaxPooling2dSize2x2Stride2x2Test( |
| 7058 | armnn::IWorkloadFactory& workloadFactory, |
| 7059 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7060 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7061 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7062 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<float>(workloadFactory, memoryManager, forceNoPadding); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7063 | } |
| 7064 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7065 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize2x2Stride2x2Uint8Test( |
| 7066 | armnn::IWorkloadFactory& workloadFactory, |
| 7067 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7068 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7069 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7070 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<uint8_t>( |
| 7071 | workloadFactory, memoryManager, forceNoPadding, 3.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7072 | } |
| 7073 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7074 | LayerTestResult<float, 4> SimpleMaxPooling2dSize3x3Stride2x4Test( |
| 7075 | armnn::IWorkloadFactory& workloadFactory, |
| 7076 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7077 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7078 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7079 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<float>(workloadFactory, memoryManager, forceNoPadding); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7080 | } |
| 7081 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7082 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize3x3Stride2x4Uint8Test( |
| 7083 | armnn::IWorkloadFactory& workloadFactory, |
| 7084 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7085 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7086 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7087 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<uint8_t>( |
| 7088 | workloadFactory, memoryManager, forceNoPadding, 0.1f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7089 | } |
| 7090 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7091 | LayerTestResult<float, 4> SimpleMaxPooling2dTest( |
| 7092 | armnn::IWorkloadFactory& workloadFactory, |
| 7093 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7094 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7095 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7096 | return SimpleMaxPooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7097 | } |
| 7098 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7099 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dUint8Test( |
| 7100 | armnn::IWorkloadFactory& workloadFactory, |
| 7101 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7102 | const armnn::DataLayout dataLayout) |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 7103 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7104 | return SimpleMaxPooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, dataLayout); |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 7105 | } |
| 7106 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7107 | LayerTestResult<float, 4> SimpleAveragePooling2dTest( |
| 7108 | armnn::IWorkloadFactory& workloadFactory, |
| 7109 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7110 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7111 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7112 | return SimpleAveragePooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout); |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 7113 | } |
| 7114 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7115 | LayerTestResult<uint8_t, 4> SimpleAveragePooling2dUint8Test( |
| 7116 | armnn::IWorkloadFactory& workloadFactory, |
| 7117 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7118 | const armnn::DataLayout dataLayout) |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 7119 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7120 | return SimpleAveragePooling2dTestCommon<uint8_t>( |
| 7121 | workloadFactory, memoryManager, dataLayout, 0.5, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7122 | } |
| 7123 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7124 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3x2Stride2x2Test( |
| 7125 | armnn::IWorkloadFactory& workloadFactory, |
| 7126 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7127 | bool forceNoPadding) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7128 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7129 | return IgnorePaddingAveragePooling2dSize3x2Stride2x2TestCommon<float>( |
| 7130 | workloadFactory, memoryManager, forceNoPadding); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7131 | } |
| 7132 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7133 | LayerTestResult<float, 4> LargeTensorsAveragePooling2dTest( |
| 7134 | armnn::IWorkloadFactory& workloadFactory, |
| 7135 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7136 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7137 | return LargeTensorsAveragePooling2dTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7138 | } |
| 7139 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7140 | LayerTestResult<uint8_t, 4> LargeTensorsAveragePooling2dUint8Test( |
| 7141 | armnn::IWorkloadFactory& workloadFactory, |
| 7142 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7143 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7144 | return LargeTensorsAveragePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, 0.5, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7145 | } |
| 7146 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7147 | LayerTestResult<float, 4> SimpleL2Pooling2dTest( |
| 7148 | armnn::IWorkloadFactory& workloadFactory, |
| 7149 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7150 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7151 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7152 | return SimpleL2Pooling2dTestCommon<float>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7153 | } |
| 7154 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7155 | LayerTestResult<uint8_t, 4> SimpleL2Pooling2dUint8Test( |
| 7156 | armnn::IWorkloadFactory& workloadFactory, |
| 7157 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 7158 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7159 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7160 | return SimpleL2Pooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7161 | } |
| 7162 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7163 | LayerTestResult<float, 4> L2Pooling2dSize3Stride1Test( |
| 7164 | armnn::IWorkloadFactory& workloadFactory, |
| 7165 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7166 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7167 | return L2Pooling2dSize3Stride1TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7168 | } |
| 7169 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7170 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride1Uint8Test( |
| 7171 | armnn::IWorkloadFactory& workloadFactory, |
| 7172 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7173 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7174 | return L2Pooling2dSize3Stride1TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7175 | } |
| 7176 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7177 | LayerTestResult<float, 4> L2Pooling2dSize3Stride3Test( |
| 7178 | armnn::IWorkloadFactory& workloadFactory, |
| 7179 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7180 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7181 | return L2Pooling2dSize3Stride3TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7182 | } |
| 7183 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7184 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride3Uint8Test( |
| 7185 | armnn::IWorkloadFactory& workloadFactory, |
| 7186 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7187 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7188 | return L2Pooling2dSize3Stride3TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7189 | } |
| 7190 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7191 | LayerTestResult<float, 4> L2Pooling2dSize3Stride4Test( |
| 7192 | armnn::IWorkloadFactory& workloadFactory, |
| 7193 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7194 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7195 | return L2Pooling2dSize3Stride4TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7196 | } |
| 7197 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7198 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride4Uint8Test( |
| 7199 | armnn::IWorkloadFactory& workloadFactory, |
| 7200 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7201 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7202 | return L2Pooling2dSize3Stride4TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7203 | } |
| 7204 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7205 | LayerTestResult<float, 4> L2Pooling2dSize7Test( |
| 7206 | armnn::IWorkloadFactory& workloadFactory, |
| 7207 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7208 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7209 | return L2Pooling2dSize7TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7210 | } |
| 7211 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7212 | LayerTestResult<uint8_t, 4> L2Pooling2dSize7Uint8Test( |
| 7213 | armnn::IWorkloadFactory& workloadFactory, |
| 7214 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7215 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7216 | return L2Pooling2dSize7TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7217 | } |
| 7218 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7219 | LayerTestResult<float, 4> L2Pooling2dSize9Test( |
| 7220 | armnn::IWorkloadFactory& workloadFactory, |
| 7221 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7222 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7223 | return L2Pooling2dSize9TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7224 | } |
| 7225 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7226 | LayerTestResult<uint8_t, 4> L2Pooling2dSize9Uint8Test( |
| 7227 | armnn::IWorkloadFactory& workloadFactory, |
| 7228 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7229 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7230 | return L2Pooling2dSize9TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7231 | } |
| 7232 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7233 | LayerTestResult<float, 4> AsymmetricNonSquarePooling2dTest( |
| 7234 | armnn::IWorkloadFactory& workloadFactory, |
| 7235 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7236 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7237 | return AsymmetricNonSquarePooling2dTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7238 | } |
| 7239 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7240 | LayerTestResult<uint8_t, 4> AsymmetricNonSquarePooling2dUint8Test( |
| 7241 | armnn::IWorkloadFactory& workloadFactory, |
| 7242 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7243 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7244 | return AsymmetricNonSquarePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7245 | } |
| 7246 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7247 | LayerTestResult<float, 4> ComparePooling2dTest( |
| 7248 | armnn::IWorkloadFactory& workloadFactory, |
| 7249 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7250 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 7251 | armnn::PoolingAlgorithm poolingType) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7252 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7253 | return ComparePooling2dTestCommon<float>( |
| 7254 | workloadFactory, memoryManager, refWorkloadFactory, poolingType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7255 | } |
| 7256 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7257 | LayerTestResult<uint8_t, 4> ComparePooling2dUint8Test( |
| 7258 | armnn::IWorkloadFactory& workloadFactory, |
| 7259 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7260 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 7261 | armnn::PoolingAlgorithm poolingType) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7262 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7263 | return ComparePooling2dTestCommon<uint8_t>( |
| 7264 | workloadFactory, memoryManager, refWorkloadFactory, poolingType, 0.1f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7265 | } |
| 7266 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7267 | LayerTestResult<float, 2> FullyConnectedLargeTest( |
| 7268 | armnn::IWorkloadFactory& workloadFactory, |
| 7269 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7270 | bool transposeWeights) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7271 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7272 | return FullyConnectedLargeTestCommon<float>(workloadFactory, memoryManager, transposeWeights); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7273 | } |
| 7274 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7275 | LayerTestResult<float, 4> IgnorePaddingSimpleMaxPooling2dTest( |
| 7276 | armnn::IWorkloadFactory& workloadFactory, |
| 7277 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7278 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7279 | return IgnorePaddingSimpleMaxPooling2dTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7280 | } |
| 7281 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7282 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleMaxPooling2dUint8Test( |
| 7283 | armnn::IWorkloadFactory& workloadFactory, |
| 7284 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7285 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7286 | return IgnorePaddingSimpleMaxPooling2dTestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7287 | } |
| 7288 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7289 | LayerTestResult<float, 4> IgnorePaddingMaxPooling2dSize3Test( |
| 7290 | armnn::IWorkloadFactory& workloadFactory, |
| 7291 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7292 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7293 | return IgnorePaddingMaxPooling2dSize3TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7294 | } |
| 7295 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7296 | LayerTestResult<uint8_t, 4> IgnorePaddingMaxPooling2dSize3Uint8Test( |
| 7297 | armnn::IWorkloadFactory& workloadFactory, |
| 7298 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7299 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7300 | return IgnorePaddingMaxPooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager, 1.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7301 | } |
| 7302 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7303 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dTest( |
| 7304 | armnn::IWorkloadFactory& workloadFactory, |
| 7305 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7306 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7307 | return IgnorePaddingSimpleAveragePooling2dTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7308 | } |
| 7309 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7310 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dUint8Test( |
| 7311 | armnn::IWorkloadFactory& workloadFactory, |
| 7312 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7313 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7314 | return IgnorePaddingSimpleAveragePooling2dTestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7315 | } |
| 7316 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7317 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingTest( |
| 7318 | armnn::IWorkloadFactory& workloadFactory, |
| 7319 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7320 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7321 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7322 | } |
| 7323 | |
| 7324 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7325 | armnn::IWorkloadFactory& workloadFactory, |
| 7326 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7327 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7328 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7329 | } |
| 7330 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7331 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3Test( |
| 7332 | armnn::IWorkloadFactory& workloadFactory, |
| 7333 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7334 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7335 | return IgnorePaddingAveragePooling2dSize3TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7336 | } |
| 7337 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7338 | LayerTestResult<uint8_t, 4> IgnorePaddingAveragePooling2dSize3Uint8Test( |
| 7339 | armnn::IWorkloadFactory& workloadFactory, |
| 7340 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7341 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7342 | return IgnorePaddingAveragePooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7343 | } |
| 7344 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7345 | LayerTestResult<float, 4> IgnorePaddingSimpleL2Pooling2dTest( |
| 7346 | armnn::IWorkloadFactory& workloadFactory, |
| 7347 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7348 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7349 | return IgnorePaddingSimpleL2Pooling2dTestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7350 | } |
| 7351 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7352 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleL2Pooling2dUint8Test( |
| 7353 | armnn::IWorkloadFactory& workloadFactory, |
| 7354 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7355 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7356 | return IgnorePaddingSimpleL2Pooling2dTestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7357 | } |
| 7358 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7359 | LayerTestResult<float, 4> IgnorePaddingL2Pooling2dSize3Test( |
| 7360 | armnn::IWorkloadFactory& workloadFactory, |
| 7361 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7362 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7363 | return IgnorePaddingL2Pooling2dSize3TestCommon<float>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7364 | } |
| 7365 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7366 | LayerTestResult<uint8_t, 4> IgnorePaddingL2Pooling2dSize3Uint8Test( |
| 7367 | armnn::IWorkloadFactory& workloadFactory, |
| 7368 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7369 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7370 | return IgnorePaddingL2Pooling2dSize3TestCommon<uint8_t>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7371 | } |
| 7372 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7373 | LayerTestResult<float, 4> SimplePermuteFloat32Test( |
| 7374 | armnn::IWorkloadFactory& workloadFactory, |
| 7375 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7376 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7377 | return SimplePermuteFloat32TestCommon(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7378 | }; |
| 7379 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7380 | LayerTestResult<uint8_t, 4> SimplePermuteUint8Test( |
| 7381 | armnn::IWorkloadFactory& workloadFactory, |
| 7382 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7383 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7384 | return SimplePermuteUint8TestCommon(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7385 | }; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7386 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7387 | LayerTestResult<float, 4> PermuteFloat32ValueSet1Test( |
| 7388 | armnn::IWorkloadFactory& workloadFactory, |
| 7389 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7390 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7391 | return PermuteFloat32ValueSet1TestCommon(workloadFactory, memoryManager); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7392 | }; |
| 7393 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7394 | LayerTestResult<float, 4> PermuteFloat32ValueSet2Test( |
| 7395 | armnn::IWorkloadFactory& workloadFactory, |
| 7396 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7397 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7398 | return PermuteFloat32ValueSet2TestCommon(workloadFactory, memoryManager); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7399 | }; |
| 7400 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7401 | LayerTestResult<float, 4> PermuteFloat32ValueSet3Test( |
| 7402 | armnn::IWorkloadFactory& workloadFactory, |
| 7403 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7404 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7405 | return PermuteFloat32ValueSet3TestCommon(workloadFactory, memoryManager); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7406 | }; |
| 7407 | |
| 7408 | namespace |
| 7409 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7410 | |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7411 | template <typename T, std::size_t InputDim, std::size_t OutputDim> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7412 | LayerTestResult<T, OutputDim> MeanTestHelper( |
| 7413 | armnn::IWorkloadFactory& workloadFactory, |
| 7414 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7415 | const unsigned int* inputShape, |
| 7416 | const std::vector<T>& inputData, |
| 7417 | const std::vector<unsigned int>& axis, |
| 7418 | bool keepDims, |
| 7419 | const unsigned int* outputShape, |
| 7420 | const std::vector<T>& outputData, |
| 7421 | float scale = 1.0f, |
| 7422 | int32_t offset = 0) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7423 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7424 | auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7425 | |
| 7426 | armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType); |
| 7427 | armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType); |
| 7428 | |
| 7429 | inputTensorInfo.SetQuantizationScale(scale); |
| 7430 | inputTensorInfo.SetQuantizationOffset(offset); |
| 7431 | |
| 7432 | outputTensorInfo.SetQuantizationScale(scale); |
| 7433 | outputTensorInfo.SetQuantizationOffset(offset); |
| 7434 | |
| 7435 | auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData); |
| 7436 | |
| 7437 | LayerTestResult<T, OutputDim> result(outputTensorInfo); |
| 7438 | result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData); |
| 7439 | |
| 7440 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7441 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7442 | |
| 7443 | armnn::MeanQueueDescriptor data; |
| 7444 | data.m_Parameters.m_Axis = axis; |
| 7445 | data.m_Parameters.m_KeepDims = keepDims; |
| 7446 | armnn::WorkloadInfo info; |
| 7447 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 7448 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 7449 | |
| 7450 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMean(data, info); |
| 7451 | |
| 7452 | inputHandle->Allocate(); |
| 7453 | outputHandle->Allocate(); |
| 7454 | |
| 7455 | CopyDataToITensorHandle(inputHandle.get(), input.origin()); |
| 7456 | |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7457 | workload->Execute(); |
| 7458 | |
| 7459 | CopyDataFromITensorHandle(result.output.origin(), outputHandle.get()); |
| 7460 | |
| 7461 | return result; |
| 7462 | } |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7463 | |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7464 | } // anonymous namespace |
| 7465 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7466 | LayerTestResult<uint8_t, 1> MeanUint8SimpleTest( |
| 7467 | armnn::IWorkloadFactory& workloadFactory, |
| 7468 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7469 | { |
| 7470 | const unsigned int inputShape[] = { 3, 2 }; |
| 7471 | const unsigned int outputShape[] = { 1 }; |
| 7472 | |
| 7473 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 7474 | std::vector<uint8_t> output({ 2 }); |
| 7475 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7476 | return MeanTestHelper<uint8_t, 2, 1>( |
| 7477 | workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7478 | } |
| 7479 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7480 | LayerTestResult<uint8_t, 3> MeanUint8SimpleAxisTest( |
| 7481 | armnn::IWorkloadFactory& workloadFactory, |
| 7482 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7483 | { |
| 7484 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 7485 | const unsigned int outputShape[] = { 1, 1, 2 }; |
| 7486 | |
| 7487 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 7488 | std::vector<uint8_t> output({ 2, 2 }); |
| 7489 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7490 | return MeanTestHelper<uint8_t, 4, 3>( |
| 7491 | workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7492 | } |
| 7493 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7494 | LayerTestResult<uint8_t, 4> MeanUint8KeepDimsTest( |
| 7495 | armnn::IWorkloadFactory& workloadFactory, |
| 7496 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7497 | { |
| 7498 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 7499 | const unsigned int outputShape[] = { 1, 1, 1, 2 }; |
| 7500 | |
| 7501 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 7502 | std::vector<uint8_t> output({ 2, 2 }); |
| 7503 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7504 | return MeanTestHelper<uint8_t, 4, 4>( |
| 7505 | workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7506 | } |
| 7507 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7508 | LayerTestResult<uint8_t, 4> MeanUint8MultipleDimsTest( |
| 7509 | armnn::IWorkloadFactory& workloadFactory, |
| 7510 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7511 | { |
| 7512 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 7513 | const unsigned int outputShape[] = { 1, 3, 1, 1 }; |
| 7514 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7515 | std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6 }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7516 | std::vector<uint8_t> output({ 1, 3, 5 }); |
| 7517 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7518 | return MeanTestHelper<uint8_t, 4, 4>( |
| 7519 | workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7520 | } |
| 7521 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7522 | LayerTestResult<uint8_t, 1> MeanVtsUint8Test( |
| 7523 | armnn::IWorkloadFactory& workloadFactory, |
| 7524 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7525 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7526 | const unsigned int inputShape[] = { 4, 3, 2 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7527 | const unsigned int outputShape[] = { 2 }; |
| 7528 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7529 | std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, |
| 7530 | 24 }); |
| 7531 | std::vector<uint8_t> output({ 12, 13 }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7532 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7533 | return MeanTestHelper<uint8_t, 3, 1>(workloadFactory, memoryManager, |
| 7534 | inputShape, input, { 0, 1 }, false, outputShape, |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7535 | output, 0.8f, 5); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7536 | } |
| 7537 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7538 | LayerTestResult<float, 1> MeanFloatSimpleTest( |
| 7539 | armnn::IWorkloadFactory& workloadFactory, |
| 7540 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7541 | { |
| 7542 | const unsigned int inputShape[] = { 3, 2 }; |
| 7543 | const unsigned int outputShape[] = { 1 }; |
| 7544 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7545 | std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }); |
| 7546 | std::vector<float> output({ 2.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7547 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7548 | return MeanTestHelper<float, 2, 1>( |
| 7549 | workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7550 | } |
| 7551 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7552 | LayerTestResult<float, 3> MeanFloatSimpleAxisTest( |
| 7553 | armnn::IWorkloadFactory& workloadFactory, |
| 7554 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7555 | { |
| 7556 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 7557 | const unsigned int outputShape[] = { 3, 1, 2 }; |
| 7558 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7559 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); |
| 7560 | std::vector<float> output({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7561 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7562 | return MeanTestHelper<float, 4, 3>( |
| 7563 | workloadFactory, memoryManager, inputShape, input, { 0 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7564 | } |
| 7565 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7566 | LayerTestResult<float, 4> MeanFloatKeepDimsTest( |
| 7567 | armnn::IWorkloadFactory& workloadFactory, |
| 7568 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7569 | { |
| 7570 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 7571 | const unsigned int outputShape[] = { 1, 1, 1, 2 }; |
| 7572 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7573 | std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }); |
| 7574 | std::vector<float> output({ 2.0f, 2.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7575 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7576 | return MeanTestHelper<float, 4, 4>( |
| 7577 | workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7578 | } |
| 7579 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7580 | LayerTestResult<float, 4> MeanFloatMultipleDimsTest( |
| 7581 | armnn::IWorkloadFactory& workloadFactory, |
| 7582 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7583 | { |
| 7584 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 7585 | const unsigned int outputShape[] = { 1, 3, 1, 1 }; |
| 7586 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7587 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }); |
| 7588 | std::vector<float> output({ 1.5f, 3.5f, 5.5f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7589 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7590 | return MeanTestHelper<float, 4, 4>( |
| 7591 | workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7592 | } |
| 7593 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7594 | LayerTestResult<float, 1> MeanVtsFloat1Test( |
| 7595 | armnn::IWorkloadFactory& workloadFactory, |
| 7596 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7597 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7598 | const unsigned int inputShape[] = { 4, 3, 2 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7599 | const unsigned int outputShape[] = { 2 }; |
| 7600 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7601 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, |
| 7602 | 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f }); |
| 7603 | std::vector<float> output({ 12.0f, 13.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7604 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7605 | return MeanTestHelper<float, 3, 1>( |
| 7606 | workloadFactory, memoryManager, inputShape, input, { 0, 1 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7607 | } |
| 7608 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7609 | LayerTestResult<float, 3> MeanVtsFloat2Test( |
| 7610 | armnn::IWorkloadFactory& workloadFactory, |
| 7611 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7612 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7613 | const unsigned int inputShape[] = { 4, 3, 2 }; |
| 7614 | const unsigned int outputShape[] = { 1, 3, 1 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7615 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7616 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, |
| 7617 | 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f }); |
| 7618 | std::vector<float> output({ 10.5f, 12.5f, 14.5f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7619 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7620 | return MeanTestHelper<float, 3, 3>( |
| 7621 | workloadFactory, memoryManager, inputShape, input, { 0, 2 }, true, outputShape, output); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7622 | } |
| 7623 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7624 | LayerTestResult<float, 3> MeanVtsFloat3Test( |
| 7625 | armnn::IWorkloadFactory& workloadFactory, |
| 7626 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 7627 | { |
| 7628 | const unsigned int inputShape[] = { 1, 2, 2, 1 }; |
| 7629 | const unsigned int outputShape[] = { 1, 2, 1 }; |
| 7630 | |
| 7631 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f }); |
| 7632 | std::vector<float> output({ 1.5f, 3.5f }); |
| 7633 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7634 | return MeanTestHelper<float, 4, 3>( |
| 7635 | workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 7636 | } |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 7637 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7638 | LayerTestResult<float, 4> AdditionAfterMaxPoolTest( |
| 7639 | armnn::IWorkloadFactory& workloadFactory, |
| 7640 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 7641 | { |
| 7642 | // Create Initial Tensor |
| 7643 | // 1, 2, 3 |
| 7644 | // 4, 5, 6 |
| 7645 | // 7, 8, 9 |
| 7646 | |
| 7647 | armnn::TensorInfo poolingInputTensorInfo({ 1, 1, 3, 3}, armnn::GetDataType<float>()); |
| 7648 | armnn::TensorInfo poolingOutputTensorInfo({ 1, 1, 2, 2}, armnn::GetDataType<float>()); |
| 7649 | |
| 7650 | boost::multi_array<float, 4> poolingInput = MakeTensor<float,4>(poolingInputTensorInfo, |
| 7651 | {1, 2, 3, |
| 7652 | 4, 5, 6, |
| 7653 | 7, 8, 9 |
| 7654 | }); |
| 7655 | |
| 7656 | std::unique_ptr<armnn::ITensorHandle> poolingInputHandle = |
| 7657 | workloadFactory.CreateTensorHandle(poolingInputTensorInfo); |
| 7658 | std::unique_ptr<armnn::ITensorHandle> poolingOutputHandle = |
| 7659 | workloadFactory.CreateTensorHandle(poolingOutputTensorInfo); |
| 7660 | |
| 7661 | // Apply MaxPool poolSize = 1x1, stride=2x2 |
| 7662 | // Result = |
| 7663 | // 1, 3 |
| 7664 | // 7, 9 |
| 7665 | armnn::Pooling2dDescriptor descriptor; |
| 7666 | descriptor.m_PoolHeight = 1; |
| 7667 | descriptor.m_PoolWidth = 1; |
| 7668 | descriptor.m_StrideX = 2; |
| 7669 | descriptor.m_StrideY = 2; |
| 7670 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 7671 | |
| 7672 | armnn::Pooling2dQueueDescriptor queueDescriptor; |
| 7673 | queueDescriptor.m_Parameters = descriptor; |
| 7674 | armnn::WorkloadInfo workloadInfo; |
| 7675 | AddInputToWorkload(queueDescriptor, workloadInfo, poolingInputTensorInfo, poolingInputHandle.get()); |
| 7676 | AddOutputToWorkload(queueDescriptor, workloadInfo, poolingOutputTensorInfo, poolingOutputHandle.get()); |
| 7677 | |
| 7678 | // Create the MaxPool |
| 7679 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePooling2d(queueDescriptor, workloadInfo); |
| 7680 | |
| 7681 | //LayerTestResult<float, 4> result(poolingOutputTensorInfo); |
| 7682 | auto shape( GetTensorShapeAsArray<4>(poolingOutputTensorInfo)); |
| 7683 | boost::multi_array<float, 4> resultMaxPool; |
| 7684 | resultMaxPool.resize(shape); |
| 7685 | |
| 7686 | |
| 7687 | // Create addition with another tensor the same size |
| 7688 | // This would be the result to apply a Conv2d with kernel ones(2) and stride 1x1 |
| 7689 | // with the initial tensor. |
| 7690 | // 12, 16 |
| 7691 | // 24, 28 |
| 7692 | |
| 7693 | armnn::TensorInfo addInputTensorInfo({ 1,1,2,2}, armnn::GetDataType<float>()); |
| 7694 | armnn::TensorInfo addOutputTensorInfo({ 1,1,2,2}, armnn::GetDataType<float>()); |
| 7695 | |
| 7696 | boost::multi_array<float, 4> addInput = MakeTensor<float,4>(addInputTensorInfo, |
| 7697 | {12, 16, |
| 7698 | 24, 28, |
| 7699 | }); |
| 7700 | |
| 7701 | // Expected output tensor after MaxPool and Addition. |
| 7702 | LayerTestResult<float,4> addRet(addOutputTensorInfo); |
| 7703 | addRet.outputExpected = MakeTensor<float, 4>(addOutputTensorInfo, std::vector<float>( |
| 7704 | { |
| 7705 | 13, 19, |
| 7706 | 31, 37 |
| 7707 | })); |
| 7708 | |
| 7709 | std::unique_ptr<armnn::ITensorHandle> addInputHandle = workloadFactory.CreateTensorHandle(addInputTensorInfo); |
| 7710 | std::unique_ptr<armnn::ITensorHandle> addOutputHandle = workloadFactory.CreateTensorHandle(addOutputTensorInfo); |
| 7711 | |
| 7712 | armnn::AdditionQueueDescriptor data; |
| 7713 | armnn::WorkloadInfo info; |
| 7714 | |
| 7715 | // Add the output of the MaxPool and the new tensor |
| 7716 | AddInputToWorkload(data, info, poolingOutputTensorInfo, poolingOutputHandle.get()); |
| 7717 | AddInputToWorkload(data, info, addInputTensorInfo, addInputHandle.get()); |
| 7718 | AddOutputToWorkload(data, info, addOutputTensorInfo, addOutputHandle.get()); |
| 7719 | |
| 7720 | std::unique_ptr<armnn::IWorkload> addWorkload = workloadFactory.CreateAddition(data, info); |
| 7721 | |
| 7722 | poolingInputHandle->Allocate(); |
| 7723 | poolingOutputHandle->Allocate(); |
| 7724 | addInputHandle->Allocate(); |
| 7725 | addOutputHandle->Allocate(); |
| 7726 | |
| 7727 | CopyDataToITensorHandle(poolingInputHandle.get(), &poolingInput[0][0][0][0]); |
| 7728 | CopyDataFromITensorHandle(&resultMaxPool[0][0][0][0], poolingOutputHandle.get()); |
| 7729 | |
| 7730 | CopyDataToITensorHandle(poolingOutputHandle.get(), &resultMaxPool[0][0][0][0]); |
| 7731 | CopyDataToITensorHandle(addInputHandle.get(), &addInput[0][0][0][0]); |
| 7732 | |
| 7733 | workload->Execute(); |
| 7734 | addWorkload->Execute(); |
| 7735 | |
| 7736 | CopyDataFromITensorHandle(&addRet.output[0][0][0][0], addOutputHandle.get()); |
| 7737 | |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 7738 | return addRet; |
| 7739 | } |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7740 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7741 | LayerTestResult<float, 4> SpaceToBatchNdSimpleFloat32Test( |
| 7742 | armnn::IWorkloadFactory& workloadFactory, |
| 7743 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7744 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7745 | return SpaceToBatchNdSimpleTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7746 | } |
| 7747 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7748 | LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsFloat32Test( |
| 7749 | armnn::IWorkloadFactory& workloadFactory, |
| 7750 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7751 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7752 | return SpaceToBatchNdMultiChannelsTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7753 | } |
| 7754 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7755 | LayerTestResult<float, 4> SpaceToBatchNdMultiBlockFloat32Test( |
| 7756 | armnn::IWorkloadFactory& workloadFactory, |
| 7757 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7758 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7759 | return SpaceToBatchNdMultiBlockTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7760 | } |
| 7761 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7762 | LayerTestResult<float, 4> SpaceToBatchNdPaddingFloat32Test( |
| 7763 | armnn::IWorkloadFactory& workloadFactory, |
| 7764 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7765 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7766 | return SpaceToBatchNdPaddingTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7767 | } |
| 7768 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7769 | LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleUint8Test( |
| 7770 | armnn::IWorkloadFactory& workloadFactory, |
| 7771 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7772 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7773 | return SpaceToBatchNdSimpleTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7774 | } |
| 7775 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7776 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsUint8Test( |
| 7777 | armnn::IWorkloadFactory& workloadFactory, |
| 7778 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7779 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7780 | return SpaceToBatchNdMultiChannelsTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7781 | } |
| 7782 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7783 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockUint8Test( |
| 7784 | armnn::IWorkloadFactory& workloadFactory, |
| 7785 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7786 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7787 | return SpaceToBatchNdMultiBlockTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7788 | } |
| 7789 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7790 | LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingUint8Test( |
| 7791 | armnn::IWorkloadFactory& workloadFactory, |
| 7792 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7793 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7794 | return SpaceToBatchNdPaddingTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7795 | } |
| 7796 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7797 | LayerTestResult<float, 4> SpaceToBatchNdSimpleNHWCFloat32Test( |
| 7798 | armnn::IWorkloadFactory& workloadFactory, |
| 7799 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7800 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7801 | return SpaceToBatchNdSimpleNHWCTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7802 | } |
| 7803 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7804 | LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsNHWCFloat32Test( |
| 7805 | armnn::IWorkloadFactory& workloadFactory, |
| 7806 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7807 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7808 | return SpaceToBatchNdMultiChannelsNHWCTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7809 | } |
| 7810 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7811 | LayerTestResult<float, 4> SpaceToBatchNdMultiBlockNHWCFloat32Test( |
| 7812 | armnn::IWorkloadFactory& workloadFactory, |
| 7813 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7814 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7815 | return SpaceToBatchNdMultiBlockNHWCTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7816 | } |
| 7817 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7818 | LayerTestResult<float, 4> SpaceToBatchNdPaddingNHWCFloat32Test( |
| 7819 | armnn::IWorkloadFactory& workloadFactory, |
| 7820 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7821 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7822 | return SpaceToBatchNdPaddingNHWCTest<float>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7823 | } |
| 7824 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7825 | LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleNHWCUint8Test( |
| 7826 | armnn::IWorkloadFactory& workloadFactory, |
| 7827 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7828 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7829 | return SpaceToBatchNdSimpleNHWCTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7830 | } |
| 7831 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7832 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsNHWCUint8Test( |
| 7833 | armnn::IWorkloadFactory& workloadFactory, |
| 7834 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7835 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7836 | return SpaceToBatchNdMultiChannelsNHWCTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7837 | } |
| 7838 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7839 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockNHWCUint8Test( |
| 7840 | armnn::IWorkloadFactory& workloadFactory, |
| 7841 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7842 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7843 | return SpaceToBatchNdMultiBlockNHWCTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7844 | } |
| 7845 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7846 | LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingNHWCUint8Test( |
| 7847 | armnn::IWorkloadFactory& workloadFactory, |
| 7848 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7849 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7850 | return SpaceToBatchNdPaddingNHWCTest<uint8_t>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 7851 | } |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7852 | |
| 7853 | namespace { |
| 7854 | |
| 7855 | template<typename T, std::size_t InputDim, std::size_t OutputDim> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7856 | LayerTestResult<T, OutputDim> BatchToSpaceNdHelper( |
| 7857 | armnn::IWorkloadFactory &workloadFactory, |
| 7858 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7859 | const armnn::DataLayout& dataLayout, |
| 7860 | const unsigned int *inputShape, |
| 7861 | const std::vector<T> &inputData, |
| 7862 | const std::vector<unsigned int> &blockShape, |
| 7863 | const std::vector<std::pair<unsigned int, unsigned int>> &crops, |
| 7864 | const unsigned int *outputShape, |
| 7865 | const std::vector<T> &outputData, |
| 7866 | float scale = 1.0f, |
| 7867 | int32_t offset = 0) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7868 | { |
| 7869 | auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32); |
| 7870 | |
| 7871 | armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType); |
| 7872 | armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType); |
| 7873 | |
| 7874 | inputTensorInfo.SetQuantizationScale(scale); |
| 7875 | inputTensorInfo.SetQuantizationOffset(offset); |
| 7876 | |
| 7877 | outputTensorInfo.SetQuantizationScale(scale); |
| 7878 | outputTensorInfo.SetQuantizationOffset(offset); |
| 7879 | |
| 7880 | auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData); |
| 7881 | |
| 7882 | LayerTestResult<T, OutputDim> result(outputTensorInfo); |
| 7883 | result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData); |
| 7884 | |
| 7885 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7886 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7887 | |
| 7888 | armnn::BatchToSpaceNdQueueDescriptor data; |
| 7889 | data.m_Parameters.m_DataLayout = dataLayout; |
| 7890 | data.m_Parameters.m_BlockShape = blockShape; |
| 7891 | data.m_Parameters.m_Crops = crops; |
| 7892 | armnn::WorkloadInfo info; |
| 7893 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 7894 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 7895 | |
| 7896 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchToSpaceNd(data, info); |
| 7897 | |
| 7898 | inputHandle->Allocate(); |
| 7899 | outputHandle->Allocate(); |
| 7900 | |
| 7901 | CopyDataToITensorHandle(inputHandle.get(), input.origin()); |
| 7902 | |
| 7903 | workload->Execute(); |
| 7904 | |
| 7905 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7906 | |
| 7907 | return result; |
| 7908 | } |
| 7909 | |
| 7910 | } // anonymous namespace |
| 7911 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7912 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test1( |
| 7913 | armnn::IWorkloadFactory& workloadFactory, |
| 7914 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7915 | { |
| 7916 | const unsigned int inputShape[] = {4, 2, 2, 1}; |
| 7917 | const unsigned int outputShape[] = {1, 4, 4, 1 }; |
| 7918 | |
| 7919 | std::vector<float> input |
| 7920 | ({ |
| 7921 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 7922 | 1.0f, 3.0f, |
| 7923 | // Batch 0, Height 1, Width (2) x Channel (1) |
| 7924 | 9.0f, 11.0f, |
| 7925 | |
| 7926 | |
| 7927 | // Batch 1, Height 0, Width (2) x Channel (1) |
| 7928 | 2.0f, 4.0f, |
| 7929 | // Batch 1, Height 1, Width (2) x Channel (1) |
| 7930 | 10.0f, 12.0f, |
| 7931 | |
| 7932 | |
| 7933 | // Batch 2, Height 0, Width (2) x Channel (1) |
| 7934 | 5.0f, 7.0f, |
| 7935 | // Batch 2, Height 1, Width (2) x Channel (1) |
| 7936 | 13.0f, 15.0f, |
| 7937 | |
| 7938 | // Batch 3, Height 0, Width (2) x Channel (3) |
| 7939 | 6.0f, 8.0f, |
| 7940 | // Batch 3, Height 1, Width (2) x Channel (1) |
| 7941 | 14.0f, 16.0f |
| 7942 | }); |
| 7943 | |
| 7944 | std::vector<float> expectedOutput |
| 7945 | ({ |
| 7946 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 7947 | 5.0f, 6.0f, 7.0f, 8.0f, |
| 7948 | 9.0f, 10.0f, 11.0f, 12.0f, |
| 7949 | 13.0f, 14.0f, 15.0f, 16.0f |
| 7950 | }); |
| 7951 | |
| 7952 | std::vector<unsigned int> blockShape {2, 2}; |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 7953 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7954 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7955 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 7956 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7957 | crops, outputShape, expectedOutput); |
| 7958 | } |
| 7959 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7960 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test2( |
| 7961 | armnn::IWorkloadFactory& workloadFactory, |
| 7962 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7963 | { |
| 7964 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 7965 | const unsigned int outputShape[] = {1, 2, 2, 1}; |
| 7966 | |
| 7967 | std::vector<float> input |
| 7968 | ({ |
| 7969 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 7970 | 1.0f, 2.0f, 3.0f, 4.0f |
| 7971 | }); |
| 7972 | |
| 7973 | std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f}); |
| 7974 | |
| 7975 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 7976 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7977 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7978 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 7979 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 7980 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7981 | } |
| 7982 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7983 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test3( |
| 7984 | armnn::IWorkloadFactory& workloadFactory, |
| 7985 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7986 | { |
| 7987 | const unsigned int inputShape[] = {4, 1, 1, 3}; |
| 7988 | const unsigned int outputShape[] = {1, 2, 2, 3}; |
| 7989 | |
| 7990 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f }); |
| 7991 | |
| 7992 | std::vector<float> expectedOutput({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f }); |
| 7993 | |
| 7994 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 7995 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 7996 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7997 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 7998 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 7999 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 8000 | } |
| 8001 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8002 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test1( |
| 8003 | armnn::IWorkloadFactory &workloadFactory, |
| 8004 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 8005 | { |
| 8006 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 8007 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 8008 | |
| 8009 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f }); |
| 8010 | |
| 8011 | std::vector<float> expectedOutput |
| 8012 | ({ |
| 8013 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 8014 | 1.0f, 4.0f, |
| 8015 | 7.0f, 10.0f, |
| 8016 | |
| 8017 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 8018 | 2.0f, 5.0f, |
| 8019 | 8.0f, 11.0f, |
| 8020 | |
| 8021 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 8022 | 3.0f, 6.0f, |
| 8023 | 9.0f, 12.0f, |
| 8024 | }); |
| 8025 | |
| 8026 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 8027 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 8028 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8029 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 8030 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8031 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 8032 | } |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 8033 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 8034 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test2( |
| 8035 | armnn::IWorkloadFactory& workloadFactory, |
| 8036 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8037 | { |
| 8038 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 8039 | const unsigned int outputShape[] = {1, 1, 2, 2}; |
| 8040 | |
| 8041 | std::vector<float> input |
| 8042 | ({ |
| 8043 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 8044 | 1.0f, 2.0f, 3.0f, 4.0f |
| 8045 | }); |
| 8046 | |
| 8047 | std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f}); |
| 8048 | |
| 8049 | std::vector<unsigned int> blockShape({2, 2}); |
| 8050 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8051 | |
| 8052 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 8053 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8054 | crops, outputShape, expectedOutput); |
| 8055 | } |
| 8056 | |
| 8057 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test3( |
| 8058 | armnn::IWorkloadFactory& workloadFactory, |
| 8059 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8060 | { |
| 8061 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 8062 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 8063 | |
| 8064 | std::vector<float> input({ 1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f }); |
| 8065 | |
| 8066 | std::vector<float> expectedOutput |
| 8067 | ({ |
| 8068 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 8069 | 1.0f, 7.0f, |
| 8070 | 2.0f, 8.0f, |
| 8071 | |
| 8072 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 8073 | 3.0f, 9.0f, |
| 8074 | 4.0f, 10.0f, |
| 8075 | |
| 8076 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 8077 | 5.0f, 11.0f, |
| 8078 | 6.0f, 12.0f, |
| 8079 | }); |
| 8080 | |
| 8081 | std::vector<unsigned int> blockShape({2, 2}); |
| 8082 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8083 | |
| 8084 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 8085 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8086 | crops, outputShape, expectedOutput); |
| 8087 | } |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 8088 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8089 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest1( |
| 8090 | armnn::IWorkloadFactory& workloadFactory, |
| 8091 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 8092 | { |
| 8093 | const unsigned int inputShape[] = {4, 2, 2, 1}; |
| 8094 | const unsigned int outputShape[] = {1, 4, 4, 1}; |
| 8095 | |
| 8096 | std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }); |
| 8097 | std::vector<uint8_t> expectedOutput({ 1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16}); |
| 8098 | |
| 8099 | std::vector<unsigned int> blockShape({2, 2}); |
| 8100 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8101 | |
Matteo Martincigh | a65b7ae | 2018-11-14 12:39:55 +0000 | [diff] [blame] | 8102 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, armnn::DataLayout::NHWC, inputShape, |
| 8103 | input, blockShape, crops, outputShape, expectedOutput); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8104 | } |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 8105 | |
| 8106 | LayerTestResult<float, 4> StridedSlice4DFloat32Test( |
| 8107 | armnn::IWorkloadFactory& workloadFactory, |
| 8108 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8109 | { |
| 8110 | return StridedSlice4DTest<float>(workloadFactory, memoryManager); |
| 8111 | } |
| 8112 | |
| 8113 | LayerTestResult<float, 4> StridedSlice4DReverseFloat32Test( |
| 8114 | armnn::IWorkloadFactory& workloadFactory, |
| 8115 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8116 | { |
| 8117 | return StridedSlice4DReverseTest<float>(workloadFactory, memoryManager); |
| 8118 | } |
| 8119 | |
| 8120 | LayerTestResult<float, 4> StridedSliceSimpleStrideFloat32Test( |
| 8121 | armnn::IWorkloadFactory& workloadFactory, |
| 8122 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8123 | { |
| 8124 | return StridedSliceSimpleStrideTest<float>(workloadFactory, memoryManager); |
| 8125 | } |
| 8126 | |
| 8127 | LayerTestResult<float, 4> StridedSliceSimpleRangeMaskFloat32Test( |
| 8128 | armnn::IWorkloadFactory& workloadFactory, |
| 8129 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8130 | { |
| 8131 | return StridedSliceSimpleRangeMaskTest<float>(workloadFactory, memoryManager); |
| 8132 | } |
| 8133 | |
| 8134 | LayerTestResult<float, 2> StridedSliceShrinkAxisMaskFloat32Test( |
| 8135 | armnn::IWorkloadFactory& workloadFactory, |
| 8136 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8137 | { |
| 8138 | return StridedSliceShrinkAxisMaskTest<float>(workloadFactory, memoryManager); |
| 8139 | } |
| 8140 | |
| 8141 | LayerTestResult<float, 3> StridedSlice3DFloat32Test( |
| 8142 | armnn::IWorkloadFactory& workloadFactory, |
| 8143 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8144 | { |
| 8145 | return StridedSlice3DTest<float>(workloadFactory, memoryManager); |
| 8146 | } |
| 8147 | |
| 8148 | LayerTestResult<float, 3> StridedSlice3DReverseFloat32Test( |
| 8149 | armnn::IWorkloadFactory& workloadFactory, |
| 8150 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8151 | { |
| 8152 | return StridedSlice3DReverseTest<float>(workloadFactory, memoryManager); |
| 8153 | } |
| 8154 | |
| 8155 | LayerTestResult<float, 2> StridedSlice2DFloat32Test( |
| 8156 | armnn::IWorkloadFactory& workloadFactory, |
| 8157 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8158 | { |
| 8159 | return StridedSlice2DTest<float>(workloadFactory, memoryManager); |
| 8160 | } |
| 8161 | |
| 8162 | LayerTestResult<float, 2> StridedSlice2DReverseFloat32Test( |
| 8163 | armnn::IWorkloadFactory& workloadFactory, |
| 8164 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8165 | { |
| 8166 | return StridedSlice2DReverseTest<float>(workloadFactory, memoryManager); |
| 8167 | } |
| 8168 | |
| 8169 | LayerTestResult<uint8_t, 4> StridedSlice4DUint8Test( |
| 8170 | armnn::IWorkloadFactory& workloadFactory, |
| 8171 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8172 | { |
| 8173 | return StridedSlice4DTest<uint8_t>(workloadFactory, memoryManager); |
| 8174 | } |
| 8175 | |
| 8176 | LayerTestResult<uint8_t, 4> StridedSlice4DReverseUint8Test( |
| 8177 | armnn::IWorkloadFactory& workloadFactory, |
| 8178 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8179 | { |
| 8180 | return StridedSlice4DReverseTest<uint8_t>(workloadFactory, memoryManager); |
| 8181 | } |
| 8182 | |
| 8183 | LayerTestResult<uint8_t, 4> StridedSliceSimpleStrideUint8Test( |
| 8184 | armnn::IWorkloadFactory& workloadFactory, |
| 8185 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8186 | { |
| 8187 | return StridedSliceSimpleStrideTest<uint8_t>(workloadFactory, memoryManager); |
| 8188 | } |
| 8189 | |
| 8190 | LayerTestResult<uint8_t, 4> StridedSliceSimpleRangeMaskUint8Test( |
| 8191 | armnn::IWorkloadFactory& workloadFactory, |
| 8192 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8193 | { |
| 8194 | return StridedSliceSimpleRangeMaskTest<uint8_t>(workloadFactory, memoryManager); |
| 8195 | } |
| 8196 | |
| 8197 | LayerTestResult<uint8_t, 2> StridedSliceShrinkAxisMaskUint8Test( |
| 8198 | armnn::IWorkloadFactory& workloadFactory, |
| 8199 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8200 | { |
| 8201 | return StridedSliceShrinkAxisMaskTest<uint8_t>(workloadFactory, memoryManager); |
| 8202 | } |
| 8203 | |
| 8204 | LayerTestResult<uint8_t, 3> StridedSlice3DUint8Test( |
| 8205 | armnn::IWorkloadFactory& workloadFactory, |
| 8206 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8207 | { |
| 8208 | return StridedSlice3DTest<uint8_t>(workloadFactory, memoryManager); |
| 8209 | } |
| 8210 | |
| 8211 | LayerTestResult<uint8_t, 3> StridedSlice3DReverseUint8Test( |
| 8212 | armnn::IWorkloadFactory& workloadFactory, |
| 8213 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8214 | { |
| 8215 | return StridedSlice3DReverseTest<uint8_t>(workloadFactory, memoryManager); |
| 8216 | } |
| 8217 | |
| 8218 | LayerTestResult<uint8_t, 2> StridedSlice2DUint8Test( |
| 8219 | armnn::IWorkloadFactory& workloadFactory, |
| 8220 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8221 | { |
| 8222 | return StridedSlice2DTest<uint8_t>(workloadFactory, memoryManager); |
| 8223 | } |
| 8224 | |
| 8225 | LayerTestResult<uint8_t, 2> StridedSlice2DReverseUint8Test( |
| 8226 | armnn::IWorkloadFactory& workloadFactory, |
| 8227 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8228 | { |
| 8229 | return StridedSlice2DReverseTest<uint8_t>(workloadFactory, memoryManager); |
| 8230 | } |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 8231 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest2( |
| 8232 | armnn::IWorkloadFactory& workloadFactory, |
| 8233 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8234 | { |
| 8235 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 8236 | const unsigned int outputShape[] = {1, 2, 2, 1}; |
| 8237 | |
| 8238 | std::vector<uint8_t> input |
| 8239 | ({ |
| 8240 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 8241 | 1, 2, 3, 4 |
| 8242 | }); |
| 8243 | |
| 8244 | std::vector<uint8_t> expectedOutput({1, 2, 3, 4}); |
| 8245 | |
| 8246 | std::vector<unsigned int> blockShape({2, 2}); |
| 8247 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8248 | |
| 8249 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 8250 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 8251 | crops, outputShape, expectedOutput); |
| 8252 | } |
| 8253 | |
| 8254 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest3( |
| 8255 | armnn::IWorkloadFactory& workloadFactory, |
| 8256 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8257 | { |
| 8258 | const unsigned int inputShape[] = {4, 1, 1, 3}; |
| 8259 | const unsigned int outputShape[] = {1, 2, 2, 3}; |
| 8260 | |
| 8261 | std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); |
| 8262 | |
| 8263 | std::vector<uint8_t> expectedOutput({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); |
| 8264 | |
| 8265 | std::vector<unsigned int> blockShape({2, 2}); |
| 8266 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8267 | |
| 8268 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 8269 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 8270 | crops, outputShape, expectedOutput); |
| 8271 | } |
| 8272 | |
| 8273 | |
| 8274 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest1( |
| 8275 | armnn::IWorkloadFactory &workloadFactory, |
| 8276 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8277 | { |
| 8278 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 8279 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 8280 | |
| 8281 | std::vector<uint8_t> input({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); |
| 8282 | |
| 8283 | std::vector<uint8_t> expectedOutput |
| 8284 | ({ |
| 8285 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 8286 | 1, 4, |
| 8287 | 7, 10, |
| 8288 | |
| 8289 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 8290 | 2, 5, |
| 8291 | 8, 11, |
| 8292 | |
| 8293 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 8294 | 3, 6, |
| 8295 | 9, 12, |
| 8296 | }); |
| 8297 | |
| 8298 | std::vector<unsigned int> blockShape({2, 2}); |
| 8299 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8300 | |
| 8301 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 8302 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8303 | crops, outputShape, expectedOutput); |
| 8304 | } |
| 8305 | |
| 8306 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest2( |
| 8307 | armnn::IWorkloadFactory& workloadFactory, |
| 8308 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8309 | { |
| 8310 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 8311 | const unsigned int outputShape[] = {1, 1, 2, 2}; |
| 8312 | |
| 8313 | std::vector<uint8_t> input |
| 8314 | ({ |
| 8315 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 8316 | 1, 2, 3, 4 |
| 8317 | }); |
| 8318 | |
| 8319 | std::vector<uint8_t> expectedOutput({1, 2, 3, 4}); |
| 8320 | |
| 8321 | std::vector<unsigned int> blockShape({2, 2}); |
| 8322 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8323 | |
| 8324 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 8325 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8326 | crops, outputShape, expectedOutput); |
| 8327 | } |
| 8328 | |
| 8329 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest3( |
| 8330 | armnn::IWorkloadFactory& workloadFactory, |
| 8331 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8332 | { |
| 8333 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 8334 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 8335 | |
| 8336 | std::vector<uint8_t> input({ 1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12 }); |
| 8337 | |
| 8338 | std::vector<uint8_t> expectedOutput |
| 8339 | ({ |
| 8340 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 8341 | 1, 7, |
| 8342 | 2, 8, |
| 8343 | |
| 8344 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 8345 | 3, 9, |
| 8346 | 4, 10, |
| 8347 | |
| 8348 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 8349 | 5, 11, |
| 8350 | 6, 12, |
| 8351 | }); |
| 8352 | std::vector<unsigned int> blockShape({2, 2}); |
| 8353 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 8354 | |
| 8355 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 8356 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 8357 | crops, outputShape, expectedOutput); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 8358 | } |
| 8359 | |
| 8360 | LayerTestResult<float, 4> Debug4DFloat32Test( |
| 8361 | armnn::IWorkloadFactory& workloadFactory, |
| 8362 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8363 | { |
| 8364 | return Debug4DTest<float>(workloadFactory, memoryManager); |
| 8365 | } |
| 8366 | |
| 8367 | LayerTestResult<float, 3> Debug3DFloat32Test( |
| 8368 | armnn::IWorkloadFactory& workloadFactory, |
| 8369 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8370 | { |
| 8371 | return Debug3DTest<float>(workloadFactory, memoryManager); |
| 8372 | } |
| 8373 | |
| 8374 | LayerTestResult<float, 2> Debug2DFloat32Test( |
| 8375 | armnn::IWorkloadFactory& workloadFactory, |
| 8376 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8377 | { |
| 8378 | return Debug2DTest<float>(workloadFactory, memoryManager); |
| 8379 | } |
| 8380 | |
| 8381 | LayerTestResult<float, 1> Debug1DFloat32Test( |
| 8382 | armnn::IWorkloadFactory& workloadFactory, |
| 8383 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8384 | { |
| 8385 | return Debug1DTest<float>(workloadFactory, memoryManager); |
| 8386 | } |
| 8387 | |
| 8388 | LayerTestResult<uint8_t, 4> Debug4DUint8Test( |
| 8389 | armnn::IWorkloadFactory& workloadFactory, |
| 8390 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8391 | { |
| 8392 | return Debug4DTest<uint8_t>(workloadFactory, memoryManager); |
| 8393 | } |
| 8394 | |
| 8395 | LayerTestResult<uint8_t, 3> Debug3DUint8Test( |
| 8396 | armnn::IWorkloadFactory& workloadFactory, |
| 8397 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8398 | { |
| 8399 | return Debug3DTest<uint8_t>(workloadFactory, memoryManager); |
| 8400 | } |
| 8401 | |
| 8402 | LayerTestResult<uint8_t, 2> Debug2DUint8Test( |
| 8403 | armnn::IWorkloadFactory& workloadFactory, |
| 8404 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8405 | { |
| 8406 | return Debug2DTest<uint8_t>(workloadFactory, memoryManager); |
| 8407 | } |
| 8408 | |
| 8409 | LayerTestResult<uint8_t, 1> Debug1DUint8Test( |
| 8410 | armnn::IWorkloadFactory& workloadFactory, |
| 8411 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8412 | { |
| 8413 | return Debug1DTest<uint8_t>(workloadFactory, memoryManager); |
| 8414 | } |