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" |
Aron Virginas-Tar | d4f0fea | 2019-04-09 14:08:06 +0100 | [diff] [blame] | 8 | #include <ResolveType.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | |
| 10 | #include "test/TensorHelpers.hpp" |
| 11 | #include "TensorCopyUtils.hpp" |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 12 | #include "Permute.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
| 14 | #include <boost/test/unit_test.hpp> |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 15 | #include <boost/assert.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 16 | |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame] | 17 | #include <armnn/LayerSupport.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 19 | #include <backendsCommon/CpuTensorHandle.hpp> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 20 | #include <backendsCommon/IBackendInternal.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 21 | #include <backendsCommon/WorkloadFactory.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 23 | #include <reference/workloads/RefWorkloads.hpp> |
| 24 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 25 | #include <algorithm> |
| 26 | #include <boost/cast.hpp> |
| 27 | |
| 28 | #include "WorkloadTestUtils.hpp" |
| 29 | #include "Conv2dTestImpl.hpp" |
| 30 | #include "BatchNormTestImpl.hpp" |
| 31 | #include "ActivationTestImpl.hpp" |
| 32 | #include "Pooling2dTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | #include "FullyConnectedTestImpl.hpp" |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 34 | #include "GatherTestImpl.hpp" |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 35 | #include "SpaceToBatchNdTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | #include "SplitterTestImpl.hpp" |
| 37 | #include "SoftmaxTestImpl.hpp" |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 38 | #include "StridedSliceTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | #include "NormTestImpl.hpp" |
| 40 | #include "PermuteTestImpl.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 41 | #include "LstmTestImpl.hpp" |
| 42 | #include "ConvertFp16ToFp32TestImpl.hpp" |
| 43 | #include "ConvertFp32ToFp16TestImpl.hpp" |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 44 | #include "DebugTestImpl.hpp" |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 45 | #include "DequantizeTestImpl.hpp" |
Nattapat Chaimanowong | a0beb3b | 2019-04-01 17:04:53 +0100 | [diff] [blame] | 46 | #include "QuantizeTestImpl.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 48 | // 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] | 49 | static std::vector<float> ConvInput3x8x16({ |
| 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.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, |
| 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.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, |
| 56 | 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, |
| 57 | 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, |
| 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 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 64 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 65 | 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 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 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 72 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 73 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 74 | }); |
| 75 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 76 | // 2-channel bias used by a number of Conv2d tests. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 77 | static std::vector<float> Bias2({0, 2}); |
| 78 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 79 | // Helper function that returns either Bias2 or an empty vector depending on whether bias is enabled. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 80 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 81 | boost::multi_array<T, 1> GetBias2(bool biasEnabled, float qScale) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | { |
| 83 | if(biasEnabled) |
| 84 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 85 | armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias2.size())}, ArmnnType); |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 86 | boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(qScale, 0.0f, Bias2)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 87 | return bias; |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | return boost::multi_array<T, 1>(); |
| 92 | } |
| 93 | } |
| 94 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 95 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 96 | LayerTestResult<T, 4> SimpleConvolution2d3x5TestCommon( |
| 97 | armnn::IWorkloadFactory& workloadFactory, |
| 98 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 99 | float qScale, |
| 100 | int32_t qOffset, |
| 101 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 102 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 104 | // Use common single-batch 3-channel 16x8 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 105 | armnn::TensorInfo inputDesc({1, 3, 8, 16}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 106 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16)); |
| 107 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 108 | // Use a 2-element batch with 3-channel 3x5 kernels. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 109 | armnn::TensorInfo kernelDesc({2, 3, 5, 3}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 110 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 111 | QuantizedVector<T>(qScale, qOffset, { |
| 112 | 1, 1, 1, |
| 113 | 1, -1, 1, |
| 114 | 1, 1, 1, |
| 115 | 1, 1, 1, |
| 116 | 1, 1, 1, |
| 117 | |
| 118 | 0, 0, 0, |
| 119 | 0, 0, 0, |
| 120 | 0, 0, 0, |
| 121 | 0, 0, 0, |
| 122 | 0, 0, 0, |
| 123 | |
| 124 | 2, 2, 2, |
| 125 | 2, 2, 2, |
| 126 | 2, 2, 2, |
| 127 | 2, 2, 2, |
| 128 | 2, 2, 2, |
| 129 | |
| 130 | |
| 131 | 0, 0, 0, |
| 132 | 0, 0, 0, |
| 133 | 0, 0, 0, |
| 134 | 0, 0, 0, |
| 135 | 0, 0, 0, |
| 136 | |
| 137 | 1, 1, 1, |
| 138 | 1, 1, 1, |
| 139 | 1, 1, 1, |
| 140 | 1, 1, 1, |
| 141 | 1, 1, 1, |
| 142 | |
| 143 | 0, 0, 0, |
| 144 | 0, 0, 0, |
| 145 | 0, 0, 0, |
| 146 | 0, 0, 0, |
| 147 | 0, 0, 0 |
| 148 | }))); |
| 149 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 150 | // Expected output is 2 batch elements of a 1-channel 14x4 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 151 | armnn::TensorInfo outputDesc({1, 2, 4, 14}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 153 | QuantizedVector<T>(qScale, qOffset, { |
| 154 | -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, |
| 155 | -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, |
| 156 | -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, |
| 157 | -23.5f, -23.5f, -23.5f, |
| 158 | -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, -23.5f, |
| 159 | -23.5f, -23.5f, -23.5f, |
| 160 | |
| 161 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 162 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 163 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 164 | 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 165 | }))); |
| 166 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 167 | return SimpleConvolution2dTestImpl<ArmnnType, ArmnnBType>( |
| 168 | workloadFactory, |
| 169 | memoryManager, |
| 170 | input, |
| 171 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 172 | GetBias2<ArmnnBType>(biasEnabled, qScale * qScale), |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 173 | expectedOutput, |
| 174 | qScale, |
| 175 | qOffset, |
| 176 | layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 179 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 180 | typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 181 | LayerTestResult<T, 4> SimpleConvolution2d3x3TestCommon( |
| 182 | armnn::IWorkloadFactory& workloadFactory, |
| 183 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 184 | float qScale, |
| 185 | int32_t qOffset, |
| 186 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 187 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 188 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 189 | // Use a 3x3 kernel, which exercises ArmCompute's direct convolution path. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 190 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 191 | // Use common single-batch 3-channel 16x8 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 192 | armnn::TensorInfo inputDesc({1, 3, 8, 16}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 193 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, QuantizedVector<T>(qScale, qOffset, ConvInput3x8x16)); |
| 194 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 195 | // Use a 2-element batch of 3-channel 3x3 kernels. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 196 | armnn::TensorInfo kernelDesc({2, 3, 3, 3}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 197 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 198 | QuantizedVector<T>(qScale, qOffset, { |
| 199 | 1, 1, 1, |
| 200 | 1, -1, 1, |
| 201 | 1, 1, 1, |
| 202 | |
| 203 | 0, 0, 0, |
| 204 | 0, 0, 0, |
| 205 | 0, 0, 0, |
| 206 | |
| 207 | 2, 2, 2, |
| 208 | 2, 2, 2, |
| 209 | 2, 2, 2, |
| 210 | |
| 211 | |
| 212 | 0, 0, 0, |
| 213 | 0, 0, 0, |
| 214 | 0, 0, 0, |
| 215 | |
| 216 | 1, 1, 1, |
| 217 | 1, 1, 1, |
| 218 | 1, 1, 1, |
| 219 | |
| 220 | 0, 0, 0, |
| 221 | 0, 0, 0, |
| 222 | 0, 0, 0 |
| 223 | }))); |
| 224 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 225 | // Expected output is 1 batch of a 2-channel 14x6 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 226 | armnn::TensorInfo outputDesc({1, 2, 6, 14}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 227 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 228 | QuantizedVector<T>(qScale, qOffset, { |
| 229 | -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, |
| 230 | -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, |
| 231 | -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, |
| 232 | -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, |
| 233 | -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, |
| 234 | -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, |
| 235 | |
| 236 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 237 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 238 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 239 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 240 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 241 | 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 242 | }))); |
| 243 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 244 | return SimpleConvolution2dTestImpl<ArmnnType, ArmnnBType>( |
| 245 | workloadFactory, |
| 246 | memoryManager, |
| 247 | input, |
| 248 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 249 | GetBias2<ArmnnBType>(biasEnabled, qScale * qScale), |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 250 | expectedOutput, |
| 251 | qScale, |
| 252 | qOffset, |
| 253 | layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 256 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 257 | LayerTestResult<T, 4> SimpleConvolution2d3x3NhwcTestCommon( |
| 258 | armnn::IWorkloadFactory& workloadFactory, |
| 259 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 260 | float qScale, |
| 261 | int32_t qOffset, |
| 262 | bool biasEnabled, |
| 263 | armnn::DataLayout dataLayout) |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 264 | { |
| 265 | // Use common single-batch 5x5 image. |
| 266 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 267 | armnn::TensorInfo inputDesc({1, 3, 4, 1}, ArmnnType); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 268 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, |
| 269 | { |
| 270 | 1, 5, 2, 3, |
| 271 | 8, 7, 3, 6, |
| 272 | 3, 3, 9, 1 |
| 273 | }); |
| 274 | |
| 275 | |
| 276 | // Use a 2-element batch of 3-channel 3x3 kernels. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 277 | armnn::TensorInfo kernelDesc({1, 3, 3, 1}, ArmnnType); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 278 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, { |
| 279 | 4, 5, 6, |
| 280 | 0, 0, 0, |
| 281 | 3, 2, 1 |
| 282 | }); |
| 283 | |
| 284 | // Expected output is 1 batch of a 5x5 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 285 | armnn::TensorInfo outputDesc({1, 3, 4, 1}, ArmnnType); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 286 | |
| 287 | const std::vector<float> outputData = |
| 288 | { |
| 289 | 23, 41, 33, 21, |
| 290 | 44, 65, 76, 52, |
| 291 | 82, 85, 79, 42 |
| 292 | }; |
| 293 | |
| 294 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData); |
| 295 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 296 | return SimpleConvolution2dNhwcTestImpl<ArmnnType, ArmnnType>( |
| 297 | workloadFactory, |
| 298 | memoryManager, |
| 299 | input, |
| 300 | kernel, |
| 301 | boost::multi_array<T, 1>(), |
| 302 | expectedOutput, |
| 303 | dataLayout, |
| 304 | qScale, |
| 305 | qOffset); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 306 | } |
| 307 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 308 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 309 | LayerTestResult<T, 4> SimpleConvolution2d3x3Stride2x2TestCommon( |
| 310 | armnn::IWorkloadFactory& workloadFactory, |
| 311 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 312 | float qScale, |
| 313 | int32_t qOffset, |
| 314 | bool biasEnabled, |
| 315 | const armnn::DataLayout& dataLayout) |
| 316 | { |
| 317 | // Input is a single-batch, 1 channel, 5x5 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 318 | armnn::TensorInfo inputDesc({1, 5, 5, 1}, ArmnnType); |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 319 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, |
| 320 | { |
| 321 | 1, 5, 2, 3, 5, |
| 322 | 8, 7, 3, 6, 3, |
| 323 | 3, 3, 9, 1, 9, |
| 324 | 4, 1, 8, 1, 3, |
| 325 | 6, 8, 1, 9, 2 |
| 326 | }); |
| 327 | |
| 328 | // Use a 3x3 kernel. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 329 | armnn::TensorInfo kernelDesc({1, 3, 3, 1}, ArmnnType); |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 330 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, |
| 331 | { |
| 332 | 4, 5, 6, |
| 333 | 0, 0, 0, |
| 334 | 3, 2, 1 |
| 335 | }); |
| 336 | |
| 337 | // Expected output is a single-batch, 1 channel, 3x3 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 338 | armnn::TensorInfo outputDesc({1, 3, 3, 1}, ArmnnType); |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 339 | |
| 340 | const std::vector<T> outputData = |
| 341 | { |
| 342 | 23, 33, 24, |
| 343 | 91, 99, 48, |
| 344 | 26, 50, 19 |
| 345 | }; |
| 346 | |
| 347 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, outputData); |
| 348 | |
| 349 | uint32_t padLeft = 1; |
| 350 | uint32_t padTop = 1; |
| 351 | uint32_t padRight = 1; |
| 352 | uint32_t padBottom = 1; |
| 353 | uint32_t strideX = 2; |
| 354 | uint32_t strideY = 2; |
| 355 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 356 | return SimpleConvolution2dNhwcTestImpl<ArmnnType, ArmnnType>( |
| 357 | workloadFactory, |
| 358 | memoryManager, |
| 359 | input, |
| 360 | kernel, |
| 361 | boost::multi_array<T, 1>(), |
| 362 | expectedOutput, |
| 363 | dataLayout, |
| 364 | qScale, |
| 365 | qOffset, |
| 366 | padLeft, |
| 367 | padTop, |
| 368 | padRight, |
| 369 | padBottom, |
| 370 | strideX, |
| 371 | strideY); |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 374 | LayerTestResult<float, 4> SimpleConvolution2d3x5Test( |
| 375 | armnn::IWorkloadFactory& workloadFactory, |
| 376 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 377 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 378 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 379 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 380 | return SimpleConvolution2d3x5TestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
| 381 | workloadFactory, memoryManager, 0.f, 0, 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<uint8_t, 4> SimpleConvolution2d3x5Uint8Test( |
| 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 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 390 | return SimpleConvolution2d3x5TestCommon<armnn::DataType::QuantisedAsymm8, armnn::DataType::Signed32>( |
| 391 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 394 | LayerTestResult<float, 4> SimpleConvolution2d3x3Test( |
| 395 | armnn::IWorkloadFactory& workloadFactory, |
| 396 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 397 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 398 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 399 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 400 | return SimpleConvolution2d3x3TestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
| 401 | workloadFactory, memoryManager, 0.f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 402 | } |
| 403 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 404 | LayerTestResult<float, 4> SimpleConvolution2d3x3NhwcTest( |
| 405 | armnn::IWorkloadFactory& workloadFactory, |
| 406 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 407 | bool biasEnabled) |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 408 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 409 | return SimpleConvolution2d3x3NhwcTestCommon<armnn::DataType::Float32>( |
| 410 | workloadFactory, |
| 411 | memoryManager, |
| 412 | 0.f, |
| 413 | 0, |
| 414 | biasEnabled, |
| 415 | armnn::DataLayout::NHWC); |
Francis Murtagh | d59116e | 2018-10-04 16:03:07 +0100 | [diff] [blame] | 416 | } |
| 417 | |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 418 | LayerTestResult<float, 4> SimpleConvolution2d3x3Stride2x2Test( |
| 419 | armnn::IWorkloadFactory& workloadFactory, |
| 420 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 421 | bool biasEnabled, |
| 422 | const armnn::DataLayout layout) |
| 423 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 424 | return SimpleConvolution2d3x3Stride2x2TestCommon<armnn::DataType::Float32>( |
| 425 | workloadFactory, |
| 426 | memoryManager, |
| 427 | 0.f, |
| 428 | 0, |
| 429 | biasEnabled, |
| 430 | layout); |
Mike Kelly | 7332ed8 | 2018-12-20 17:03:06 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 433 | LayerTestResult<uint8_t, 4> SimpleConvolution2d3x3Uint8Test( |
| 434 | armnn::IWorkloadFactory& workloadFactory, |
| 435 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 436 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 437 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 438 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 439 | return SimpleConvolution2d3x3TestCommon<armnn::DataType::QuantisedAsymm8, armnn::DataType::Signed32>( |
| 440 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 441 | } |
| 442 | |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 443 | LayerTestResult<int16_t, 4> SimpleConvolution2d3x5QSymm16Test( |
| 444 | armnn::IWorkloadFactory& workloadFactory, |
| 445 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 446 | bool biasEnabled, |
| 447 | const armnn::DataLayout layout) |
| 448 | { |
| 449 | return SimpleConvolution2d3x5TestCommon<armnn::DataType::QuantisedSymm16, armnn::DataType::Signed32>( |
| 450 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
| 451 | } |
| 452 | |
| 453 | LayerTestResult<int16_t, 4> SimpleConvolution2d3x3QSymm16Test( |
| 454 | armnn::IWorkloadFactory& workloadFactory, |
| 455 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 456 | bool biasEnabled, |
| 457 | const armnn::DataLayout layout) |
| 458 | { |
| 459 | return SimpleConvolution2d3x3TestCommon<armnn::DataType::QuantisedSymm16, armnn::DataType::Signed32>( |
| 460 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
| 461 | } |
| 462 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 463 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 464 | typename T = armnn::ResolveType<ArmnnType>> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 465 | LayerTestResult<T, 4> Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon( |
| 466 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 467 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 468 | const armnn::DataLayout layout, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 469 | float qScale, |
| 470 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 471 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 472 | // Use a single-batch 1-channel 3x3 image as input. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 473 | armnn::TensorInfo inputDesc({1, 1, 3, 3}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 474 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>( |
| 475 | QuantizedVector<T>(qScale, qOffset, { |
| 476 | 11,21,31, |
| 477 | 12,22,32, |
| 478 | 13,23,33 |
| 479 | }))); |
| 480 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 481 | // Use 1 batch of a 1-channel 2x2 kernel. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 482 | armnn::TensorInfo kernelDesc({1, 1, 2, 2}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 483 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 484 | QuantizedVector<T>(qScale, qOffset, { |
| 485 | -11,-21, |
| 486 | -12,-22, |
| 487 | }))); |
| 488 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 489 | // Expected output is 1 batch of a 1-channel 6x8 image. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 490 | // Manually calculated like this: |
| 491 | //[-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 ..] |
| 492 | //[-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 ..] |
| 493 | //[-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 ..] |
| 494 | //[-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 ..] |
| 495 | //[-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 ..] |
| 496 | //[-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 ..] |
| 497 | //[..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ; ..... ..... ..... ..... ..] |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 498 | armnn::TensorInfo outputDesc({1, 1, 8, 6}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 499 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 500 | QuantizedVector<T>(qScale, qOffset, { |
| 501 | 0, 0, 0, 0, 0, 0, |
| 502 | -242, -594, -934, -372, 0, 0, |
| 503 | -495, -1190, -1850, -725, 0, 0, |
| 504 | -538, -1256, -1916, -748, 0, 0, |
| 505 | -273, -626, -946, -363, 0, 0, |
| 506 | 0, 0, 0, 0, 0, 0, |
| 507 | 0, 0, 0, 0, 0, 0, |
| 508 | 0, 0, 0, 0, 0, 0 |
| 509 | }))); |
| 510 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 511 | return SimpleConvolution2dTestImpl<ArmnnType, ArmnnBType>( |
| 512 | workloadFactory, |
| 513 | memoryManager, |
| 514 | input, |
| 515 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 516 | GetBias2<ArmnnBType>(false, qScale * qScale), |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 517 | expectedOutput, |
| 518 | qScale, |
| 519 | qOffset, |
| 520 | layout, |
| 521 | 1, // Padding left. |
| 522 | 2, // Padding top. |
| 523 | 3, // Padding right. |
| 524 | 4); // Padding bottom. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 527 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 528 | typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 529 | LayerTestResult<T, 4> SimpleConvolution2dAsymmetricPaddingTestCommon( |
| 530 | armnn::IWorkloadFactory& workloadFactory, |
| 531 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 532 | const armnn::DataLayout layout, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 533 | float qScale, |
| 534 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 535 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 536 | // Use a single-batch 1-channel 5x5 image as input. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 537 | armnn::TensorInfo inputDesc({ 1, 1, 5, 5 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 538 | boost::multi_array<T, 4> input = MakeTensor<T, 4>(inputDesc, std::vector<T>( |
| 539 | QuantizedVector<T>(qScale, qOffset, { |
| 540 | 11,21,31,41,51, |
| 541 | 12,22,32,42,52, |
| 542 | 13,23,33,43,53, |
| 543 | 14,24,34,44,54, |
| 544 | 15,25,35,45,55, |
| 545 | }))); |
| 546 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 547 | // Use 1 batch of a 1-channel 4x4 kernel. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 548 | armnn::TensorInfo kernelDesc({ 1, 1, 4, 4 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 549 | boost::multi_array<T, 4> kernel = MakeTensor<T, 4>(kernelDesc, std::vector<T>( |
| 550 | QuantizedVector<T>(qScale, qOffset, { |
| 551 | -11,-21,-31,-41, |
| 552 | -12,-22,-32,-42, |
| 553 | -13,-23,-33,-43, |
| 554 | -14,-24,-34,-44, |
| 555 | }))); |
| 556 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 557 | // Expected output is 1 batch of a 1-channel 5x5 image. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 558 | armnn::TensorInfo outputDesc({ 1, 1, 5, 5 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 559 | std::vector<T> myVec(outputDesc.GetNumElements(), 0); |
| 560 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputDesc, std::vector<T>( |
| 561 | QuantizedVector<T>(qScale, qOffset, { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 562 | -7140, -10580, -13940, -9300, -5230, |
| 563 | -9590, -14120, -18520, -12290, -6860, |
| 564 | -9980, -14560, -18960, -12560, -7000, |
| 565 | -7518, -10904, -14144, -9318, -5152, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 566 | -5032, -7256, -9376, -6142, -3368, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 567 | }))); |
| 568 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 569 | return SimpleConvolution2dTestImpl<ArmnnType, ArmnnBType>( |
| 570 | workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 571 | memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 572 | input, |
| 573 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 574 | GetBias2<ArmnnBType>(false, qScale * qScale), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 575 | expectedOutput, |
| 576 | qScale, |
| 577 | qOffset, |
narpra01 | 5f70318 | 2018-10-26 16:24:58 +0100 | [diff] [blame] | 578 | layout, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 579 | 1, // Padding left. |
| 580 | 1, // Padding top. |
| 581 | 2, // Padding right. |
| 582 | 2); // Padding bottom. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 583 | } |
| 584 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 585 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 586 | typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 587 | LayerTestResult<T, 4> DepthwiseConvolution2dAsymmetricTestCommon( |
| 588 | armnn::IWorkloadFactory& workloadFactory, |
| 589 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 590 | float qScale, |
| 591 | int32_t qOffset, |
| 592 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 593 | const armnn::DataLayout layout) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 594 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 595 | // Use a single-batch 2-channel 5x5 image as input. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 596 | armnn::TensorInfo inputTensorInfo({ 1, 2, 5, 5 }, ArmnnType); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 597 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 598 | QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), { |
| 599 | 0, 1, 2, 3, 4, |
| 600 | 5, 6, 7, 8, 9, |
| 601 | 10, 11, 12, 13, 14, |
| 602 | 15, 16, 17, 18, 19, |
| 603 | 20, 21, 22, 23, 24, |
| 604 | |
| 605 | 25, 26, 27, 28, 29, |
| 606 | 30, 31, 32, 33, 34, |
| 607 | 35, 36, 37, 38, 39, |
| 608 | 40, 41, 42, 43, 44, |
| 609 | 45, 46, 47, 48, 49 |
| 610 | }))); |
| 611 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 612 | // Use a depth multiplier of 1 on a 2-channel 4x4 kernel. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 613 | armnn::TensorInfo kernelTensorInfo({ 1, 2, 4, 4 }, ArmnnType); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 614 | auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>( |
| 615 | QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), { |
| 616 | 32, 31, 30, 29, |
| 617 | 28, 27, 26, 25, |
| 618 | 24, 23, 22, 21, |
| 619 | 20, 19, 18, 17, |
| 620 | |
| 621 | 16, 15, 14, 13, |
| 622 | 12, 11, 10, 9, |
| 623 | 8, 7, 6, 5, |
| 624 | 4, 3, 2, 1 |
| 625 | }))); |
| 626 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 627 | // Expected output is 1 batch of a 2-channel 5x5 image. |
| 628 | // Calculated using the python tensorflow library with strideX=1, strideY=1. |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 629 | armnn::TensorInfo outputTensorInfo({ 1, 2, 5, 5 }, ArmnnType); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 630 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>( |
| 631 | QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), { |
| 632 | 1062, 1580, 1850, 1530, 1117, |
| 633 | 2140, 3108, 3500, 2842, 2042, |
| 634 | 3580, 5068, 5460, 4342, 3062, |
| 635 | 3618, 5072, 5390, 4248, 2971, |
| 636 | 3074, 4282, 4510, 3533, 2457, |
| 637 | 1550, 2284, 2362, 1955, 1428, |
| 638 | 2910, 4206, 4342, 3528, 2536, |
| 639 | 3390, 4886, 5022, 4068, 2916, |
| 640 | 3566, 5056, 5182, 4133, 2922, |
| 641 | 3100, 4352, 4452, 3517, 2465 |
| 642 | }))); |
| 643 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 644 | return DepthwiseConvolution2dAsymmetricTestImpl<ArmnnType, ArmnnBType>( |
| 645 | workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 646 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 647 | input, |
| 648 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 649 | GetBias2<ArmnnBType>(biasEnabled, qScale * qScale), |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 650 | expectedOutput, |
| 651 | qScale, |
| 652 | qOffset, |
jimfly01 | 382a91d | 2018-10-26 15:55:50 +0100 | [diff] [blame] | 653 | layout, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 654 | 1, // Padding left. |
| 655 | 1, // Padding top. |
| 656 | 2, // Padding right. |
| 657 | 2, // Padding bottom. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 658 | 1, // strideX |
| 659 | 1); // strideY |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 660 | } |
| 661 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 662 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 663 | typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 664 | LayerTestResult<T, 4> DepthwiseConvolution2dNhwcTestCommon( |
| 665 | armnn::IWorkloadFactory& workloadFactory, |
| 666 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 667 | float qScale, |
| 668 | int32_t qOffset, |
| 669 | bool biasEnabled) |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 670 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 671 | armnn::TensorInfo inputTensorInfo({ 1, 5, 5, 2}, ArmnnType); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 672 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 673 | QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), { |
| 674 | 0, 25, |
| 675 | 1, 26, |
| 676 | 2, 27, |
| 677 | 3, 28, |
| 678 | 4, 29, |
| 679 | |
| 680 | 5, 30, |
| 681 | 6, 31, |
| 682 | 7, 32, |
| 683 | 8, 33, |
| 684 | 9, 34, |
| 685 | |
| 686 | 10, 35, |
| 687 | 11, 36, |
| 688 | 12, 37, |
| 689 | 13, 38, |
| 690 | 14, 39, |
| 691 | |
| 692 | 15, 40, |
| 693 | 16, 41, |
| 694 | 17, 42, |
| 695 | 18, 43, |
| 696 | 19, 44, |
| 697 | |
| 698 | 20, 45, |
| 699 | 21, 46, |
| 700 | 22, 47, |
| 701 | 23, 48, |
| 702 | 24, 49 |
| 703 | }))); |
| 704 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 705 | armnn::TensorInfo kernelTensorInfo({ 1, 2, 4, 4 }, ArmnnType); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 706 | auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>( |
| 707 | QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), { |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 708 | 32, 31, 30, 29, |
| 709 | 28, 27, 26, 25, |
| 710 | 24, 23, 22, 21, |
| 711 | 20, 19, 18, 17, |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 712 | |
Matteo Martincigh | 747ef82 | 2018-12-18 09:26:39 +0000 | [diff] [blame] | 713 | 16, 15, 14, 13, |
| 714 | 12, 11, 10, 9, |
| 715 | 8, 7, 6, 5, |
| 716 | 4, 3, 2, 1 |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 717 | }))); |
| 718 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 719 | armnn::TensorInfo outputTensorInfo({ 1, 5, 5, 2}, ArmnnType); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 720 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>( |
| 721 | QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), { |
| 722 | 1062, 1550, |
| 723 | 1580, 2284, |
| 724 | 1850, 2362, |
| 725 | 1530, 1955, |
| 726 | 1117, 1428, |
| 727 | |
| 728 | 2140, 2910, |
| 729 | 3108, 4206, |
| 730 | 3500, 4342, |
| 731 | 2842, 3528, |
| 732 | 2042, 2536, |
| 733 | |
| 734 | 3580, 3390, |
| 735 | 5068, 4886, |
| 736 | 5460, 5022, |
| 737 | 4342, 4068, |
| 738 | 3062, 2916, |
| 739 | |
| 740 | 3618, 3566, |
| 741 | 5072, 5056, |
| 742 | 5390, 5182, |
| 743 | 4248, 4133, |
| 744 | 2971, 2922, |
| 745 | |
| 746 | 3074, 3100, |
| 747 | 4282, 4352, |
| 748 | 4510, 4452, |
| 749 | 3533, 3517, |
| 750 | 2457, 2465 |
| 751 | }))); |
| 752 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 753 | return DepthwiseConvolution2dNhwcTestImpl<ArmnnType, ArmnnBType>( |
| 754 | workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 755 | memoryManager, |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 756 | input, |
| 757 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 758 | GetBias2<ArmnnBType>(biasEnabled, qScale * qScale), |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 759 | expectedOutput, |
| 760 | qScale, |
| 761 | qOffset, |
| 762 | 1, // Padding left. |
| 763 | 1, // Padding top. |
| 764 | 2, // Padding right. |
| 765 | 2, // Padding bottom. |
| 766 | 1, // strideX |
| 767 | 1); // strideY |
| 768 | } |
| 769 | |
Bruno Goncalves | 22972f0 | 2019-04-26 21:03:24 -0300 | [diff] [blame] | 770 | template<armnn::DataType ArmnnType, armnn::DataType ArmnnBType, |
| 771 | typename T = armnn::ResolveType<ArmnnType>> |
| 772 | LayerTestResult<T, 4> SimpleDepthwiseConvolution2d3x3Dilation3x3NhwcTestCommon( |
| 773 | armnn::IWorkloadFactory& workloadFactory, |
| 774 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 775 | float qScale, |
| 776 | int32_t qOffset, |
| 777 | bool biasEnabled) |
| 778 | { |
| 779 | armnn::TensorInfo inputTensorInfo({ 1, 9, 9, 1}, ArmnnType); |
| 780 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 781 | QuantizedVector<T>(inputTensorInfo.GetQuantizationScale(), inputTensorInfo.GetQuantizationOffset(), { |
| 782 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 783 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 784 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 785 | 0, 0, 0, 1, 1, 1, 0, 0, 0, |
| 786 | 0, 0, 0, 1, 1, 1, 0, 0, 0, |
| 787 | 0, 0, 0, 1, 1, 1, 0, 0, 0, |
| 788 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 789 | 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 790 | 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 791 | }))); |
| 792 | |
| 793 | armnn::TensorInfo kernelTensorInfo({ 1, 1, 3, 3}, ArmnnType); |
| 794 | auto kernel = MakeTensor<T, 4>(kernelTensorInfo, std::vector<T>( |
| 795 | QuantizedVector<T>(kernelTensorInfo.GetQuantizationScale(), kernelTensorInfo.GetQuantizationOffset(), { |
| 796 | 1, 2, 3, |
| 797 | 4, 5, 6, |
| 798 | 7, 8, 9 |
| 799 | }))); |
| 800 | |
| 801 | uint32_t padLeft = 0; |
| 802 | uint32_t padTop = 0; |
| 803 | uint32_t padRight = 0; |
| 804 | uint32_t padBottom = 0; |
| 805 | uint32_t strideX = 1; |
| 806 | uint32_t strideY = 1; |
| 807 | uint32_t dilationX = 3; |
| 808 | uint32_t dilationY = 3; |
| 809 | |
| 810 | // Since the dilation rate is 3 this will reduce the size of the output from 9x9 to 3x3 of all 5s. |
| 811 | armnn::TensorInfo outputTensorInfo({ 1, 3, 3, 1}, ArmnnType); |
| 812 | boost::multi_array<T, 4> expectedOutput = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>( |
| 813 | QuantizedVector<T>(outputTensorInfo.GetQuantizationScale(), outputTensorInfo.GetQuantizationOffset(), { |
| 814 | 5, 5, 5, |
| 815 | 5, 5, 5, |
| 816 | 5, 5, 5 |
| 817 | }))); |
| 818 | |
| 819 | return DepthwiseConvolution2dNhwcTestImpl<ArmnnType, ArmnnBType>( |
| 820 | workloadFactory, |
| 821 | memoryManager, |
| 822 | input, |
| 823 | kernel, |
Mike Kelly | 9b39832 | 2019-05-22 17:21:49 +0100 | [diff] [blame] | 824 | GetBias2<ArmnnBType>(biasEnabled, qScale * qScale), |
Bruno Goncalves | 22972f0 | 2019-04-26 21:03:24 -0300 | [diff] [blame] | 825 | expectedOutput, |
| 826 | qScale, |
| 827 | qOffset, |
| 828 | padLeft, |
| 829 | padTop, |
| 830 | padRight, |
| 831 | padBottom, |
| 832 | strideX, |
| 833 | strideY, |
| 834 | dilationX, |
| 835 | dilationY); |
| 836 | |
| 837 | } |
| 838 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 839 | LayerTestResult<float, 4> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 840 | Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTest( |
| 841 | armnn::IWorkloadFactory& workloadFactory, |
| 842 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 843 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 844 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 845 | return Convolution2dAsymmetricPaddingLargerThanHalfKernelSizeTestCommon |
| 846 | <armnn::DataType::Float32, armnn::DataType::Float32>( |
| 847 | workloadFactory, memoryManager, layout, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 848 | } |
| 849 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 850 | LayerTestResult<float, 4> Convolution2dAsymmetricPaddingTest( |
| 851 | armnn::IWorkloadFactory& workloadFactory, |
| 852 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 853 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 854 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 855 | return SimpleConvolution2dAsymmetricPaddingTestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 856 | workloadFactory, memoryManager, layout, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 857 | } |
| 858 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 859 | LayerTestResult<float, 4> DepthwiseConvolution2dTest( |
| 860 | armnn::IWorkloadFactory& workloadFactory, |
| 861 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 862 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 863 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 864 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 865 | return DepthwiseConvolution2dTestImpl<armnn::DataType::Float32, armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 866 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 869 | LayerTestResult<float, 4> DepthwiseConvolution2dDepthNhwcTest( |
| 870 | armnn::IWorkloadFactory& workloadFactory, |
| 871 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 872 | bool biasEnabled) |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 873 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 874 | return DepthwiseConvolution2dNhwcTestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
| 875 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled); |
Nikhil Raj | cec6b65 | 2018-10-12 13:51:57 +0100 | [diff] [blame] | 876 | } |
| 877 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 878 | LayerTestResult<float, 4> DepthwiseConvolution2dDepthMul1Test( |
| 879 | armnn::IWorkloadFactory& workloadFactory, |
| 880 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 881 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 882 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 883 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 884 | return DepthwiseConvolution2dDepthMul1TestImpl<armnn::DataType::Float32, armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 885 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 886 | } |
| 887 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 888 | LayerTestResult<float, 4> DepthwiseConvolution2dAsymmetricTest( |
| 889 | armnn::IWorkloadFactory& workloadFactory, |
| 890 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 891 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 892 | const armnn::DataLayout layout) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 893 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 894 | return DepthwiseConvolution2dAsymmetricTestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 895 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 896 | } |
| 897 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 898 | LayerTestResult<uint8_t, 4> DepthwiseConvolution2dUint8Test( |
| 899 | armnn::IWorkloadFactory& workloadFactory, |
| 900 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 901 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 902 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 903 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 904 | return DepthwiseConvolution2dTestImpl<armnn::DataType::QuantisedAsymm8, armnn::DataType::Signed32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 905 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 906 | } |
| 907 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 908 | LayerTestResult<uint8_t, 4> DepthwiseConvolution2dDepthMul1Uint8Test( |
| 909 | armnn::IWorkloadFactory& workloadFactory, |
| 910 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 911 | bool biasEnabled, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 912 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 913 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 914 | return DepthwiseConvolution2dDepthMul1TestImpl<armnn::DataType::QuantisedAsymm8, armnn::DataType::Signed32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 915 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 916 | } |
| 917 | |
Bruno Goncalves | 22972f0 | 2019-04-26 21:03:24 -0300 | [diff] [blame] | 918 | LayerTestResult<float, 4> SimpleDepthwiseConvolution2d3x3Dilation3x3NhwcTest( |
| 919 | armnn::IWorkloadFactory& workloadFactory, |
| 920 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 921 | { |
| 922 | return SimpleDepthwiseConvolution2d3x3Dilation3x3NhwcTestCommon<armnn::DataType::Float32, armnn::DataType::Float32>( |
| 923 | workloadFactory, |
| 924 | memoryManager, |
| 925 | 0.f, |
| 926 | 0, |
| 927 | false); |
| 928 | } |
| 929 | |
Ruomei Yan | 88d44b8 | 2019-05-23 14:29:06 +0100 | [diff] [blame] | 930 | LayerTestResult<int16_t, 4> DepthwiseConvolution2dInt16Test( |
| 931 | armnn::IWorkloadFactory& workloadFactory, |
| 932 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 933 | bool biasEnabled, |
| 934 | const armnn::DataLayout layout) |
| 935 | { |
| 936 | return DepthwiseConvolution2dTestImpl<armnn::DataType::QuantisedSymm16, armnn::DataType::Signed32>( |
| 937 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
| 938 | } |
| 939 | |
| 940 | LayerTestResult<int16_t, 4> DepthwiseConvolution2dDepthMul1Int16Test( |
| 941 | armnn::IWorkloadFactory& workloadFactory, |
| 942 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 943 | bool biasEnabled, |
| 944 | const armnn::DataLayout layout) |
| 945 | { |
| 946 | return DepthwiseConvolution2dDepthMul1TestImpl<armnn::DataType::QuantisedSymm16, armnn::DataType::Signed32>( |
| 947 | workloadFactory, memoryManager, 0.5f, 50, biasEnabled, layout); |
| 948 | } |
| 949 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 950 | LayerTestResult<float, 4> Convolution1dTest( |
| 951 | armnn::IWorkloadFactory& workloadFactory, |
| 952 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 953 | bool biasEnabled) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 954 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 955 | return Convolution1dTestImpl<armnn::DataType::Float32, armnn::DataType::Float32>( |
| 956 | workloadFactory, memoryManager, 0.0f, 0, biasEnabled); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 957 | } |
| 958 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 959 | LayerTestResult<uint8_t, 4> Convolution1dUint8Test( |
| 960 | armnn::IWorkloadFactory& workloadFactory, |
| 961 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 962 | bool biasEnabled) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 963 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 964 | return Convolution1dTestImpl<armnn::DataType::QuantisedAsymm8, armnn::DataType::Signed32>( |
| 965 | workloadFactory, memoryManager, 0.1f, 128, biasEnabled); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 966 | } |
| 967 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 968 | LayerTestResult<float,4> CompareConvolution2dTest( |
| 969 | armnn::IWorkloadFactory& workloadFactory, |
| 970 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 971 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 972 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 973 | return CompareConvolution2dTestImpl<armnn::DataType::Float32>( |
| 974 | workloadFactory, memoryManager, refWorkloadFactory); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 975 | } |
| 976 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 977 | LayerTestResult<float, 4> CompareDepthwiseConvolution2dFloatTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 978 | armnn::IWorkloadFactory& workloadFactory, |
| 979 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 980 | armnn::IWorkloadFactory& refWorkloadFactory, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 981 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 982 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 983 | return CompareDepthwiseConvolution2dTestImpl<armnn::DataType::Float32>( |
| 984 | workloadFactory, memoryManager, refWorkloadFactory, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 985 | } |
| 986 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 987 | LayerTestResult<uint8_t, 4> CompareDepthwiseConvolution2dUint8Test( |
| 988 | armnn::IWorkloadFactory& workloadFactory, |
| 989 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 990 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 991 | const armnn::DataLayout layout) |
| 992 | { |
| 993 | return CompareDepthwiseConvolution2dTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 994 | workloadFactory, memoryManager, refWorkloadFactory, layout); |
| 995 | } |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 996 | |
| 997 | LayerTestResult<float,4> SimpleNormalizationAcrossTest( |
| 998 | armnn::IWorkloadFactory& workloadFactory, |
| 999 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1000 | { |
| 1001 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 1002 | auto normChannel = armnn::NormalizationAlgorithmChannel::Across; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1003 | return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1006 | LayerTestResult<float,4> SimpleNormalizationWithinTest( |
| 1007 | armnn::IWorkloadFactory& workloadFactory, |
| 1008 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1009 | { |
| 1010 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 1011 | auto normChannel = armnn::NormalizationAlgorithmChannel::Within; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1012 | return SimpleNormalizationTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1015 | LayerTestResult<float,4> SimpleNormalizationAcrossNhwcTest( |
| 1016 | armnn::IWorkloadFactory& workloadFactory, |
| 1017 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 1018 | { |
| 1019 | auto normMethod = armnn::NormalizationAlgorithmMethod::LocalBrightness; |
| 1020 | auto normChannel = armnn::NormalizationAlgorithmChannel::Across; |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1021 | return SimpleNormalizationNhwcTestImpl(workloadFactory, memoryManager, normChannel, normMethod); |
narpra01 | 55a97bc | 2018-10-02 14:35:53 +0100 | [diff] [blame] | 1022 | } |
| 1023 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1024 | LayerTestResult<float,2> SimpleSoftmaxTest( |
| 1025 | armnn::IWorkloadFactory& workloadFactory, |
| 1026 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1027 | float beta) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1028 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1029 | return SimpleSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Narumol Prangnawarat | 65d3096 | 2019-03-14 11:55:03 +0000 | [diff] [blame] | 1032 | LayerTestResult<float,3> Simple3dSoftmaxTest( |
| 1033 | armnn::IWorkloadFactory& workloadFactory, |
| 1034 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1035 | float beta) |
| 1036 | { |
| 1037 | return Simple3dSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, beta); |
| 1038 | } |
| 1039 | |
| 1040 | LayerTestResult<float,4> Simple4dSoftmaxTest( |
| 1041 | armnn::IWorkloadFactory& workloadFactory, |
| 1042 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1043 | float beta) |
| 1044 | { |
| 1045 | return Simple4dSoftmaxTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, beta); |
| 1046 | } |
| 1047 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1048 | LayerTestResult<uint8_t,2> SimpleSoftmaxUint8Test( |
| 1049 | armnn::IWorkloadFactory& workloadFactory, |
| 1050 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1051 | float beta) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1052 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1053 | return SimpleSoftmaxTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
Narumol Prangnawarat | 65d3096 | 2019-03-14 11:55:03 +0000 | [diff] [blame] | 1056 | LayerTestResult<uint8_t,3> Simple3dSoftmaxUint8Test( |
| 1057 | armnn::IWorkloadFactory& workloadFactory, |
| 1058 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1059 | float beta) |
| 1060 | { |
| 1061 | return Simple3dSoftmaxTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, beta); |
| 1062 | } |
| 1063 | |
| 1064 | LayerTestResult<uint8_t,4> Simple4dSoftmaxUint8Test( |
| 1065 | armnn::IWorkloadFactory& workloadFactory, |
| 1066 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1067 | float beta) |
| 1068 | { |
| 1069 | return Simple4dSoftmaxTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, beta); |
| 1070 | } |
| 1071 | |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1072 | LayerTestResult<int16_t,2> SimpleSoftmaxUint16Test( |
| 1073 | armnn::IWorkloadFactory& workloadFactory, |
| 1074 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1075 | float beta) |
| 1076 | { |
| 1077 | return SimpleSoftmaxTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, beta); |
| 1078 | } |
| 1079 | |
| 1080 | LayerTestResult<int16_t,3> Simple3dSoftmaxUint16Test( |
| 1081 | armnn::IWorkloadFactory& workloadFactory, |
| 1082 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1083 | float beta) |
| 1084 | { |
| 1085 | return Simple3dSoftmaxTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, beta); |
| 1086 | } |
| 1087 | |
| 1088 | LayerTestResult<int16_t,4> Simple4dSoftmaxUint16Test( |
| 1089 | armnn::IWorkloadFactory& workloadFactory, |
| 1090 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1091 | float beta) |
| 1092 | { |
| 1093 | return Simple4dSoftmaxTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, beta); |
| 1094 | } |
| 1095 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1096 | LayerTestResult<float,4> CompareNormalizationTest( |
| 1097 | armnn::IWorkloadFactory& workloadFactory, |
| 1098 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1099 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1100 | armnn::NormalizationAlgorithmChannel normChannel, |
| 1101 | armnn::NormalizationAlgorithmMethod normMethod) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1102 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1103 | return CompareNormalizationTestImpl(workloadFactory, memoryManager, refWorkloadFactory, normChannel, normMethod); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1104 | } |
| 1105 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1106 | LayerTestResult<float,2> CompareSoftmaxTest( |
| 1107 | armnn::IWorkloadFactory& workloadFactory, |
| 1108 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1109 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1110 | float beta) |
| 1111 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1112 | return CompareSoftmaxTestImpl<armnn::DataType::Float32>( |
| 1113 | workloadFactory, memoryManager, refWorkloadFactory, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1116 | LayerTestResult<uint8_t,2> CompareSoftmaxUint8Test( |
| 1117 | armnn::IWorkloadFactory& workloadFactory, |
| 1118 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1119 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 1120 | float beta) |
| 1121 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1122 | return CompareSoftmaxTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 1123 | workloadFactory, memoryManager, refWorkloadFactory, beta); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1126 | std::vector<LayerTestResult<float,3>> SplitterTest( |
| 1127 | armnn::IWorkloadFactory& workloadFactory, |
| 1128 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1129 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1130 | return SplitterTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1133 | std::vector<LayerTestResult<uint8_t,3>> SplitterUint8Test( |
| 1134 | armnn::IWorkloadFactory& workloadFactory, |
| 1135 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1136 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1137 | return SplitterTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1138 | } |
| 1139 | |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 1140 | std::vector<LayerTestResult<int16_t,3>> SplitterInt16Test( |
| 1141 | armnn::IWorkloadFactory& workloadFactory, |
| 1142 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1143 | { |
| 1144 | return SplitterTestCommon<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, 1.0f, 0); |
| 1145 | } |
| 1146 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1147 | LayerTestResult<float, 3> CopyViaSplitterTest( |
| 1148 | armnn::IWorkloadFactory& workloadFactory, |
| 1149 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1150 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1151 | return CopyViaSplitterTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1152 | } |
| 1153 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1154 | LayerTestResult<uint8_t, 3> CopyViaSplitterUint8Test( |
| 1155 | armnn::IWorkloadFactory& workloadFactory, |
| 1156 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1157 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1158 | return CopyViaSplitterTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1159 | } |
| 1160 | |
Ruomei Yan | 25339c3 | 2019-05-28 16:48:20 +0100 | [diff] [blame] | 1161 | LayerTestResult<int16_t, 3> CopyViaSplitterInt16Test( |
| 1162 | armnn::IWorkloadFactory& workloadFactory, |
| 1163 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1164 | { |
| 1165 | return CopyViaSplitterTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, 1.0f, 0); |
| 1166 | } |
| 1167 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1168 | LayerTestResult<float, 2> LstmLayerFloat32WithCifgWithPeepholeNoProjectionTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1169 | armnn::IWorkloadFactory& workloadFactory, |
| 1170 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1171 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1172 | armnn::TensorInfo inputDesc({ 2, 2 }, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1173 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 1174 | { 2., 3., 3., 4. })); |
| 1175 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1176 | armnn::TensorInfo outputDesc({ 2, 4 }, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1177 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 1178 | {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f, |
| 1179 | -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f})); |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1180 | return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1181 | workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | LayerTestResult<float, 2> LstmLayerFloat32NoCifgWithPeepholeWithProjectionTest( |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1185 | armnn::IWorkloadFactory& workloadFactory, |
| 1186 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1187 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1188 | armnn::TensorInfo inputDesc({ 2, 5 }, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1189 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 1190 | {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f, |
| 1191 | 0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f})); |
| 1192 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1193 | armnn::TensorInfo outputDesc({ 2, 16 }, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1194 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 1195 | {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f, |
| 1196 | -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f, |
| 1197 | -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f, |
| 1198 | 0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f, |
| 1199 | -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f, |
| 1200 | 0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f, |
| 1201 | 0.02168f})); |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1202 | return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<armnn::DataType::Float32>( |
| 1203 | workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1204 | } |
| 1205 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1206 | LayerTestResult<float, 2> LstmLayerFloat32NoCifgNoPeepholeNoProjectionTest( |
| 1207 | armnn::IWorkloadFactory& workloadFactory, |
| 1208 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1209 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1210 | armnn::TensorInfo inputDesc({2, 2}, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1211 | boost::multi_array<float, 2> input = MakeTensor<float, 2>(inputDesc, std::vector<float>( |
| 1212 | {2., 3., 3., 4.})); |
| 1213 | |
| 1214 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1215 | armnn::TensorInfo outputDesc({2, 4}, armnn::DataType::Float32); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1216 | boost::multi_array<float, 2> expectedOutput = MakeTensor<float, 2>(outputDesc, std::vector<float>( |
| 1217 | {{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f, |
| 1218 | -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}})); |
| 1219 | |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1220 | return LstmNoCifgNoPeepholeNoProjectionTestImpl<armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1221 | workloadFactory, memoryManager, input, expectedOutput); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1222 | } |
| 1223 | |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1224 | LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgNoPeepholeNoProjectionTest( |
| 1225 | armnn::IWorkloadFactory& workloadFactory, |
| 1226 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1227 | { |
| 1228 | const float qScale = 1.0f; |
| 1229 | const int32_t qOffset = 0; |
| 1230 | |
| 1231 | const armnn::DataType datatype = armnn::DataType::QuantisedSymm16; |
| 1232 | const armnn::DataType constantDatatype = armnn::DataType::QuantisedAsymm8; |
| 1233 | |
| 1234 | armnn::TensorInfo inputDesc({2, 2}, datatype); |
| 1235 | boost::multi_array<int16_t , 2> input = MakeTensor<int16_t , 2>(inputDesc, QuantizedVector<int16_t>(qScale, qOffset, |
| 1236 | std::vector<float>{2., 3., 3., 4.})); |
| 1237 | |
| 1238 | armnn::TensorInfo outputDesc({2, 4}, datatype); |
| 1239 | boost::multi_array<int16_t, 2> expectedOutput = MakeTensor<int16_t, 2>(outputDesc, QuantizedVector<int16_t>(qScale, |
| 1240 | qOffset, std::vector<float>({{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f, |
| 1241 | -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}}))); |
| 1242 | |
| 1243 | return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>( |
| 1244 | workloadFactory, memoryManager, input, expectedOutput, qScale, qOffset, constantDatatype); |
| 1245 | |
| 1246 | } |
| 1247 | |
| 1248 | LayerTestResult<int16_t, 2> LstmLayerInt16WithCifgWithPeepholeNoProjectionTest( |
| 1249 | armnn::IWorkloadFactory& workloadFactory, |
| 1250 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1251 | { |
| 1252 | const float qScale = 1.0f; |
| 1253 | const int32_t qOffset = 0; |
| 1254 | |
| 1255 | const armnn::DataType datatype = armnn::DataType::QuantisedSymm16; |
| 1256 | const armnn::DataType constantDatatype = armnn::DataType::QuantisedAsymm8; |
| 1257 | |
| 1258 | armnn::TensorInfo inputDesc({ 2, 2 }, datatype); |
| 1259 | boost::multi_array<int16_t, 2> input = MakeTensor<int16_t, 2>(inputDesc, QuantizedVector<int16_t>(qScale, qOffset, |
| 1260 | std::vector<float>({ 2., 3., 3., 4. }))); |
| 1261 | |
| 1262 | armnn::TensorInfo outputDesc({ 2, 4 }, datatype); |
| 1263 | boost::multi_array<int16_t, 2> expectedOutput = MakeTensor<int16_t, 2>(outputDesc, QuantizedVector<int16_t>(qScale, |
| 1264 | qOffset, std::vector<float>( |
| 1265 | {-0.36444446f, -0.00352185f, 0.12886585f, -0.05163646f, |
| 1266 | -0.42734814f, -0.00478661f, 0.13455015f, -0.03560682f}))); |
| 1267 | |
| 1268 | return LstmLayerWithCifgWithPeepholeNoProjectionTestImpl<datatype>( |
| 1269 | workloadFactory, memoryManager, input, expectedOutput, qScale, qOffset, constantDatatype); |
| 1270 | } |
| 1271 | |
| 1272 | LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgWithPeepholeWithProjectionTest( |
| 1273 | armnn::IWorkloadFactory& workloadFactory, |
| 1274 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1275 | { |
| 1276 | const float qScale = 2.0f; |
| 1277 | const int32_t qOffset = 0; |
| 1278 | |
| 1279 | const armnn::DataType datatype = armnn::DataType::QuantisedSymm16; |
| 1280 | const armnn::DataType constantDatatype = armnn::DataType::QuantisedAsymm8; |
| 1281 | |
| 1282 | armnn::TensorInfo inputDesc({ 2, 5 }, datatype); |
| 1283 | boost::multi_array<int16_t, 2> input = MakeTensor<int16_t, 2>(inputDesc, QuantizedVector<int16_t>(qScale, |
| 1284 | qOffset, std::vector<float>( |
| 1285 | {0.787926f, 0.151646f, 0.071352f, 0.118426f, 0.458058f, |
| 1286 | 0.295743f, 0.544053f, 0.690064f, 0.858138f, 0.497181f}))); |
| 1287 | |
| 1288 | armnn::TensorInfo outputDesc({ 2, 16 }, datatype); |
| 1289 | boost::multi_array<int16_t, 2> expectedOutput = MakeTensor<int16_t, 2>(outputDesc, QuantizedVector<int16_t>(qScale, |
| 1290 | qOffset, std::vector<float>( |
| 1291 | {-0.00396806f, 0.029352f, -0.00279226f, 0.0159977f, -0.00835576f, |
| 1292 | -0.0211779f, 0.0283512f, -0.0114597f, 0.00907307f, -0.0244004f, |
| 1293 | -0.0152191f, -0.0259063f, 0.00914318f, 0.00415118f, 0.017147f, |
| 1294 | 0.0134203f, -0.013869f, 0.0287268f, -0.00334693f, 0.00733398f, -0.0287926f, |
| 1295 | -0.0186926f, 0.0193662f, -0.0115437f, 0.00422612f, -0.0345232f, |
| 1296 | 0.00223253f, -0.00957321f, 0.0210624f, 0.013331f, 0.0150954f, 0.02168f}))); |
| 1297 | |
| 1298 | return LstmLayerNoCifgWithPeepholeWithProjectionTestImpl<datatype>( |
| 1299 | workloadFactory, memoryManager, input, expectedOutput, qScale, qOffset, constantDatatype); |
| 1300 | } |
| 1301 | |
| 1302 | LayerTestResult<int16_t, 2> LstmLayerInt16NoCifgNoPeepholeNoProjectionInt16ConstantTest( |
| 1303 | armnn::IWorkloadFactory& workloadFactory, |
| 1304 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1305 | { |
| 1306 | const float qScale = 1.0f; |
| 1307 | const int32_t qOffset = 0; |
| 1308 | |
| 1309 | const armnn::DataType datatype = armnn::DataType::QuantisedSymm16; // datatype & constants set to QSymm16 |
| 1310 | |
| 1311 | armnn::TensorInfo inputDesc({2, 2}, datatype); |
| 1312 | boost::multi_array<int16_t , 2> input = MakeTensor<int16_t , 2>(inputDesc, QuantizedVector<int16_t>(qScale, |
| 1313 | qOffset, std::vector<float>{2., 3., 3., 4.})); |
| 1314 | |
| 1315 | armnn::TensorInfo outputDesc({2, 4}, datatype); |
| 1316 | boost::multi_array<int16_t, 2> expectedOutput = MakeTensor<int16_t, 2>(outputDesc, QuantizedVector<int16_t>(qScale, |
| 1317 | qOffset, std::vector<float>({{-0.02973187f, 0.1229473f, 0.20885126f, -0.15358765f, |
| 1318 | -0.0185422f, 0.11281417f, 0.24466537f, -0.1826292f}}))); |
| 1319 | |
| 1320 | return LstmNoCifgNoPeepholeNoProjectionTestImpl<datatype>( |
| 1321 | workloadFactory, memoryManager, input, expectedOutput, qScale, qOffset, datatype); |
| 1322 | } |
| 1323 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 1324 | LayerTestResult<float,3> ConcatTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1325 | armnn::IWorkloadFactory& workloadFactory, |
| 1326 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1327 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1328 | unsigned int outputWidth = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1329 | unsigned int outputHeight = 6; |
| 1330 | unsigned int outputChannels = 3; |
| 1331 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1332 | unsigned int inputWidth1 = 3; |
| 1333 | unsigned int inputHeight1 = 6; |
| 1334 | unsigned int inputChannels1 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1335 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1336 | unsigned int inputWidth2 = 3; |
| 1337 | unsigned int inputHeight2 = 6; |
| 1338 | unsigned int inputChannels2 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1339 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1340 | // Define the tensor descriptors. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1341 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::Float32); |
| 1342 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::Float32); |
| 1343 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1344 | |
| 1345 | LayerTestResult<float,3> ret(outputTensorInfo); |
| 1346 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1347 | ret.outputExpected = MakeTensor<float, 3>(outputTensorInfo, std::vector<float>( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1348 | { |
| 1349 | 1.0f, 2.0f, 3.0f, |
| 1350 | 4.0f, 5.0f, 6.0f, |
| 1351 | 7.0f, 8.0f, 9.0f, |
| 1352 | 10.0f, 11.0f, 12.0f, |
| 1353 | 13.0f, 14.0f, 15.0f, |
| 1354 | 16.0f, 17.0f, 18.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1355 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1356 | 19.0f, 20.0f, 21.0f, |
| 1357 | 22.0f, 23.0f, 24.0f, |
| 1358 | 25.0f, 26.0f, 27.0f, |
| 1359 | 28.0f, 29.0f, 30.0f, |
| 1360 | 31.0f, 32.0f, 33.0f, |
| 1361 | 34.0f, 35.0f, 36.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1362 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1363 | 37.0f, 38.0f, 39.0f, |
| 1364 | 40.0f, 41.0f, 42.0f, |
| 1365 | 43.0f, 44.0f, 45.0f, |
| 1366 | 46.0f, 47.0f, 48.0f, |
| 1367 | 49.0f, 50.0f, 51.0f, |
| 1368 | 52.0f, 53.0f, 54.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1369 | }) |
| 1370 | ); |
| 1371 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1372 | auto input1 = MakeTensor<float, 3>(inputTensorInfo1, std::vector<float>( |
| 1373 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1374 | 1.0f, 2.0f, 3.0f, |
| 1375 | 4.0f, 5.0f, 6.0f, |
| 1376 | 7.0f, 8.0f, 9.0f, |
| 1377 | 10.0f, 11.0f, 12.0f, |
| 1378 | 13.0f, 14.0f, 15.0f, |
| 1379 | 16.0f, 17.0f, 18.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1380 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1381 | 19.0f, 20.0f, 21.0f, |
| 1382 | 22.0f, 23.0f, 24.0f, |
| 1383 | 25.0f, 26.0f, 27.0f, |
| 1384 | 28.0f, 29.0f, 30.0f, |
| 1385 | 31.0f, 32.0f, 33.0f, |
| 1386 | 34.0f, 35.0f, 36.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1387 | }) |
| 1388 | ); |
| 1389 | |
| 1390 | auto input2 = MakeTensor<float, 3>(inputTensorInfo2, std::vector<float>( |
| 1391 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1392 | 37.0f, 38.0f, 39.0f, |
| 1393 | 40.0f, 41.0f, 42.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1394 | 43.0f, 44.0f, 45.0f, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1395 | 46.0f, 47.0f, 48.0f, |
| 1396 | 49.0f, 50.0f, 51.0f, |
| 1397 | 52.0f, 53.0f, 54.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1398 | }) |
| 1399 | ); |
| 1400 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1401 | std::vector<unsigned int> wOrigin1 = {0, 0, 0}; //Extent of the window is defined by size of input[0]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1402 | armnn::ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1403 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1404 | std::vector<unsigned int> wOrigin2 = {2, 0, 0}; //Extent of the window is defined by size of input[1]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1405 | armnn::ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1406 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1407 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1408 | |
| 1409 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 1410 | |
| 1411 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 1412 | subTensorsSupported ? |
| 1413 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 1414 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1415 | |
| 1416 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 1417 | subTensorsSupported ? |
| 1418 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 1419 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1420 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1421 | armnn::ConcatQueueDescriptor data; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1422 | armnn::WorkloadInfo info; |
| 1423 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1424 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1425 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1426 | |
| 1427 | data.m_ViewOrigins.push_back(window1); |
| 1428 | data.m_ViewOrigins.push_back(window2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1429 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 1430 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConcat(data, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1431 | |
| 1432 | inputHandle1->Allocate(); |
| 1433 | inputHandle2->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1434 | outputHandle->Allocate(); |
| 1435 | |
| 1436 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 1437 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1438 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1439 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1440 | workload->Execute(); |
| 1441 | |
| 1442 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 1443 | |
| 1444 | return ret; |
| 1445 | } |
| 1446 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1447 | LayerTestResult<float,4> AdditionTest( |
| 1448 | armnn::IWorkloadFactory& workloadFactory, |
| 1449 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1450 | { |
| 1451 | unsigned int batchSize = 2; |
| 1452 | unsigned int channels = 2; |
| 1453 | unsigned int height = 2; |
| 1454 | unsigned int width = 3; |
| 1455 | |
| 1456 | armnn::TensorInfo inputTensorInfo1, inputTensorInfo2; |
| 1457 | armnn::TensorInfo outputTensorInfo; |
| 1458 | |
| 1459 | unsigned int shape[] = {batchSize, channels, height, width}; |
| 1460 | |
| 1461 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1462 | inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1463 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1464 | |
| 1465 | |
| 1466 | auto input1 = MakeTensor<float, 4>(inputTensorInfo1, std::vector<float>( |
| 1467 | { |
| 1468 | 0.0f, 2.0f, 1.0f, |
| 1469 | 0.2f, 1.0f, 2.0f, |
| 1470 | |
| 1471 | 1.0f, 2.0f, 1.0f, |
| 1472 | 0.2f, 1.0f, 2.0f, |
| 1473 | |
| 1474 | 0.0f, 2.0f, 1.0f, |
| 1475 | 4.2f, 1.0f, 2.0f, |
| 1476 | |
| 1477 | 0.0f, 0.0f, 1.0f, |
| 1478 | 0.2f, 1.0f, 2.0f, |
| 1479 | })); |
| 1480 | |
| 1481 | auto input2 = MakeTensor<float, 4>(inputTensorInfo2, std::vector<float>( |
| 1482 | { |
| 1483 | 1.0f, 2.0f, 1.0f, |
| 1484 | 0.0f, 1.0f, 2.0f, |
| 1485 | |
| 1486 | 1.0f, 2.0f, -2.0f, |
| 1487 | 0.2f, 1.0f, 2.0f, |
| 1488 | |
| 1489 | 0.0f, 2.0f, 1.0f, |
| 1490 | 4.2f, 0.0f, -3.0f, |
| 1491 | |
| 1492 | 0.0f, 0.0f, 1.0f, |
| 1493 | 0.7f, 1.0f, 5.0f, |
| 1494 | })); |
| 1495 | |
| 1496 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 1497 | ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, std::vector<float>( |
| 1498 | { |
| 1499 | 1.0f, 4.0f, 2.0f, |
| 1500 | 0.2f, 2.0f, 4.0f, |
| 1501 | |
| 1502 | 2.0f, 4.0f, -1.0f, |
| 1503 | 0.4f, 2.0f, 4.0f, |
| 1504 | |
| 1505 | 0.0f, 4.0f, 2.0f, |
| 1506 | 8.4f, 1.0f, -1.0f, |
| 1507 | |
| 1508 | 0.0f, 0.0f, 2.0f, |
| 1509 | 0.9f, 2.0f, 7.0f, |
| 1510 | })); |
| 1511 | |
| 1512 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1513 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1514 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1515 | |
| 1516 | armnn::AdditionQueueDescriptor data; |
| 1517 | armnn::WorkloadInfo info; |
| 1518 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1519 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1520 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1521 | |
| 1522 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1523 | |
| 1524 | inputHandle1->Allocate(); |
| 1525 | inputHandle2->Allocate(); |
| 1526 | outputHandle->Allocate(); |
| 1527 | |
| 1528 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1529 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1530 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1531 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1532 | workload->Execute(); |
| 1533 | |
| 1534 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1535 | |
| 1536 | return ret; |
| 1537 | } |
| 1538 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1539 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1540 | LayerTestResult<T, 4> AdditionBroadcastTestImpl( |
| 1541 | armnn::IWorkloadFactory& workloadFactory, |
| 1542 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1543 | float qScale, |
| 1544 | int32_t qOffset) |
| 1545 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1546 | armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 1}, ArmnnType); |
| 1547 | armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 2, 3}, ArmnnType); |
| 1548 | armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1549 | |
| 1550 | if (armnn::IsQuantizedType<T>()) |
| 1551 | { |
| 1552 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 1553 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
| 1554 | inputTensorInfo2.SetQuantizationScale(qScale); |
| 1555 | inputTensorInfo2.SetQuantizationOffset(qOffset); |
| 1556 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1557 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1558 | } |
| 1559 | |
| 1560 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, |
| 1561 | { |
| 1562 | 0.0f, |
| 1563 | 1.0f, |
| 1564 | |
| 1565 | 2.0f, |
| 1566 | 3.0f, |
| 1567 | |
| 1568 | 4.0f, |
| 1569 | 5.0f, |
| 1570 | })); |
| 1571 | |
| 1572 | auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset, |
| 1573 | { |
| 1574 | 0.5f, 1.5f, 2.5f, |
| 1575 | 3.5f, 4.5f, 5.5f, |
| 1576 | })); |
| 1577 | |
| 1578 | LayerTestResult<T,4> ret(outputTensorInfo); |
| 1579 | ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, |
| 1580 | { |
| 1581 | 0.5f, 1.5f, 2.5f, |
| 1582 | 4.5f, 5.5f, 6.5f, |
| 1583 | |
| 1584 | 2.5f, 3.5f, 4.5f, |
| 1585 | 6.5f, 7.5f, 8.5f, |
| 1586 | |
| 1587 | 4.5f, 5.5f, 6.5f, |
| 1588 | 8.5f, 9.5f, 10.5f, |
| 1589 | })); |
| 1590 | |
| 1591 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1592 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1593 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1594 | |
| 1595 | armnn::AdditionQueueDescriptor data; |
| 1596 | armnn::WorkloadInfo info; |
| 1597 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1598 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1599 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1600 | |
| 1601 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1602 | |
| 1603 | inputHandle1->Allocate(); |
| 1604 | inputHandle2->Allocate(); |
| 1605 | outputHandle->Allocate(); |
| 1606 | |
| 1607 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1608 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1609 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1610 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1611 | workload->Execute(); |
| 1612 | |
| 1613 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1614 | |
| 1615 | return ret; |
| 1616 | } |
| 1617 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1618 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1619 | LayerTestResult<T, 4> AdditionBroadcast1ElementTestImpl( |
| 1620 | armnn::IWorkloadFactory& workloadFactory, |
| 1621 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1622 | float qScale, |
| 1623 | int32_t qOffset) |
| 1624 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1625 | armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({1, 3, 2, 3}, ArmnnType); |
| 1626 | armnn::TensorInfo inputTensorInfo2 = armnn::TensorInfo({1, 1, 1, 1}, ArmnnType); |
| 1627 | armnn::TensorInfo outputTensorInfo = armnn::TensorInfo({1, 3, 2, 3}, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1628 | |
| 1629 | if (armnn::IsQuantizedType<T>()) |
| 1630 | { |
| 1631 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 1632 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
| 1633 | inputTensorInfo2.SetQuantizationScale(qScale); |
| 1634 | inputTensorInfo2.SetQuantizationOffset(qOffset); |
| 1635 | outputTensorInfo.SetQuantizationScale(qScale); |
| 1636 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 1637 | } |
| 1638 | |
| 1639 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, |
| 1640 | { |
| 1641 | 0.0f, 1.0f, 2.0f, |
| 1642 | 3.0f, 4.0f, 5.0f, |
| 1643 | 6.0f, 7.0f, 8.0f, |
| 1644 | 9.0f, 10.0f, 11.0f, |
| 1645 | 12.0f, 13.0f, 14.0f, |
| 1646 | 15.0f, 16.0f, 17.0f, |
| 1647 | })); |
| 1648 | |
| 1649 | auto input2 = MakeTensor<T, 4>(inputTensorInfo2, QuantizedVector<T>(qScale, qOffset, |
| 1650 | { |
| 1651 | 0.5f, |
| 1652 | })); |
| 1653 | |
| 1654 | LayerTestResult<T,4> ret(outputTensorInfo); |
| 1655 | ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, |
| 1656 | { |
| 1657 | 0.5f, 1.5f, 2.5f, |
| 1658 | 3.5f, 4.5f, 5.5f, |
| 1659 | 6.5f, 7.5f, 8.5f, |
| 1660 | 9.5f, 10.5f, 11.5f, |
| 1661 | 12.5f, 13.5f, 14.5f, |
| 1662 | 15.5f, 16.5f, 17.5f, |
| 1663 | })); |
| 1664 | |
| 1665 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1666 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1667 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1668 | |
| 1669 | armnn::AdditionQueueDescriptor data; |
| 1670 | armnn::WorkloadInfo info; |
| 1671 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1672 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1673 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1674 | |
| 1675 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1676 | |
| 1677 | inputHandle1->Allocate(); |
| 1678 | inputHandle2->Allocate(); |
| 1679 | outputHandle->Allocate(); |
| 1680 | |
| 1681 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1682 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1683 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1684 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1685 | workload->Execute(); |
| 1686 | |
| 1687 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1688 | |
| 1689 | return ret; |
| 1690 | } |
| 1691 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1692 | LayerTestResult<float, 4> AdditionBroadcastTest( |
| 1693 | armnn::IWorkloadFactory& workloadFactory, |
| 1694 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1695 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1696 | return AdditionBroadcastTestImpl<armnn::DataType::Float32>( |
| 1697 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1698 | } |
| 1699 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1700 | LayerTestResult<uint8_t, 4> AdditionBroadcastUint8Test( |
| 1701 | armnn::IWorkloadFactory& workloadFactory, |
| 1702 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1703 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1704 | return AdditionBroadcastTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 1705 | workloadFactory, memoryManager, 2.f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1706 | } |
| 1707 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1708 | LayerTestResult<int16_t, 4> AdditionBroadcastInt16Test( |
| 1709 | armnn::IWorkloadFactory& workloadFactory, |
| 1710 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1711 | { |
| 1712 | return AdditionBroadcastTestImpl<armnn::DataType::QuantisedSymm16>( |
| 1713 | workloadFactory, memoryManager, 2.f, 0); |
| 1714 | } |
| 1715 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1716 | LayerTestResult<float, 4> AdditionBroadcast1ElementTest( |
| 1717 | armnn::IWorkloadFactory& workloadFactory, |
| 1718 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1719 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1720 | return AdditionBroadcast1ElementTestImpl<armnn::DataType::Float32>( |
| 1721 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1722 | } |
| 1723 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1724 | LayerTestResult<uint8_t, 4> AdditionBroadcast1ElementUint8Test( |
| 1725 | armnn::IWorkloadFactory& workloadFactory, |
| 1726 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1727 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 1728 | return AdditionBroadcast1ElementTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 1729 | workloadFactory, memoryManager, 0.1333333f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1730 | } |
| 1731 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1732 | LayerTestResult<int16_t, 4> AdditionBroadcast1ElementInt16Test( |
| 1733 | armnn::IWorkloadFactory& workloadFactory, |
| 1734 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 1735 | { |
| 1736 | return AdditionBroadcast1ElementTestImpl<armnn::DataType::QuantisedSymm16>( |
| 1737 | workloadFactory, memoryManager, 0.1333333f, 0); |
| 1738 | } |
| 1739 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1740 | LayerTestResult<float,4> CompareAdditionTest( |
| 1741 | armnn::IWorkloadFactory& workloadFactory, |
| 1742 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1743 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1744 | { |
| 1745 | unsigned int batchSize = 4; |
| 1746 | unsigned int channels = 1; |
| 1747 | unsigned int height = 2; |
| 1748 | unsigned int width = 3; |
| 1749 | |
| 1750 | armnn::TensorInfo inputTensorInfo1, inputTensorInfo2; |
| 1751 | armnn::TensorInfo outputTensorInfo; |
| 1752 | |
| 1753 | unsigned int shape[] = {batchSize, channels, height, width}; |
| 1754 | |
| 1755 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1756 | inputTensorInfo2 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1757 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 1758 | |
| 1759 | auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 1232); |
| 1760 | auto input2 = MakeRandomTensor<float, 4>(inputTensorInfo2, 456); |
| 1761 | |
| 1762 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 1763 | |
| 1764 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1765 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1766 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1767 | |
| 1768 | std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1769 | std::unique_ptr<armnn::ITensorHandle> inputHandle2Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 1770 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 1771 | |
| 1772 | armnn::AdditionQueueDescriptor data; |
| 1773 | armnn::WorkloadInfo info; |
| 1774 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1775 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 1776 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 1777 | |
| 1778 | armnn::AdditionQueueDescriptor refData = data; |
| 1779 | armnn::WorkloadInfo refInfo = info; |
| 1780 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo1, inputHandle1Ref.get()); |
| 1781 | SetWorkloadInput(refData, refInfo, 1, inputTensorInfo2, inputHandle2Ref.get()); |
| 1782 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 1783 | |
| 1784 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 1785 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateAddition(refData, refInfo); |
| 1786 | |
| 1787 | inputHandle1->Allocate(); |
| 1788 | inputHandle2->Allocate(); |
| 1789 | outputHandle->Allocate(); |
| 1790 | inputHandle1Ref->Allocate(); |
| 1791 | inputHandle2Ref->Allocate(); |
| 1792 | outputHandleRef->Allocate(); |
| 1793 | |
| 1794 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1795 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0][0]); |
| 1796 | CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]); |
| 1797 | CopyDataToITensorHandle(inputHandle2Ref.get(), &input2[0][0][0][0]); |
| 1798 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1799 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1800 | workload->Execute(); |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1801 | workloadRef->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1802 | workloadRef->Execute(); |
| 1803 | |
| 1804 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 1805 | CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 1806 | |
| 1807 | return ret; |
| 1808 | } |
| 1809 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1810 | namespace { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1811 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1812 | LayerTestResult<T, 4> DivisionTestHelper( |
| 1813 | armnn::IWorkloadFactory& workloadFactory, |
| 1814 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 1815 | const unsigned int shape0[4], |
| 1816 | const std::vector<T>& values0, |
| 1817 | float scale0, |
| 1818 | int32_t offset0, |
| 1819 | const unsigned int shape1[4], |
| 1820 | const std::vector<T> & values1, |
| 1821 | float scale1, |
| 1822 | int32_t offset1, |
| 1823 | const unsigned int outShape[4], |
| 1824 | const std::vector<T> & outValues, |
| 1825 | float outScale, |
| 1826 | int32_t outOffset) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1827 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1828 | armnn::TensorInfo inputTensorInfo0(4, shape0, ArmnnType); |
| 1829 | armnn::TensorInfo inputTensorInfo1(4, shape1, ArmnnType); |
| 1830 | armnn::TensorInfo outputTensorInfo(4, outShape, ArmnnType); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1831 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1832 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 1833 | inputTensorInfo0.SetQuantizationOffset(offset0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1834 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1835 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 1836 | inputTensorInfo1.SetQuantizationOffset(offset1); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1837 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1838 | outputTensorInfo.SetQuantizationScale(outScale); |
| 1839 | outputTensorInfo.SetQuantizationOffset(outOffset); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1840 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1841 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 1842 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1843 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1844 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1845 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1846 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1847 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 1848 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 1849 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1850 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1851 | armnn::DivisionQueueDescriptor data; |
| 1852 | armnn::WorkloadInfo info; |
| 1853 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 1854 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 1855 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1856 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1857 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateDivision(data, info); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1858 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1859 | inputHandle0->Allocate(); |
| 1860 | inputHandle1->Allocate(); |
| 1861 | outputHandle->Allocate(); |
| 1862 | |
| 1863 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 1864 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 1865 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 1866 | workload->PostAllocationConfigure(); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1867 | workload->Execute(); |
| 1868 | |
| 1869 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 1870 | |
| 1871 | return result; |
| 1872 | } |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1873 | } // anonymous namespace |
| 1874 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1875 | LayerTestResult<float,4> DivisionByZeroTest( |
| 1876 | armnn::IWorkloadFactory& workloadFactory, |
| 1877 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | 8c5e3dc | 2018-08-30 17:18:37 +0100 | [diff] [blame] | 1878 | { |
| 1879 | const unsigned int width = 2; |
| 1880 | const unsigned int height = 2; |
| 1881 | const unsigned int channelCount = 2; |
| 1882 | const unsigned int batchSize = 2; |
| 1883 | |
| 1884 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1885 | |
| 1886 | std::vector<float> input0({ |
| 1887 | 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, |
| 1888 | -1.f, -1.f, -1.f, -1.f, 5.f, 5.f, 5.f, 5.f }); |
| 1889 | |
| 1890 | std::vector<float> input1({ |
| 1891 | 0.f, 0.f, -0.f, -0.f, 0.f, 0.f, -0.f, -0.f, |
| 1892 | 0.f, 0.f, -0.f, -0.f, 5.f, 5.f, 5.f, 5.f }); |
| 1893 | |
| 1894 | std::vector<float> output({ |
| 1895 | INFINITY, INFINITY, -INFINITY, -INFINITY, NAN, NAN, -NAN, -NAN, |
| 1896 | -INFINITY, -INFINITY, INFINITY, INFINITY, 1, 1, 1, 1 }); |
| 1897 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1898 | return DivisionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 1899 | memoryManager, |
| 1900 | shape, input0, 1.0f, 0, |
| 1901 | shape, input1, 1.0f, 0, |
| 1902 | shape, output, 1.0f, 0); |
Francis Murtagh | 8c5e3dc | 2018-08-30 17:18:37 +0100 | [diff] [blame] | 1903 | } |
| 1904 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1905 | LayerTestResult<float,4> DivisionTest( |
| 1906 | armnn::IWorkloadFactory& workloadFactory, |
| 1907 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1908 | { |
| 1909 | const unsigned int width = 2; |
| 1910 | const unsigned int height = 2; |
| 1911 | const unsigned int channelCount = 2; |
| 1912 | const unsigned int batchSize = 2; |
| 1913 | |
| 1914 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1915 | |
| 1916 | std::vector<float> input0({ |
| 1917 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 1918 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 1919 | |
| 1920 | std::vector<float> input1({ |
| 1921 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 1922 | 4, 4, 4, 4, 4, 4, 4, 4 }); |
| 1923 | |
| 1924 | std::vector<float> output({ |
| 1925 | 2, 2, 2, 2, 1.5, 1.5, 1.5, 1.5, |
| 1926 | 1, 1, 1, 1, 1.25, 1.25, 1.25, 1.25 }); |
| 1927 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1928 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1929 | return DivisionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 1930 | memoryManager, |
| 1931 | shape, input0, 1.0f, 0, |
| 1932 | shape, input1, 1.0f, 0, |
| 1933 | shape, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1934 | } |
| 1935 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1936 | LayerTestResult<float, 4> DivisionBroadcast1ElementTest( |
| 1937 | armnn::IWorkloadFactory& workloadFactory, |
| 1938 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1939 | { |
| 1940 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 1941 | std::vector<float> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 1942 | |
| 1943 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 1944 | std::vector<float> input1({ 2 }); |
| 1945 | |
| 1946 | std::vector<float> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 1947 | |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1948 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1949 | return DivisionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 1950 | memoryManager, |
| 1951 | shape0, input0, 1.0f, 0, |
| 1952 | shape1, input1, 1.0f, 0, |
| 1953 | shape0, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1954 | } |
| 1955 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1956 | LayerTestResult<float, 4> DivisionBroadcast1DVectorTest( |
| 1957 | armnn::IWorkloadFactory& workloadFactory, |
| 1958 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 1959 | { |
| 1960 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 1961 | std::vector<float> input0({ |
| 1962 | 1, 4, 3, 8, 5, 12, |
| 1963 | 7, 16, 9, 20, 11, 24, |
| 1964 | 13, 28, 15, 32, 17, 36}); |
| 1965 | |
| 1966 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 1967 | std::vector<float> input1({ 1, 2 }); |
| 1968 | |
| 1969 | std::vector<float> output({ |
| 1970 | 1, 2, 3, 4, 5, 6, |
| 1971 | 7, 8, 9, 10, 11, 12, |
| 1972 | 13, 14, 15, 16, 17, 18}); |
| 1973 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1974 | return DivisionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 1975 | memoryManager, |
| 1976 | shape0, input0, 1.0f, 0, |
| 1977 | shape1, input1, 1.0f, 0, |
| 1978 | shape0, output, 1.0f, 0); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1979 | } |
| 1980 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 1981 | LayerTestResult<uint8_t,4> DivisionUint8Test( |
| 1982 | armnn::IWorkloadFactory& workloadFactory, |
| 1983 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 1984 | { |
| 1985 | const unsigned int width = 2; |
| 1986 | const unsigned int height = 2; |
| 1987 | const unsigned int channelCount = 2; |
| 1988 | const unsigned int batchSize = 2; |
| 1989 | |
| 1990 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 1991 | |
| 1992 | std::vector<uint8_t> input0({2, 2, 2, 2, 3, 3, 3, 3, |
| 1993 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 1994 | |
| 1995 | std::vector<uint8_t> input1({1, 1, 1, 1, 2, 2, 2, 2, |
| 1996 | 4, 4, 4, 4, 4, 4, 4, 4 }); |
| 1997 | |
| 1998 | std::vector<uint8_t> output({8, 8, 8, 8, 6, 6, 6, 6, |
| 1999 | 4, 4, 4, 4, 5, 5, 5, 5}); |
| 2000 | |
| 2001 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2002 | return DivisionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 2003 | memoryManager, |
| 2004 | shape, input0, 1.0f, 0, |
| 2005 | shape, input1, 1.0f, 0, |
| 2006 | shape, output, 0.25f, 0); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 2007 | } |
| 2008 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2009 | LayerTestResult<uint8_t, 4> DivisionBroadcast1ElementUint8Test( |
| 2010 | armnn::IWorkloadFactory& workloadFactory, |
| 2011 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 2012 | { |
| 2013 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2014 | std::vector<uint8_t> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 2015 | |
| 2016 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2017 | std::vector<uint8_t> input1({ 2 }); |
| 2018 | |
| 2019 | std::vector<uint8_t> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2020 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2021 | return DivisionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 2022 | memoryManager, |
| 2023 | shape0, input0, 1.0f, 0, |
| 2024 | shape1, input1, 1.0f, 0, |
| 2025 | shape0, output, 1.0f, 0); |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 2026 | } |
| 2027 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 2028 | LayerTestResult<uint8_t, 4> DivisionBroadcast1DVectorUint8Test( |
| 2029 | armnn::IWorkloadFactory& workloadFactory, |
| 2030 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | 5cd01f3 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 2031 | { |
| 2032 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 2033 | std::vector<uint8_t> input0({1, 4, 3, 8, 5, 12, |
| 2034 | 7, 16, 9, 20, 11, 24, |
| 2035 | 13, 28, 15, 32, 17, 36}); |
| 2036 | |
| 2037 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 2038 | std::vector<uint8_t> input1({ 1, 2 }); |
| 2039 | |
| 2040 | std::vector<uint8_t> output({1, 2, 3, 4, 5, 6, |
| 2041 | 7, 8, 9, 10, 11, 12, |
| 2042 | 13, 14, 15, 16, 17, 18}); |
| 2043 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2044 | return DivisionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 2045 | memoryManager, |
| 2046 | shape0, input0, 1.0f, 0, |
| 2047 | shape1, input1, 1.0f, 0, |
| 2048 | shape0, output, 1.0f, 0); |
| 2049 | } |
| 2050 | |
| 2051 | LayerTestResult<int16_t,4> DivisionInt16Test( |
| 2052 | armnn::IWorkloadFactory& workloadFactory, |
| 2053 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2054 | { |
| 2055 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2056 | |
| 2057 | std::vector<int16_t> input0({2, 2, 2, 2, 3, 3, 3, 3, |
| 2058 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2059 | |
| 2060 | std::vector<int16_t> input1({1, 1, 1, 1, 2, 2, 2, 2, |
| 2061 | 4, 4, 4, 4, 4, 4, 4, 4 }); |
| 2062 | |
| 2063 | std::vector<int16_t> output({8, 8, 8, 8, 6, 6, 6, 6, |
| 2064 | 4, 4, 4, 4, 5, 5, 5, 5}); |
| 2065 | |
| 2066 | |
| 2067 | return DivisionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 2068 | memoryManager, |
| 2069 | shape, input0, 1.0f, 0, |
| 2070 | shape, input1, 1.0f, 0, |
| 2071 | shape, output, 0.25f, 0); |
| 2072 | } |
| 2073 | |
| 2074 | LayerTestResult<int16_t, 4> DivisionBroadcast1ElementInt16Test( |
| 2075 | armnn::IWorkloadFactory& workloadFactory, |
| 2076 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2077 | { |
| 2078 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2079 | std::vector<int16_t> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 2080 | |
| 2081 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2082 | std::vector<int16_t> input1({ 2 }); |
| 2083 | |
| 2084 | std::vector<int16_t> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2085 | |
| 2086 | return DivisionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 2087 | memoryManager, |
| 2088 | shape0, input0, 1.0f, 0, |
| 2089 | shape1, input1, 1.0f, 0, |
| 2090 | shape0, output, 1.0f, 0); |
| 2091 | } |
| 2092 | |
| 2093 | LayerTestResult<int16_t, 4> DivisionBroadcast1DVectorInt16Test( |
| 2094 | armnn::IWorkloadFactory& workloadFactory, |
| 2095 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2096 | { |
| 2097 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 2098 | std::vector<int16_t> input0({1, 4, 3, 8, 5, 12, |
| 2099 | 7, 16, 9, 20, 11, 24, |
| 2100 | 13, 28, 15, 32, 17, 36}); |
| 2101 | |
| 2102 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 2103 | std::vector<int16_t> input1({ 1, 2 }); |
| 2104 | |
| 2105 | std::vector<int16_t> output({1, 2, 3, 4, 5, 6, |
| 2106 | 7, 8, 9, 10, 11, 12, |
| 2107 | 13, 14, 15, 16, 17, 18}); |
| 2108 | |
| 2109 | return DivisionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 2110 | memoryManager, |
| 2111 | shape0, input0, 1.0f, 0, |
| 2112 | shape1, input1, 1.0f, 0, |
| 2113 | shape0, output, 1.0f, 0); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 2114 | } |
| 2115 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2116 | template<typename DescriptorType> |
| 2117 | std::unique_ptr<armnn::IWorkload> CreateWorkload( |
| 2118 | const armnn::IWorkloadFactory& workloadFactory, |
| 2119 | const armnn::WorkloadInfo& info, |
| 2120 | const DescriptorType& descriptor) |
| 2121 | { |
| 2122 | return CreateWorkload(workloadFactory, info, descriptor); |
| 2123 | }; |
| 2124 | |
| 2125 | template<> |
| 2126 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MaximumQueueDescriptor>( |
| 2127 | const armnn::IWorkloadFactory& workloadFactory, |
| 2128 | const armnn::WorkloadInfo& info, |
| 2129 | const armnn::MaximumQueueDescriptor& descriptor) |
| 2130 | { |
| 2131 | return workloadFactory.CreateMaximum(descriptor, info); |
| 2132 | } |
| 2133 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2134 | template<> |
| 2135 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>( |
| 2136 | const armnn::IWorkloadFactory& workloadFactory, |
| 2137 | const armnn::WorkloadInfo& info, |
| 2138 | const armnn::MinimumQueueDescriptor& descriptor) |
| 2139 | { |
| 2140 | return workloadFactory.CreateMinimum(descriptor, info); |
| 2141 | } |
| 2142 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2143 | template<> |
| 2144 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::EqualQueueDescriptor>( |
| 2145 | const armnn::IWorkloadFactory& workloadFactory, |
| 2146 | const armnn::WorkloadInfo& info, |
| 2147 | const armnn::EqualQueueDescriptor& descriptor) |
| 2148 | { |
| 2149 | return workloadFactory.CreateEqual(descriptor, info); |
| 2150 | } |
| 2151 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2152 | template<> |
| 2153 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::GreaterQueueDescriptor>( |
| 2154 | const armnn::IWorkloadFactory& workloadFactory, |
| 2155 | const armnn::WorkloadInfo& info, |
| 2156 | const armnn::GreaterQueueDescriptor& descriptor) |
| 2157 | { |
| 2158 | return workloadFactory.CreateGreater(descriptor, info); |
| 2159 | } |
| 2160 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2161 | namespace { |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2162 | |
| 2163 | template <typename Descriptor, |
| 2164 | armnn::DataType ArmnnTypeInput, |
| 2165 | armnn::DataType ArmnnTypeOutput, |
| 2166 | typename TInput = armnn::ResolveType<ArmnnTypeInput>, |
| 2167 | typename TOutput = armnn::ResolveType<ArmnnTypeOutput>> |
| 2168 | LayerTestResult<TOutput, 4> ElementwiseTestHelper( |
| 2169 | armnn::IWorkloadFactory & workloadFactory, |
| 2170 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager, |
| 2171 | const unsigned int shape0[4], std::vector<TInput> values0, |
| 2172 | const unsigned int shape1[4], std::vector<TInput> values1, |
| 2173 | const unsigned int outShape[4], std::vector<TOutput> outValues, |
| 2174 | float qScale = 0.0f, int qOffset = 0) |
| 2175 | { |
| 2176 | const size_t dimensionCount = 4; |
| 2177 | armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, ArmnnTypeInput}; |
| 2178 | armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, ArmnnTypeInput}; |
| 2179 | armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, ArmnnTypeOutput}; |
| 2180 | |
| 2181 | auto input0 = MakeTensor<TInput, 4>(inputTensorInfo0, values0); |
| 2182 | auto input1 = MakeTensor<TInput, 4>(inputTensorInfo1, values1); |
| 2183 | |
| 2184 | if (armnn::IsQuantizedType<TInput>()) |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2185 | { |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2186 | inputTensorInfo0.SetQuantizationScale(qScale); |
| 2187 | inputTensorInfo0.SetQuantizationOffset(qOffset); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2188 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2189 | inputTensorInfo1.SetQuantizationScale(qScale); |
| 2190 | inputTensorInfo1.SetQuantizationOffset(qOffset); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2191 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2192 | outputTensorInfo.SetQuantizationScale(qScale); |
| 2193 | outputTensorInfo.SetQuantizationOffset(qOffset); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2194 | } |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2195 | |
| 2196 | LayerTestResult<TOutput,4> ret(outputTensorInfo); |
| 2197 | |
| 2198 | if(ArmnnTypeOutput == armnn::DataType::Boolean) |
| 2199 | { |
| 2200 | ret.compareBoolean = true; |
| 2201 | } |
| 2202 | |
| 2203 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 2204 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 2205 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 2206 | |
| 2207 | Descriptor data; |
| 2208 | armnn::WorkloadInfo info; |
| 2209 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 2210 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2211 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2212 | auto workload = CreateWorkload<Descriptor>(workloadFactory, info, data); |
| 2213 | |
| 2214 | inputHandle0->Allocate(); |
| 2215 | inputHandle1->Allocate(); |
| 2216 | outputHandle->Allocate(); |
| 2217 | |
| 2218 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 2219 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 2220 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 2221 | workload->PostAllocationConfigure(); |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2222 | ExecuteWorkload(*workload, memoryManager); |
| 2223 | |
| 2224 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 2225 | |
| 2226 | ret.outputExpected = MakeTensor<TOutput, 4>(outputTensorInfo, outValues); |
| 2227 | return ret; |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2228 | } |
| 2229 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2230 | template <typename Descriptor, armnn::DataType ArmnnT, typename T = armnn::ResolveType<ArmnnT>> |
| 2231 | LayerTestResult<T, 4> ElementwiseTestHelper( |
| 2232 | armnn::IWorkloadFactory & workloadFactory, |
| 2233 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager, |
| 2234 | const unsigned int shape0[4], std::vector<T> values0, |
| 2235 | const unsigned int shape1[4], std::vector<T> values1, |
| 2236 | const unsigned int outShape[4], std::vector<T> outValues, |
| 2237 | float qScale = 0.0f, int qOffset = 0) |
| 2238 | { |
| 2239 | return ElementwiseTestHelper<Descriptor, ArmnnT, ArmnnT> |
| 2240 | (workloadFactory, |
| 2241 | memoryManager, |
| 2242 | shape0, |
| 2243 | values0, |
| 2244 | shape1, |
| 2245 | values1, |
| 2246 | outShape, |
| 2247 | outValues, |
| 2248 | qScale, |
| 2249 | qOffset); |
| 2250 | } |
| 2251 | } |
| 2252 | |
| 2253 | LayerTestResult<uint8_t, 4> EqualSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
| 2254 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2255 | { |
| 2256 | const unsigned int width = 2; |
| 2257 | const unsigned int height = 2; |
| 2258 | const unsigned int channelCount = 2; |
| 2259 | const unsigned int batchSize = 2; |
| 2260 | |
| 2261 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2262 | |
| 2263 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 2264 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2265 | |
| 2266 | std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3, |
| 2267 | 5, 5, 5, 5, 4, 4, 4, 4 }); |
| 2268 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2269 | std::vector<uint8_t> output({ 1, 1, 1, 1, 0, 0, 0, 0, |
| 2270 | 0, 0, 0, 0, 1, 1, 1, 1 }); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2271 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2272 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2273 | workloadFactory, |
| 2274 | memoryManager, |
| 2275 | shape, |
| 2276 | input0, |
| 2277 | shape, |
| 2278 | input1, |
| 2279 | shape, |
| 2280 | output); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2281 | } |
| 2282 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2283 | LayerTestResult<uint8_t, 4> EqualBroadcast1ElementTest( |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2284 | armnn::IWorkloadFactory& workloadFactory, |
| 2285 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2286 | { |
| 2287 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2288 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2289 | |
| 2290 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2291 | std::vector<float> input1({ 1 }); |
| 2292 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2293 | std::vector<uint8_t> output({ 1, 0, 0, 0, 0, 0, 0, 0}); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2294 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2295 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2296 | workloadFactory, |
| 2297 | memoryManager, |
| 2298 | shape0, |
| 2299 | input0, |
| 2300 | shape1, |
| 2301 | input1, |
| 2302 | shape0, |
| 2303 | output); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2304 | } |
| 2305 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2306 | LayerTestResult<uint8_t, 4> EqualBroadcast1DVectorTest( |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2307 | armnn::IWorkloadFactory& workloadFactory, |
| 2308 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2309 | { |
| 2310 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2311 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2312 | |
| 2313 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, |
| 2314 | 7, 8, 9, 10, 11, 12 }); |
| 2315 | |
| 2316 | std::vector<float> input1({ 1, 2, 3}); |
| 2317 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2318 | std::vector<uint8_t> output({ 1, 1, 1, 0, 0, 0, |
| 2319 | 0, 0, 0, 0, 0, 0 }); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2320 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2321 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2322 | workloadFactory, |
| 2323 | memoryManager, |
| 2324 | shape0, |
| 2325 | input0, |
| 2326 | shape1, |
| 2327 | input1, |
| 2328 | shape0, |
| 2329 | output); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2330 | } |
| 2331 | |
| 2332 | LayerTestResult<uint8_t, 4> EqualUint8Test( |
| 2333 | armnn::IWorkloadFactory& workloadFactory, |
| 2334 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2335 | { |
| 2336 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2337 | |
| 2338 | // See dequantized values to the right. |
| 2339 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2340 | 3, 3, 3, 3, 7, 7, 7, 7 }); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2341 | |
| 2342 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2343 | 3, 3, 3, 3, 5, 5, 5, 5 }); |
| 2344 | |
| 2345 | std::vector<uint8_t> output({ 0, 0, 0, 0, 1, 1, 1, 1, |
| 2346 | 1, 1, 1, 1, 0, 0, 0, 0 }); |
| 2347 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2348 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, |
| 2349 | armnn::DataType::QuantisedAsymm8, |
| 2350 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2351 | workloadFactory, |
| 2352 | memoryManager, |
| 2353 | shape, |
| 2354 | input0, |
| 2355 | shape, |
| 2356 | input1, |
| 2357 | shape, |
| 2358 | output, |
| 2359 | 1.0f, |
| 2360 | 0); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2361 | } |
| 2362 | |
| 2363 | LayerTestResult<uint8_t, 4> EqualBroadcast1ElementUint8Test( |
| 2364 | armnn::IWorkloadFactory& workloadFactory, |
| 2365 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2366 | { |
| 2367 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2368 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2369 | |
| 2370 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2371 | 7, 8, 9, 10, 11, 12 }); |
| 2372 | |
| 2373 | std::vector<uint8_t> input1({ 1 }); |
| 2374 | |
| 2375 | std::vector<uint8_t> output({ 1, 0, 0, 0, 0, 0, |
| 2376 | 0, 0, 0, 0, 0, 0 }); |
| 2377 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2378 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, |
| 2379 | armnn::DataType::QuantisedAsymm8, |
| 2380 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2381 | workloadFactory, |
| 2382 | memoryManager, |
| 2383 | shape0, |
| 2384 | input0, |
| 2385 | shape1, |
| 2386 | input1, |
| 2387 | shape0, |
| 2388 | output, |
| 2389 | 1.0f, |
| 2390 | 0); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | LayerTestResult<uint8_t, 4> EqualBroadcast1DVectorUint8Test( |
| 2394 | armnn::IWorkloadFactory& workloadFactory, |
| 2395 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2396 | { |
| 2397 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2398 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2399 | |
| 2400 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2401 | 7, 8, 9, 10, 11, 12 }); |
| 2402 | |
| 2403 | std::vector<uint8_t> input1({ 1, 1, 3}); |
| 2404 | |
| 2405 | std::vector<uint8_t> output({ 1, 0, 1, 0, 0, 0, |
| 2406 | 0, 0, 0, 0, 0, 0 }); |
| 2407 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2408 | return ElementwiseTestHelper<armnn::EqualQueueDescriptor, |
| 2409 | armnn::DataType::QuantisedAsymm8, |
| 2410 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2411 | workloadFactory, |
| 2412 | memoryManager, |
| 2413 | shape0, |
| 2414 | input0, |
| 2415 | shape1, |
| 2416 | input1, |
| 2417 | shape0, |
| 2418 | output, |
| 2419 | 1.0f, |
| 2420 | 0); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 2421 | } |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2422 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2423 | LayerTestResult<uint8_t, 4> GreaterSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2424 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2425 | { |
| 2426 | const unsigned int width = 2; |
| 2427 | const unsigned int height = 2; |
| 2428 | const unsigned int channelCount = 2; |
| 2429 | const unsigned int batchSize = 2; |
| 2430 | |
| 2431 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2432 | |
| 2433 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 2434 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2435 | |
| 2436 | std::vector<float> input1({ 1, 1, 1, 1, 3, 3, 3, 3, |
| 2437 | 5, 5, 5, 5, 4, 4, 4, 4 }); |
| 2438 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2439 | std::vector<uint8_t> output({ 0, 0, 0, 0, 1, 1, 1, 1, |
| 2440 | 0, 0, 0, 0, 0, 0, 0, 0 }); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2441 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2442 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2443 | workloadFactory, |
| 2444 | memoryManager, |
| 2445 | shape, |
| 2446 | input0, |
| 2447 | shape, |
| 2448 | input1, |
| 2449 | shape, |
| 2450 | output); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2451 | } |
| 2452 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2453 | LayerTestResult<uint8_t, 4> GreaterBroadcast1ElementTest( |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2454 | armnn::IWorkloadFactory& workloadFactory, |
| 2455 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2456 | { |
| 2457 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2458 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2459 | |
| 2460 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2461 | std::vector<float> input1({ 1 }); |
| 2462 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2463 | std::vector<uint8_t> output({ 0, 1, 1, 1, 1, 1, 1, 1}); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2464 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2465 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2466 | workloadFactory, |
| 2467 | memoryManager, |
| 2468 | shape0, |
| 2469 | input0, |
| 2470 | shape1, |
| 2471 | input1, |
| 2472 | shape0, |
| 2473 | output); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2474 | } |
| 2475 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2476 | LayerTestResult<uint8_t, 4> GreaterBroadcast1DVectorTest( |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2477 | armnn::IWorkloadFactory& workloadFactory, |
| 2478 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2479 | { |
| 2480 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2481 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2482 | |
| 2483 | std::vector<float> input0({ 1, 2.9f, 2.1f, 4, 5, 6, |
| 2484 | 7, 8, 9, 10, 11, 12 }); |
| 2485 | |
| 2486 | std::vector<float> input1({ 1, 3, 2}); |
| 2487 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2488 | std::vector<uint8_t> output({ 0, 0, 1, 1, 1, 1, |
| 2489 | 1, 1, 1, 1, 1, 1 }); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2490 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2491 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2492 | workloadFactory, |
| 2493 | memoryManager, |
| 2494 | shape0, |
| 2495 | input0, |
| 2496 | shape1, |
| 2497 | input1, |
| 2498 | shape0, |
| 2499 | output); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2500 | } |
| 2501 | |
| 2502 | LayerTestResult<uint8_t, 4> GreaterUint8Test( |
| 2503 | armnn::IWorkloadFactory& workloadFactory, |
| 2504 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2505 | { |
| 2506 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2507 | |
| 2508 | // See dequantized values to the right. |
| 2509 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2510 | 3, 3, 3, 3, 5, 5, 5, 5 }); |
| 2511 | |
| 2512 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2513 | 2, 2, 2, 2, 5, 5, 5, 5 }); |
| 2514 | |
| 2515 | std::vector<uint8_t> output({ 0, 0, 0, 0, 0, 0, 0, 0, |
| 2516 | 1, 1, 1, 1, 0, 0, 0, 0 }); |
| 2517 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2518 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, |
| 2519 | armnn::DataType::QuantisedAsymm8, |
| 2520 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2521 | workloadFactory, |
| 2522 | memoryManager, |
| 2523 | shape, |
| 2524 | input0, |
| 2525 | shape, |
| 2526 | input1, |
| 2527 | shape, |
| 2528 | output, |
| 2529 | 1.0f, |
| 2530 | 0); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | LayerTestResult<uint8_t, 4> GreaterBroadcast1ElementUint8Test( |
| 2534 | armnn::IWorkloadFactory& workloadFactory, |
| 2535 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2536 | { |
| 2537 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2538 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2539 | |
| 2540 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2541 | 7, 8, 9, 10, 11, 12 }); |
| 2542 | |
| 2543 | std::vector<uint8_t> input1({ 1 }); |
| 2544 | |
| 2545 | std::vector<uint8_t> output({ 0, 1, 1, 1, 1, 1, |
| 2546 | 1, 1, 1, 1, 1, 1 }); |
| 2547 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2548 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, |
| 2549 | armnn::DataType::QuantisedAsymm8, |
| 2550 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2551 | workloadFactory, |
| 2552 | memoryManager, |
| 2553 | shape0, |
| 2554 | input0, |
| 2555 | shape1, |
| 2556 | input1, |
| 2557 | shape0, |
| 2558 | output, |
| 2559 | 1.0f, |
| 2560 | 0); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2561 | } |
| 2562 | |
| 2563 | LayerTestResult<uint8_t, 4> GreaterBroadcast1DVectorUint8Test( |
| 2564 | armnn::IWorkloadFactory& workloadFactory, |
| 2565 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2566 | { |
| 2567 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2568 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2569 | |
| 2570 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2571 | 7, 8, 9, 10, 11, 12 }); |
| 2572 | |
| 2573 | std::vector<uint8_t> input1({ 1, 1, 3}); |
| 2574 | |
| 2575 | std::vector<uint8_t> output({ 0, 1, 0, 1, 1, 1, |
| 2576 | 1, 1, 1, 1, 1, 1 }); |
| 2577 | |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2578 | return ElementwiseTestHelper<armnn::GreaterQueueDescriptor, |
| 2579 | armnn::DataType::QuantisedAsymm8, |
| 2580 | armnn::DataType::Boolean>( |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2581 | workloadFactory, |
| 2582 | memoryManager, |
| 2583 | shape0, |
| 2584 | input0, |
| 2585 | shape1, |
| 2586 | input1, |
| 2587 | shape0, |
| 2588 | output, |
| 2589 | 1.0f, |
| 2590 | 0); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 2591 | } |
| 2592 | |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2593 | LayerTestResult<float, 4> MaximumSimpleTest(armnn::IWorkloadFactory& workloadFactory, |
| 2594 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2595 | { |
| 2596 | const unsigned int width = 2; |
| 2597 | const unsigned int height = 2; |
| 2598 | const unsigned int channelCount = 2; |
| 2599 | const unsigned int batchSize = 2; |
| 2600 | |
| 2601 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 2602 | |
| 2603 | std::vector<float> input0({ 1, 1, 1, 1, 5, 5, 5, 5, |
| 2604 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2605 | |
| 2606 | std::vector<float> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2607 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2608 | |
| 2609 | std::vector<float> output({ 2, 2, 2, 2, 5, 5, 5, 5, |
| 2610 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2611 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2612 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::Float32>( |
| 2613 | workloadFactory, |
| 2614 | memoryManager, |
| 2615 | shape, |
| 2616 | input0, |
| 2617 | shape, |
| 2618 | input1, |
| 2619 | shape, |
| 2620 | output); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2621 | } |
| 2622 | |
| 2623 | LayerTestResult<float, 4> MaximumBroadcast1ElementTest( |
| 2624 | armnn::IWorkloadFactory& workloadFactory, |
| 2625 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2626 | { |
| 2627 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2628 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2629 | |
| 2630 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2631 | std::vector<float> input1({ 2 }); |
| 2632 | |
| 2633 | std::vector<float> output({ 2, 2, 3, 4, 5, 6, 7, 8}); |
| 2634 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2635 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::Float32>( |
| 2636 | workloadFactory, |
| 2637 | memoryManager, |
| 2638 | shape0, |
| 2639 | input0, |
| 2640 | shape1, |
| 2641 | input1, |
| 2642 | shape0, |
| 2643 | output); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2644 | } |
| 2645 | |
| 2646 | LayerTestResult<float, 4> MaximumBroadcast1DVectorTest( |
| 2647 | armnn::IWorkloadFactory& workloadFactory, |
| 2648 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2649 | { |
| 2650 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2651 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2652 | |
| 2653 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, |
| 2654 | 7, 8, 9, 10, 11, 12 }); |
| 2655 | |
| 2656 | std::vector<float> input1({ 1, 2, 3}); |
| 2657 | |
| 2658 | std::vector<float> output({ 1, 2, 3, 4, 5, 6, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 2659 | 7, 8, 9, 10, 11, 12 }); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2660 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2661 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::Float32>( |
| 2662 | workloadFactory, |
| 2663 | memoryManager, |
| 2664 | shape0, |
| 2665 | input0, |
| 2666 | shape1, |
| 2667 | input1, |
| 2668 | shape0, |
| 2669 | output); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2670 | } |
| 2671 | |
| 2672 | LayerTestResult<uint8_t, 4> MaximumUint8Test( |
| 2673 | armnn::IWorkloadFactory& workloadFactory, |
| 2674 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2675 | { |
| 2676 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2677 | |
| 2678 | // See dequantized values to the right. |
| 2679 | std::vector<uint8_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2680 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2681 | |
| 2682 | std::vector<uint8_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2683 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2684 | |
| 2685 | std::vector<uint8_t> output({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2686 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2687 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2688 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 2689 | workloadFactory, |
| 2690 | memoryManager, |
| 2691 | shape, |
| 2692 | input0, |
| 2693 | shape, |
| 2694 | input1, |
| 2695 | shape, |
| 2696 | output, |
| 2697 | 1.0f, |
| 2698 | 0); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2699 | } |
| 2700 | |
| 2701 | LayerTestResult<uint8_t, 4> MaximumBroadcast1ElementUint8Test( |
| 2702 | armnn::IWorkloadFactory& workloadFactory, |
| 2703 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2704 | { |
| 2705 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2706 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2707 | |
| 2708 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2709 | 7, 8, 9, 10, 11, 12 }); |
| 2710 | |
| 2711 | std::vector<uint8_t> input1({2}); |
| 2712 | |
| 2713 | std::vector<uint8_t> output({ 2, 2, 3, 4, 5, 6, |
| 2714 | 7, 8, 9, 10, 11, 12 }); |
| 2715 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2716 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 2717 | workloadFactory, |
| 2718 | memoryManager, |
| 2719 | shape0, |
| 2720 | input0, |
| 2721 | shape1, |
| 2722 | input1, |
| 2723 | shape0, |
| 2724 | output, |
| 2725 | 1.0f, |
| 2726 | 0); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2727 | } |
| 2728 | |
| 2729 | LayerTestResult<uint8_t, 4> MaximumBroadcast1DVectorUint8Test( |
| 2730 | armnn::IWorkloadFactory& workloadFactory, |
| 2731 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2732 | { |
| 2733 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2734 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2735 | |
| 2736 | std::vector<uint8_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2737 | 7, 8, 9, 10, 11, 12 }); |
| 2738 | |
| 2739 | std::vector<uint8_t> input1({ 1, 10, 3}); |
| 2740 | |
| 2741 | std::vector<uint8_t> output({ 1, 10, 3, 4, 10, 6, |
| 2742 | 7, 10, 9, 10, 11, 12 }); |
| 2743 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2744 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 2745 | workloadFactory, |
| 2746 | memoryManager, |
| 2747 | shape0, |
| 2748 | input0, |
| 2749 | shape1, |
| 2750 | input1, |
| 2751 | shape0, |
| 2752 | output, |
| 2753 | 1.0f, |
| 2754 | 0); |
Éanna Ó Catháin | de70558 | 2018-12-03 13:04:22 +0000 | [diff] [blame] | 2755 | } |
| 2756 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2757 | LayerTestResult<int16_t, 4> MaximumInt16Test( |
| 2758 | armnn::IWorkloadFactory& workloadFactory, |
| 2759 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2760 | { |
| 2761 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2762 | |
| 2763 | std::vector<int16_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2764 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2765 | |
| 2766 | std::vector<int16_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2767 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2768 | |
| 2769 | std::vector<int16_t> output({ 2, 2, 2, 2, 6, 6, 6, 6, |
| 2770 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2771 | |
| 2772 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2773 | workloadFactory, |
| 2774 | memoryManager, |
| 2775 | shape, |
| 2776 | input0, |
| 2777 | shape, |
| 2778 | input1, |
| 2779 | shape, |
| 2780 | output, |
| 2781 | 1.0f, |
| 2782 | 0); |
| 2783 | } |
| 2784 | |
| 2785 | LayerTestResult<int16_t, 4> MaximumBroadcast1ElementInt16Test( |
| 2786 | armnn::IWorkloadFactory& workloadFactory, |
| 2787 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2788 | { |
| 2789 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2790 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2791 | |
| 2792 | std::vector<int16_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2793 | 7, 8, 9, 10, 11, 12 }); |
| 2794 | |
| 2795 | std::vector<int16_t> input1({2}); |
| 2796 | |
| 2797 | std::vector<int16_t> output({ 2, 2, 3, 4, 5, 6, |
| 2798 | 7, 8, 9, 10, 11, 12 }); |
| 2799 | |
| 2800 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2801 | workloadFactory, |
| 2802 | memoryManager, |
| 2803 | shape0, |
| 2804 | input0, |
| 2805 | shape1, |
| 2806 | input1, |
| 2807 | shape0, |
| 2808 | output, |
| 2809 | 1.0f, |
| 2810 | 0); |
| 2811 | } |
| 2812 | |
| 2813 | LayerTestResult<int16_t, 4> MaximumBroadcast1DVectorInt16Test( |
| 2814 | armnn::IWorkloadFactory& workloadFactory, |
| 2815 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2816 | { |
| 2817 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2818 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2819 | |
| 2820 | std::vector<int16_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2821 | 7, 8, 9, 10, 11, 12 }); |
| 2822 | |
| 2823 | std::vector<int16_t> input1({ 1, 10, 3}); |
| 2824 | |
| 2825 | std::vector<int16_t> output({ 1, 10, 3, 4, 10, 6, |
| 2826 | 7, 10, 9, 10, 11, 12 }); |
| 2827 | |
| 2828 | return ElementwiseTestHelper<armnn::MaximumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2829 | workloadFactory, |
| 2830 | memoryManager, |
| 2831 | shape0, |
| 2832 | input0, |
| 2833 | shape1, |
| 2834 | input1, |
| 2835 | shape0, |
| 2836 | output, |
| 2837 | 1.0f, |
| 2838 | 0); |
| 2839 | } |
| 2840 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2841 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest1( |
| 2842 | armnn::IWorkloadFactory& workloadFactory, |
| 2843 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2844 | { |
| 2845 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2846 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 2847 | |
| 2848 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2849 | std::vector<float> input1({ 2 }); |
| 2850 | |
| 2851 | std::vector<float> output({ 1, 2, 2, 2, 2, 2, 2, 2}); |
| 2852 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2853 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 2854 | workloadFactory, |
| 2855 | memoryManager, |
| 2856 | shape0, |
| 2857 | input0, |
| 2858 | shape1, |
| 2859 | input1, |
| 2860 | shape0, |
| 2861 | output); |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2862 | } |
| 2863 | |
| 2864 | |
| 2865 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest2( |
| 2866 | armnn::IWorkloadFactory& workloadFactory, |
| 2867 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2868 | { |
| 2869 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 2870 | std::vector<float> input0({ 1, 6, 3, 2, 8, 9, 1, 10}); |
| 2871 | |
| 2872 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2873 | std::vector<float> input1({ 5 }); |
| 2874 | |
| 2875 | std::vector<float> output({ 1, 5, 3, 2, 5, 5, 1, 5}); |
| 2876 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2877 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 2878 | workloadFactory, |
| 2879 | memoryManager, |
| 2880 | shape0, |
| 2881 | input0, |
| 2882 | shape1, |
| 2883 | input1, |
| 2884 | shape0, |
| 2885 | output); |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2886 | } |
| 2887 | |
| 2888 | LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test( |
| 2889 | armnn::IWorkloadFactory & workloadFactory, |
| 2890 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager) |
| 2891 | { |
| 2892 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2893 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2894 | |
| 2895 | std::vector<uint8_t> input0({ 1, 2, 3, 3, 2, 1, |
| 2896 | 7, 1, 2, 3, 4, 5 }); |
| 2897 | |
| 2898 | std::vector<uint8_t> input1({ 1, 2, 3}); |
| 2899 | |
| 2900 | std::vector<uint8_t> output({ 1, 2, 3, 1, 2, 1, |
| 2901 | 1, 1, 2, 1, 2, 3 }); |
| 2902 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 2903 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 2904 | workloadFactory, |
| 2905 | memoryManager, |
| 2906 | shape0, |
| 2907 | input0, |
| 2908 | shape1, |
| 2909 | input1, |
| 2910 | shape0, |
| 2911 | output, |
| 2912 | 1.0f, |
| 2913 | 0); |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 2914 | } |
| 2915 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 2916 | LayerTestResult<int16_t, 4> MinimumInt16Test( |
| 2917 | armnn::IWorkloadFactory& workloadFactory, |
| 2918 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2919 | { |
| 2920 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 2921 | |
| 2922 | std::vector<int16_t> input0({ 1, 1, 1, 1, 6, 6, 6, 6, |
| 2923 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2924 | |
| 2925 | std::vector<int16_t> input1({ 2, 2, 2, 2, 3, 3, 3, 3, |
| 2926 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 2927 | |
| 2928 | std::vector<int16_t> output({ 1, 1, 1, 1, 3, 3, 3, 3, |
| 2929 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 2930 | |
| 2931 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2932 | workloadFactory, |
| 2933 | memoryManager, |
| 2934 | shape, |
| 2935 | input0, |
| 2936 | shape, |
| 2937 | input1, |
| 2938 | shape, |
| 2939 | output, |
| 2940 | 1.0f, |
| 2941 | 0); |
| 2942 | } |
| 2943 | |
| 2944 | LayerTestResult<int16_t, 4> MinimumBroadcast1ElementInt16Test( |
| 2945 | armnn::IWorkloadFactory& workloadFactory, |
| 2946 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2947 | { |
| 2948 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2949 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 2950 | |
| 2951 | std::vector<int16_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2952 | 7, 8, 9, 10, 11, 12 }); |
| 2953 | |
| 2954 | std::vector<int16_t> input1({2}); |
| 2955 | |
| 2956 | std::vector<int16_t> output({ 1, 2, 2, 2, 2, 2, |
| 2957 | 2, 2, 2, 2, 2, 2 }); |
| 2958 | |
| 2959 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2960 | workloadFactory, |
| 2961 | memoryManager, |
| 2962 | shape0, |
| 2963 | input0, |
| 2964 | shape1, |
| 2965 | input1, |
| 2966 | shape0, |
| 2967 | output, |
| 2968 | 1.0f, |
| 2969 | 0); |
| 2970 | } |
| 2971 | |
| 2972 | LayerTestResult<int16_t, 4> MinimumBroadcast1DVectorInt16Test( |
| 2973 | armnn::IWorkloadFactory& workloadFactory, |
| 2974 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 2975 | { |
| 2976 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 2977 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 2978 | |
| 2979 | std::vector<int16_t> input0({ 1, 2, 3, 4, 5, 6, |
| 2980 | 7, 8, 9, 10, 11, 12 }); |
| 2981 | |
| 2982 | std::vector<int16_t> input1({ 1, 10, 3}); |
| 2983 | |
| 2984 | std::vector<int16_t> output({ 1, 2, 3, 1, 5, 3, |
| 2985 | 1, 8, 3, 1, 10, 3 }); |
| 2986 | |
| 2987 | return ElementwiseTestHelper<armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 2988 | workloadFactory, |
| 2989 | memoryManager, |
| 2990 | shape0, |
| 2991 | input0, |
| 2992 | shape1, |
| 2993 | input1, |
| 2994 | shape0, |
| 2995 | output, |
| 2996 | 1.0f, |
| 2997 | 0); |
| 2998 | } |
| 2999 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 3000 | namespace { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3001 | LayerTestResult<float,4> MultiplicationTestHelper( |
| 3002 | armnn::IWorkloadFactory& workloadFactory, |
| 3003 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3004 | const unsigned int shape0[4], |
| 3005 | const std::vector<float> & values0, |
| 3006 | const unsigned int shape1[4], |
| 3007 | const std::vector<float> & values1, |
| 3008 | const unsigned int outShape[4], |
| 3009 | const std::vector<float> & outValues) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3010 | { |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3011 | const size_t dimensionCount = 4; |
| 3012 | armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::DataType::Float32}; |
| 3013 | armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::DataType::Float32}; |
| 3014 | armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::DataType::Float32}; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3015 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3016 | auto input0 = MakeTensor<float, 4>(inputTensorInfo0, values0); |
| 3017 | auto input1 = MakeTensor<float, 4>(inputTensorInfo1, values1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3018 | |
| 3019 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 3020 | |
| 3021 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 3022 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 3023 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3024 | |
| 3025 | armnn::MultiplicationQueueDescriptor data; |
| 3026 | armnn::WorkloadInfo info; |
| 3027 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 3028 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 3029 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 3030 | |
| 3031 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 3032 | |
| 3033 | inputHandle0->Allocate(); |
| 3034 | inputHandle1->Allocate(); |
| 3035 | outputHandle->Allocate(); |
| 3036 | |
| 3037 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 3038 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 3039 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3040 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3041 | workload->Execute(); |
| 3042 | |
| 3043 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 3044 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3045 | ret.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outValues); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3046 | return ret; |
| 3047 | } |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3048 | } // anonymous namespace |
| 3049 | |
| 3050 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3051 | LayerTestResult<float,4> MultiplicationTest( |
| 3052 | armnn::IWorkloadFactory& workloadFactory, |
| 3053 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3054 | { |
| 3055 | const unsigned int width = 2; |
| 3056 | const unsigned int height = 2; |
| 3057 | const unsigned int channelCount = 2; |
| 3058 | const unsigned int batchSize = 2; |
| 3059 | |
| 3060 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 3061 | |
| 3062 | std::vector<float> input0({ |
| 3063 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 3064 | 3, 3, 3, 3, 4, 4, 4, 4 }); |
| 3065 | |
| 3066 | std::vector<float> input1({ |
| 3067 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 3068 | 4, 4, 4, 4, 5, 5, 5, 5 }); |
| 3069 | |
| 3070 | std::vector<float> output({ |
| 3071 | 2, 2, 2, 2, 6, 6, 6, 6, |
| 3072 | 12, 12, 12, 12, 20, 20, 20, 20 }); |
| 3073 | |
| 3074 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3075 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3076 | shape, |
| 3077 | input0, |
| 3078 | shape, |
| 3079 | input1, |
| 3080 | shape, |
| 3081 | output); |
| 3082 | } |
| 3083 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3084 | LayerTestResult<float, 4> MultiplicationBroadcast1ElementTest( |
| 3085 | armnn::IWorkloadFactory& workloadFactory, |
| 3086 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3087 | { |
| 3088 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 3089 | std::vector<float> input0({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 3090 | |
| 3091 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 3092 | std::vector<float> input1({ 2 }); |
| 3093 | |
| 3094 | std::vector<float> output({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 3095 | |
| 3096 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3097 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3098 | shape0, |
| 3099 | input0, |
| 3100 | shape1, |
| 3101 | input1, |
| 3102 | shape0, |
| 3103 | output); |
| 3104 | } |
| 3105 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3106 | LayerTestResult<float, 4> MultiplicationBroadcast1DVectorTest( |
| 3107 | armnn::IWorkloadFactory& workloadFactory, |
| 3108 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3109 | { |
| 3110 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 3111 | std::vector<float> input0({ |
| 3112 | 1, 2, 3, 4, 5, 6, |
| 3113 | 7, 8, 9, 10, 11, 12, |
| 3114 | 13, 14, 15, 16, 17, 18}); |
| 3115 | |
| 3116 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 3117 | std::vector<float> input1({ 1, 2 }); |
| 3118 | |
| 3119 | std::vector<float> output({ |
| 3120 | 1, 4, 3, 8, 5, 12, |
| 3121 | 7, 16, 9, 20, 11, 24, |
| 3122 | 13, 28, 15, 32, 17, 36}); |
| 3123 | |
| 3124 | return MultiplicationTestHelper(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3125 | memoryManager, |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 3126 | shape0, |
| 3127 | input0, |
| 3128 | shape1, |
| 3129 | input1, |
| 3130 | shape0, |
| 3131 | output); |
| 3132 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3133 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3134 | LayerTestResult<float,4> CompareMultiplicationTest( |
| 3135 | armnn::IWorkloadFactory& workloadFactory, |
| 3136 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3137 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3138 | { |
| 3139 | const unsigned int width = 16; |
| 3140 | const unsigned int height = 32; |
| 3141 | const unsigned int channelCount = 2; |
| 3142 | const unsigned int batchSize = 5; |
| 3143 | |
| 3144 | armnn::TensorInfo inputTensorInfo0; |
| 3145 | armnn::TensorInfo inputTensorInfo1; |
| 3146 | armnn::TensorInfo outputTensorInfo; |
| 3147 | |
| 3148 | constexpr unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 3149 | |
| 3150 | inputTensorInfo0 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 3151 | inputTensorInfo1 = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 3152 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 3153 | |
| 3154 | LayerTestResult<float,4> comparisonResult(outputTensorInfo); |
| 3155 | |
| 3156 | auto input0 = MakeRandomTensor<float, 4>(inputTensorInfo0, 803506992); |
| 3157 | auto input1 = MakeRandomTensor<float, 4>(inputTensorInfo1, 54902257); |
| 3158 | |
| 3159 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 3160 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 3161 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3162 | |
| 3163 | std::unique_ptr<armnn::ITensorHandle> inputHandle0Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 3164 | std::unique_ptr<armnn::ITensorHandle> inputHandle1Ref = refWorkloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 3165 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3166 | |
| 3167 | armnn::MultiplicationQueueDescriptor data; |
| 3168 | armnn::WorkloadInfo info; |
| 3169 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 3170 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 3171 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 3172 | |
| 3173 | armnn::MultiplicationQueueDescriptor refData = data; |
| 3174 | armnn::WorkloadInfo refInfo = info; |
| 3175 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo0, inputHandle0Ref.get()); |
| 3176 | SetWorkloadInput(refData, refInfo, 1, inputTensorInfo1, inputHandle1Ref.get()); |
| 3177 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 3178 | |
| 3179 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 3180 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateMultiplication(refData, refInfo); |
| 3181 | |
| 3182 | inputHandle0->Allocate(); |
| 3183 | inputHandle1->Allocate(); |
| 3184 | outputHandle->Allocate(); |
| 3185 | inputHandle0Ref->Allocate(); |
| 3186 | inputHandle1Ref->Allocate(); |
| 3187 | outputHandleRef->Allocate(); |
| 3188 | |
| 3189 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 3190 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 3191 | CopyDataToITensorHandle(inputHandle0Ref.get(), &input0[0][0][0][0]); |
| 3192 | CopyDataToITensorHandle(inputHandle1Ref.get(), &input1[0][0][0][0]); |
| 3193 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3194 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3195 | workload->Execute(); |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3196 | workloadRef->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3197 | workloadRef->Execute(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3198 | CopyDataFromITensorHandle(&comparisonResult.output[0][0][0][0], outputHandle.get()); |
| 3199 | CopyDataFromITensorHandle(&comparisonResult.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 3200 | |
| 3201 | return comparisonResult; |
| 3202 | } |
| 3203 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3204 | LayerTestResult<float,4> CompareBatchNormTest( |
| 3205 | armnn::IWorkloadFactory& workloadFactory, |
| 3206 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3207 | armnn::IWorkloadFactory& refWorkloadFactory) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3208 | { |
| 3209 | const unsigned int width = 2; |
| 3210 | const unsigned int height = 3; |
| 3211 | const unsigned int channels = 5; |
| 3212 | const unsigned int batchSize = 3; |
| 3213 | |
| 3214 | armnn::TensorInfo inputTensorInfo; |
| 3215 | armnn::TensorInfo outputTensorInfo; |
| 3216 | armnn::TensorInfo tensorInfo; |
| 3217 | |
| 3218 | constexpr unsigned int shape[] = {batchSize, channels, height, width}; |
| 3219 | constexpr unsigned int tensorShape[] = {channels}; |
| 3220 | |
| 3221 | inputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 3222 | outputTensorInfo = armnn::TensorInfo(4, shape, armnn::DataType::Float32); |
| 3223 | tensorInfo = armnn::TensorInfo(1, tensorShape, armnn::DataType::Float32); |
| 3224 | |
| 3225 | auto input = MakeRandomTensor<float, 4>(inputTensorInfo, 21312); |
| 3226 | |
| 3227 | auto mean = MakeRandomTensor<float, 1>(tensorInfo, 123); |
| 3228 | auto variance = MakeRandomTensor<float, 1>(tensorInfo, 234, 0.0f); |
| 3229 | auto beta = MakeRandomTensor<float, 1>(tensorInfo, 123); |
| 3230 | auto gamma = MakeRandomTensor<float, 1>(tensorInfo, 345); |
| 3231 | |
| 3232 | LayerTestResult<float,4> ret(outputTensorInfo); |
| 3233 | |
| 3234 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 3235 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3236 | |
| 3237 | std::unique_ptr<armnn::ITensorHandle> inputHandleRef = refWorkloadFactory.CreateTensorHandle(inputTensorInfo); |
| 3238 | std::unique_ptr<armnn::ITensorHandle> outputHandleRef = refWorkloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3239 | |
| 3240 | armnn::BatchNormalizationQueueDescriptor data; |
| 3241 | armnn::WorkloadInfo info; |
| 3242 | armnn::ScopedCpuTensorHandle meanTensor(tensorInfo); |
| 3243 | armnn::ScopedCpuTensorHandle varianceTensor(tensorInfo); |
| 3244 | armnn::ScopedCpuTensorHandle betaTensor(tensorInfo); |
| 3245 | armnn::ScopedCpuTensorHandle gammaTensor(tensorInfo); |
| 3246 | |
| 3247 | AllocateAndCopyDataToITensorHandle(&meanTensor, &mean[0]); |
| 3248 | AllocateAndCopyDataToITensorHandle(&varianceTensor, &variance[0]); |
| 3249 | AllocateAndCopyDataToITensorHandle(&betaTensor, &beta[0]); |
| 3250 | AllocateAndCopyDataToITensorHandle(&gammaTensor, &gamma[0]); |
| 3251 | |
| 3252 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 3253 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 3254 | data.m_Mean = &meanTensor; |
| 3255 | data.m_Variance = &varianceTensor; |
| 3256 | data.m_Beta = &betaTensor; |
| 3257 | data.m_Gamma = &gammaTensor; |
| 3258 | data.m_Parameters.m_Eps = 0.01f; |
| 3259 | |
| 3260 | armnn::BatchNormalizationQueueDescriptor refData = data; |
| 3261 | armnn::WorkloadInfo refInfo = info; |
| 3262 | SetWorkloadInput(refData, refInfo, 0, inputTensorInfo, inputHandleRef.get()); |
| 3263 | SetWorkloadOutput(refData, refInfo, 0, outputTensorInfo, outputHandleRef.get()); |
| 3264 | |
| 3265 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchNormalization(data, info); |
| 3266 | std::unique_ptr<armnn::IWorkload> workloadRef = refWorkloadFactory.CreateBatchNormalization(refData, refInfo); |
| 3267 | |
| 3268 | inputHandle->Allocate(); |
| 3269 | outputHandle->Allocate(); |
| 3270 | inputHandleRef->Allocate(); |
| 3271 | outputHandleRef->Allocate(); |
| 3272 | |
| 3273 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 3274 | CopyDataToITensorHandle(inputHandleRef.get(), &input[0][0][0][0]); |
| 3275 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3276 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3277 | workload->Execute(); |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3278 | workloadRef->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3279 | workloadRef->Execute(); |
| 3280 | |
| 3281 | CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); |
| 3282 | CopyDataFromITensorHandle(&ret.outputExpected[0][0][0][0], outputHandleRef.get()); |
| 3283 | |
| 3284 | return ret; |
| 3285 | } |
| 3286 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3287 | template<typename T> |
| 3288 | void PermuteTensorData( |
| 3289 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3290 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3291 | const armnn::PermutationVector& mappings, |
| 3292 | armnn::TensorInfo & inputTensorInfo, |
| 3293 | const T * inputData, |
| 3294 | std::vector<T>& outputData) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3295 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3296 | BOOST_ASSERT_MSG(inputData != nullptr, "inputData must not be null"); |
| 3297 | if (inputData == nullptr) |
| 3298 | { |
| 3299 | // Nullptr is an error in the test. By returning without doing the concatenation |
| 3300 | // I expect the caller to fail the test. It still makes sense to report this as |
| 3301 | // an assert for Debug builds. |
| 3302 | return; |
| 3303 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3304 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3305 | armnn::TensorInfo outputTensorInfo = armnnUtils::Permuted(inputTensorInfo, mappings); |
| 3306 | |
| 3307 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 3308 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3309 | |
| 3310 | armnn::PermuteQueueDescriptor queueDescriptor; |
| 3311 | queueDescriptor.m_Parameters = armnn::PermuteDescriptor{mappings}; |
| 3312 | armnn::WorkloadInfo workloadInfo; |
| 3313 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get()); |
| 3314 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 3315 | |
| 3316 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePermute(queueDescriptor, workloadInfo); |
| 3317 | |
| 3318 | inputHandle->Allocate(); |
| 3319 | outputHandle->Allocate(); |
| 3320 | |
| 3321 | CopyDataToITensorHandle(inputHandle.get(), inputData); |
| 3322 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3323 | workload->PostAllocationConfigure(); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3324 | workload->Execute(); |
| 3325 | |
| 3326 | outputData.resize(outputTensorInfo.GetNumElements()); |
| 3327 | CopyDataFromITensorHandle(&outputData[0], outputHandle.get()); |
| 3328 | inputTensorInfo = outputTensorInfo; |
| 3329 | } |
| 3330 | |
Jim Flynn | 825af45 | 2019-05-20 12:49:28 +0100 | [diff] [blame] | 3331 | armnn::OriginsDescriptor CreateDescriptorForConcatenation( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3332 | const std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 3333 | unsigned int concatDim) |
| 3334 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3335 | std::vector<armnn::TensorShape> shapes; |
| 3336 | shapes.reserve(inputTensorInfos.size()); |
| 3337 | for (const armnn::TensorInfo& it: inputTensorInfos) |
| 3338 | { |
| 3339 | shapes.push_back(it.GetShape()); |
| 3340 | } |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3341 | |
Jim Flynn | 825af45 | 2019-05-20 12:49:28 +0100 | [diff] [blame] | 3342 | return armnn::CreateDescriptorForConcatenation(shapes.begin(), |
| 3343 | shapes.end(), |
| 3344 | concatDim); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3345 | } |
| 3346 | |
| 3347 | // |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3348 | // Concatenation is only supported for N and C dimensions for NCHW and the inner most dimension |
| 3349 | // In case of <4 dimensions we need to make sure that the concat dimensions are at least |
| 3350 | // the 3rd slowest iterating one or the inner most dimension. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3351 | // |
| 3352 | |
| 3353 | bool NeedPermuteForConcat( |
| 3354 | const std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 3355 | unsigned int concatDim) |
| 3356 | { |
| 3357 | // See note above. Additionally we expect the input shapes to have the |
| 3358 | // same number of dimensions. |
| 3359 | unsigned int nDimensions = 0; |
| 3360 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3361 | // Determine the number of dimensions as well as sanity check them |
| 3362 | // agains test implementation issues. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3363 | for (auto && tensorInfo : inputTensorInfos) |
| 3364 | { |
| 3365 | if (!nDimensions) |
| 3366 | { |
| 3367 | nDimensions = tensorInfo.GetShape().GetNumDimensions(); |
| 3368 | } |
| 3369 | else |
| 3370 | { |
| 3371 | BOOST_ASSERT_MSG(nDimensions == tensorInfo.GetShape().GetNumDimensions(), |
| 3372 | "Input shapes must have the same number of dimensions"); |
| 3373 | } |
| 3374 | } |
| 3375 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3376 | return (nDimensions < 3 || (nDimensions == 3 && (nDimensions-concatDim) < 3 && (nDimensions-concatDim) != 1)); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3377 | } |
| 3378 | |
| 3379 | armnn::TensorShape ExpandTensorShapeTo3dForPermute(const armnn::TensorShape & inputShape) |
| 3380 | { |
| 3381 | unsigned int numDims = inputShape.GetNumDimensions(); |
| 3382 | if (numDims >= 3) |
| 3383 | { |
| 3384 | // Nothing to do if the inputShape has at least 3 dimensions. |
| 3385 | return inputShape; |
| 3386 | } |
| 3387 | |
| 3388 | std::vector<unsigned int> newDims(size_t(3), 1u); |
| 3389 | unsigned int expandedBy = 3 - numDims; |
| 3390 | for (unsigned int i=0; i<numDims; ++i) |
| 3391 | { |
| 3392 | newDims[expandedBy+i] = inputShape[i]; |
| 3393 | } |
| 3394 | return armnn::TensorShape(3u, &newDims[0]); |
| 3395 | } |
| 3396 | |
| 3397 | void Generate3dPermuteVectorForConcat( |
| 3398 | unsigned int numDimensions, |
| 3399 | unsigned int & concatDim, |
| 3400 | std::pair<armnn::PermutationVector, armnn::PermutationVector> & permutations) |
| 3401 | { |
| 3402 | BOOST_ASSERT_MSG(numDimensions <= 3, |
| 3403 | "Only dimensions 1,2 and 3 are supported by this helper"); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3404 | unsigned int expandedBy = 3 - numDimensions; |
| 3405 | unsigned int expandedConcatAxis = concatDim + expandedBy; |
| 3406 | |
| 3407 | if (expandedConcatAxis == 2) |
| 3408 | { |
| 3409 | concatDim = 0; |
| 3410 | armnn::PermutationVector forwardPermutation({1, 2, 0}); |
| 3411 | armnn::PermutationVector reversePermutation({2, 0, 1}); |
| 3412 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 3413 | } |
| 3414 | else if (expandedConcatAxis == 1) |
| 3415 | { |
| 3416 | concatDim = 0; |
| 3417 | armnn::PermutationVector forwardPermutation({2, 0, 1}); |
| 3418 | armnn::PermutationVector reversePermutation({1, 2, 0}); |
| 3419 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 3420 | } |
| 3421 | else |
| 3422 | { |
| 3423 | BOOST_ASSERT(expandedConcatAxis == 0); |
| 3424 | concatDim = 0; |
| 3425 | } |
| 3426 | } |
| 3427 | |
| 3428 | // |
| 3429 | // Permute the input tensors so we can do a supported concatenation. |
| 3430 | // Also treat lower than 3d tensors as 3d by adding dummy 1 dimensions |
| 3431 | // at the front. Finally this function tells what the output shape |
| 3432 | // of the permuted concatenated tensor is going to be. |
| 3433 | // |
| 3434 | template <typename T> |
| 3435 | void PermuteInputsForConcat( |
| 3436 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3437 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3438 | std::vector<armnn::TensorInfo> & inputTensorInfos, |
| 3439 | std::vector<T *> & inputData, |
| 3440 | std::vector<std::vector<T>> & inputDataStorage, |
| 3441 | armnn::PermutationVector & permuteVector, |
| 3442 | unsigned int & concatDim, |
| 3443 | armnn::TensorInfo & outputTensorInfo) |
| 3444 | { |
| 3445 | BOOST_ASSERT_MSG(inputTensorInfos.size() > 1, |
| 3446 | "Expecting more than one tensor to be concatenated here"); |
| 3447 | |
| 3448 | unsigned int numDims = 0; |
| 3449 | unsigned int nthInput = 0; |
| 3450 | const armnn::PermutationVector identity({0, 1, 2}); |
| 3451 | |
| 3452 | std::pair<armnn::PermutationVector, armnn::PermutationVector> permutations = |
| 3453 | std::make_pair(identity, identity); |
| 3454 | |
| 3455 | inputDataStorage.resize(inputData.size()); |
| 3456 | |
| 3457 | for (auto && tensorInfo : inputTensorInfos) |
| 3458 | { |
| 3459 | if (numDims == 0) |
| 3460 | { |
| 3461 | numDims = tensorInfo.GetShape().GetNumDimensions(); |
| 3462 | Generate3dPermuteVectorForConcat(numDims, concatDim, permutations); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3463 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3464 | // Store the reverese permutation. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3465 | permuteVector = permutations.second; |
| 3466 | BOOST_ASSERT_MSG(!permuteVector.IsEqual(identity), |
| 3467 | "Test logic error, we don't need permutation, so we shouldn't arrive here"); |
| 3468 | } |
| 3469 | else |
| 3470 | { |
| 3471 | BOOST_ASSERT_MSG(numDims == tensorInfo.GetShape().GetNumDimensions(), |
| 3472 | "All inputs must have the same number of dimensions"); |
| 3473 | } |
| 3474 | |
| 3475 | armnn::TensorInfo newTensorInfo = tensorInfo; |
| 3476 | newTensorInfo.SetShape(ExpandTensorShapeTo3dForPermute(tensorInfo.GetShape())); |
| 3477 | |
| 3478 | PermuteTensorData<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3479 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3480 | permutations.first, |
| 3481 | newTensorInfo, |
| 3482 | inputData[nthInput], |
| 3483 | inputDataStorage[nthInput]); |
| 3484 | |
| 3485 | inputData[nthInput] = inputDataStorage[nthInput].data(); |
| 3486 | inputTensorInfos[nthInput] = newTensorInfo; |
| 3487 | |
| 3488 | ++nthInput; |
| 3489 | } |
| 3490 | |
| 3491 | outputTensorInfo.SetShape( |
| 3492 | armnnUtils::Permuted( |
| 3493 | ExpandTensorShapeTo3dForPermute(outputTensorInfo.GetShape()), |
| 3494 | permutations.first)); |
| 3495 | } |
| 3496 | |
| 3497 | |
| 3498 | // |
| 3499 | // This is the pair of PermuteInputsForConcat(...) which permutes back |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3500 | // the output of the concatenation so we can check it against an expected |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3501 | // output. |
| 3502 | // |
| 3503 | template <typename T> |
| 3504 | void PermuteOutputForConcat( |
| 3505 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3506 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3507 | const armnn::TensorInfo & tensorInfo, |
| 3508 | const armnn::PermutationVector & permuteVector, |
| 3509 | std::unique_ptr<armnn::ITensorHandle> && inputDataHandle, |
| 3510 | T * data) |
| 3511 | { |
| 3512 | BOOST_ASSERT_MSG(data != nullptr, "data must not be null"); |
| 3513 | if (data == nullptr) |
| 3514 | { |
| 3515 | // Nullptr is an error in the test. By returning without doing the permutation |
| 3516 | // I expect the caller to fail the test. It still makes sense to report this as |
| 3517 | // an assert for Debug builds. |
| 3518 | return; |
| 3519 | } |
| 3520 | |
| 3521 | armnn::TensorInfo resultTensorInfo = tensorInfo; |
| 3522 | std::vector<T> inputData(tensorInfo.GetNumElements()); |
| 3523 | std::vector<T> outputData; |
| 3524 | |
| 3525 | CopyDataFromITensorHandle(&inputData[0], inputDataHandle.get()); |
| 3526 | |
| 3527 | PermuteTensorData<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3528 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3529 | permuteVector, |
| 3530 | resultTensorInfo, |
| 3531 | &inputData[0], |
| 3532 | outputData); |
| 3533 | |
| 3534 | ::memcpy(data, &outputData[0], sizeof(T)*outputData.size()); |
| 3535 | } |
| 3536 | |
| 3537 | template <typename T> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3538 | void Concatenate( |
| 3539 | armnn::IWorkloadFactory& workloadFactory, |
| 3540 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3541 | std::initializer_list<const armnn::TensorInfo> inputTensorInfosOrig, |
| 3542 | std::initializer_list<T *> inputsOrig, |
| 3543 | const armnn::TensorInfo& outputTensorInfoOrig, |
| 3544 | T * output, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3545 | unsigned int concatDim, |
| 3546 | bool useSubtensor) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3547 | { |
| 3548 | BOOST_ASSERT_MSG(output != nullptr, "output must not be null"); |
| 3549 | if (output == nullptr) |
| 3550 | { |
| 3551 | // Nullptr is an error in the test. By returning without doing the permutation |
| 3552 | // I expect the caller to fail the test. It still makes sense to report this as |
| 3553 | // an assert for Debug builds. |
| 3554 | return; |
| 3555 | } |
| 3556 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3557 | // Saves a copy of the parameters which we might need to change. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3558 | std::vector<armnn::TensorInfo> inputTensorInfos(inputTensorInfosOrig.begin(), inputTensorInfosOrig.end()); |
| 3559 | std::vector<T *> inputs = inputsOrig; |
| 3560 | armnn::TensorInfo outputTensorInfo = outputTensorInfoOrig; |
| 3561 | |
| 3562 | armnn::PermutationVector permuteVector{0, 1, 2}; |
| 3563 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3564 | // Holds and automatically releases memory for the reshaped input data. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3565 | std::vector<std::vector<T>> tmpInputDataStorage; |
| 3566 | |
| 3567 | const size_t inputCount = inputTensorInfos.size(); |
| 3568 | |
| 3569 | bool needPermuteForConcat = NeedPermuteForConcat(inputTensorInfos, concatDim); |
| 3570 | |
| 3571 | if (needPermuteForConcat) |
| 3572 | { |
| 3573 | // |
| 3574 | // We need to permute the inputs, because concatenation along |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 3575 | // the requested axis is not supported. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3576 | // |
| 3577 | PermuteInputsForConcat<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3578 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3579 | inputTensorInfos, |
| 3580 | inputs, |
| 3581 | tmpInputDataStorage, |
| 3582 | permuteVector, |
| 3583 | concatDim, |
| 3584 | outputTensorInfo); |
| 3585 | } |
| 3586 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3587 | armnn::WorkloadInfo workloadInfo; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3588 | |
| 3589 | std::vector<std::unique_ptr<armnn::ITensorHandle>> inputHandles; |
| 3590 | inputHandles.reserve(inputCount); |
| 3591 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3592 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 3593 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 3594 | armnn::ConcatQueueDescriptor queueDescriptor; |
Jim Flynn | 825af45 | 2019-05-20 12:49:28 +0100 | [diff] [blame] | 3595 | armnn::OriginsDescriptor viewsDescriptor = CreateDescriptorForConcatenation(inputTensorInfos, concatDim); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3596 | queueDescriptor.m_Parameters = viewsDescriptor; |
| 3597 | |
| 3598 | if (useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3599 | { |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3600 | queueDescriptor.m_ViewOrigins.reserve(viewsDescriptor.GetNumViews()); |
| 3601 | for (unsigned int i = 0; i < viewsDescriptor.GetNumViews(); ++i) |
| 3602 | { |
| 3603 | queueDescriptor.m_ViewOrigins.emplace_back(std::vector<unsigned int>(viewsDescriptor.GetViewOrigin(i), |
| 3604 | viewsDescriptor.GetViewOrigin(i) + viewsDescriptor.GetNumDimensions())); |
| 3605 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3606 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3607 | outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3608 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3609 | const bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 3610 | for (unsigned int i = 0; i < inputCount; ++i) |
| 3611 | { |
| 3612 | const armnn::TensorInfo& inputTensorInfo = inputTensorInfos[i]; |
| 3613 | std::unique_ptr<armnn::ITensorHandle> inputHandle = |
| 3614 | subTensorsSupported ? |
| 3615 | workloadFactory.CreateSubTensorHandle(*outputHandle, |
| 3616 | inputTensorInfo.GetShape(), |
| 3617 | queueDescriptor.m_ViewOrigins[i].m_Origin.data()) : |
| 3618 | workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 3619 | |
| 3620 | inputHandles.emplace_back(std::move(inputHandle)); |
| 3621 | } |
| 3622 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3623 | } |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3624 | else |
| 3625 | { |
| 3626 | for (unsigned int i = 0; i < inputCount; ++i) |
| 3627 | { |
| 3628 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfos[i]); |
| 3629 | inputHandles.emplace_back(std::move(inputHandle)); |
| 3630 | } |
| 3631 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3632 | |
| 3633 | for (unsigned int i = 0; i < inputCount; ++i) |
| 3634 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3635 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfos[i], inputHandles[i].get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3636 | } |
| 3637 | |
| 3638 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 3639 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 3640 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConcat(queueDescriptor, workloadInfo); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3641 | |
| 3642 | for (auto& inputHandle : inputHandles) |
| 3643 | { |
| 3644 | inputHandle->Allocate(); |
| 3645 | } |
| 3646 | |
| 3647 | outputHandle->Allocate(); |
| 3648 | |
| 3649 | unsigned int nextInputId = 0; |
| 3650 | for (auto& inputHandle : inputHandles) |
| 3651 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3652 | CopyDataToITensorHandle(inputHandle.get(), inputs[nextInputId]); |
| 3653 | ++nextInputId; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3654 | } |
| 3655 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 3656 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3657 | workload->Execute(); |
| 3658 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3659 | if (needPermuteForConcat) |
| 3660 | { |
| 3661 | PermuteOutputForConcat<T>(workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3662 | memoryManager, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 3663 | outputTensorInfo, |
| 3664 | permuteVector, |
| 3665 | std::move(outputHandle), |
| 3666 | output); |
| 3667 | } |
| 3668 | else |
| 3669 | { |
| 3670 | CopyDataFromITensorHandle(output, outputHandle.get()); |
| 3671 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3672 | } |
| 3673 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3674 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3675 | LayerTestResult<T, 1> Concatenation1dTestImpl( |
| 3676 | armnn::IWorkloadFactory& workloadFactory, |
| 3677 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3678 | float qScale, |
| 3679 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3680 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3681 | armnn::TensorInfo inputTensorInfo({ 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3682 | |
| 3683 | auto input0 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 1.0f, 2.0f, 3.0f })); |
| 3684 | auto input1 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 4.0f, 5.0f, 6.0f })); |
| 3685 | auto input2 = MakeTensor<T, 1>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { 7.0f, 8.0f, 9.0f })); |
| 3686 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3687 | armnn::TensorInfo outputTensorInfo({ 9 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3688 | |
| 3689 | LayerTestResult<T, 1> result(outputTensorInfo); |
| 3690 | |
| 3691 | std::vector<T> output; |
| 3692 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3693 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3694 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 3695 | { input0.data(), input1.data(), input2.data() }, |
| 3696 | outputTensorInfo, |
| 3697 | output.data(), |
| 3698 | 0, |
| 3699 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3700 | |
| 3701 | result.output = MakeTensor<T, 1>(outputTensorInfo, output); |
| 3702 | result.outputExpected = MakeTensor<T, 1>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3703 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f |
| 3704 | })); |
| 3705 | |
| 3706 | return result; |
| 3707 | } |
| 3708 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3709 | LayerTestResult<float, 1> Concatenation1dTest( |
| 3710 | armnn::IWorkloadFactory& workloadFactory, |
| 3711 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3712 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3713 | return Concatenation1dTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3714 | } |
| 3715 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3716 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3717 | LayerTestResult<T, 2> Concatenation2dTestImpl( |
| 3718 | armnn::IWorkloadFactory& workloadFactory, |
| 3719 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3720 | const armnn::TensorInfo& outputTensorInfo, |
| 3721 | unsigned int dimension, |
| 3722 | const float qScale, |
| 3723 | const int32_t qOffset) |
| 3724 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3725 | armnn::TensorInfo inputTensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3726 | |
| 3727 | auto input0 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3728 | // Batch 0 |
| 3729 | 1.0f, 2.0f, 3.0f, |
| 3730 | |
| 3731 | // Batch 1 |
| 3732 | 10.0f, 11.0f, 12.0f, |
| 3733 | })); |
| 3734 | |
| 3735 | auto input1 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3736 | // Batch 0 |
| 3737 | 4.0f, 5.0f, 6.0f, |
| 3738 | |
| 3739 | // Batch 1 |
| 3740 | 13.0f, 14.0f, 15.0f, |
| 3741 | })); |
| 3742 | |
| 3743 | auto input2 = MakeTensor<T, 2>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3744 | // Batch 0 |
| 3745 | 7.0f, 8.0f, 9.0f, |
| 3746 | |
| 3747 | // Batch 1 |
| 3748 | 16.0f, 17.0f, 18.0f, |
| 3749 | })); |
| 3750 | |
| 3751 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3752 | |
| 3753 | std::vector<T> output; |
| 3754 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3755 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3756 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 3757 | { input0.data(), input1.data(), input2.data() }, |
| 3758 | outputTensorInfo, |
| 3759 | output.data(), |
| 3760 | dimension, |
| 3761 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3762 | |
| 3763 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3764 | return result; |
| 3765 | } |
| 3766 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3767 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3768 | LayerTestResult<T, 2> Concatenation2dDim0TestImpl( |
| 3769 | armnn::IWorkloadFactory& workloadFactory, |
| 3770 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3771 | float qScale, |
| 3772 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3773 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3774 | armnn::TensorInfo outputTensorInfo({ 6, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3775 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3776 | LayerTestResult<T, 2> result = Concatenation2dTestImpl<ArmnnType>( |
| 3777 | workloadFactory, memoryManager, outputTensorInfo, 0, qScale, qOffset); |
| 3778 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3779 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3780 | // Batch 0 |
| 3781 | 1.0f, 2.0f, 3.0f, |
| 3782 | |
| 3783 | // Batch 1 |
| 3784 | 10.0f, 11.0f, 12.0f, |
| 3785 | |
| 3786 | // Batch 2 |
| 3787 | 4.0f, 5.0f, 6.0f, |
| 3788 | |
| 3789 | // Batch 3 |
| 3790 | 13.0f, 14.0f, 15.0f, |
| 3791 | |
| 3792 | // Batch 4 |
| 3793 | 7.0f, 8.0f, 9.0f, |
| 3794 | |
| 3795 | // Batch 5 |
| 3796 | 16.0f, 17.0f, 18.0f, |
| 3797 | })); |
| 3798 | |
| 3799 | return result; |
| 3800 | } |
| 3801 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3802 | LayerTestResult<float, 2> Concatenation2dDim0Test( |
| 3803 | armnn::IWorkloadFactory& workloadFactory, |
| 3804 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3805 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3806 | return Concatenation2dDim0TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3807 | } |
| 3808 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3809 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3810 | LayerTestResult<T, 2> Concatenation2dDim1TestImpl( |
| 3811 | armnn::IWorkloadFactory& workloadFactory, |
| 3812 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3813 | float qScale, |
| 3814 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3815 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3816 | armnn::TensorInfo outputTensorInfo({ 2, 9 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3817 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3818 | LayerTestResult<T, 2> result = Concatenation2dTestImpl<ArmnnType>( |
| 3819 | workloadFactory, memoryManager, outputTensorInfo, 1, qScale, qOffset); |
| 3820 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3821 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3822 | // Batch 0 |
| 3823 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
| 3824 | |
| 3825 | // Batch 1 |
| 3826 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f |
| 3827 | })); |
| 3828 | |
| 3829 | return result; |
| 3830 | } |
| 3831 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3832 | LayerTestResult<float, 2> Concatenation2dDim1Test( |
| 3833 | armnn::IWorkloadFactory& workloadFactory, |
| 3834 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3835 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3836 | return Concatenation2dDim1TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3837 | } |
| 3838 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3839 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3840 | LayerTestResult<T, 2> Concatenation2dDim0DiffInputDimsTestImpl( |
| 3841 | armnn::IWorkloadFactory& workloadFactory, |
| 3842 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3843 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3844 | int32_t qOffset) |
| 3845 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3846 | armnn::TensorInfo input0TensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3847 | auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3848 | // Batch 0 |
| 3849 | 1.0f, 2.0f, 3.0f, |
| 3850 | |
| 3851 | // Batch 1 |
| 3852 | 10.0f, 11.0f, 12.0f, |
| 3853 | })); |
| 3854 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3855 | armnn::TensorInfo input1TensorInfo({ 3, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3856 | auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3857 | // Batch 0 |
| 3858 | 4.0f, 5.0f, 6.0f, |
| 3859 | |
| 3860 | // Batch 1 |
| 3861 | 13.0f, 14.0f, 15.0f, |
| 3862 | |
| 3863 | // Batch 0 |
| 3864 | 7.0f, 8.0f, 9.0f, |
| 3865 | })); |
| 3866 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3867 | armnn::TensorInfo input2TensorInfo({ 1, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3868 | auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3869 | // Batch 1 |
| 3870 | 16.0f, 17.0f, 18.0f, |
| 3871 | })); |
| 3872 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3873 | armnn::TensorInfo outputTensorInfo({ 6, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3874 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3875 | |
| 3876 | std::vector<T> output; |
| 3877 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3878 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3879 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3880 | { input0.data(), input1.data(), input2.data() }, |
| 3881 | outputTensorInfo, |
| 3882 | output.data(), |
| 3883 | 0, |
| 3884 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3885 | |
| 3886 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3887 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3888 | // Batch 0 |
| 3889 | 1.0f, 2.0f, 3.0f, |
| 3890 | |
| 3891 | // Batch 1 |
| 3892 | 10.0f, 11.0f, 12.0f, |
| 3893 | |
| 3894 | // Batch 2 |
| 3895 | 4.0f, 5.0f, 6.0f, |
| 3896 | |
| 3897 | // Batch 3 |
| 3898 | 13.0f, 14.0f, 15.0f, |
| 3899 | |
| 3900 | // Batch 4 |
| 3901 | 7.0f, 8.0f, 9.0f, |
| 3902 | |
| 3903 | // Batch 5 |
| 3904 | 16.0f, 17.0f, 18.0f, |
| 3905 | })); |
| 3906 | |
| 3907 | return result; |
| 3908 | } |
| 3909 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3910 | LayerTestResult<float, 2> Concatenation2dDim0DiffInputDimsTest( |
| 3911 | armnn::IWorkloadFactory& workloadFactory, |
| 3912 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3913 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3914 | return Concatenation2dDim0DiffInputDimsTestImpl<armnn::DataType::Float32>( |
| 3915 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3916 | } |
| 3917 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3918 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3919 | LayerTestResult<T, 2> Concatenation2dDim1DiffInputDimsTestImpl( |
| 3920 | armnn::IWorkloadFactory& workloadFactory, |
| 3921 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 3922 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3923 | int32_t qOffset) |
| 3924 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3925 | armnn::TensorInfo input0TensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3926 | auto input0 = MakeTensor<T, 2>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3927 | // Batch 0 |
| 3928 | 1.0f, 2.0f, 3.0f, |
| 3929 | |
| 3930 | // Batch 1 |
| 3931 | 10.0f, 11.0f, 12.0f, |
| 3932 | })); |
| 3933 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3934 | armnn::TensorInfo input1TensorInfo({ 2, 5 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3935 | auto input1 = MakeTensor<T, 2>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3936 | // Batch 0 |
| 3937 | 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, |
| 3938 | |
| 3939 | // Batch 1 |
| 3940 | 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, |
| 3941 | })); |
| 3942 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3943 | armnn::TensorInfo input2TensorInfo({ 2, 1 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3944 | auto input2 = MakeTensor<T, 2>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3945 | // Batch 0 |
| 3946 | 9.0f, |
| 3947 | |
| 3948 | // Batch 1 |
| 3949 | 18.0f |
| 3950 | })); |
| 3951 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3952 | armnn::TensorInfo outputTensorInfo({ 2, 9 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3953 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 3954 | |
| 3955 | std::vector<T> output; |
| 3956 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3957 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3958 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 3959 | { input0.data(), input1.data(), input2.data() }, |
| 3960 | outputTensorInfo, |
| 3961 | output.data(), |
| 3962 | 1, |
| 3963 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3964 | |
| 3965 | result.output = MakeTensor<T, 2>(outputTensorInfo, output); |
| 3966 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3967 | // Batch 0 |
| 3968 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
| 3969 | |
| 3970 | // Batch 1 |
| 3971 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, |
| 3972 | })); |
| 3973 | |
| 3974 | return result; |
| 3975 | } |
| 3976 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3977 | LayerTestResult<float, 2> Concatenation2dDim1DiffInputDimsTest( |
| 3978 | armnn::IWorkloadFactory& workloadFactory, |
| 3979 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3980 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3981 | return Concatenation2dDim1DiffInputDimsTestImpl<armnn::DataType::Float32>( |
| 3982 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3983 | } |
| 3984 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 3985 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 3986 | LayerTestResult<T, 3> Concatenation3dTestImpl( |
| 3987 | armnn::IWorkloadFactory& workloadFactory, |
| 3988 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3989 | const armnn::TensorInfo& outputTensorInfo, |
| 3990 | unsigned int dimension, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 3991 | bool useSubtensor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3992 | float qScale, |
| 3993 | int32_t qOffset) |
| 3994 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 3995 | armnn::TensorInfo inputTensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 3996 | |
| 3997 | auto input0 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 3998 | // Batch 0, Channel 0 |
| 3999 | 1.0f, 2.0f, |
| 4000 | |
| 4001 | // Batch 0, Channel 1 |
| 4002 | 3.0f, 4.0f, |
| 4003 | |
| 4004 | // Batch 0, Channel 2 |
| 4005 | 5.0f, 6.0f, |
| 4006 | |
| 4007 | // Batch 1, Channel 0 |
| 4008 | 19.0f, 20.0f, |
| 4009 | |
| 4010 | // Batch 1, Channel 1 |
| 4011 | 21.0f, 22.0f, |
| 4012 | |
| 4013 | // Batch 1, Channel 2 |
| 4014 | 23.0f, 24.0f |
| 4015 | })); |
| 4016 | |
| 4017 | auto input1 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4018 | // Batch 0, Channel 0 |
| 4019 | 7.0f, 8.0f, |
| 4020 | |
| 4021 | // Batch 0, Channel 1 |
| 4022 | 9.0f, 10.0f, |
| 4023 | |
| 4024 | // Batch 0, Channel 2 |
| 4025 | 11.0f, 12.0f, |
| 4026 | |
| 4027 | // Batch 1, Channel 0 |
| 4028 | 25.0f, 26.0f, |
| 4029 | |
| 4030 | // Batch 1, Channel 1 |
| 4031 | 27.0f, 28.0f, |
| 4032 | |
| 4033 | // Batch 1, Channel 2 |
| 4034 | 29.0f, 30.0f |
| 4035 | })); |
| 4036 | |
| 4037 | auto input2 = MakeTensor<T, 3>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4038 | // Batch 0, Channel 0 |
| 4039 | 13.0f, 14.0f, |
| 4040 | |
| 4041 | // Batch 0, Channel 1 |
| 4042 | 15.0f, 16.0f, |
| 4043 | |
| 4044 | // Batch 0, Channel 2 |
| 4045 | 17.0f, 18.0f, |
| 4046 | |
| 4047 | // Batch 1, Channel 0 |
| 4048 | 31.0f, 32.0f, |
| 4049 | |
| 4050 | // Batch 1, Channel 1 |
| 4051 | 33.0f, 34.0f, |
| 4052 | |
| 4053 | // Batch 1, Channel 2 |
| 4054 | 35.0f, 36.0f |
| 4055 | })); |
| 4056 | |
| 4057 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 4058 | |
| 4059 | std::vector<T> output; |
| 4060 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4061 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4062 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 4063 | { input0.data(), input1.data(), input2.data() }, |
| 4064 | outputTensorInfo, |
| 4065 | output.data(), |
| 4066 | dimension, |
| 4067 | useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4068 | |
| 4069 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 4070 | return result; |
| 4071 | } |
| 4072 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4073 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4074 | LayerTestResult<T, 3> Concatenation3dDim0TestImpl( |
| 4075 | armnn::IWorkloadFactory& workloadFactory, |
| 4076 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4077 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4078 | int32_t qOffset) |
| 4079 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4080 | armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4081 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4082 | LayerTestResult<T, 3> result = Concatenation3dTestImpl<ArmnnType>( |
| 4083 | workloadFactory, memoryManager, outputTensorInfo, 0, true, qScale, qOffset); |
| 4084 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4085 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4086 | // Batch 0, Channel 0 |
| 4087 | 1.0f, 2.0f, |
| 4088 | |
| 4089 | // Batch 0, Channel 1 |
| 4090 | 3.0f, 4.0f, |
| 4091 | |
| 4092 | // Batch 0, Channel 2 |
| 4093 | 5.0f, 6.0f, |
| 4094 | |
| 4095 | // Batch 1, Channel 0 |
| 4096 | 19.0f, 20.0f, |
| 4097 | |
| 4098 | // Batch 1, Channel 1 |
| 4099 | 21.0f, 22.0f, |
| 4100 | |
| 4101 | // Batch 1, Channel 2 |
| 4102 | 23.0f, 24.0f, |
| 4103 | |
| 4104 | // Batch 2, Channel 0 |
| 4105 | 7.0f, 8.0f, |
| 4106 | |
| 4107 | // Batch 2, Channel 1 |
| 4108 | 9.0f, 10.0f, |
| 4109 | |
| 4110 | // Batch 2, Channel 2 |
| 4111 | 11.0f, 12.0f, |
| 4112 | |
| 4113 | // Batch 3, Channel 0 |
| 4114 | 25.0f, 26.0f, |
| 4115 | |
| 4116 | // Batch 3, Channel 1 |
| 4117 | 27.0f, 28.0f, |
| 4118 | |
| 4119 | // Batch 3, Channel 2 |
| 4120 | 29.0f, 30.0f, |
| 4121 | |
| 4122 | // Batch 4, Channel 0 |
| 4123 | 13.0f, 14.0f, |
| 4124 | |
| 4125 | // Batch 4, Channel 1 |
| 4126 | 15.0f, 16.0f, |
| 4127 | |
| 4128 | // Batch 4, Channel 2 |
| 4129 | 17.0f, 18.0f, |
| 4130 | |
| 4131 | // Batch 5, Channel 0 |
| 4132 | 31.0f, 32.0f, |
| 4133 | |
| 4134 | // Batch 5, Channel 1 |
| 4135 | 33.0f, 34.0f, |
| 4136 | |
| 4137 | // Batch 5, Channel 2 |
| 4138 | 35.0f, 36.0f |
| 4139 | })); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4140 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4141 | return result; |
| 4142 | } |
| 4143 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4144 | LayerTestResult<float, 3> Concatenation3dDim0Test( |
| 4145 | armnn::IWorkloadFactory& workloadFactory, |
| 4146 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4147 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4148 | return Concatenation3dDim0TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4149 | } |
| 4150 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4151 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4152 | LayerTestResult<T, 3> Concatenation3dDim1TestImpl( |
| 4153 | armnn::IWorkloadFactory& workloadFactory, |
| 4154 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4155 | float qScale, |
| 4156 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4157 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4158 | armnn::TensorInfo outputTensorInfo({ 2, 9, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4159 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4160 | LayerTestResult<T, 3> result = Concatenation3dTestImpl<ArmnnType>( |
| 4161 | workloadFactory, memoryManager, outputTensorInfo, 1, true, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4162 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4163 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4164 | // Batch 0, Channel 0 |
| 4165 | 1.0f, 2.0f, |
| 4166 | |
| 4167 | // Batch 0, Channel 1 |
| 4168 | 3.0f, 4.0f, |
| 4169 | |
| 4170 | // Batch 0, Channel 2 |
| 4171 | 5.0f, 6.0f, |
| 4172 | |
| 4173 | // Batch 0, Channel 3 |
| 4174 | 7.0f, 8.0f, |
| 4175 | |
| 4176 | // Batch 0, Channel 4 |
| 4177 | 9.0f, 10.0f, |
| 4178 | |
| 4179 | // Batch 0, Channel 5 |
| 4180 | 11.0f, 12.0f, |
| 4181 | |
| 4182 | // Batch 0, Channel 6 |
| 4183 | 13.0f, 14.0f, |
| 4184 | |
| 4185 | // Batch 0, Channel 7 |
| 4186 | 15.0f, 16.0f, |
| 4187 | |
| 4188 | // Batch 0, Channel 8 |
| 4189 | 17.0f, 18.0f, |
| 4190 | |
| 4191 | // Batch 1, Channel 0 |
| 4192 | 19.0f, 20.0f, |
| 4193 | |
| 4194 | // Batch 1, Channel 1 |
| 4195 | 21.0f, 22.0f, |
| 4196 | |
| 4197 | // Batch 1, Channel 2 |
| 4198 | 23.0f, 24.0f, |
| 4199 | |
| 4200 | // Batch 1, Channel 3 |
| 4201 | 25.0f, 26.0f, |
| 4202 | |
| 4203 | // Batch 1, Channel 4 |
| 4204 | 27.0f, 28.0f, |
| 4205 | |
| 4206 | // Batch 1, Channel 5 |
| 4207 | 29.0f, 30.0f, |
| 4208 | |
| 4209 | // Batch 1, Channel 6 |
| 4210 | 31.0f, 32.0f, |
| 4211 | |
| 4212 | // Batch 1, Channel 7 |
| 4213 | 33.0f, 34.0f, |
| 4214 | |
| 4215 | // Batch 1, Channel 8 |
| 4216 | 35.0f, 36.0f |
| 4217 | })); |
| 4218 | |
| 4219 | return result; |
| 4220 | } |
| 4221 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4222 | LayerTestResult<float, 3> Concatenation3dDim1Test( |
| 4223 | armnn::IWorkloadFactory& workloadFactory, |
| 4224 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4225 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4226 | return Concatenation3dDim1TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4227 | } |
| 4228 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4229 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4230 | LayerTestResult<T, 3> Concatenation3dDim2TestImpl( |
| 4231 | armnn::IWorkloadFactory& workloadFactory, |
| 4232 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4233 | bool useSubtensor, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4234 | float qScale, |
| 4235 | int32_t qOffset) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4236 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4237 | armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4238 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4239 | LayerTestResult<T, 3> result = Concatenation3dTestImpl<ArmnnType>( |
| 4240 | workloadFactory, memoryManager, outputTensorInfo, 2, useSubtensor, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4241 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4242 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4243 | // Batch 0, Channel 0 |
| 4244 | 1.0f, 2.0f, 7.0f, 8.0f, 13.0f, 14.0f, |
| 4245 | |
| 4246 | // Batch 0, Channel 1 |
| 4247 | 3.0f, 4.0f, 9.0f, 10.0f, 15.0f, 16.0f, |
| 4248 | |
| 4249 | // Batch 0, Channel 2 |
| 4250 | 5.0f, 6.0f, 11.0f, 12.0f, 17.0f, 18.0f, |
| 4251 | |
| 4252 | // Batch 1, Channel 0 |
| 4253 | 19.0f, 20.0f, 25.0f, 26.0f, 31.0f, 32.0f, |
| 4254 | |
| 4255 | // Batch 1, Channel 1 |
| 4256 | 21.0f, 22.0f, 27.0f, 28.0f, 33.0f, 34.0f, |
| 4257 | |
| 4258 | // Batch 1, Channel 2 |
| 4259 | 23.0f, 24.0f, 29.0f, 30.0f, 35.0f, 36.0f, |
| 4260 | })); |
| 4261 | |
| 4262 | return result; |
| 4263 | } |
| 4264 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4265 | LayerTestResult<float, 3> Concatenation3dDim2Test( |
| 4266 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4267 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4268 | bool useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4269 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4270 | return Concatenation3dDim2TestImpl<armnn::DataType::Float32>( |
| 4271 | workloadFactory, memoryManager, useSubtensor, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4272 | } |
| 4273 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4274 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4275 | LayerTestResult<T, 3> Concatenation3dDim0DiffInputDimsTestImpl( |
| 4276 | armnn::IWorkloadFactory& workloadFactory, |
| 4277 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4278 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4279 | int32_t qOffset) |
| 4280 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4281 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4282 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4283 | // Batch 0, Channel 0 |
| 4284 | 1.0f, 2.0f, |
| 4285 | |
| 4286 | // Batch 0, Channel 1 |
| 4287 | 3.0f, 4.0f, |
| 4288 | |
| 4289 | // Batch 0, Channel 2 |
| 4290 | 5.0f, 6.0f, |
| 4291 | |
| 4292 | // Batch 1, Channel 0 |
| 4293 | 19.0f, 20.0f, |
| 4294 | |
| 4295 | // Batch 1, Channel 1 |
| 4296 | 21.0f, 22.0f, |
| 4297 | |
| 4298 | // Batch 1, Channel 2 |
| 4299 | 23.0f, 24.0f |
| 4300 | })); |
| 4301 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4302 | armnn::TensorInfo input1TensorInfo({ 1, 3, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4303 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4304 | // Batch 0, Channel 0 |
| 4305 | 7.0f, 8.0f, |
| 4306 | |
| 4307 | // Batch 0, Channel 1 |
| 4308 | 9.0f, 10.0f, |
| 4309 | |
| 4310 | // Batch 0, Channel 2 |
| 4311 | 11.0f, 12.0f, |
| 4312 | })); |
| 4313 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4314 | armnn::TensorInfo input2TensorInfo({ 3, 3, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4315 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4316 | // Batch 0, Channel 0 |
| 4317 | 25.0f, 26.0f, |
| 4318 | |
| 4319 | // Batch 0, Channel 1 |
| 4320 | 27.0f, 28.0f, |
| 4321 | |
| 4322 | // Batch 0, Channel 2 |
| 4323 | 29.0f, 30.0f, |
| 4324 | |
| 4325 | // Batch 1, Channel 0 |
| 4326 | 13.0f, 14.0f, |
| 4327 | |
| 4328 | // Batch 1, Channel 1 |
| 4329 | 15.0f, 16.0f, |
| 4330 | |
| 4331 | // Batch 1, Channel 2 |
| 4332 | 17.0f, 18.0f, |
| 4333 | |
| 4334 | // Batch 2, Channel 0 |
| 4335 | 31.0f, 32.0f, |
| 4336 | |
| 4337 | // Batch 2, Channel 1 |
| 4338 | 33.0f, 34.0f, |
| 4339 | |
| 4340 | // Batch 2, Channel 2 |
| 4341 | 35.0f, 36.0f |
| 4342 | })); |
| 4343 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4344 | armnn::TensorInfo outputTensorInfo({ 6, 3, 2 }, ArmnnType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4345 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 4346 | |
| 4347 | std::vector<T> output; |
| 4348 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4349 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4350 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 4351 | { input0.data(), input1.data(), input2.data() }, |
| 4352 | outputTensorInfo, |
| 4353 | output.data(), |
| 4354 | 0, |
| 4355 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4356 | |
| 4357 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 4358 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4359 | // Batch 0, Channel 0 |
| 4360 | 1.0f, 2.0f, |
| 4361 | |
| 4362 | // Batch 0, Channel 1 |
| 4363 | 3.0f, 4.0f, |
| 4364 | |
| 4365 | // Batch 0, Channel 2 |
| 4366 | 5.0f, 6.0f, |
| 4367 | |
| 4368 | // Batch 1, Channel 0 |
| 4369 | 19.0f, 20.0f, |
| 4370 | |
| 4371 | // Batch 1, Channel 1 |
| 4372 | 21.0f, 22.0f, |
| 4373 | |
| 4374 | // Batch 1, Channel 2 |
| 4375 | 23.0f, 24.0f, |
| 4376 | |
| 4377 | // Batch 2, Channel 0 |
| 4378 | 7.0f, 8.0f, |
| 4379 | |
| 4380 | // Batch 2, Channel 1 |
| 4381 | 9.0f, 10.0f, |
| 4382 | |
| 4383 | // Batch 2, Channel 2 |
| 4384 | 11.0f, 12.0f, |
| 4385 | |
| 4386 | // Batch 3, Channel 0 |
| 4387 | 25.0f, 26.0f, |
| 4388 | |
| 4389 | // Batch 3, Channel 1 |
| 4390 | 27.0f, 28.0f, |
| 4391 | |
| 4392 | // Batch 3, Channel 2 |
| 4393 | 29.0f, 30.0f, |
| 4394 | |
| 4395 | // Batch 4, Channel 0 |
| 4396 | 13.0f, 14.0f, |
| 4397 | |
| 4398 | // Batch 4, Channel 1 |
| 4399 | 15.0f, 16.0f, |
| 4400 | |
| 4401 | // Batch 4, Channel 2 |
| 4402 | 17.0f, 18.0f, |
| 4403 | |
| 4404 | // Batch 5, Channel 0 |
| 4405 | 31.0f, 32.0f, |
| 4406 | |
| 4407 | // Batch 5, Channel 1 |
| 4408 | 33.0f, 34.0f, |
| 4409 | |
| 4410 | // Batch 5, Channel 2 |
| 4411 | 35.0f, 36.0f |
| 4412 | })); |
| 4413 | |
| 4414 | return result; |
| 4415 | } |
| 4416 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4417 | LayerTestResult<float, 3> Concatenation3dDim0DiffInputDimsTest( |
| 4418 | armnn::IWorkloadFactory& workloadFactory, |
| 4419 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4420 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4421 | return Concatenation3dDim0DiffInputDimsTestImpl<armnn::DataType::Float32>( |
| 4422 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4423 | } |
| 4424 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4425 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4426 | LayerTestResult<T, 3> Concatenation3dDim1DiffInputDimsTestImpl( |
| 4427 | armnn::IWorkloadFactory& workloadFactory, |
| 4428 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4429 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4430 | int32_t qOffset) |
| 4431 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4432 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4433 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4434 | // Batch 0, Channel 0 |
| 4435 | 1.0f, 2.0f, |
| 4436 | |
| 4437 | // Batch 0, Channel 1 |
| 4438 | 3.0f, 4.0f, |
| 4439 | |
| 4440 | // Batch 0, Channel 2 |
| 4441 | 5.0f, 6.0f, |
| 4442 | |
| 4443 | // Batch 1, Channel 0 |
| 4444 | 19.0f, 20.0f, |
| 4445 | |
| 4446 | // Batch 1, Channel 1 |
| 4447 | 21.0f, 22.0f, |
| 4448 | |
| 4449 | // Batch 1, Channel 2 |
| 4450 | 23.0f, 24.0f |
| 4451 | })); |
| 4452 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4453 | armnn::TensorInfo input1TensorInfo({ 2, 4, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4454 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4455 | // Batch 0, Channel 0 |
| 4456 | 7.0f, 8.0f, |
| 4457 | |
| 4458 | // Batch 0, Channel 1 |
| 4459 | 9.0f, 10.0f, |
| 4460 | |
| 4461 | // Batch 0, Channel 2 |
| 4462 | 11.0f, 12.0f, |
| 4463 | |
| 4464 | // Batch 0, Channel 3 |
| 4465 | 25.0f, 26.0f, |
| 4466 | |
| 4467 | // Batch 1, Channel 0 |
| 4468 | 27.0f, 28.0f, |
| 4469 | |
| 4470 | // Batch 1, Channel 1 |
| 4471 | 29.0f, 30.0f, |
| 4472 | |
| 4473 | // Batch 1, Channel 2 |
| 4474 | 13.0f, 14.0f, |
| 4475 | |
| 4476 | // Batch 1, Channel 3 |
| 4477 | 15.0f, 16.0f, |
| 4478 | })); |
| 4479 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4480 | armnn::TensorInfo input2TensorInfo({ 2, 1, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4481 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4482 | // Batch 0, Channel 0 |
| 4483 | 17.0f, 18.0f, |
| 4484 | |
| 4485 | // Batch 1, Channel 0 |
| 4486 | 31.0f, 32.0f, |
| 4487 | })); |
| 4488 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4489 | armnn::TensorInfo outputTensorInfo({ 2, 8, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4490 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 4491 | |
| 4492 | std::vector<T> output; |
| 4493 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4494 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4495 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 4496 | { input0.data(), input1.data(), input2.data() }, |
| 4497 | outputTensorInfo, |
| 4498 | output.data(), |
| 4499 | 1, |
| 4500 | true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4501 | |
| 4502 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 4503 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4504 | // Batch 0, Channel 0 |
| 4505 | 1.0f, 2.0f, |
| 4506 | |
| 4507 | // Batch 0, Channel 1 |
| 4508 | 3.0f, 4.0f, |
| 4509 | |
| 4510 | // Batch 0, Channel 2 |
| 4511 | 5.0f, 6.0f, |
| 4512 | |
| 4513 | // Batch 0, Channel 3 |
| 4514 | 7.0f, 8.0f, |
| 4515 | |
| 4516 | // Batch 0, Channel 4 |
| 4517 | 9.0f, 10.0f, |
| 4518 | |
| 4519 | // Batch 0, Channel 5 |
| 4520 | 11.0f, 12.0f, |
| 4521 | |
| 4522 | // Batch 0, Channel 6 |
| 4523 | 25.0f, 26.0f, |
| 4524 | |
| 4525 | // Batch 0, Channel 7 |
| 4526 | 17.0f, 18.0f, |
| 4527 | |
| 4528 | // Batch 1, Channel 0 |
| 4529 | 19.0f, 20.0f, |
| 4530 | |
| 4531 | // Batch 1, Channel 1 |
| 4532 | 21.0f, 22.0f, |
| 4533 | |
| 4534 | // Batch 1, Channel 2 |
| 4535 | 23.0f, 24.0f, |
| 4536 | |
| 4537 | // Batch 1, Channel 3 |
| 4538 | 27.0f, 28.0f, |
| 4539 | |
| 4540 | // Batch 1, Channel 4 |
| 4541 | 29.0f, 30.0f, |
| 4542 | |
| 4543 | // Batch 1, Channel 5 |
| 4544 | 13.0f, 14.0f, |
| 4545 | |
| 4546 | // Batch 1, Channel 6 |
| 4547 | 15.0f, 16.0f, |
| 4548 | |
| 4549 | // Batch 1, Channel 7 |
| 4550 | 31.0f, 32.0f, |
| 4551 | })); |
| 4552 | |
| 4553 | return result; |
| 4554 | } |
| 4555 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4556 | LayerTestResult<float, 3> Concatenation3dDim1DiffInputDimsTest( |
| 4557 | armnn::IWorkloadFactory& workloadFactory, |
| 4558 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4559 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4560 | return Concatenation3dDim1DiffInputDimsTestImpl<armnn::DataType::Float32>( |
| 4561 | workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4562 | } |
| 4563 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4564 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4565 | LayerTestResult<T, 3> Concatenation3dDim2DiffInputDimsTestImpl( |
| 4566 | armnn::IWorkloadFactory& workloadFactory, |
| 4567 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4568 | bool useSubtensor, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4569 | float qScale, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4570 | int32_t qOffset) |
| 4571 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4572 | armnn::TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4573 | auto input0 = MakeTensor<T, 3>(input0TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4574 | // Batch 0, Channel 0 |
| 4575 | 1.0f, 2.0f, |
| 4576 | |
| 4577 | // Batch 0, Channel 1 |
| 4578 | 3.0f, 4.0f, |
| 4579 | |
| 4580 | // Batch 0, Channel 2 |
| 4581 | 5.0f, 6.0f, |
| 4582 | |
| 4583 | // Batch 1, Channel 0 |
| 4584 | 19.0f, 20.0f, |
| 4585 | |
| 4586 | // Batch 1, Channel 1 |
| 4587 | 21.0f, 22.0f, |
| 4588 | |
| 4589 | // Batch 1, Channel 2 |
| 4590 | 23.0f, 24.0f |
| 4591 | })); |
| 4592 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4593 | armnn::TensorInfo input1TensorInfo({ 2, 3, 1 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4594 | auto input1 = MakeTensor<T, 3>(input1TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4595 | // Batch 0, Channel 0 |
| 4596 | 7.0f, |
| 4597 | |
| 4598 | // Batch 0, Channel 1 |
| 4599 | 9.0f, |
| 4600 | |
| 4601 | // Batch 0, Channel 2 |
| 4602 | 11.0f, |
| 4603 | |
| 4604 | // Batch 1, Channel 0 |
| 4605 | 25.0f, |
| 4606 | |
| 4607 | // Batch 1, Channel 1 |
| 4608 | 27.0f, |
| 4609 | |
| 4610 | // Batch 1, Channel 2 |
| 4611 | 29.0f |
| 4612 | })); |
| 4613 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4614 | armnn::TensorInfo input2TensorInfo({ 2, 3, 3 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4615 | auto input2 = MakeTensor<T, 3>(input2TensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4616 | // Batch 0, Channel 0 |
| 4617 | 13.0f, 14.0f, 50.0f, |
| 4618 | |
| 4619 | // Batch 0, Channel 1 |
| 4620 | 15.0f, 16.0f, 51.0f, |
| 4621 | |
| 4622 | // Batch 0, Channel 2 |
| 4623 | 17.0f, 18.0f, 52.0f, |
| 4624 | |
| 4625 | // Batch 1, Channel 0 |
| 4626 | 31.0f, 32.0f, 53.0f, |
| 4627 | |
| 4628 | // Batch 1, Channel 1 |
| 4629 | 33.0f, 34.0f, 54.0f, |
| 4630 | |
| 4631 | // Batch 1, Channel 2 |
| 4632 | 35.0f, 36.0f, 55.0f, |
| 4633 | })); |
| 4634 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4635 | armnn::TensorInfo outputTensorInfo({ 2, 3, 6 }, ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4636 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 4637 | |
| 4638 | std::vector<T> output; |
| 4639 | output.resize(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4640 | Concatenate<T>(workloadFactory, memoryManager, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4641 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 4642 | { input0.data(), input1.data(), input2.data() }, |
| 4643 | outputTensorInfo, |
| 4644 | output.data(), |
| 4645 | 2, |
| 4646 | useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4647 | |
| 4648 | result.output = MakeTensor<T, 3>(outputTensorInfo, output); |
| 4649 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4650 | // Batch 0, Channel 0 |
| 4651 | 1.0f, 2.0f, 7.0f, 13.0f, 14.0f, 50.0f, |
| 4652 | |
| 4653 | // Batch 0, Channel 1 |
| 4654 | 3.0f, 4.0f, 9.0f, 15.0f, 16.0f, 51.0f, |
| 4655 | |
| 4656 | // Batch 0, Channel 2 |
| 4657 | 5.0f, 6.0f, 11.0f, 17.0f, 18.0f, 52.0f, |
| 4658 | |
| 4659 | // Batch 1, Channel 0 |
| 4660 | 19.0f, 20.0f, 25.0f, 31.0f, 32.0f, 53.0f, |
| 4661 | |
| 4662 | // Batch 1, Channel 1 |
| 4663 | 21.0f, 22.0f, 27.0f, 33.0f, 34.0f, 54.0f, |
| 4664 | |
| 4665 | // Batch 1, Channel 2 |
| 4666 | 23.0f, 24.0f, 29.0f, 35.0f, 36.0f, 55.0f, |
| 4667 | })); |
| 4668 | |
| 4669 | return result; |
| 4670 | } |
| 4671 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4672 | LayerTestResult<float, 3> Concatenation3dDim2DiffInputDimsTest( |
| 4673 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4674 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4675 | bool useSubtensor) |
| 4676 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4677 | return Concatenation3dDim2DiffInputDimsTestImpl<armnn::DataType::Float32>( |
| 4678 | workloadFactory, memoryManager, useSubtensor, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4679 | } |
| 4680 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4681 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4682 | LayerTestResult<T, 4> Concatenation4dTestImpl( |
| 4683 | armnn::IWorkloadFactory& workloadFactory, |
| 4684 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4685 | const armnn::TensorInfo& outputTensorInfo, |
| 4686 | unsigned int dimension, |
| 4687 | bool useSubtensor, |
| 4688 | float qScale, |
| 4689 | int32_t qOffset) |
| 4690 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4691 | armnn::TensorInfo inputTensorInfo({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4692 | |
| 4693 | auto input0 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4694 | 1.0f, 2.0f, |
| 4695 | 3.0f, 4.0f, |
| 4696 | 5.0f, 6.0f, |
| 4697 | 7.0f, 8.0f, |
| 4698 | 9.0f, 10.0f, |
| 4699 | 11.0f, 12.0f |
| 4700 | })); |
| 4701 | |
| 4702 | auto input1 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4703 | 11.0f, 12.0f, |
| 4704 | 13.0f, 14.0f, |
| 4705 | 15.0f, 16.0f, |
| 4706 | 17.0f, 18.0f, |
| 4707 | 19.0f, 20.0f, |
| 4708 | 21.0f, 22.0f |
| 4709 | })); |
| 4710 | |
| 4711 | auto input2 = MakeTensor<T, 4>(inputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4712 | 21.0f, 22.0f, |
| 4713 | 23.0f, 24.0f, |
| 4714 | 25.0f, 26.0f, |
| 4715 | 27.0f, 28.0f, |
| 4716 | 29.0f, 30.0f, |
| 4717 | 31.0f, 32.0f |
| 4718 | })); |
| 4719 | |
| 4720 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4721 | |
| 4722 | std::vector<T> output; |
| 4723 | output.resize(outputTensorInfo.GetNumElements()); |
| 4724 | |
| 4725 | Concatenate<T>(workloadFactory, |
| 4726 | memoryManager, |
| 4727 | {inputTensorInfo, inputTensorInfo, inputTensorInfo}, |
| 4728 | {input0.data(), input1.data(), input2.data()}, |
| 4729 | outputTensorInfo, |
| 4730 | output.data(), |
| 4731 | dimension, |
| 4732 | useSubtensor); |
| 4733 | |
| 4734 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4735 | return result; |
| 4736 | } |
| 4737 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4738 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4739 | LayerTestResult<T, 4> Concatenation4dDim0TestImpl( |
| 4740 | armnn::IWorkloadFactory& workloadFactory, |
| 4741 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4742 | float qScale, |
| 4743 | int32_t qOffset) |
| 4744 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4745 | armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4746 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4747 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<ArmnnType>( |
| 4748 | workloadFactory, memoryManager, outputTensorInfo, 0, true, qScale, qOffset); |
| 4749 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4750 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4751 | 1.0f, 2.0f, |
| 4752 | 3.0f, 4.0f, |
| 4753 | 5.0f, 6.0f, |
| 4754 | 7.0f, 8.0f, |
| 4755 | 9.0f, 10.0f, |
| 4756 | 11.0f, 12.0f, |
| 4757 | |
| 4758 | 11.0f, 12.0f, |
| 4759 | 13.0f, 14.0f, |
| 4760 | 15.0f, 16.0f, |
| 4761 | 17.0f, 18.0f, |
| 4762 | 19.0f, 20.0f, |
| 4763 | 21.0f, 22.0f, |
| 4764 | |
| 4765 | 21.0f, 22.0f, |
| 4766 | 23.0f, 24.0f, |
| 4767 | 25.0f, 26.0f, |
| 4768 | 27.0f, 28.0f, |
| 4769 | 29.0f, 30.0f, |
| 4770 | 31.0f, 32.0f |
| 4771 | })); |
| 4772 | return result; |
| 4773 | } |
| 4774 | |
| 4775 | LayerTestResult<float, 4> Concatenation4dDim0Test( |
| 4776 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 4777 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4778 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4779 | return Concatenation4dDim0TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4780 | } |
| 4781 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4782 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4783 | LayerTestResult<T, 4> Concatenation4dDim1TestImpl( |
| 4784 | armnn::IWorkloadFactory& workloadFactory, |
| 4785 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4786 | float qScale, |
| 4787 | int32_t qOffset) |
| 4788 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4789 | armnn::TensorInfo outputTensorInfo({ 1, 9, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4790 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4791 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<ArmnnType>( |
| 4792 | workloadFactory, memoryManager, outputTensorInfo, 1, true, qScale, qOffset); |
| 4793 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4794 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4795 | 1.0f, 2.0f, |
| 4796 | 3.0f, 4.0f, |
| 4797 | 5.0f, 6.0f, |
| 4798 | 7.0f, 8.0f, |
| 4799 | 9.0f, 10.0f, |
| 4800 | 11.0f, 12.0f, |
| 4801 | |
| 4802 | 11.0f, 12.0f, |
| 4803 | 13.0f, 14.0f, |
| 4804 | 15.0f, 16.0f, |
| 4805 | 17.0f, 18.0f, |
| 4806 | 19.0f, 20.0f, |
| 4807 | 21.0f, 22.0f, |
| 4808 | |
| 4809 | 21.0f, 22.0f, |
| 4810 | 23.0f, 24.0f, |
| 4811 | 25.0f, 26.0f, |
| 4812 | 27.0f, 28.0f, |
| 4813 | 29.0f, 30.0f, |
| 4814 | 31.0f, 32.0f |
| 4815 | })); |
| 4816 | |
| 4817 | return result; |
| 4818 | } |
| 4819 | |
| 4820 | LayerTestResult<float, 4> Concatenation4dDim1Test( |
| 4821 | armnn::IWorkloadFactory& workloadFactory, |
| 4822 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4823 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4824 | return Concatenation4dDim1TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4825 | } |
| 4826 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4827 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4828 | LayerTestResult<T, 4> Concatenation4dDim2TestImpl( |
| 4829 | armnn::IWorkloadFactory& workloadFactory, |
| 4830 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4831 | float qScale, |
| 4832 | int32_t qOffset) |
| 4833 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4834 | armnn::TensorInfo outputTensorInfo({ 1, 3, 6, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4835 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4836 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<ArmnnType>( |
| 4837 | workloadFactory, memoryManager, outputTensorInfo, 2, true, qScale, qOffset); |
| 4838 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4839 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4840 | 1.0f, 2.0f, |
| 4841 | 3.0f, 4.0f, |
| 4842 | 11.0f, 12.0f, |
| 4843 | 13.0f, 14.0f, |
| 4844 | 21.0f, 22.0f, |
| 4845 | 23.0f, 24.0f, |
| 4846 | |
| 4847 | 5.0f, 6.0f, |
| 4848 | 7.0f, 8.0f, |
| 4849 | 15.0f, 16.0f, |
| 4850 | 17.0f, 18.0f, |
| 4851 | 25.0f, 26.0f, |
| 4852 | 27.0f, 28.0f, |
| 4853 | |
| 4854 | 9.0f, 10.0f, |
| 4855 | 11.0f, 12.0f, |
| 4856 | 19.0f, 20.0f, |
| 4857 | 21.0f, 22.0f, |
| 4858 | 29.0f, 30.0f, |
| 4859 | 31.0f, 32.0f |
| 4860 | })); |
| 4861 | |
| 4862 | return result; |
| 4863 | } |
| 4864 | |
| 4865 | LayerTestResult<float, 4> Concatenation4dDim2Test( |
| 4866 | armnn::IWorkloadFactory& workloadFactory, |
| 4867 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 4868 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4869 | return Concatenation4dDim2TestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4870 | } |
| 4871 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4872 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4873 | LayerTestResult<T, 4> Concatenation4dDim3TestImpl( |
| 4874 | armnn::IWorkloadFactory& workloadFactory, |
| 4875 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4876 | float qScale, |
| 4877 | int32_t qOffset, |
| 4878 | bool useSubtensor) |
| 4879 | { |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4880 | armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 6 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4881 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4882 | LayerTestResult<T, 4> result = Concatenation4dTestImpl<ArmnnType>( |
| 4883 | workloadFactory, memoryManager, outputTensorInfo, 3, useSubtensor, qScale, qOffset); |
| 4884 | |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4885 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4886 | 1.0f, 2.0f, |
| 4887 | 11.0f, 12.0f, |
| 4888 | 21.0f, 22.0f, |
| 4889 | 3.0f, 4.0f, |
| 4890 | 13.0f, 14.0f, |
| 4891 | 23.0f, 24.0f, |
| 4892 | |
| 4893 | 5.0f, 6.0f, |
| 4894 | 15.0f, 16.0f, |
| 4895 | 25.0f, 26.0f, |
| 4896 | 7.0f, 8.0f, |
| 4897 | 17.0f, 18.0f, |
| 4898 | 27.0f, 28.0f, |
| 4899 | |
| 4900 | 9.0f, 10.0f, |
| 4901 | 19.0f, 20.0f, |
| 4902 | 29.0f, 30.0f, |
| 4903 | 11.0f, 12.0f, |
| 4904 | 21.0f, 22.0f, |
| 4905 | 31.0f, 32.0f |
| 4906 | })); |
| 4907 | |
| 4908 | return result; |
| 4909 | } |
| 4910 | |
| 4911 | LayerTestResult<float, 4> Concatenation4dDim3Test( |
| 4912 | armnn::IWorkloadFactory& workloadFactory, |
| 4913 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4914 | bool useSubtensor) |
| 4915 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4916 | return Concatenation4dDim3TestImpl<armnn::DataType::Float32>( |
| 4917 | workloadFactory, memoryManager, 0.0f, 0, useSubtensor); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4918 | } |
| 4919 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 4920 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4921 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim0TestImpl( |
| 4922 | armnn::IWorkloadFactory& workloadFactory, |
| 4923 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 4924 | float qScale, |
| 4925 | int32_t qOffset) |
| 4926 | { |
| 4927 | unsigned int dimension = 0; |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4928 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4929 | |
| 4930 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 4931 | 1.0f, 2.0f, |
| 4932 | 3.0f, 4.0f, |
| 4933 | 5.0f, 6.0f, |
| 4934 | 7.0f, 8.0f, |
| 4935 | 9.0f, 10.0f, |
| 4936 | 11.0f, 12.0f |
| 4937 | })); |
| 4938 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4939 | armnn::TensorInfo inputTensorInfo1({ 2, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4940 | |
| 4941 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 4942 | 11.0f, 12.0f, |
| 4943 | 13.0f, 14.0f, |
| 4944 | 15.0f, 16.0f, |
| 4945 | 17.0f, 18.0f, |
| 4946 | 19.0f, 20.0f, |
| 4947 | 21.0f, 22.0f, |
| 4948 | |
| 4949 | 21.0f, 22.0f, |
| 4950 | 23.0f, 24.0f, |
| 4951 | 25.0f, 26.0f, |
| 4952 | 27.0f, 28.0f, |
| 4953 | 29.0f, 30.0f, |
| 4954 | 31.0f, 32.0f |
| 4955 | |
| 4956 | })); |
| 4957 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 4958 | armnn::TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 4959 | |
| 4960 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 4961 | |
| 4962 | std::vector<T> output; |
| 4963 | output.resize(outputTensorInfo.GetNumElements()); |
| 4964 | Concatenate<T>(workloadFactory, |
| 4965 | memoryManager, |
| 4966 | {inputTensorInfo0, inputTensorInfo1}, |
| 4967 | {input0.data(), input1.data()}, |
| 4968 | outputTensorInfo, |
| 4969 | output.data(), |
| 4970 | dimension, |
| 4971 | true); |
| 4972 | |
| 4973 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 4974 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 4975 | 1.0f, 2.0f, |
| 4976 | 3.0f, 4.0f, |
| 4977 | 5.0f, 6.0f, |
| 4978 | 7.0f, 8.0f, |
| 4979 | 9.0f, 10.0f, |
| 4980 | 11.0f, 12.0f, |
| 4981 | |
| 4982 | 11.0f, 12.0f, |
| 4983 | 13.0f, 14.0f, |
| 4984 | 15.0f, 16.0f, |
| 4985 | 17.0f, 18.0f, |
| 4986 | 19.0f, 20.0f, |
| 4987 | 21.0f, 22.0f, |
| 4988 | |
| 4989 | 21.0f, 22.0f, |
| 4990 | 23.0f, 24.0f, |
| 4991 | 25.0f, 26.0f, |
| 4992 | 27.0f, 28.0f, |
| 4993 | 29.0f, 30.0f, |
| 4994 | 31.0f, 32.0f |
| 4995 | })); |
| 4996 | |
| 4997 | return result; |
| 4998 | } |
| 4999 | |
| 5000 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim0Test( |
| 5001 | armnn::IWorkloadFactory& workloadFactory, |
| 5002 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 5003 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5004 | return Concatenation4dDiffShapeDim0TestImpl<armnn::DataType::Float32>( |
| 5005 | workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5006 | } |
| 5007 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5008 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5009 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim1TestImpl( |
| 5010 | armnn::IWorkloadFactory& workloadFactory, |
| 5011 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5012 | float qScale, |
| 5013 | int32_t qOffset) |
| 5014 | { |
| 5015 | unsigned int dimension = 1; |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5016 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5017 | |
| 5018 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 5019 | 1.0f, 2.0f, |
| 5020 | 3.0f, 4.0f, |
| 5021 | 5.0f, 6.0f, |
| 5022 | 7.0f, 8.0f, |
| 5023 | 9.0f, 10.0f, |
| 5024 | 11.0f, 12.0f |
| 5025 | })); |
| 5026 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5027 | armnn::TensorInfo inputTensorInfo1({ 1, 2, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5028 | |
| 5029 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 5030 | 11.0f, 12.0f, |
| 5031 | 13.0f, 14.0f, |
| 5032 | 15.0f, 16.0f, |
| 5033 | 17.0f, 18.0f, |
| 5034 | |
| 5035 | })); |
| 5036 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5037 | armnn::TensorInfo outputTensorInfo({ 1, 5, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5038 | |
| 5039 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 5040 | |
| 5041 | std::vector<T> output; |
| 5042 | output.resize(outputTensorInfo.GetNumElements()); |
| 5043 | Concatenate<T>(workloadFactory, |
| 5044 | memoryManager, |
| 5045 | {inputTensorInfo0, inputTensorInfo1}, |
| 5046 | {input0.data(), input1.data()}, |
| 5047 | outputTensorInfo, |
| 5048 | output.data(), |
| 5049 | dimension, |
| 5050 | true); |
| 5051 | |
| 5052 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 5053 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 5054 | 1.0f, 2.0f, |
| 5055 | 3.0f, 4.0f, |
| 5056 | 5.0f, 6.0f, |
| 5057 | 7.0f, 8.0f, |
| 5058 | 9.0f, 10.0f, |
| 5059 | 11.0f, 12.0f, |
| 5060 | 11.0f, 12.0f, |
| 5061 | 13.0f, 14.0f, |
| 5062 | 15.0f, 16.0f, |
| 5063 | 17.0f, 18.0f |
| 5064 | })); |
| 5065 | |
| 5066 | return result; |
| 5067 | } |
| 5068 | |
| 5069 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim1Test( |
| 5070 | armnn::IWorkloadFactory& workloadFactory, |
| 5071 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 5072 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5073 | return Concatenation4dDiffShapeDim1TestImpl<armnn::DataType::Float32>( |
| 5074 | workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5075 | } |
| 5076 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5077 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5078 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim2TestImpl( |
| 5079 | armnn::IWorkloadFactory& workloadFactory, |
| 5080 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5081 | float qScale, |
| 5082 | int32_t qOffset) |
| 5083 | { |
| 5084 | unsigned int dimension = 2; |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5085 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5086 | |
| 5087 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 5088 | 1.0f, 2.0f, |
| 5089 | 3.0f, 4.0f, |
| 5090 | 5.0f, 6.0f, |
| 5091 | 7.0f, 8.0f, |
| 5092 | 9.0f, 10.0f, |
| 5093 | 11.0f, 12.0f |
| 5094 | })); |
| 5095 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5096 | armnn::TensorInfo inputTensorInfo1({ 1, 3, 3, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5097 | |
| 5098 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 5099 | 11.0f, 12.0f, |
| 5100 | 13.0f, 14.0f, |
| 5101 | 15.0f, 16.0f, |
| 5102 | 17.0f, 18.0f, |
| 5103 | 19.0f, 20.0f, |
| 5104 | 21.0f, 22.0f, |
| 5105 | 23.0f, 24.0f, |
| 5106 | 25.0f, 26.0f, |
| 5107 | 27.0f, 28.0f |
| 5108 | })); |
| 5109 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5110 | armnn::TensorInfo outputTensorInfo({ 1, 3, 5, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5111 | |
| 5112 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 5113 | |
| 5114 | std::vector<T> output; |
| 5115 | output.resize(outputTensorInfo.GetNumElements()); |
| 5116 | Concatenate<T>(workloadFactory, |
| 5117 | memoryManager, |
| 5118 | {inputTensorInfo0, inputTensorInfo1}, |
| 5119 | {input0.data(), input1.data()}, |
| 5120 | outputTensorInfo, |
| 5121 | output.data(), |
| 5122 | dimension, |
| 5123 | true); |
| 5124 | |
| 5125 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 5126 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 5127 | 1.0f, 2.0f, |
| 5128 | 3.0f, 4.0f, |
| 5129 | 11.0f, 12.0f, |
| 5130 | 13.0f, 14.0f, |
| 5131 | 15.0f, 16.0f, |
| 5132 | |
| 5133 | 5.0f, 6.0f, |
| 5134 | 7.0f, 8.0f, |
| 5135 | 17.0f, 18.0f, |
| 5136 | 19.0f, 20.0f, |
| 5137 | 21.0f, 22.0f, |
| 5138 | |
| 5139 | 9.0f, 10.0f, |
| 5140 | 11.0f, 12.0f, |
| 5141 | 23.0f, 24.0f, |
| 5142 | 25.0f, 26.0f, |
| 5143 | 27.0f, 28.0f |
| 5144 | })); |
| 5145 | |
| 5146 | return result; |
| 5147 | } |
| 5148 | |
| 5149 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim2Test( |
| 5150 | armnn::IWorkloadFactory& workloadFactory, |
| 5151 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 5152 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5153 | return Concatenation4dDiffShapeDim2TestImpl<armnn::DataType::Float32>( |
| 5154 | workloadFactory, memoryManager, 0.0f, 0); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5155 | } |
| 5156 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5157 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5158 | LayerTestResult<T, 4> Concatenation4dDiffShapeDim3TestImpl( |
| 5159 | armnn::IWorkloadFactory& workloadFactory, |
| 5160 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5161 | float qScale, |
| 5162 | int32_t qOffset, |
| 5163 | bool useSubtensor) |
| 5164 | { |
| 5165 | unsigned int dimension = 3; |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5166 | armnn::TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5167 | |
| 5168 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, QuantizedVector<T>(qScale, qOffset, { |
| 5169 | 1.0f, 2.0f, |
| 5170 | 3.0f, 4.0f, |
| 5171 | 5.0f, 6.0f, |
| 5172 | 7.0f, 8.0f, |
| 5173 | 9.0f, 10.0f, |
| 5174 | 11.0f, 12.0f |
| 5175 | })); |
| 5176 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5177 | armnn::TensorInfo inputTensorInfo1({ 1, 3, 2, 3 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5178 | |
| 5179 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, QuantizedVector<T>(qScale, qOffset, { |
| 5180 | 11.0f, 12.0f, 13.0f, |
| 5181 | 14.0f, 15.0f, 16.0f, |
| 5182 | |
| 5183 | 17.0f, 18.0f, 19.0f, |
| 5184 | 20.0f, 21.0f, 22.0f, |
| 5185 | |
| 5186 | 23.0f, 24.0f, 25.0f, |
| 5187 | 26.0f, 27.0f, 28.0f |
| 5188 | })); |
| 5189 | |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 5190 | armnn::TensorInfo outputTensorInfo({ 1, 3, 2, 5 }, ArmnnType, qScale, qOffset); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 5191 | |
| 5192 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 5193 | |
| 5194 | std::vector<T> output; |
| 5195 | output.resize(outputTensorInfo.GetNumElements()); |
| 5196 | Concatenate<T>(workloadFactory, |
| 5197 | memoryManager, |
| 5198 | {inputTensorInfo0, inputTensorInfo1}, |
| 5199 | {input0.data(), input1.data()}, |
| 5200 | outputTensorInfo, |
| 5201 | output.data(), |
| 5202 | dimension, |
| 5203 | useSubtensor); |
| 5204 | |
| 5205 | result.output = MakeTensor<T, 4>(outputTensorInfo, output); |
| 5206 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, QuantizedVector<T>(qScale, qOffset, { |
| 5207 | 1.0f, 2.0f, 11.0f, 12.0f, 13.0f, |
| 5208 | 3.0f, 4.0f, 14.0f, 15.0f, 16.0f, |
| 5209 | 5.0f, 6.0f, 17.0f, 18.0f, 19.0f, |
| 5210 | 7.0f, 8.0f, 20.0f, 21.0f, 22.0f, |
| 5211 | 9.0f, 10.0f, 23.0f, 24.0f, 25.0f, |
| 5212 | 11.0f, 12.0f, 26.0f, 27.0f, 28.0f |
| 5213 | })); |
| 5214 | |
| 5215 | return result; |
| 5216 | } |
| 5217 | |
| 5218 | LayerTestResult<float, 4> Concatenation4dDiffShapeDim3Test( |
| 5219 | armnn::IWorkloadFactory& workloadFactory, |
| 5220 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5221 | bool useSubtensor) |
| 5222 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5223 | return Concatenation4dDiffShapeDim3TestImpl<armnn::DataType::Float32>( |
| 5224 | workloadFactory, memoryManager, 0.0f, 0, useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5225 | } |
| 5226 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5227 | LayerTestResult<float, 4> ResizeBilinearNopTest( |
| 5228 | armnn::IWorkloadFactory& workloadFactory, |
| 5229 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5230 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5231 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5232 | const armnn::TensorInfo inputTensorInfo = |
| 5233 | armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, armnn::DataType::Float32); |
| 5234 | |
| 5235 | const armnn::TensorInfo outputTensorInfo = |
| 5236 | armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5237 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5238 | std::vector<float> inputData({ |
| 5239 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 5240 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 5241 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 5242 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 5243 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5244 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 5245 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 5246 | 3.0f, 4.0f, 5.0f, 6.0f, |
| 5247 | 4.0f, 5.0f, 6.0f, 7.0f |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5248 | }); |
| 5249 | |
| 5250 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5251 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5252 | { |
| 5253 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5254 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5255 | inputData = tmp; |
| 5256 | } |
| 5257 | |
| 5258 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5259 | |
| 5260 | LayerTestResult<float, 4> result(outputTensorInfo); |
| 5261 | result.outputExpected = input; |
| 5262 | |
| 5263 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5264 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5265 | |
| 5266 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5267 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
| 5268 | armnn::WorkloadInfo info; |
| 5269 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5270 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5271 | |
| 5272 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 5273 | |
| 5274 | inputHandle->Allocate(); |
| 5275 | outputHandle->Allocate(); |
| 5276 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 5277 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5278 | workload->PostAllocationConfigure(); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5279 | workload->Execute(); |
| 5280 | |
| 5281 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5282 | return result; |
| 5283 | } |
| 5284 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5285 | LayerTestResult<float, 4> SimpleResizeBilinearTest( |
| 5286 | armnn::IWorkloadFactory& workloadFactory, |
| 5287 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5288 | const armnn::DataLayout dataLayout) |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5289 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5290 | const armnn::TensorInfo inputTensorInfo = |
| 5291 | armnnUtils::GetTensorInfo(1, 2, 2, 2, dataLayout, armnn::DataType::Float32); |
| 5292 | |
| 5293 | const armnn::TensorInfo outputTensorInfo = |
| 5294 | armnnUtils::GetTensorInfo(1, 2, 1, 1, dataLayout, armnn::DataType::Float32); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5295 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5296 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5297 | 1.0f, 255.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5298 | 200.0f, 250.0f, |
| 5299 | |
| 5300 | 250.0f, 200.0f, |
| 5301 | 250.0f, 1.0f |
| 5302 | }); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5303 | |
| 5304 | // The 'resize bilinear' operation projects the top-left corner of output texels into the input image, |
| 5305 | // 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] | 5306 | // output texel. Thus, for a input matrix of 2x2, we'll expect the output 1x1 matrix to contain, as |
| 5307 | // its single element, the value that was at position (0,0) of the input matrix (rather than an average, |
| 5308 | // which we would expect if projecting the centre). |
| 5309 | |
| 5310 | std::vector<float> outputData({ |
| 5311 | 1.0f, |
| 5312 | |
| 5313 | 250.0f |
| 5314 | }); |
| 5315 | |
| 5316 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5317 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5318 | { |
| 5319 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5320 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5321 | inputData = tmp; |
| 5322 | |
| 5323 | std::vector<float> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5324 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5325 | outputData = tmp1; |
| 5326 | } |
| 5327 | |
| 5328 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
| 5329 | |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5330 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5331 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5332 | |
| 5333 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5334 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5335 | |
| 5336 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 5337 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5338 | armnn::WorkloadInfo info; |
| 5339 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5340 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5341 | |
| 5342 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 5343 | |
| 5344 | inputHandle->Allocate(); |
| 5345 | outputHandle->Allocate(); |
| 5346 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 5347 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5348 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5349 | workload->Execute(); |
| 5350 | |
| 5351 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5352 | return result; |
| 5353 | } |
| 5354 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5355 | LayerTestResult<float, 4> ResizeBilinearSqMinTest( |
| 5356 | armnn::IWorkloadFactory& workloadFactory, |
| 5357 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5358 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5359 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5360 | const armnn::TensorInfo inputTensorInfo = |
| 5361 | armnnUtils::GetTensorInfo(1, 2, 4, 4, dataLayout, armnn::DataType::Float32); |
| 5362 | |
| 5363 | const armnn::TensorInfo outputTensorInfo = |
| 5364 | armnnUtils::GetTensorInfo(1, 2, 2, 2, dataLayout, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5365 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5366 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5367 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 5368 | 2.0f, 3.0f, 4.0f, 5.0f, |
| 5369 | 3.0f, 4.0f, 5.0f, 6.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5370 | 4.0f, 5.0f, 6.0f, 7.0f, |
| 5371 | |
| 5372 | 7.0f, 6.0f, 5.0f, 4.0f, |
| 5373 | 6.0f, 5.0f, 4.0f, 3.0f, |
| 5374 | 5.0f, 4.0f, 3.0f, 2.0f, |
| 5375 | 4.0f, 3.0f, 2.0f, 1.0f |
| 5376 | }); |
| 5377 | |
| 5378 | std::vector<float> outputData({ |
| 5379 | 1.0f, 3.0f, |
| 5380 | 3.0f, 5.0f, |
| 5381 | |
| 5382 | 7.0f, 5.0f, |
| 5383 | 5.0f, 3.0f |
| 5384 | }); |
| 5385 | |
| 5386 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5387 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5388 | { |
| 5389 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5390 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5391 | inputData = tmp; |
| 5392 | |
| 5393 | std::vector<float> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5394 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5395 | outputData = tmp1; |
| 5396 | } |
| 5397 | |
| 5398 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5399 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5400 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5401 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5402 | |
| 5403 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5404 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5405 | |
| 5406 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5407 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5408 | armnn::WorkloadInfo info; |
| 5409 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5410 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5411 | |
| 5412 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 5413 | |
| 5414 | inputHandle->Allocate(); |
| 5415 | outputHandle->Allocate(); |
| 5416 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 5417 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5418 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5419 | workload->Execute(); |
| 5420 | |
| 5421 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5422 | return result; |
| 5423 | } |
| 5424 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5425 | LayerTestResult<float, 4> ResizeBilinearMinTest( |
| 5426 | armnn::IWorkloadFactory& workloadFactory, |
| 5427 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5428 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5429 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5430 | const armnn::TensorInfo inputTensorInfo = |
| 5431 | armnnUtils::GetTensorInfo(1, 2, 3, 5, dataLayout, armnn::DataType::Float32); |
| 5432 | |
| 5433 | const armnn::TensorInfo outputTensorInfo = |
| 5434 | armnnUtils::GetTensorInfo(1, 2, 2, 3, dataLayout, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5435 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5436 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5437 | 1.0f, 2.0f, 3.0f, 5.0f, 8.0f, |
| 5438 | 13.0f, 21.0f, 34.0f, 55.0f, 89.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5439 | 144.0f, 233.0f, 377.0f, 610.0f, 987.0f, |
| 5440 | |
| 5441 | 987.0f, 610.0f, 377.0f, 233.0f, 144.0f, |
| 5442 | 89.0f, 55.0f, 34.0f, 21.0f, 13.0f, |
| 5443 | 8.0f, 5.0f, 3.0f, 2.0f, 1.0f |
| 5444 | }); |
| 5445 | |
| 5446 | std::vector<float> outputData({ |
| 5447 | 1.0f, 2.6666f, 6.00f, |
| 5448 | 78.5f, 179.3333f, 401.00f, |
| 5449 | |
| 5450 | 987.0f, 454.6670f, 203.33f, |
| 5451 | 48.5f, 22.3333f, 10.00f |
| 5452 | }); |
| 5453 | |
| 5454 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5455 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5456 | { |
| 5457 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5458 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5459 | inputData = tmp; |
| 5460 | |
| 5461 | std::vector<float> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5462 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5463 | outputData = tmp1; |
| 5464 | } |
| 5465 | |
| 5466 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5467 | |
| 5468 | LayerTestResult<float, 4> result(outputTensorInfo); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5469 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5470 | |
| 5471 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5472 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5473 | |
| 5474 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5475 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5476 | armnn::WorkloadInfo info; |
| 5477 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5478 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5479 | |
| 5480 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 5481 | |
| 5482 | inputHandle->Allocate(); |
| 5483 | outputHandle->Allocate(); |
| 5484 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 5485 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5486 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5487 | workload->Execute(); |
| 5488 | |
| 5489 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5490 | return result; |
| 5491 | } |
| 5492 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5493 | LayerTestResult<float, 4> ResizeBilinearMagTest( |
| 5494 | armnn::IWorkloadFactory& workloadFactory, |
| 5495 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5496 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5497 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5498 | const armnn::TensorInfo inputTensorInfo = |
| 5499 | armnnUtils::GetTensorInfo(1, 2, 3, 2, dataLayout, armnn::DataType::Float32); |
| 5500 | |
| 5501 | const armnn::TensorInfo outputTensorInfo = |
| 5502 | armnnUtils::GetTensorInfo(1, 2, 3, 5, dataLayout, armnn::DataType::Float32); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5503 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5504 | std::vector<float> inputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5505 | 1.0f, 2.0f, |
| 5506 | 13.0f, 21.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5507 | 144.0f, 233.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5508 | |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5509 | 233.0f, 144.0f, |
| 5510 | 21.0f, 13.0f, |
| 5511 | 2.0f, 1.0f |
| 5512 | }); |
| 5513 | |
| 5514 | std::vector<float> outputData({ |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5515 | 1.0f, 1.4f, 1.8f, 2.0f, 2.0f, |
| 5516 | 13.0f, 16.2f, 19.4f, 21.0f, 21.0f, |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5517 | 144.0f, 179.6f, 215.2f, 233.0f, 233.0f, |
| 5518 | |
| 5519 | 233.0f, 197.4f, 161.8f, 144.0f, 144.0f, |
| 5520 | 21.0f, 17.8f, 14.6f, 13.0f, 13.0f, |
| 5521 | 2.0f, 1.6f, 1.2f, 1.0f, 1.0f |
| 5522 | }); |
| 5523 | |
| 5524 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5525 | if (dataLayout == armnn::DataLayout::NHWC) |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5526 | { |
| 5527 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5528 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5529 | inputData = tmp; |
| 5530 | |
| 5531 | std::vector<float> tmp1(outputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5532 | armnnUtils::Permute(outputTensorInfo.GetShape(), NCHWToNHWC, outputData.data(), tmp1.data(), sizeof(float)); |
James Conroy | 6b96582 | 2018-11-01 11:33:09 +0000 | [diff] [blame] | 5533 | outputData = tmp1; |
| 5534 | } |
| 5535 | |
| 5536 | auto input = MakeTensor<float, 4>(inputTensorInfo, inputData); |
| 5537 | |
| 5538 | LayerTestResult<float, 4> result(outputTensorInfo); |
| 5539 | result.outputExpected = MakeTensor<float, 4>(outputTensorInfo, outputData); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5540 | |
| 5541 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5542 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5543 | |
| 5544 | armnn::ResizeBilinearQueueDescriptor descriptor; |
James Conroy | 074f371 | 2018-10-03 09:32:03 +0100 | [diff] [blame] | 5545 | descriptor.m_Parameters.m_DataLayout = dataLayout; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5546 | armnn::WorkloadInfo info; |
| 5547 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5548 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5549 | |
| 5550 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 5551 | |
| 5552 | inputHandle->Allocate(); |
| 5553 | outputHandle->Allocate(); |
| 5554 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 5555 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5556 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5557 | workload->Execute(); |
| 5558 | |
| 5559 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5560 | return result; |
| 5561 | } |
| 5562 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5563 | LayerTestResult<float, 2> FakeQuantizationTest( |
| 5564 | armnn::IWorkloadFactory& workloadFactory, |
| 5565 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5566 | { |
| 5567 | constexpr unsigned int width = 2; |
| 5568 | constexpr unsigned int height = 3; |
| 5569 | |
| 5570 | const armnn::TensorInfo tensorInfo({height, width }, |
| 5571 | armnn::DataType::Float32); |
| 5572 | auto input = MakeTensor<float, 2>(tensorInfo, std::vector<float>({ |
| 5573 | -10.0f, -5.0f, |
| 5574 | 0.0f, 5.0f, |
| 5575 | 10.0f, 10.0f |
| 5576 | })); |
| 5577 | |
| 5578 | LayerTestResult<float, 2> ret(tensorInfo); |
| 5579 | |
| 5580 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(tensorInfo); |
| 5581 | |
| 5582 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(tensorInfo); |
| 5583 | |
| 5584 | armnn::FakeQuantizationQueueDescriptor data; |
| 5585 | armnn::WorkloadInfo info; |
| 5586 | |
| 5587 | AddInputToWorkload(data, info, tensorInfo, inputHandle.get()); |
| 5588 | AddOutputToWorkload(data, info, tensorInfo, outputHandle.get()); |
| 5589 | float min = -10.f; |
| 5590 | float max = 10.f; |
| 5591 | |
| 5592 | data.m_Parameters.m_Min = min; |
| 5593 | data.m_Parameters.m_Max = max; |
| 5594 | |
| 5595 | armnn::PassthroughCpuTensorHandle refHandle(tensorInfo, &ret.outputExpected[0][0]); |
| 5596 | armnn::FakeQuantizationQueueDescriptor refData = data; |
| 5597 | armnn::WorkloadInfo refInfo = info; |
| 5598 | SetWorkloadOutput(refData, refInfo, 0, tensorInfo, &refHandle); |
| 5599 | |
| 5600 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateFakeQuantization(data, info); |
| 5601 | |
| 5602 | inputHandle->Allocate(); |
| 5603 | outputHandle->Allocate(); |
| 5604 | |
| 5605 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0]); |
| 5606 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5607 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5608 | workload->Execute(); |
| 5609 | |
| 5610 | CopyDataFromITensorHandle(&ret.output[0][0], outputHandle.get()); |
| 5611 | |
| 5612 | ret.outputExpected = MakeTensor<float, 2>(tensorInfo, std::vector<float>({ |
| 5613 | 0.0f, 63.0f, |
| 5614 | 128.0f, 191.0f, |
| 5615 | 255.0f, 255.0f |
| 5616 | })); |
| 5617 | return ret; |
| 5618 | } |
| 5619 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5620 | namespace |
| 5621 | { |
| 5622 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5623 | LayerTestResult<float, 4> L2NormalizationTestImpl( |
| 5624 | armnn::IWorkloadFactory& workloadFactory, |
| 5625 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5626 | const armnn::TensorShape& inputOutputTensorShape, |
| 5627 | const std::vector<float>& inputValues, |
| 5628 | const std::vector<float>& expectedOutputValues, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5629 | const armnn::DataLayout layout) |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5630 | { |
| 5631 | const armnn::TensorInfo inputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32); |
| 5632 | const armnn::TensorInfo outputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32); |
| 5633 | |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5634 | // at this point if we require it permute the input data |
| 5635 | const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 }; |
| 5636 | std::vector<float> inputData = inputValues; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5637 | if (layout == armnn::DataLayout::NHWC) |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5638 | { |
| 5639 | std::vector<float> tmp(inputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5640 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float)); |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5641 | inputData = tmp; |
| 5642 | } |
| 5643 | |
| 5644 | auto inputTensor = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(inputData)); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5645 | |
| 5646 | LayerTestResult<float, 4> result(outputTensorInfo); |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5647 | std::vector<float> expectedOutputData = expectedOutputValues; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5648 | if (layout == armnn::DataLayout::NHWC) |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5649 | { |
| 5650 | std::vector<float> tmp(expectedOutputData.size()); |
Matteo Martincigh | d5b9e64 | 2019-01-04 18:01:21 +0000 | [diff] [blame] | 5651 | armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, |
| 5652 | expectedOutputData.data(), tmp.data(), sizeof(float)); |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 5653 | expectedOutputData = tmp; |
| 5654 | } |
| 5655 | result.outputExpected = MakeTensor<float, 4>(inputTensorInfo, std::vector<float>(expectedOutputData)); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5656 | |
| 5657 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5658 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5659 | |
| 5660 | armnn::L2NormalizationQueueDescriptor descriptor; |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 5661 | descriptor.m_Parameters.m_DataLayout = layout; |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5662 | armnn::WorkloadInfo info; |
| 5663 | |
| 5664 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5665 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5666 | |
| 5667 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateL2Normalization(descriptor, info); |
| 5668 | |
| 5669 | inputHandle->Allocate(); |
| 5670 | outputHandle->Allocate(); |
| 5671 | |
| 5672 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]); |
| 5673 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5674 | workload->PostAllocationConfigure(); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5675 | ExecuteWorkload(*workload, memoryManager); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 5676 | |
| 5677 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 5678 | |
| 5679 | return result; |
| 5680 | } |
| 5681 | |
| 5682 | float CalcInvL2Norm(std::initializer_list<float> elements) |
| 5683 | { |
| 5684 | const float reduction = std::accumulate(elements.begin(), elements.end(), 0.0f, |
| 5685 | [](float acc, float element) { return acc + element * element; }); |
| 5686 | return 1.0f / sqrtf(reduction); |
| 5687 | } |
| 5688 | |
| 5689 | } // anonymous namespace |
| 5690 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5691 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5692 | LayerTestResult<T, 2> Pad2dTestCommon( |
| 5693 | armnn::IWorkloadFactory& workloadFactory, |
| 5694 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5695 | float qScale, |
| 5696 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5697 | { |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5698 | const armnn::TensorShape inputShape{ 3, 3 }; |
| 5699 | const armnn::TensorShape outputShape{ 7, 7 }; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5700 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5701 | const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); |
| 5702 | const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5703 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5704 | std::vector<T> inputValues( |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5705 | QuantizedVector<T>(qScale, qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5706 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5707 | // Height (3) x Width (3) |
| 5708 | 4, 8, 6, |
| 5709 | 7, 4, 4, |
| 5710 | 3, 2, 4 |
| 5711 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5712 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5713 | std::vector<T> expectedOutputValues( |
| 5714 | QuantizedVector<T>(qScale, qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5715 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5716 | 0, 0, 0, 0, 0, 0, 0, |
| 5717 | 0, 0, 0, 0, 0, 0, 0, |
| 5718 | 0, 0, 4, 8, 6, 0, 0, |
| 5719 | 0, 0, 7, 4, 4, 0, 0, |
| 5720 | 0, 0, 3, 2, 4, 0, 0, |
| 5721 | 0, 0, 0, 0, 0, 0, 0, |
| 5722 | 0, 0, 0, 0, 0, 0, 0 |
| 5723 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5724 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5725 | auto inputTensor = MakeTensor<T, 2>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5726 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5727 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 5728 | result.outputExpected = MakeTensor<T, 2>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5729 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5730 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5731 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5732 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5733 | armnn::PadQueueDescriptor descriptor; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5734 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5735 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 5736 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
| 5737 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5738 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5739 | descriptor.m_Parameters.m_PadList = PadList; |
| 5740 | armnn::WorkloadInfo info; |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5741 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5742 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5743 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5744 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5745 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5746 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5747 | inputHandle->Allocate(); |
| 5748 | outputHandle->Allocate(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5749 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5750 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0]); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5751 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5752 | workload->PostAllocationConfigure(); |
| 5753 | workload->Execute(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5754 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5755 | CopyDataFromITensorHandle(&result.output[0][0], outputHandle.get()); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5756 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5757 | return result; |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5758 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5759 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5760 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5761 | LayerTestResult<T, 3> Pad3dTestCommon( |
| 5762 | armnn::IWorkloadFactory& workloadFactory, |
| 5763 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5764 | float qScale, |
| 5765 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5766 | { |
| 5767 | const armnn::TensorShape inputShape{ 2, 2, 2 }; |
| 5768 | const armnn::TensorShape outputShape{ 3, 5, 6 }; |
| 5769 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5770 | const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); |
| 5771 | const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5772 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5773 | std::vector<T> inputValues( |
| 5774 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5775 | { |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5776 | // Channel 0, Height (2) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5777 | 0, 4, |
| 5778 | 2, 5, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5779 | |
| 5780 | // Channel 1, Height (2) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5781 | 6, 1, |
| 5782 | 5, 2 |
| 5783 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5784 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5785 | std::vector<T> expectedOutputValues( |
| 5786 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5787 | { |
| 5788 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5789 | 0, 0, 0, 0, 0, 0, |
| 5790 | 0, 0, 0, 0, 0, 0, |
| 5791 | 0, 0, 0, 4, 0, 0, |
| 5792 | 0, 0, 2, 5, 0, 0, |
| 5793 | 0, 0, 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5794 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5795 | 0, 0, 0, 0, 0, 0, |
| 5796 | 0, 0, 0, 0, 0, 0, |
| 5797 | 0, 0, 6, 1, 0, 0, |
| 5798 | 0, 0, 5, 2, 0, 0, |
| 5799 | 0, 0, 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5800 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5801 | 0, 0, 0, 0, 0, 0, |
| 5802 | 0, 0, 0, 0, 0, 0, |
| 5803 | 0, 0, 0, 0, 0, 0, |
| 5804 | 0, 0, 0, 0, 0, 0, |
| 5805 | 0, 0, 0, 0, 0, 0 |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5806 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5807 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5808 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5809 | auto inputTensor = MakeTensor<T, 3>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5810 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5811 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 5812 | result.outputExpected = MakeTensor<T, 3>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5813 | |
| 5814 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 5815 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 5816 | |
| 5817 | armnn::PadQueueDescriptor descriptor; |
| 5818 | |
| 5819 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 5820 | PadList.push_back(std::pair<unsigned int, unsigned int>(0,1)); |
| 5821 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,1)); |
| 5822 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,2)); |
| 5823 | |
| 5824 | descriptor.m_Parameters.m_PadList = PadList; |
| 5825 | armnn::WorkloadInfo info; |
| 5826 | |
| 5827 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 5828 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 5829 | |
| 5830 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
| 5831 | |
| 5832 | inputHandle->Allocate(); |
| 5833 | outputHandle->Allocate(); |
| 5834 | |
| 5835 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0]); |
| 5836 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 5837 | workload->PostAllocationConfigure(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5838 | workload->Execute(); |
| 5839 | |
| 5840 | CopyDataFromITensorHandle(&result.output[0][0][0], outputHandle.get()); |
| 5841 | |
| 5842 | return result; |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5843 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5844 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5845 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 5846 | LayerTestResult<T, 4> Pad4dTestCommon( |
| 5847 | armnn::IWorkloadFactory& workloadFactory, |
| 5848 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 5849 | float qScale, |
| 5850 | int32_t qOffset) |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5851 | { |
| 5852 | const armnn::TensorShape inputShape{ 2, 2, 3, 2 }; |
| 5853 | const armnn::TensorShape outputShape{ 4, 5, 7, 4 }; |
| 5854 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 5855 | const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); |
| 5856 | const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5857 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5858 | std::vector<T> inputValues( |
| 5859 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5860 | { |
| 5861 | // Batch 0, Channel 0, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5862 | 0, 1, |
| 5863 | 2, 3, |
| 5864 | 4, 5, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5865 | |
| 5866 | // Batch 0, Channel 1, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5867 | 6, 7, |
| 5868 | 8, 9, |
| 5869 | 10, 11, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5870 | |
| 5871 | // Batch 1, Channel 0, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5872 | 12, 13, |
| 5873 | 14, 15, |
| 5874 | 16, 17, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5875 | |
| 5876 | // Batch 1, Channel 1, Height (3) x Width (2) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5877 | 18, 19, |
| 5878 | 20, 21, |
| 5879 | 22, 23 |
| 5880 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5881 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5882 | std::vector<T> expectedOutputValues( |
| 5883 | QuantizedVector<T>(qScale,qOffset, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5884 | { |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5885 | 0, 0, 0, 0, |
| 5886 | 0, 0, 0, 0, |
| 5887 | 0, 0, 0, 0, |
| 5888 | 0, 0, 0, 0, |
| 5889 | 0, 0, 0, 0, |
| 5890 | 0, 0, 0, 0, |
| 5891 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5892 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5893 | 0, 0, 0, 0, |
| 5894 | 0, 0, 0, 0, |
| 5895 | 0, 0, 0, 0, |
| 5896 | 0, 0, 0, 0, |
| 5897 | 0, 0, 0, 0, |
| 5898 | 0, 0, 0, 0, |
| 5899 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5900 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5901 | 0, 0, 0, 0, |
| 5902 | 0, 0, 0, 0, |
| 5903 | 0, 0, 0, 0, |
| 5904 | 0, 0, 0, 0, |
| 5905 | 0, 0, 0, 0, |
| 5906 | 0, 0, 0, 0, |
| 5907 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5908 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5909 | 0, 0, 0, 0, |
| 5910 | 0, 0, 0, 0, |
| 5911 | 0, 0, 0, 0, |
| 5912 | 0, 0, 0, 0, |
| 5913 | 0, 0, 0, 0, |
| 5914 | 0, 0, 0, 0, |
| 5915 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5916 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5917 | 0, 0, 0, 0, |
| 5918 | 0, 0, 0, 0, |
| 5919 | 0, 0, 0, 0, |
| 5920 | 0, 0, 0, 0, |
| 5921 | 0, 0, 0, 0, |
| 5922 | 0, 0, 0, 0, |
| 5923 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5924 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5925 | 0, 0, 0, 0, |
| 5926 | 0, 0, 0, 0, |
| 5927 | 0, 0, 0, 0, |
| 5928 | 0, 0, 0, 0, |
| 5929 | 0, 0, 0, 0, |
| 5930 | 0, 0, 0, 0, |
| 5931 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5932 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5933 | 0, 0, 0, 0, |
| 5934 | 0, 0, 0, 0, |
| 5935 | 0, 0, 0, 0, |
| 5936 | 0, 0, 0, 0, |
| 5937 | 0, 0, 0, 0, |
| 5938 | 0, 0, 0, 0, |
| 5939 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5940 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5941 | 0, 0, 0, 0, |
| 5942 | 0, 0, 0, 0, |
| 5943 | 0, 0, 0, 0, |
| 5944 | 0, 0, 1, 0, |
| 5945 | 0, 2, 3, 0, |
| 5946 | 0, 4, 5, 0, |
| 5947 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5948 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5949 | 0, 0, 0, 0, |
| 5950 | 0, 0, 0, 0, |
| 5951 | 0, 0, 0, 0, |
| 5952 | 0, 6, 7, 0, |
| 5953 | 0, 8, 9, 0, |
| 5954 | 0, 10, 11, 0, |
| 5955 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5956 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5957 | 0, 0, 0, 0, |
| 5958 | 0, 0, 0, 0, |
| 5959 | 0, 0, 0, 0, |
| 5960 | 0, 0, 0, 0, |
| 5961 | 0, 0, 0, 0, |
| 5962 | 0, 0, 0, 0, |
| 5963 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5964 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5965 | 0, 0, 0, 0, |
| 5966 | 0, 0, 0, 0, |
| 5967 | 0, 0, 0, 0, |
| 5968 | 0, 0, 0, 0, |
| 5969 | 0, 0, 0, 0, |
| 5970 | 0, 0, 0, 0, |
| 5971 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5972 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5973 | 0, 0, 0, 0, |
| 5974 | 0, 0, 0, 0, |
| 5975 | 0, 0, 0, 0, |
| 5976 | 0, 0, 0, 0, |
| 5977 | 0, 0, 0, 0, |
| 5978 | 0, 0, 0, 0, |
| 5979 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5980 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5981 | 0, 0, 0, 0, |
| 5982 | 0, 0, 0, 0, |
| 5983 | 0, 0, 0, 0, |
| 5984 | 0, 12, 13, 0, |
| 5985 | 0, 14, 15, 0, |
| 5986 | 0, 16, 17, 0, |
| 5987 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5988 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5989 | 0, 0, 0, 0, |
| 5990 | 0, 0, 0, 0, |
| 5991 | 0, 0, 0, 0, |
| 5992 | 0, 18, 19, 0, |
| 5993 | 0, 20, 21, 0, |
| 5994 | 0, 22, 23, 0, |
| 5995 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 5996 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 5997 | 0, 0, 0, 0, |
| 5998 | 0, 0, 0, 0, |
| 5999 | 0, 0, 0, 0, |
| 6000 | 0, 0, 0, 0, |
| 6001 | 0, 0, 0, 0, |
| 6002 | 0, 0, 0, 0, |
| 6003 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6004 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6005 | 0, 0, 0, 0, |
| 6006 | 0, 0, 0, 0, |
| 6007 | 0, 0, 0, 0, |
| 6008 | 0, 0, 0, 0, |
| 6009 | 0, 0, 0, 0, |
| 6010 | 0, 0, 0, 0, |
| 6011 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6012 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6013 | 0, 0, 0, 0, |
| 6014 | 0, 0, 0, 0, |
| 6015 | 0, 0, 0, 0, |
| 6016 | 0, 0, 0, 0, |
| 6017 | 0, 0, 0, 0, |
| 6018 | 0, 0, 0, 0, |
| 6019 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6020 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6021 | 0, 0, 0, 0, |
| 6022 | 0, 0, 0, 0, |
| 6023 | 0, 0, 0, 0, |
| 6024 | 0, 0, 0, 0, |
| 6025 | 0, 0, 0, 0, |
| 6026 | 0, 0, 0, 0, |
| 6027 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6028 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6029 | 0, 0, 0, 0, |
| 6030 | 0, 0, 0, 0, |
| 6031 | 0, 0, 0, 0, |
| 6032 | 0, 0, 0, 0, |
| 6033 | 0, 0, 0, 0, |
| 6034 | 0, 0, 0, 0, |
| 6035 | 0, 0, 0, 0, |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6036 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6037 | 0, 0, 0, 0, |
| 6038 | 0, 0, 0, 0, |
| 6039 | 0, 0, 0, 0, |
| 6040 | 0, 0, 0, 0, |
| 6041 | 0, 0, 0, 0, |
| 6042 | 0, 0, 0, 0, |
| 6043 | 0, 0, 0, 0 |
| 6044 | })); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6045 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6046 | auto inputTensor = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>(inputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6047 | |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6048 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 6049 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, std::vector<T>(expectedOutputValues)); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6050 | |
| 6051 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 6052 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6053 | |
| 6054 | armnn::PadQueueDescriptor descriptor; |
| 6055 | |
| 6056 | std::vector<std::pair<unsigned int, unsigned int>> PadList; |
| 6057 | PadList.push_back(std::pair<unsigned int, unsigned int>(1,1)); |
| 6058 | PadList.push_back(std::pair<unsigned int, unsigned int>(2,1)); |
| 6059 | PadList.push_back(std::pair<unsigned int, unsigned int>(3,1)); |
| 6060 | PadList.push_back(std::pair<unsigned int, unsigned int>(1,1)); |
| 6061 | |
| 6062 | descriptor.m_Parameters.m_PadList = PadList; |
| 6063 | armnn::WorkloadInfo info; |
| 6064 | |
| 6065 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 6066 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6067 | |
| 6068 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePad(descriptor, info); |
| 6069 | |
| 6070 | inputHandle->Allocate(); |
| 6071 | outputHandle->Allocate(); |
| 6072 | |
| 6073 | CopyDataToITensorHandle(inputHandle.get(), &inputTensor[0][0][0][0]); |
| 6074 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 6075 | workload->PostAllocationConfigure(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6076 | workload->Execute(); |
| 6077 | |
| 6078 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6079 | |
| 6080 | return result; |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6081 | } |
| 6082 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6083 | LayerTestResult<uint8_t, 2> PadUint82dTest( |
| 6084 | armnn::IWorkloadFactory& workloadFactory, |
| 6085 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6086 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6087 | return Pad2dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6088 | } |
| 6089 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6090 | LayerTestResult<uint8_t, 3> PadUint83dTest( |
| 6091 | armnn::IWorkloadFactory& workloadFactory, |
| 6092 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6093 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6094 | return Pad3dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6095 | } |
| 6096 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6097 | LayerTestResult<uint8_t, 4> PadUint84dTest( |
| 6098 | armnn::IWorkloadFactory& workloadFactory, |
| 6099 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6100 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6101 | return Pad4dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6102 | } |
| 6103 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6104 | LayerTestResult<float, 2> PadFloat322dTest( |
| 6105 | armnn::IWorkloadFactory& workloadFactory, |
| 6106 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6107 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6108 | return Pad2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6109 | } |
| 6110 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6111 | LayerTestResult<float, 3> PadFloat323dTest( |
| 6112 | armnn::IWorkloadFactory& workloadFactory, |
| 6113 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6114 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6115 | return Pad3dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6116 | } |
| 6117 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6118 | LayerTestResult<float, 4> PadFloat324dTest( |
| 6119 | armnn::IWorkloadFactory& workloadFactory, |
| 6120 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6121 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6122 | return Pad4dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
Mohamed Nour Abouelseoud | dd6acea | 2018-10-18 12:26:19 +0100 | [diff] [blame] | 6123 | } |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 6124 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6125 | LayerTestResult<float, 4> L2Normalization1dTest( |
| 6126 | armnn::IWorkloadFactory& workloadFactory, |
| 6127 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 6128 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6129 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6130 | // Width: 1 |
| 6131 | // Height: 1 |
| 6132 | // Channels: 10 |
| 6133 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6134 | unsigned int numberOfBatches = 1; |
| 6135 | unsigned int numberOfChannels = 10; |
| 6136 | unsigned int height = 1; |
| 6137 | unsigned int width = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6138 | |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6139 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 6140 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6141 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6142 | std::vector<float> inputValues |
| 6143 | { |
| 6144 | // Batch 0, Channel 0, Height (1) x Width (1) |
| 6145 | 1.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6146 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6147 | // Batch 0, Channel 1, Height (1) x Width (1) |
| 6148 | 2.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6149 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6150 | // Batch 0, Channel 2, Height (1) x Width (1) |
| 6151 | 3.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6152 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6153 | // Batch 0, Channel 3, Height (1) x Width (1) |
| 6154 | 4.0f, |
| 6155 | |
| 6156 | // Batch 0, Channel 4, Height (1) x Width (1) |
| 6157 | 5.0f, |
| 6158 | |
| 6159 | // Batch 0, Channel 5, Height (1) x Width (1) |
| 6160 | 6.0f, |
| 6161 | |
| 6162 | // Batch 0, Channel 6, Height (1) x Width (1) |
| 6163 | 7.0f, |
| 6164 | |
| 6165 | // Batch 0, Channel 7, Height (1) x Width (1) |
| 6166 | 8.0f, |
| 6167 | |
| 6168 | // Batch 0, Channel 8, Height (1) x Width (1) |
| 6169 | 9.0f, |
| 6170 | |
| 6171 | // Batch 0, Channel 9, Height (1) x Width (1) |
| 6172 | 10.0f |
| 6173 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6174 | const float approxInvL2Norm = 0.050964719f; |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6175 | std::vector<float> expectedOutputValues |
| 6176 | { |
| 6177 | // Batch 0, Channel 0, Height (1) x Width (1) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6178 | 1.0f * approxInvL2Norm, |
| 6179 | 2.0f * approxInvL2Norm, |
| 6180 | 3.0f * approxInvL2Norm, |
| 6181 | 4.0f * approxInvL2Norm, |
| 6182 | 5.0f * approxInvL2Norm, |
| 6183 | 6.0f * approxInvL2Norm, |
| 6184 | 7.0f * approxInvL2Norm, |
| 6185 | 8.0f * approxInvL2Norm, |
| 6186 | 9.0f * approxInvL2Norm, |
| 6187 | 10.0f * approxInvL2Norm |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6188 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6189 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6190 | |
| 6191 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6192 | inputValues, expectedOutputValues, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6193 | } |
| 6194 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6195 | LayerTestResult<float, 4> L2Normalization2dTest( |
| 6196 | armnn::IWorkloadFactory& workloadFactory, |
| 6197 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 6198 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6199 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6200 | // Width: 5 |
| 6201 | // Height: 1 |
| 6202 | // Channels: 2 |
| 6203 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6204 | unsigned int numberOfBatches = 1; |
| 6205 | unsigned int numberOfChannels = 2; |
| 6206 | unsigned int height = 1; |
| 6207 | unsigned int width = 5; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6208 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 6209 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6210 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6211 | std::vector<float> inputValues |
| 6212 | { |
| 6213 | // Batch 0, Channel 0, Height (1) x Width (5) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6214 | 1.0f, 3.0f, 5.0f, 7.0f, 9.0f, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6215 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6216 | // Batch 0, Channel 1, Height (1) x Width (5) |
| 6217 | 2.0f, 4.0f, 6.0f, 8.0f, 10.0f |
| 6218 | }; |
| 6219 | std::vector<float> expectedOutputValues |
| 6220 | { |
| 6221 | // Batch 0, Channel 0, Height (1) x Width (5) |
| 6222 | 1.0f * CalcInvL2Norm({ 1.0f, 2.0f }), |
| 6223 | 3.0f * CalcInvL2Norm({ 3.0f, 4.0f }), |
| 6224 | 5.0f * CalcInvL2Norm({ 5.0f, 6.0f }), |
| 6225 | 7.0f * CalcInvL2Norm({ 7.0f, 8.0f }), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6226 | 9.0f * CalcInvL2Norm({ 9.0f, 10.0f }), |
| 6227 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6228 | // Batch 0, Channel 1, Height (1) x Width (5) |
| 6229 | 2.0f * CalcInvL2Norm({ 1.0f, 2.0f }), |
| 6230 | 4.0f * CalcInvL2Norm({ 3.0f, 4.0f }), |
| 6231 | 6.0f * CalcInvL2Norm({ 5.0f, 6.0f }), |
| 6232 | 8.0f * CalcInvL2Norm({ 7.0f, 8.0f }), |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6233 | 10.0f * CalcInvL2Norm({ 9.0f, 10.0f }) |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6234 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6235 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6236 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6237 | inputValues, expectedOutputValues, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6238 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6239 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6240 | LayerTestResult<float, 4> L2Normalization3dTest( |
| 6241 | armnn::IWorkloadFactory& workloadFactory, |
| 6242 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 6243 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6244 | { |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6245 | // Width: 3 |
| 6246 | // Height: 4 |
| 6247 | // Channels: 2 |
| 6248 | // BatchSize: 1 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6249 | unsigned int numberOfBatches = 1; |
| 6250 | unsigned int numberOfChannels = 2; |
| 6251 | unsigned int height = 4; |
| 6252 | unsigned int width = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6253 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 6254 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6255 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6256 | std::vector<float> inputValues |
| 6257 | { |
| 6258 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6259 | 119.0f, 21.0f, 150.0f, |
| 6260 | 149.0f, 32.0f, 179.0f, |
| 6261 | 15.0f, 227.0f, 141.0f, |
| 6262 | 147.0f, 199.0f, 220.0f, |
| 6263 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6264 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6265 | 110.0f, 140.0f, 73.0f, |
| 6266 | 211.0f, 212.0f, 89.0f, |
| 6267 | 24.0f, 138.0f, 188.0f, |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6268 | 162.0f, 12.0f, 161.0f |
| 6269 | }; |
| 6270 | std::vector<float> expectedOutputValues |
| 6271 | { |
| 6272 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6273 | 119.0f * CalcInvL2Norm({ 119.0f, 110.0f }), |
| 6274 | 21.0f * CalcInvL2Norm({ 21.0f, 140.0f }), |
| 6275 | 150.0f * CalcInvL2Norm({ 150.0f, 73.0f }), |
| 6276 | 149.0f * CalcInvL2Norm({ 149.0f, 211.0f }), |
| 6277 | 32.0f * CalcInvL2Norm({ 32.0f, 212.0f }), |
| 6278 | 179.0f * CalcInvL2Norm({ 179.0f, 89.0f }), |
| 6279 | 15.0f * CalcInvL2Norm({ 15.0f, 24.0f }), |
| 6280 | 227.0f * CalcInvL2Norm({ 227.0f, 138.0f }), |
| 6281 | 141.0f * CalcInvL2Norm({ 141.0f, 188.0f }), |
| 6282 | 147.0f * CalcInvL2Norm({ 147.0f, 162.0f }), |
| 6283 | 199.0f * CalcInvL2Norm({ 199.0f, 12.0f }), |
| 6284 | 220.0f * CalcInvL2Norm({ 220.0f, 161.0f }), |
| 6285 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6286 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6287 | 110.0f * CalcInvL2Norm({ 119.0f, 110.0f }), |
| 6288 | 140.0f * CalcInvL2Norm({ 21.0f, 140.0f }), |
| 6289 | 73.0f * CalcInvL2Norm({ 150.0f, 73.0f }), |
| 6290 | 211.0f * CalcInvL2Norm({ 149.0f, 211.0f }), |
| 6291 | 212.0f * CalcInvL2Norm({ 32.0f, 212.0f }), |
| 6292 | 89.0f * CalcInvL2Norm({ 179.0f, 89.0f }), |
| 6293 | 24.0f * CalcInvL2Norm({ 15.0f, 24.0f }), |
| 6294 | 138.0f * CalcInvL2Norm({ 227.0f, 138.0f }), |
| 6295 | 188.0f * CalcInvL2Norm({ 141.0f, 188.0f }), |
| 6296 | 162.0f * CalcInvL2Norm({ 147.0f, 162.0f }), |
| 6297 | 12.0f * CalcInvL2Norm({ 199.0f, 12.0f }), |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6298 | 161.0f * CalcInvL2Norm({ 220.0f, 161.0f }) |
| 6299 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6300 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6301 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6302 | inputValues, expectedOutputValues, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6303 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6304 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6305 | LayerTestResult<float, 4> L2Normalization4dTest( |
| 6306 | armnn::IWorkloadFactory& workloadFactory, |
| 6307 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 6308 | const armnn::DataLayout layout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6309 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6310 | // Width: 3 |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6311 | // Height: 4 |
| 6312 | // Channels: 3 |
| 6313 | // BatchSize: 2 |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6314 | unsigned int numberOfBatches = 2; |
| 6315 | unsigned int numberOfChannels = 3; |
| 6316 | unsigned int height = 4; |
| 6317 | unsigned int width = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6318 | |
Nina Drozd | d41b259 | 2018-11-19 13:03:36 +0000 | [diff] [blame] | 6319 | const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape( |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6320 | numberOfBatches, numberOfChannels, height, width, layout); |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6321 | std::vector<float> inputValues |
| 6322 | { |
| 6323 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6324 | 235.0f, 46.0f, 178.0f, |
| 6325 | 100.0f, 123.0f, 19.0f, |
| 6326 | 172.0f, 74.0f, 250.0f, |
| 6327 | 6.0f, 195.0f, 80.0f, |
| 6328 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6329 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6330 | 113.0f, 95.0f, 202.0f, |
| 6331 | 77.0f, 114.0f, 71.0f, |
| 6332 | 122.0f, 246.0f, 166.0f, |
| 6333 | 82.0f, 28.0f, 37.0f, |
| 6334 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6335 | // Batch 0, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6336 | 56.0f, 170.0f, 162.0f, |
| 6337 | 194.0f, 89.0f, 254.0f, |
| 6338 | 12.0f, 209.0f, 200.0f, |
| 6339 | 1.0f, 64.0f, 54.0f, |
| 6340 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6341 | // Batch 1, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6342 | 67.0f, 90.0f, 49.0f, |
| 6343 | 7.0f, 163.0f, 18.0f, |
| 6344 | 25.0f, 117.0f, 103.0f, |
| 6345 | 247.0f, 59.0f, 189.0f, |
| 6346 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6347 | // Batch 1, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6348 | 239.0f, 104.0f, 199.0f, |
| 6349 | 17.0f, 124.0f, 153.0f, |
| 6350 | 222.0f, 217.0f, 75.0f, |
| 6351 | 32.0f, 126.0f, 21.0f, |
| 6352 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6353 | // Batch 1, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6354 | 97.0f, 145.0f, 215.0f, |
| 6355 | 115.0f, 116.0f, 238.0f, |
| 6356 | 226.0f, 16.0f, 132.0f, |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6357 | 92.0f, 125.0f, 88.0f |
| 6358 | }; |
| 6359 | std::vector<float> expectedOutputValues |
| 6360 | { |
| 6361 | // Batch 0, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6362 | 235.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 6363 | 46.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 6364 | 178.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 6365 | 100.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 6366 | 123.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 6367 | 19.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 6368 | 172.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 6369 | 74.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 6370 | 250.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 6371 | 6.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 6372 | 195.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 6373 | 80.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 6374 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6375 | // Batch 0, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6376 | 113.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 6377 | 95.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 6378 | 202.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 6379 | 77.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 6380 | 114.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 6381 | 71.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 6382 | 122.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 6383 | 246.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 6384 | 166.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 6385 | 82.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 6386 | 28.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 6387 | 37.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 6388 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6389 | // Batch 0, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6390 | 56.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }), |
| 6391 | 170.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }), |
| 6392 | 162.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }), |
| 6393 | 194.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }), |
| 6394 | 89.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }), |
| 6395 | 254.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }), |
| 6396 | 12.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }), |
| 6397 | 209.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }), |
| 6398 | 200.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }), |
| 6399 | 1.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }), |
| 6400 | 64.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }), |
| 6401 | 54.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }), |
| 6402 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6403 | // Batch 1, Channel 0, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6404 | 67.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 6405 | 90.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 6406 | 49.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 6407 | 7.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 6408 | 163.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 6409 | 18.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 6410 | 25.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 6411 | 117.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 6412 | 103.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 6413 | 247.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 6414 | 59.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
| 6415 | 189.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }), |
| 6416 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6417 | // Batch 1, Channel 1, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6418 | 239.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 6419 | 104.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 6420 | 199.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 6421 | 17.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 6422 | 124.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 6423 | 153.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 6424 | 222.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 6425 | 217.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 6426 | 75.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 6427 | 32.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 6428 | 126.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
| 6429 | 21.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }), |
| 6430 | |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6431 | // Batch 1, Channel 2, Height (4) x Width (3) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6432 | 97.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }), |
| 6433 | 145.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }), |
| 6434 | 215.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }), |
| 6435 | 115.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }), |
| 6436 | 116.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }), |
| 6437 | 238.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }), |
| 6438 | 226.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }), |
| 6439 | 16.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }), |
| 6440 | 132.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }), |
| 6441 | 92.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }), |
| 6442 | 125.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }), |
Matteo Martincigh | 539b44d | 2018-10-01 09:26:39 +0100 | [diff] [blame] | 6443 | 88.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }) |
| 6444 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6445 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6446 | return L2NormalizationTestImpl(workloadFactory, memoryManager, inputOutputShape, |
jimfly01 | 3aab7c3 | 2018-11-12 13:32:08 +0000 | [diff] [blame] | 6447 | inputValues, expectedOutputValues, layout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6448 | } |
| 6449 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6450 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6451 | LayerTestResult<T, 4> ConstantTestImpl( |
| 6452 | armnn::IWorkloadFactory& workloadFactory, |
| 6453 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6454 | float qScale, |
| 6455 | int32_t qOffset) |
| 6456 | { |
| 6457 | constexpr unsigned int inputWidth = 3; |
| 6458 | constexpr unsigned int inputHeight = 4; |
| 6459 | constexpr unsigned int inputChannels = 3; |
| 6460 | constexpr unsigned int inputBatchSize = 2; |
| 6461 | |
| 6462 | constexpr unsigned int outputWidth = inputWidth; |
| 6463 | constexpr unsigned int outputHeight = inputHeight; |
| 6464 | constexpr unsigned int outputChannels = inputChannels; |
| 6465 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 6466 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 6467 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 6468 | ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6469 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 6470 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 6471 | ArmnnType, qScale, qOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6472 | |
| 6473 | // Set quantization parameters if the requested type is a quantized type. |
| 6474 | if(armnn::IsQuantizedType<T>()) |
| 6475 | { |
| 6476 | inputTensorInfo.SetQuantizationScale(qScale); |
| 6477 | inputTensorInfo.SetQuantizationOffset(qOffset); |
| 6478 | outputTensorInfo.SetQuantizationScale(qScale); |
| 6479 | outputTensorInfo.SetQuantizationOffset(qOffset); |
| 6480 | } |
| 6481 | |
| 6482 | auto input = MakeTensor<T, 4>(inputTensorInfo, std::vector<T>( |
| 6483 | QuantizedVector<T>(qScale, qOffset, { |
| 6484 | // Batch 0, Channel 0 |
| 6485 | 235.0f, 46.0f, 178.0f, |
| 6486 | 100.0f, 123.0f, 19.0f, |
| 6487 | 172.0f, 74.0f, 250.0f, |
| 6488 | 6.0f, 195.0f, 80.0f, |
| 6489 | |
| 6490 | // Batch 0, Channel 1 |
| 6491 | 113.0f, 95.0f, 202.0f, |
| 6492 | 77.0f, 114.0f, 71.0f, |
| 6493 | 122.0f, 246.0f, 166.0f, |
| 6494 | 82.0f, 28.0f, 37.0f, |
| 6495 | |
| 6496 | // Batch 0, Channel 2 |
| 6497 | 56.0f, 170.0f, 162.0f, |
| 6498 | 194.0f, 89.0f, 254.0f, |
| 6499 | 12.0f, 209.0f, 200.0f, |
| 6500 | 1.0f, 64.0f, 54.0f, |
| 6501 | |
| 6502 | // Batch 1, Channel 0 |
| 6503 | 67.0f, 90.0f, 49.0f, |
| 6504 | 7.0f, 163.0f, 18.0f, |
| 6505 | 25.0f, 117.0f, 103.0f, |
| 6506 | 247.0f, 59.0f, 189.0f, |
| 6507 | |
| 6508 | // Batch 1, Channel 1 |
| 6509 | 239.0f, 104.0f, 199.0f, |
| 6510 | 17.0f, 124.0f, 153.0f, |
| 6511 | 222.0f, 217.0f, 75.0f, |
| 6512 | 32.0f, 126.0f, 21.0f, |
| 6513 | |
| 6514 | // Batch 1, Channel 2 |
| 6515 | 97.0f, 145.0f, 215.0f, |
| 6516 | 115.0f, 116.0f, 238.0f, |
| 6517 | 226.0f, 16.0f, 132.0f, |
| 6518 | 92.0f, 125.0f, 88.0f, |
| 6519 | }))); |
| 6520 | |
| 6521 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 6522 | result.outputExpected = input; |
| 6523 | |
| 6524 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6525 | |
| 6526 | armnn::ScopedCpuTensorHandle constantTensor(inputTensorInfo); |
| 6527 | AllocateAndCopyDataToITensorHandle(&constantTensor, &input[0][0][0][0]); |
| 6528 | |
| 6529 | armnn::ConstantQueueDescriptor descriptor; |
| 6530 | descriptor.m_LayerOutput = &constantTensor; |
| 6531 | |
| 6532 | armnn::WorkloadInfo info; |
| 6533 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 6534 | |
| 6535 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConstant(descriptor, info); |
| 6536 | |
| 6537 | outputHandle->Allocate(); |
| 6538 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 6539 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6540 | workload->Execute(); |
| 6541 | |
| 6542 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 6543 | return result; |
| 6544 | } |
| 6545 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6546 | LayerTestResult<float, 4> ConstantTest( |
| 6547 | armnn::IWorkloadFactory& workloadFactory, |
| 6548 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6549 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6550 | return ConstantTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager, 0.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6551 | } |
| 6552 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 6553 | LayerTestResult<int16_t, 4> ConstantInt16SimpleQuantizationScaleNoOffsetTest( |
| 6554 | armnn::IWorkloadFactory& workloadFactory, |
| 6555 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 6556 | { |
| 6557 | return ConstantTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, 1.0f, 0); |
| 6558 | } |
| 6559 | |
| 6560 | LayerTestResult<uint8_t, 4> ConstantUint8SimpleQuantizationScaleNoOffsetTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6561 | armnn::IWorkloadFactory& workloadFactory, |
| 6562 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6563 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 6564 | return ConstantTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 1.0f, 0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6565 | } |
| 6566 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6567 | LayerTestResult<uint8_t, 3> ConcatUint8DifferentQParamsTest( |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6568 | armnn::IWorkloadFactory& workloadFactory, |
| 6569 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 6570 | { |
| 6571 | unsigned int outputWidth = 3; |
| 6572 | unsigned int outputHeight = 6; |
| 6573 | unsigned int outputChannels = 3; |
| 6574 | |
| 6575 | unsigned int inputWidth1 = 3; |
| 6576 | unsigned int inputHeight1 = 6; |
| 6577 | unsigned int inputChannels1 = 2; |
| 6578 | |
| 6579 | unsigned int inputWidth2 = 3; |
| 6580 | unsigned int inputHeight2 = 6; |
| 6581 | unsigned int inputChannels2 = 1; |
| 6582 | |
| 6583 | // Defines the tensor descriptors. |
| 6584 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::QuantisedAsymm8); |
| 6585 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::QuantisedAsymm8); |
| 6586 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::QuantisedAsymm8); |
| 6587 | |
| 6588 | // Quantized input1 tensor. Range [-3, 1] |
| 6589 | const float inputScale1 = 0.015686f; |
| 6590 | const int32_t inputOffset1 = 192; |
| 6591 | |
| 6592 | auto input1 = MakeTensor<uint8_t, 3>(inputTensorInfo1, std::vector<uint8_t>( |
| 6593 | { |
| 6594 | 1, 2, 3, |
| 6595 | 4, 5, 6, |
| 6596 | 7, 8, 9, |
| 6597 | 10, 11, 12, |
| 6598 | 13, 14, 15, |
| 6599 | 16, 17, 18, |
| 6600 | |
| 6601 | 19, 20, 21, |
| 6602 | 22, 23, 24, |
| 6603 | 25, 26, 27, |
| 6604 | 28, 29, 30, |
| 6605 | 31, 32, 33, |
| 6606 | 34, 35, 36, |
| 6607 | }) |
| 6608 | ); |
| 6609 | |
| 6610 | // Quatized input2 tensor. Range [-1, 4] |
| 6611 | const float inputScale2 = 0.019608f; |
| 6612 | const int32_t inputOffset2 = 50; |
| 6613 | |
| 6614 | auto input2 = MakeTensor<uint8_t, 3>(inputTensorInfo2, std::vector<uint8_t>( |
| 6615 | { |
| 6616 | 37, 38, 39, |
| 6617 | 40, 41, 42, |
| 6618 | 43, 44, 45, |
| 6619 | 46, 47, 48, |
| 6620 | 49, 50, 51, |
| 6621 | 52, 53, 54, |
| 6622 | }) |
| 6623 | ); |
| 6624 | |
| 6625 | // Output has the same quantization parameters than input1, |
| 6626 | // so that only the requantization of input2 is required |
| 6627 | const float outputScale = 0.015686f; |
| 6628 | const int32_t outputOffset = 192; |
| 6629 | |
| 6630 | LayerTestResult<uint8_t, 3> ret(outputTensorInfo); |
| 6631 | |
| 6632 | ret.outputExpected = MakeTensor<uint8_t, 3>(outputTensorInfo, std::vector<uint8_t>( |
| 6633 | { |
| 6634 | 1, 2, 3, |
| 6635 | 4, 5, 6, |
| 6636 | 7, 8, 9, |
| 6637 | 10, 11, 12, |
| 6638 | 13, 14, 15, |
| 6639 | 16, 17, 18, |
| 6640 | |
| 6641 | 19, 20, 21, |
| 6642 | 22, 23, 24, |
| 6643 | 25, 26, 27, |
| 6644 | 28, 29, 30, |
| 6645 | 31, 32, 33, |
| 6646 | 34, 35, 36, |
| 6647 | |
| 6648 | 176, 177, 178, |
| 6649 | 179, 181, 182, |
| 6650 | 183, 184, 186, |
| 6651 | 187, 188, 189, |
| 6652 | 191, 192, 193, |
| 6653 | 195, 196, 197, |
| 6654 | }) |
| 6655 | ); |
| 6656 | |
| 6657 | outputTensorInfo.SetQuantizationScale(outputScale); |
| 6658 | outputTensorInfo.SetQuantizationOffset(outputOffset); |
| 6659 | inputTensorInfo1.SetQuantizationScale(inputScale1); |
| 6660 | inputTensorInfo1.SetQuantizationOffset(inputOffset1); |
| 6661 | inputTensorInfo2.SetQuantizationScale(inputScale2); |
| 6662 | inputTensorInfo2.SetQuantizationOffset(inputOffset2); |
| 6663 | |
| 6664 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6665 | armnn::ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6666 | |
| 6667 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6668 | armnn::ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6669 | |
| 6670 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6671 | |
| 6672 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 6673 | |
| 6674 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 6675 | subTensorsSupported ? |
| 6676 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 6677 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6678 | |
| 6679 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 6680 | subTensorsSupported ? |
| 6681 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 6682 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 6683 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6684 | armnn::ConcatQueueDescriptor data; |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6685 | armnn::WorkloadInfo info; |
| 6686 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6687 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 6688 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6689 | |
| 6690 | data.m_ViewOrigins.push_back(window1); |
| 6691 | data.m_ViewOrigins.push_back(window2); |
| 6692 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6693 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6694 | |
| 6695 | inputHandle1->Allocate(); |
| 6696 | inputHandle2->Allocate(); |
| 6697 | outputHandle->Allocate(); |
| 6698 | |
| 6699 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 6700 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
| 6701 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 6702 | workload->PostAllocationConfigure(); |
Ferran Balaguer | b284565 | 2019-02-27 09:42:06 +0000 | [diff] [blame] | 6703 | workload->Execute(); |
| 6704 | |
| 6705 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 6706 | |
| 6707 | return ret; |
| 6708 | } |
| 6709 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6710 | LayerTestResult<uint8_t, 3> ConcatUint8Test( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6711 | armnn::IWorkloadFactory& workloadFactory, |
| 6712 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6713 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6714 | unsigned int outputWidth = 3; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6715 | unsigned int outputHeight = 6; |
| 6716 | unsigned int outputChannels = 3; |
| 6717 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6718 | unsigned int inputWidth1 = 3; |
| 6719 | unsigned int inputHeight1 = 6; |
| 6720 | unsigned int inputChannels1 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6721 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6722 | unsigned int inputWidth2 = 3; |
| 6723 | unsigned int inputHeight2 = 6; |
| 6724 | unsigned int inputChannels2 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6725 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6726 | // Defines the tensor descriptors. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6727 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::QuantisedAsymm8); |
| 6728 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::QuantisedAsymm8); |
| 6729 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::QuantisedAsymm8); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6730 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6731 | // Arbitrary scale and offsets. They don't really matter as the Concat operator doesn't dequantize/quantize them. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6732 | const float scale = 0.13497836f; |
| 6733 | const int32_t offset = -7; |
| 6734 | |
| 6735 | outputTensorInfo.SetQuantizationScale(scale); |
| 6736 | outputTensorInfo.SetQuantizationOffset(offset); |
| 6737 | inputTensorInfo1.SetQuantizationScale(scale); |
| 6738 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 6739 | inputTensorInfo2.SetQuantizationScale(scale); |
| 6740 | inputTensorInfo2.SetQuantizationOffset(offset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6741 | |
| 6742 | LayerTestResult<uint8_t, 3> ret(outputTensorInfo); |
| 6743 | |
| 6744 | ret.outputExpected = MakeTensor<uint8_t, 3>(outputTensorInfo, std::vector<uint8_t>( |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6745 | { |
| 6746 | 1, 2, 3, |
| 6747 | 4, 5, 6, |
| 6748 | 7, 8, 9, |
| 6749 | 10, 11, 12, |
| 6750 | 13, 14, 15, |
| 6751 | 16, 17, 18, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6752 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6753 | 19, 20, 21, |
| 6754 | 22, 23, 24, |
| 6755 | 25, 26, 27, |
| 6756 | 28, 29, 30, |
| 6757 | 31, 32, 33, |
| 6758 | 34, 35, 36, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6759 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6760 | 37, 38, 39, |
| 6761 | 40, 41, 42, |
| 6762 | 43, 44, 45, |
| 6763 | 46, 47, 48, |
| 6764 | 49, 50, 51, |
| 6765 | 52, 53, 54, |
| 6766 | }) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6767 | ); |
| 6768 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6769 | auto input1 = MakeTensor<uint8_t, 3>(inputTensorInfo1, std::vector<uint8_t>( |
| 6770 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6771 | 1, 2, 3, |
| 6772 | 4, 5, 6, |
| 6773 | 7, 8, 9, |
| 6774 | 10, 11, 12, |
| 6775 | 13, 14, 15, |
| 6776 | 16, 17, 18, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6777 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6778 | 19, 20, 21, |
| 6779 | 22, 23, 24, |
| 6780 | 25, 26, 27, |
| 6781 | 28, 29, 30, |
| 6782 | 31, 32, 33, |
| 6783 | 34, 35, 36, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6784 | }) |
| 6785 | ); |
| 6786 | |
| 6787 | auto input2 = MakeTensor<uint8_t, 3>(inputTensorInfo2, std::vector<uint8_t>( |
| 6788 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6789 | 37, 38, 39, |
| 6790 | 40, 41, 42, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6791 | 43, 44, 45, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 6792 | 46, 47, 48, |
| 6793 | 49, 50, 51, |
| 6794 | 52, 53, 54, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6795 | }) |
| 6796 | ); |
| 6797 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6798 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6799 | armnn::ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6800 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 6801 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6802 | armnn::ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6803 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6804 | |
| 6805 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6806 | |
| 6807 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 6808 | |
| 6809 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 6810 | subTensorsSupported ? |
| 6811 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 6812 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6813 | |
| 6814 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 6815 | subTensorsSupported ? |
| 6816 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 6817 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 6818 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6819 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6820 | armnn::ConcatQueueDescriptor data; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6821 | armnn::WorkloadInfo info; |
| 6822 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6823 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6824 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6825 | |
| 6826 | data.m_ViewOrigins.push_back(window1); |
| 6827 | data.m_ViewOrigins.push_back(window2); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6828 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6829 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConcat(data, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6830 | |
| 6831 | inputHandle1->Allocate(); |
| 6832 | inputHandle2->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6833 | outputHandle->Allocate(); |
| 6834 | |
| 6835 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 6836 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6837 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 6838 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6839 | workload->Execute(); |
| 6840 | |
| 6841 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 6842 | |
| 6843 | return ret; |
| 6844 | } |
| 6845 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6846 | LayerTestResult<uint16_t, 3> ConcatUint16Test( |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6847 | armnn::IWorkloadFactory& workloadFactory, |
| 6848 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 6849 | { |
| 6850 | unsigned int outputWidth = 3; |
| 6851 | unsigned int outputHeight = 6; |
| 6852 | unsigned int outputChannels = 3; |
| 6853 | |
| 6854 | unsigned int inputWidth1 = 3; |
| 6855 | unsigned int inputHeight1 = 6; |
| 6856 | unsigned int inputChannels1 = 2; |
| 6857 | |
| 6858 | unsigned int inputWidth2 = 3; |
| 6859 | unsigned int inputHeight2 = 6; |
| 6860 | unsigned int inputChannels2 = 1; |
| 6861 | |
| 6862 | // Defines the tensor descriptors. |
| 6863 | armnn::TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, armnn::DataType::QuantisedSymm16); |
| 6864 | armnn::TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, armnn::DataType::QuantisedSymm16); |
| 6865 | armnn::TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, armnn::DataType::QuantisedSymm16); |
| 6866 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6867 | // Arbitrary scale and offsets. They don't really matter as the Concat operator doesn't dequantize/quantize them. |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6868 | const float scale = 0.13497836f; |
| 6869 | const int32_t offset = -7; |
| 6870 | |
| 6871 | outputTensorInfo.SetQuantizationScale(scale); |
| 6872 | outputTensorInfo.SetQuantizationOffset(offset); |
| 6873 | inputTensorInfo1.SetQuantizationScale(scale); |
| 6874 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 6875 | inputTensorInfo2.SetQuantizationScale(scale); |
| 6876 | inputTensorInfo2.SetQuantizationOffset(offset); |
| 6877 | |
| 6878 | LayerTestResult<uint16_t, 3> ret(outputTensorInfo); |
| 6879 | |
| 6880 | ret.outputExpected = MakeTensor<uint16_t, 3>(outputTensorInfo, std::vector<uint16_t>( |
| 6881 | { |
| 6882 | 1, 2, 3, |
| 6883 | 4, 5, 6, |
| 6884 | 7, 8, 9, |
| 6885 | 10, 11, 12, |
| 6886 | 13, 14, 15, |
| 6887 | 16, 17, 18, |
| 6888 | |
| 6889 | 19, 20, 21, |
| 6890 | 22, 23, 24, |
| 6891 | 25, 26, 27, |
| 6892 | 28, 29, 30, |
| 6893 | 31, 32, 33, |
| 6894 | 34, 35, 36, |
| 6895 | |
| 6896 | 37, 38, 39, |
| 6897 | 40, 41, 42, |
| 6898 | 43, 44, 45, |
| 6899 | 46, 47, 48, |
| 6900 | 49, 50, 51, |
| 6901 | 52, 53, 54, |
| 6902 | })); |
| 6903 | |
| 6904 | auto input1 = MakeTensor<uint16_t, 3>(inputTensorInfo1, std::vector<uint16_t>( |
| 6905 | { |
| 6906 | 1, 2, 3, |
| 6907 | 4, 5, 6, |
| 6908 | 7, 8, 9, |
| 6909 | 10, 11, 12, |
| 6910 | 13, 14, 15, |
| 6911 | 16, 17, 18, |
| 6912 | |
| 6913 | 19, 20, 21, |
| 6914 | 22, 23, 24, |
| 6915 | 25, 26, 27, |
| 6916 | 28, 29, 30, |
| 6917 | 31, 32, 33, |
| 6918 | 34, 35, 36, |
| 6919 | })); |
| 6920 | |
| 6921 | auto input2 = MakeTensor<uint16_t, 3>(inputTensorInfo2, std::vector<uint16_t>( |
| 6922 | { |
| 6923 | 37, 38, 39, |
| 6924 | 40, 41, 42, |
| 6925 | 43, 44, 45, |
| 6926 | 46, 47, 48, |
| 6927 | 49, 50, 51, |
| 6928 | 52, 53, 54, |
| 6929 | })); |
| 6930 | |
| 6931 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6932 | armnn::ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6933 | |
| 6934 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6935 | armnn::ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6936 | |
| 6937 | |
| 6938 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 6939 | |
| 6940 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 6941 | |
| 6942 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = |
| 6943 | subTensorsSupported ? |
| 6944 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 6945 | workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 6946 | |
| 6947 | std::unique_ptr<armnn::ITensorHandle> inputHandle2 = |
| 6948 | subTensorsSupported ? |
| 6949 | workloadFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 6950 | workloadFactory.CreateTensorHandle(inputTensorInfo2); |
| 6951 | |
| 6952 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 6953 | armnn::ConcatQueueDescriptor data; |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6954 | armnn::WorkloadInfo info; |
| 6955 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 6956 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 6957 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 6958 | |
| 6959 | data.m_ViewOrigins.push_back(window1); |
| 6960 | data.m_ViewOrigins.push_back(window2); |
| 6961 | |
Jim Flynn | 4ed6c83 | 2019-05-20 11:02:46 +0100 | [diff] [blame] | 6962 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Jim Flynn | cbb66aa | 2019-05-15 13:03:54 +0100 | [diff] [blame] | 6963 | |
| 6964 | inputHandle1->Allocate(); |
| 6965 | inputHandle2->Allocate(); |
| 6966 | outputHandle->Allocate(); |
| 6967 | |
| 6968 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0]); |
| 6969 | CopyDataToITensorHandle(inputHandle2.get(), &input2[0][0][0]); |
| 6970 | |
| 6971 | workload->PostAllocationConfigure(); |
| 6972 | workload->Execute(); |
| 6973 | |
| 6974 | CopyDataFromITensorHandle(&ret.output[0][0][0], outputHandle.get()); |
| 6975 | |
| 6976 | return ret; |
| 6977 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6978 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6979 | namespace |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6980 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 6981 | template <typename T> |
| 6982 | LayerTestResult<T, 4> AdditionQuantizeTestHelper( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6983 | armnn::IWorkloadFactory& workloadFactory, |
| 6984 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 6985 | const unsigned int shape0[4], |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 6986 | const std::vector<T>& values0, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6987 | float scale0, |
| 6988 | int32_t offset0, |
| 6989 | const unsigned int shape1[4], |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 6990 | const std::vector<T> & values1, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6991 | float scale1, |
| 6992 | int32_t offset1, |
| 6993 | const unsigned int outShape[4], |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 6994 | const std::vector<T> & outValues, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 6995 | float outScale, |
| 6996 | int32_t outOffset) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 6997 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 6998 | auto dataType = (std::is_same<T, uint8_t>::value ? |
| 6999 | armnn::DataType::QuantisedAsymm8 : |
| 7000 | armnn::DataType::QuantisedSymm16); |
| 7001 | |
| 7002 | armnn::TensorInfo inputTensorInfo0(4, shape0, dataType); |
| 7003 | armnn::TensorInfo inputTensorInfo1(4, shape1, dataType); |
| 7004 | armnn::TensorInfo outputTensorInfo(4, outShape, dataType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7005 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7006 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 7007 | inputTensorInfo0.SetQuantizationOffset(offset0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7008 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7009 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 7010 | inputTensorInfo1.SetQuantizationOffset(offset1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7011 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7012 | outputTensorInfo.SetQuantizationScale(outScale); |
| 7013 | outputTensorInfo.SetQuantizationOffset(outOffset); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7014 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7015 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 7016 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7017 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7018 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 7019 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
| 7020 | |
| 7021 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 7022 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 7023 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7024 | |
| 7025 | armnn::AdditionQueueDescriptor data; |
| 7026 | armnn::WorkloadInfo info; |
| 7027 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 7028 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 7029 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 7030 | |
| 7031 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateAddition(data, info); |
| 7032 | |
| 7033 | inputHandle0->Allocate(); |
| 7034 | inputHandle1->Allocate(); |
| 7035 | outputHandle->Allocate(); |
| 7036 | |
| 7037 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 7038 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 7039 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7040 | workload->PostAllocationConfigure(); |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7041 | workload->Execute(); |
| 7042 | |
| 7043 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7044 | |
| 7045 | return result; |
| 7046 | } |
| 7047 | } // anonymous namespace |
| 7048 | |
| 7049 | LayerTestResult<uint8_t, 4> AdditionUint8Test( |
| 7050 | armnn::IWorkloadFactory& workloadFactory, |
| 7051 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7052 | { |
| 7053 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7054 | const unsigned int shape1[] = { 1, 2, 2, 3 }; |
| 7055 | |
| 7056 | std::vector<uint8_t> input0( |
| 7057 | { |
| 7058 | 63, 35, 77, 70, 56, 112, // 420, 224, 518, 469, 371, 763 |
| 7059 | 203, 28, 252, 168, 245, 91 // 1400, 175, 1743, 1155, 1694, 616 |
| 7060 | }); |
| 7061 | |
| 7062 | std::vector<uint8_t> input1( |
| 7063 | { |
| 7064 | 21, 7, 175, 231, 175, 210, // 126, 28, 1204, 1596, 1204, 1449 |
| 7065 | 126, 161, 63, 21, 105, 126 // 861, 1106, 420, 126, 714, 861 |
| 7066 | }); |
| 7067 | |
| 7068 | std::vector<uint8_t> output( |
| 7069 | { |
| 7070 | 81, 39, 249, 255, 228, 255, // 546, 252, 1722, 2065(clamped), 1575, 2212(clamped) |
| 7071 | 255, 186, 255, 186, 255, 214, // 2261(clamped), 1281, 2163(clamped), 1281, 2408(clamped), 1477 |
| 7072 | }); |
| 7073 | |
| 7074 | return AdditionQuantizeTestHelper(workloadFactory, |
| 7075 | memoryManager, |
| 7076 | shape0, input0, 7.0f, 3, |
| 7077 | shape1, input1, 7.0f, 3, |
| 7078 | shape0, output, 7.0f, 3); |
| 7079 | } |
| 7080 | |
| 7081 | LayerTestResult<int16_t, 4> AdditionInt16Test( |
| 7082 | armnn::IWorkloadFactory& workloadFactory, |
| 7083 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7084 | { |
| 7085 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7086 | const unsigned int shape1[] = { 1, 2, 2, 3 }; |
| 7087 | |
| 7088 | std::vector<int16_t> input0( |
| 7089 | { |
| 7090 | 63, 35, 77, 70, 56, 112, // 441, 245, 539, 490, 392, 184 |
| 7091 | 203, 28, 252, 168, 245, 91 // 1421, 196, 1764, 1176, 1715, 637 |
| 7092 | }); |
| 7093 | |
| 7094 | std::vector<int16_t> input1( |
| 7095 | { |
| 7096 | 21, 7, 175, 231, 175, 210, // 126, 28, 1204, 1596, 1204, 1449 |
| 7097 | 126, 161, 63, 21, 105, 126 // 861, 1106, 420, 126, 714, 861 |
| 7098 | }); |
| 7099 | |
| 7100 | std::vector<int16_t> output( |
| 7101 | { |
| 7102 | 84, 42, 252, 301, 231, 322, // 588, 294, 1764, 2107(clamped), 1617, 2254(clamped) |
| 7103 | 329, 189, 315, 189, 350, 217, // 2303(clamped), 1323, 2205(clamped), 1323, 2450(clamped), 1519 |
| 7104 | }); |
| 7105 | |
| 7106 | return AdditionQuantizeTestHelper(workloadFactory, |
| 7107 | memoryManager, |
| 7108 | shape0, input0, 7.0f, 0, |
| 7109 | shape1, input1, 7.0f, 0, |
| 7110 | shape0, output, 7.0f, 0); |
| 7111 | } |
| 7112 | |
| 7113 | namespace |
| 7114 | { |
| 7115 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 7116 | LayerTestResult<T, 4> MultiplicationQuantizeTestHelper( |
| 7117 | armnn::IWorkloadFactory& workloadFactory, |
| 7118 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7119 | const unsigned int shape0[4], |
| 7120 | const std::vector<T> & values0, |
| 7121 | float scale0, |
| 7122 | int32_t offset0, |
| 7123 | const unsigned int shape1[4], |
| 7124 | const std::vector<T> & values1, |
| 7125 | float scale1, |
| 7126 | int32_t offset1, |
| 7127 | const unsigned int outShape[4], |
| 7128 | const std::vector<T> & outValues, |
| 7129 | float outScale, |
| 7130 | int32_t outOffset) |
| 7131 | { |
| 7132 | armnn::TensorInfo inputTensorInfo0(4, shape0, ArmnnType); |
| 7133 | armnn::TensorInfo inputTensorInfo1(4, shape1, ArmnnType); |
| 7134 | armnn::TensorInfo outputTensorInfo(4, outShape, ArmnnType); |
| 7135 | |
| 7136 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 7137 | inputTensorInfo0.SetQuantizationOffset(offset0); |
| 7138 | |
| 7139 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 7140 | inputTensorInfo1.SetQuantizationOffset(offset1); |
| 7141 | |
| 7142 | outputTensorInfo.SetQuantizationScale(outScale); |
| 7143 | outputTensorInfo.SetQuantizationOffset(outOffset); |
| 7144 | |
| 7145 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 7146 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
| 7147 | |
| 7148 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 7149 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7150 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7151 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7152 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7153 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7154 | |
| 7155 | armnn::MultiplicationQueueDescriptor data; |
| 7156 | armnn::WorkloadInfo info; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7157 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 7158 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7159 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 7160 | |
| 7161 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMultiplication(data, info); |
| 7162 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7163 | inputHandle0->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7164 | inputHandle1->Allocate(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7165 | outputHandle->Allocate(); |
| 7166 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7167 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7168 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7169 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7170 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7171 | workload->Execute(); |
| 7172 | |
| 7173 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7174 | |
| 7175 | return result; |
| 7176 | } |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7177 | } // anonymous namespace |
| 7178 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7179 | LayerTestResult<uint8_t, 4> MultiplicationUint8Test( |
| 7180 | armnn::IWorkloadFactory& workloadFactory, |
| 7181 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7182 | { |
| 7183 | unsigned int batchSize = 1; |
| 7184 | unsigned int channels = 2; |
| 7185 | unsigned int height = 2; |
| 7186 | unsigned int width = 3; |
| 7187 | const unsigned int shape[] = { batchSize, channels, height, width }; |
| 7188 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 7189 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7190 | std::vector<uint8_t> input0({ |
| 7191 | 62, 37, 3, 172, 13, 111, // 244, 144, 8, 684, 48, 440, |
| 7192 | 188, 20, 73, 31, 23, 31 // 748, 76, 288, 120, 88, 120 |
| 7193 | }); |
| 7194 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 7195 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7196 | std::vector<uint8_t> input1({ |
| 7197 | 126, 240, 252, 183, 121, 247, // 384, 726, 762, 555, 369, 747, |
| 7198 | 48, 115, 151, 79, 78, 97 // 150, 351, 459, 243, 240, 297 |
| 7199 | }); |
| 7200 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 7201 | // See dequantized values to the right. |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7202 | std::vector<uint8_t> output( |
| 7203 | { |
| 7204 | 64, 72, 0, 255, 8, 236, // 93696, 104544, 6096(clamped), 379620(clamped), 17712, 328680, |
| 7205 | 77, 15, 92, 16, 10, 21, // 112200, 26676, 132192, 29160, 21120, 35640 |
| 7206 | }); |
| 7207 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7208 | // Scale/offset chosen to have output values out of range. |
| 7209 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7210 | memoryManager, |
| 7211 | shape, |
| 7212 | input0, |
| 7213 | 4.0f, |
| 7214 | 1, |
| 7215 | shape, |
| 7216 | input1, |
| 7217 | 3.0f, |
| 7218 | -2, |
| 7219 | shape, |
| 7220 | output, |
| 7221 | 1366.255f, |
| 7222 | -5); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7223 | } |
| 7224 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7225 | LayerTestResult<uint8_t, 4> MultiplicationBroadcast1ElementUint8Test( |
| 7226 | armnn::IWorkloadFactory& workloadFactory, |
| 7227 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7228 | { |
| 7229 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7230 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 7231 | |
| 7232 | std::vector<uint8_t> input0({ |
| 7233 | 1, 2, 3, 4, 5, 6, |
| 7234 | 7, 8, 9, 10, 11, 12 |
| 7235 | }); |
| 7236 | |
| 7237 | std::vector<uint8_t> input1({2}); |
| 7238 | |
| 7239 | std::vector<uint8_t> output({ |
| 7240 | 2, 4, 6, 8, 10, 12, |
| 7241 | 14, 16, 18, 20, 22, 24 |
| 7242 | }); |
| 7243 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7244 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7245 | memoryManager, |
| 7246 | shape0, |
| 7247 | input0, |
| 7248 | 1.0f, |
| 7249 | 0, |
| 7250 | shape1, |
| 7251 | input1, |
| 7252 | 1.0f, |
| 7253 | 0, |
| 7254 | shape0, |
| 7255 | output, |
| 7256 | 1.0f, |
| 7257 | 0); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7258 | } |
| 7259 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7260 | LayerTestResult<uint8_t, 4> MultiplicationBroadcast1DVectorUint8Test( |
| 7261 | armnn::IWorkloadFactory& workloadFactory, |
| 7262 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7263 | { |
| 7264 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7265 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 7266 | |
| 7267 | std::vector<uint8_t> input0({ |
| 7268 | 1, 2, 3, 4, 5, 6, |
| 7269 | 7, 8, 9, 10, 11, 12 |
| 7270 | }); |
| 7271 | |
| 7272 | std::vector<uint8_t> input1({1, 2, 3}); |
| 7273 | |
| 7274 | std::vector<uint8_t> output({ |
| 7275 | 1, 4, 9, 4, 10, 18, |
| 7276 | 7, 16, 27, 10, 22, 36 |
| 7277 | }); |
| 7278 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7279 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7280 | memoryManager, |
| 7281 | shape0, |
| 7282 | input0, |
| 7283 | 1.0f, |
| 7284 | 0, |
| 7285 | shape1, |
| 7286 | input1, |
| 7287 | 1.0f, |
| 7288 | 0, |
| 7289 | shape0, |
| 7290 | output, |
| 7291 | 1.0f, |
| 7292 | 0); |
| 7293 | } |
| 7294 | |
| 7295 | LayerTestResult<int16_t, 4> MultiplicationInt16Test( |
| 7296 | armnn::IWorkloadFactory& workloadFactory, |
| 7297 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7298 | { |
| 7299 | const unsigned int shape[] = { 1, 2, 2, 3 }; |
| 7300 | |
| 7301 | std::vector<int16_t> input0( |
| 7302 | { |
| 7303 | 6, 7, 8, 9, 10, 11, |
| 7304 | 12, 13, 14, 15, 16, 17 |
| 7305 | }); |
| 7306 | |
| 7307 | std::vector<int16_t> input1( |
| 7308 | { |
| 7309 | 1, 2, 3, 4, 5, 6, |
| 7310 | 7, 8, 9, 10, 11, 12 |
| 7311 | }); |
| 7312 | |
| 7313 | std::vector<int16_t> output( |
| 7314 | { |
| 7315 | 6, 14, 24, 36, 50, 66, |
| 7316 | 84, 104, 126, 150, 176, 204 |
| 7317 | }); |
| 7318 | |
| 7319 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7320 | memoryManager, |
| 7321 | shape, |
| 7322 | input0, |
| 7323 | 1.0f, |
| 7324 | 0, |
| 7325 | shape, |
| 7326 | input1, |
| 7327 | 1.0f, |
| 7328 | 0, |
| 7329 | shape, |
| 7330 | output, |
| 7331 | 1.0f, |
| 7332 | 0); |
| 7333 | } |
| 7334 | |
| 7335 | LayerTestResult<int16_t, 4> MultiplicationBroadcast1ElementInt16Test( |
| 7336 | armnn::IWorkloadFactory& workloadFactory, |
| 7337 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7338 | { |
| 7339 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7340 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 7341 | |
| 7342 | std::vector<int16_t> input0( |
| 7343 | { |
| 7344 | 1, 2, 3, 4, 5, 6, |
| 7345 | 7, 8, 9, 10, 11, 12 |
| 7346 | }); |
| 7347 | |
| 7348 | std::vector<int16_t> input1({2}); |
| 7349 | |
| 7350 | std::vector<int16_t> output( |
| 7351 | { |
| 7352 | 2, 4, 6, 8, 10, 12, |
| 7353 | 14, 16, 18, 20, 22, 24 |
| 7354 | }); |
| 7355 | |
| 7356 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7357 | memoryManager, |
| 7358 | shape0, |
| 7359 | input0, |
| 7360 | 1.0f, |
| 7361 | 0, |
| 7362 | shape1, |
| 7363 | input1, |
| 7364 | 1.0f, |
| 7365 | 0, |
| 7366 | shape0, |
| 7367 | output, |
| 7368 | 1.0f, |
| 7369 | 0); |
| 7370 | } |
| 7371 | |
| 7372 | LayerTestResult<int16_t, 4> MultiplicationBroadcast1DVectorInt16Test( |
| 7373 | armnn::IWorkloadFactory& workloadFactory, |
| 7374 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7375 | { |
| 7376 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 7377 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 7378 | |
| 7379 | std::vector<int16_t> input0( |
| 7380 | { |
| 7381 | 1, 2, 3, 4, 5, 6, |
| 7382 | 7, 8, 9, 10, 11, 12 |
| 7383 | }); |
| 7384 | |
| 7385 | std::vector<int16_t> input1({1, 2, 3}); |
| 7386 | |
| 7387 | std::vector<int16_t> output( |
| 7388 | { |
| 7389 | 1, 4, 9, 4, 10, 18, |
| 7390 | 7, 16, 27, 10, 22, 36 |
| 7391 | }); |
| 7392 | |
| 7393 | return MultiplicationQuantizeTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7394 | memoryManager, |
| 7395 | shape0, |
| 7396 | input0, |
| 7397 | 1.0f, |
| 7398 | 0, |
| 7399 | shape1, |
| 7400 | input1, |
| 7401 | 1.0f, |
| 7402 | 0, |
| 7403 | shape0, |
| 7404 | output, |
| 7405 | 1.0f, |
| 7406 | 0); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 7407 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7408 | |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7409 | namespace |
| 7410 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7411 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7412 | LayerTestResult<T, 4> SubtractionTestHelper( |
| 7413 | armnn::IWorkloadFactory& workloadFactory, |
| 7414 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 7415 | const unsigned int shape0[4], |
| 7416 | const std::vector<T>& values0, |
| 7417 | float scale0, |
| 7418 | int32_t offset0, |
| 7419 | const unsigned int shape1[4], |
| 7420 | const std::vector<T> & values1, |
| 7421 | float scale1, |
| 7422 | int32_t offset1, |
| 7423 | const unsigned int outShape[4], |
| 7424 | const std::vector<T> & outValues, |
| 7425 | float outScale, |
| 7426 | int32_t outOffset) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7427 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7428 | armnn::TensorInfo inputTensorInfo0(4, shape0, ArmnnType); |
| 7429 | armnn::TensorInfo inputTensorInfo1(4, shape1, ArmnnType); |
| 7430 | armnn::TensorInfo outputTensorInfo(4, outShape, ArmnnType); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7431 | |
| 7432 | inputTensorInfo0.SetQuantizationScale(scale0); |
| 7433 | inputTensorInfo0.SetQuantizationOffset(offset0); |
| 7434 | |
| 7435 | inputTensorInfo1.SetQuantizationScale(scale1); |
| 7436 | inputTensorInfo1.SetQuantizationOffset(offset1); |
| 7437 | |
| 7438 | outputTensorInfo.SetQuantizationScale(outScale); |
| 7439 | outputTensorInfo.SetQuantizationOffset(outOffset); |
| 7440 | |
| 7441 | auto input0 = MakeTensor<T, 4>(inputTensorInfo0, values0); |
| 7442 | auto input1 = MakeTensor<T, 4>(inputTensorInfo1, values1); |
| 7443 | |
| 7444 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 7445 | result.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outValues); |
| 7446 | |
| 7447 | std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0); |
| 7448 | std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1); |
| 7449 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7450 | |
| 7451 | armnn::SubtractionQueueDescriptor data; |
| 7452 | armnn::WorkloadInfo info; |
| 7453 | AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get()); |
| 7454 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 7455 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 7456 | |
| 7457 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateSubtraction(data, info); |
| 7458 | |
| 7459 | inputHandle0->Allocate(); |
| 7460 | inputHandle1->Allocate(); |
| 7461 | outputHandle->Allocate(); |
| 7462 | |
| 7463 | CopyDataToITensorHandle(inputHandle0.get(), &input0[0][0][0][0]); |
| 7464 | CopyDataToITensorHandle(inputHandle1.get(), &input1[0][0][0][0]); |
| 7465 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7466 | workload->PostAllocationConfigure(); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7467 | workload->Execute(); |
| 7468 | |
| 7469 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7470 | |
| 7471 | return result; |
| 7472 | } |
| 7473 | } // anonymous namespace |
| 7474 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7475 | LayerTestResult<uint8_t, 4> SubtractionUint8Test( |
| 7476 | armnn::IWorkloadFactory& workloadFactory, |
| 7477 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7478 | { |
| 7479 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7480 | const unsigned int shape1[] = { 1, 1, 2, 2 }; |
| 7481 | |
| 7482 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 7483 | std::vector<uint8_t> input1({ 1, 2, 1, 2 }); |
| 7484 | std::vector<uint8_t> output({ 3, 3, 5, 5 }); |
| 7485 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7486 | return SubtractionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7487 | memoryManager, |
| 7488 | shape0, input0, 0.5f, 2, |
| 7489 | shape1, input1, 1.0f, 0, |
| 7490 | shape0, output, 1.0f, 0); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7491 | } |
| 7492 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7493 | LayerTestResult<uint8_t, 4> SubtractionBroadcast1ElementUint8Test( |
| 7494 | armnn::IWorkloadFactory& workloadFactory, |
| 7495 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7496 | { |
| 7497 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7498 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 7499 | |
| 7500 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 7501 | std::vector<uint8_t> input1({ 2 }); |
| 7502 | std::vector<uint8_t> output({ 5, 6, 7, 8 }); |
| 7503 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7504 | return SubtractionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7505 | memoryManager, |
| 7506 | shape0, input0, 0.5f, 2, |
| 7507 | shape1, input1, 1.0f, 0, |
| 7508 | shape0, output, 1.0f, 3); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7509 | } |
| 7510 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7511 | LayerTestResult<uint8_t, 4> SubtractionBroadcastUint8Test( |
| 7512 | armnn::IWorkloadFactory& workloadFactory, |
| 7513 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7514 | { |
| 7515 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7516 | const unsigned int shape1[] = { 1, 1, 2, 1 }; |
| 7517 | |
| 7518 | std::vector<uint8_t> input0({ 10, 12, 14, 16 }); |
| 7519 | std::vector<uint8_t> input1({ 2, 1 }); |
| 7520 | std::vector<uint8_t> output({ 8, 11, 12, 15 }); |
| 7521 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7522 | return SubtractionTestHelper<armnn::DataType::QuantisedAsymm8>(workloadFactory, |
| 7523 | memoryManager, |
| 7524 | shape0, input0, 1.0f, 0, |
| 7525 | shape1, input1, 1.0f, 0, |
| 7526 | shape0, output, 1.0f, 0); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7527 | } |
| 7528 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7529 | LayerTestResult<float, 4> SubtractionTest( |
| 7530 | armnn::IWorkloadFactory& workloadFactory, |
| 7531 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7532 | { |
| 7533 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7534 | const unsigned int shape1[] = { 1, 1, 2, 2 }; |
| 7535 | |
| 7536 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 7537 | std::vector<float> input1({ 1, -1, 0, 2 }); |
| 7538 | std::vector<float> output({ 0, 3, 3, 2 }); |
| 7539 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7540 | return SubtractionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 7541 | memoryManager, |
| 7542 | shape0, input0, 1.0f, 0, |
| 7543 | shape1, input1, 1.0f, 0, |
| 7544 | shape0, output, 1.0f, 0); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7545 | } |
| 7546 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7547 | LayerTestResult<float, 4> SubtractionBroadcast1ElementTest( |
| 7548 | armnn::IWorkloadFactory& workloadFactory, |
| 7549 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7550 | { |
| 7551 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7552 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 7553 | |
| 7554 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 7555 | std::vector<float> input1({ 10 }); |
| 7556 | std::vector<float> output({ -9, -8, -7, -6 }); |
| 7557 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7558 | return SubtractionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 7559 | memoryManager, |
| 7560 | shape0, input0, 1.0f, 0, |
| 7561 | shape1, input1, 1.0f, 0, |
| 7562 | shape0, output, 1.0f, 0); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7563 | } |
| 7564 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7565 | LayerTestResult<float, 4> SubtractionBroadcastTest( |
| 7566 | armnn::IWorkloadFactory& workloadFactory, |
| 7567 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7568 | { |
| 7569 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7570 | const unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 7571 | |
| 7572 | std::vector<float> input0({ 1, 2, 3, 4 }); |
| 7573 | std::vector<float> input1({ 10, -5 }); |
| 7574 | std::vector<float> output({ -9, 7, -7, 9 }); |
| 7575 | |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 7576 | return SubtractionTestHelper<armnn::DataType::Float32>(workloadFactory, |
| 7577 | memoryManager, |
| 7578 | shape0, input0, 1.0f, 0, |
| 7579 | shape1, input1, 1.0f, 0, |
| 7580 | shape0, output, 1.0f, 0); |
| 7581 | } |
| 7582 | |
| 7583 | LayerTestResult<int16_t, 4> SubtractionInt16Test( |
| 7584 | armnn::IWorkloadFactory& workloadFactory, |
| 7585 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7586 | { |
| 7587 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7588 | const unsigned int shape1[] = { 1, 1, 2, 2 }; |
| 7589 | |
| 7590 | std::vector<int16_t> input0({ 10, 12, 14, 16 }); |
| 7591 | std::vector<int16_t> input1({ 1, 2, 1, 2 }); |
| 7592 | std::vector<int16_t> output({ 3, 3, 5, 5 }); |
| 7593 | |
| 7594 | return SubtractionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7595 | memoryManager, |
| 7596 | shape0, input0, 0.5f, 0, |
| 7597 | shape1, input1, 1.0f, 0, |
| 7598 | shape0, output, 1.0f, 0); |
| 7599 | } |
| 7600 | |
| 7601 | LayerTestResult<int16_t, 4> SubtractionBroadcast1ElementInt16Test( |
| 7602 | armnn::IWorkloadFactory& workloadFactory, |
| 7603 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7604 | { |
| 7605 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7606 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 7607 | |
| 7608 | std::vector<int16_t> input0({ 10, 12, 14, 16 }); |
| 7609 | std::vector<int16_t> input1({ 2 }); |
| 7610 | std::vector<int16_t> output({ 3, 4, 5, 6 }); |
| 7611 | |
| 7612 | return SubtractionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7613 | memoryManager, |
| 7614 | shape0, input0, 0.5f, 0, |
| 7615 | shape1, input1, 1.0f, 0, |
| 7616 | shape0, output, 1.0f, 0); |
| 7617 | } |
| 7618 | |
| 7619 | LayerTestResult<int16_t, 4> SubtractionBroadcastInt16Test( |
| 7620 | armnn::IWorkloadFactory& workloadFactory, |
| 7621 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 7622 | { |
| 7623 | const unsigned int shape0[] = { 1, 1, 2, 2 }; |
| 7624 | const unsigned int shape1[] = { 1, 1, 2, 1 }; |
| 7625 | |
| 7626 | std::vector<int16_t> input0({ 10, 12, 14, 16 }); |
| 7627 | std::vector<int16_t> input1({ 2, 1 }); |
| 7628 | std::vector<int16_t> output({ 8, 11, 12, 15 }); |
| 7629 | |
| 7630 | return SubtractionTestHelper<armnn::DataType::QuantisedSymm16>(workloadFactory, |
| 7631 | memoryManager, |
| 7632 | shape0, input0, 1.0f, 0, |
| 7633 | shape1, input1, 1.0f, 0, |
| 7634 | shape0, output, 1.0f, 0); |
David Beck | f195f03 | 2018-09-06 16:46:34 +0100 | [diff] [blame] | 7635 | } |
| 7636 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7637 | LayerTestResult<uint8_t, 4> ResizeBilinearNopUint8Test( |
| 7638 | armnn::IWorkloadFactory& workloadFactory, |
| 7639 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7640 | { |
| 7641 | constexpr unsigned int inputWidth = 4; |
| 7642 | constexpr unsigned int inputHeight = 4; |
| 7643 | constexpr unsigned int inputChannels = 1; |
| 7644 | constexpr unsigned int inputBatchSize = 1; |
| 7645 | |
| 7646 | constexpr unsigned int outputWidth = inputWidth; |
| 7647 | constexpr unsigned int outputHeight = inputHeight; |
| 7648 | constexpr unsigned int outputChannels = inputChannels; |
| 7649 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 7650 | |
| 7651 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 7652 | armnn::DataType::QuantisedAsymm8); |
| 7653 | inputTensorInfo.SetQuantizationScale(1.5f); |
| 7654 | inputTensorInfo.SetQuantizationOffset(-3); |
| 7655 | |
| 7656 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 7657 | armnn::DataType::QuantisedAsymm8); |
| 7658 | outputTensorInfo.SetQuantizationScale(1.5f); |
| 7659 | outputTensorInfo.SetQuantizationOffset(-3); |
| 7660 | |
| 7661 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 7662 | 1, 2, 3, 4, |
| 7663 | 2, 3, 4, 5, |
| 7664 | 3, 4, 5, 6, |
| 7665 | 4, 5, 6, 7 |
| 7666 | })); |
| 7667 | |
| 7668 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 7669 | result.outputExpected = input; |
| 7670 | |
| 7671 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7672 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7673 | |
| 7674 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 7675 | armnn::WorkloadInfo info; |
| 7676 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 7677 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 7678 | |
| 7679 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 7680 | |
| 7681 | inputHandle->Allocate(); |
| 7682 | outputHandle->Allocate(); |
| 7683 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 7684 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7685 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7686 | workload->Execute(); |
| 7687 | |
| 7688 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7689 | return result; |
| 7690 | } |
| 7691 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7692 | LayerTestResult<uint8_t, 4> SimpleResizeBilinearUint8Test( |
| 7693 | armnn::IWorkloadFactory& workloadFactory, |
| 7694 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7695 | { |
| 7696 | constexpr unsigned int inputWidth = 2; |
| 7697 | constexpr unsigned int inputHeight = 2; |
| 7698 | constexpr unsigned int inputChannels = 1; |
| 7699 | constexpr unsigned int inputBatchSize = 1; |
| 7700 | |
| 7701 | constexpr unsigned int outputWidth = inputWidth / 2; |
| 7702 | constexpr unsigned int outputHeight = inputHeight / 2; |
| 7703 | constexpr unsigned int outputChannels = inputChannels; |
| 7704 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 7705 | |
| 7706 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 7707 | armnn::DataType::QuantisedAsymm8); |
| 7708 | inputTensorInfo.SetQuantizationScale(0.1567f); |
| 7709 | inputTensorInfo.SetQuantizationOffset(1); |
| 7710 | |
| 7711 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 7712 | armnn::DataType::QuantisedAsymm8); |
| 7713 | outputTensorInfo.SetQuantizationScale(0.1567f); |
| 7714 | outputTensorInfo.SetQuantizationOffset(1); |
| 7715 | |
| 7716 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 7717 | 1, 255, |
| 7718 | 200, 250 |
| 7719 | })); |
| 7720 | |
| 7721 | // The 'resize bilinear' operation projects the top-left corner of output texels into the input image, |
| 7722 | // 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] | 7723 | // 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] | 7724 | // that was at position (0,0) of the input matrix (rather than an average, which we would expect if projecting |
| 7725 | // the centre). |
| 7726 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 7727 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 7728 | 1 |
| 7729 | })); |
| 7730 | |
| 7731 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7732 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7733 | |
| 7734 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 7735 | armnn::WorkloadInfo info; |
| 7736 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 7737 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 7738 | |
| 7739 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 7740 | |
| 7741 | inputHandle->Allocate(); |
| 7742 | outputHandle->Allocate(); |
| 7743 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 7744 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7745 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7746 | workload->Execute(); |
| 7747 | |
| 7748 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7749 | return result; |
| 7750 | } |
| 7751 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7752 | LayerTestResult<uint8_t, 4> ResizeBilinearSqMinUint8Test( |
| 7753 | armnn::IWorkloadFactory& workloadFactory, |
| 7754 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7755 | { |
| 7756 | constexpr unsigned int inputWidth = 4; |
| 7757 | constexpr unsigned int inputHeight = 4; |
| 7758 | constexpr unsigned int inputChannels = 1; |
| 7759 | constexpr unsigned int inputBatchSize = 1; |
| 7760 | |
| 7761 | constexpr unsigned int outputWidth = inputWidth / 2; |
| 7762 | constexpr unsigned int outputHeight = inputHeight / 2; |
| 7763 | constexpr unsigned int outputChannels = inputChannels; |
| 7764 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 7765 | |
| 7766 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 7767 | armnn::DataType::QuantisedAsymm8); |
| 7768 | inputTensorInfo.SetQuantizationScale(3.141592f); |
| 7769 | inputTensorInfo.SetQuantizationOffset(3); |
| 7770 | |
| 7771 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 7772 | armnn::DataType::QuantisedAsymm8); |
| 7773 | outputTensorInfo.SetQuantizationScale(3.141592f); |
| 7774 | outputTensorInfo.SetQuantizationOffset(3); |
| 7775 | |
| 7776 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 7777 | 1, 2, 3, 4, |
| 7778 | 2, 3, 4, 5, |
| 7779 | 3, 4, 5, 6, |
| 7780 | 4, 5, 6, 7 |
| 7781 | })); |
| 7782 | |
| 7783 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 7784 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 7785 | 1, 3, |
| 7786 | 3, 5 |
| 7787 | })); |
| 7788 | |
| 7789 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7790 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7791 | |
| 7792 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 7793 | armnn::WorkloadInfo info; |
| 7794 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 7795 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 7796 | |
| 7797 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 7798 | |
| 7799 | inputHandle->Allocate(); |
| 7800 | outputHandle->Allocate(); |
| 7801 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 7802 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7803 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7804 | workload->Execute(); |
| 7805 | |
| 7806 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7807 | return result; |
| 7808 | } |
| 7809 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7810 | LayerTestResult<uint8_t, 4> ResizeBilinearMinUint8Test( |
| 7811 | armnn::IWorkloadFactory& workloadFactory, |
| 7812 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7813 | { |
| 7814 | constexpr unsigned int inputWidth = 3; |
| 7815 | constexpr unsigned int inputHeight = 2; |
| 7816 | constexpr unsigned int inputChannels = 1; |
| 7817 | constexpr unsigned int inputBatchSize = 1; |
| 7818 | |
| 7819 | constexpr unsigned int outputWidth = 2; |
| 7820 | constexpr unsigned int outputHeight = 1; |
| 7821 | constexpr unsigned int outputChannels = inputChannels; |
| 7822 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 7823 | |
| 7824 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 7825 | armnn::DataType::QuantisedAsymm8); |
| 7826 | inputTensorInfo.SetQuantizationScale(1.5f); |
| 7827 | inputTensorInfo.SetQuantizationOffset(-1); |
| 7828 | |
| 7829 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 7830 | armnn::DataType::QuantisedAsymm8); |
| 7831 | outputTensorInfo.SetQuantizationScale(1.5f); |
| 7832 | outputTensorInfo.SetQuantizationOffset(-1); |
| 7833 | |
| 7834 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 7835 | 1, 2, 3, // 3.0, 4.5, 6.0 |
| 7836 | 5, 8, 13 // 9.0, 13.5, 21.0 |
| 7837 | })); |
| 7838 | |
| 7839 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 7840 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 7841 | 1, 3 // 3.0, 5.25 |
| 7842 | })); |
| 7843 | |
| 7844 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7845 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7846 | |
| 7847 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 7848 | armnn::WorkloadInfo info; |
| 7849 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 7850 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 7851 | |
| 7852 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 7853 | |
| 7854 | inputHandle->Allocate(); |
| 7855 | outputHandle->Allocate(); |
| 7856 | |
| 7857 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 7858 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7859 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7860 | workload->Execute(); |
| 7861 | |
| 7862 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7863 | return result; |
| 7864 | } |
| 7865 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7866 | LayerTestResult<uint8_t, 4> ResizeBilinearMagUint8Test( |
| 7867 | armnn::IWorkloadFactory& workloadFactory, |
| 7868 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7869 | { |
| 7870 | constexpr unsigned int inputWidth = 2; |
| 7871 | constexpr unsigned int inputHeight = 3; |
| 7872 | constexpr unsigned int inputChannels = 1; |
| 7873 | constexpr unsigned int inputBatchSize = 1; |
| 7874 | |
| 7875 | constexpr unsigned int outputWidth = 5; |
| 7876 | constexpr unsigned int outputHeight = 3; |
| 7877 | constexpr unsigned int outputChannels = inputChannels; |
| 7878 | constexpr unsigned int outputBatchSize = inputBatchSize; |
| 7879 | |
| 7880 | armnn::TensorInfo inputTensorInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, |
| 7881 | armnn::DataType::QuantisedAsymm8); |
| 7882 | inputTensorInfo.SetQuantizationScale(0.010765f); |
| 7883 | inputTensorInfo.SetQuantizationOffset(7); |
| 7884 | |
| 7885 | armnn::TensorInfo outputTensorInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, |
| 7886 | armnn::DataType::QuantisedAsymm8); |
| 7887 | outputTensorInfo.SetQuantizationScale(0.010132f); |
| 7888 | outputTensorInfo.SetQuantizationOffset(-18); |
| 7889 | |
| 7890 | auto input = MakeTensor<uint8_t, 4>(inputTensorInfo, std::vector<uint8_t>({ |
| 7891 | 24, 228, // 0.183005, 2.379065, |
| 7892 | 105, 128, // 1.05497, 1.302565 |
| 7893 | 230, 71 // 2.400595, 0.68896 |
| 7894 | })); |
| 7895 | |
| 7896 | LayerTestResult<uint8_t, 4> result(outputTensorInfo); |
| 7897 | result.outputExpected = MakeTensor<uint8_t, 4>(outputTensorInfo, std::vector<uint8_t>({ |
| 7898 | 0, 87, 173, 217, 217, // 0.18300501, 1.06142902, 1.93985295, 2.37906504, 2.37906504 |
| 7899 | 86, 96, 106, 111, 111, // 1.05497003, 1.15400803, 1.25304604, 1.30256498, 1.30256498 |
| 7900 | 219, 151, 84, 50, 50 // 2.40059495, 1.71594095, 1.03128707, 0.68896002, 0.68896002 |
| 7901 | })); |
| 7902 | |
| 7903 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 7904 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 7905 | |
| 7906 | armnn::ResizeBilinearQueueDescriptor descriptor; |
| 7907 | armnn::WorkloadInfo info; |
| 7908 | AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get()); |
| 7909 | AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get()); |
| 7910 | |
| 7911 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateResizeBilinear(descriptor, info); |
| 7912 | |
| 7913 | inputHandle->Allocate(); |
| 7914 | outputHandle->Allocate(); |
| 7915 | CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); |
| 7916 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 7917 | workload->PostAllocationConfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7918 | workload->Execute(); |
| 7919 | |
| 7920 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 7921 | return result; |
| 7922 | } |
| 7923 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7924 | LayerTestResult<float, 4> BatchNormTest( |
| 7925 | armnn::IWorkloadFactory& workloadFactory, |
| 7926 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7927 | { |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 7928 | // BatchSize: 1 |
| 7929 | // Channels: 2 |
| 7930 | // Height: 3 |
| 7931 | // Width: 2 |
| 7932 | |
| 7933 | const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; |
| 7934 | std::vector<float> inputValues |
| 7935 | { |
| 7936 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 7937 | 1.f, 4.f, |
| 7938 | 4.f, 2.f, |
| 7939 | 1.f, 6.f, |
| 7940 | |
| 7941 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 7942 | 1.f, 1.f, |
| 7943 | 4.f, 1.f, |
| 7944 | -2.f, 4.f |
| 7945 | }; |
| 7946 | std::vector<float> expectedOutputValues |
| 7947 | { |
| 7948 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 7949 | 1.f, 4.f, |
| 7950 | 4.f, 2.f, |
| 7951 | 1.f, 6.f, |
| 7952 | |
| 7953 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 7954 | 3.f, 3.f, |
| 7955 | 4.f, 3.f, |
| 7956 | 2.f, 4.f |
| 7957 | }; |
| 7958 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 7959 | return BatchNormTestImpl<armnn::DataType::Float32>( |
| 7960 | workloadFactory, memoryManager, |
| 7961 | inputOutputShape, inputValues, expectedOutputValues, |
| 7962 | 0.f, 0, armnn::DataLayout::NCHW); |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 7963 | } |
| 7964 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 7965 | LayerTestResult<float, 4> BatchNormNhwcTest( |
| 7966 | armnn::IWorkloadFactory& workloadFactory, |
| 7967 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 7968 | { |
| 7969 | // BatchSize: 1 |
| 7970 | // Height: 3 |
| 7971 | // Width: 2 |
| 7972 | // Channels: 2 |
| 7973 | |
| 7974 | const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; |
| 7975 | std::vector<float> inputValues |
| 7976 | { |
| 7977 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 7978 | 1.f, 1.f, |
| 7979 | 4.f, 1.f, |
| 7980 | |
| 7981 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 7982 | 4.f, 4.f, |
| 7983 | 2.f, 1.f, |
| 7984 | |
| 7985 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 7986 | 1.f, -2.f, |
| 7987 | 6.f, 4.f |
| 7988 | }; |
| 7989 | std::vector<float> expectedOutputValues |
| 7990 | { |
| 7991 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 7992 | 1.f, 3.f, |
| 7993 | 4.f, 3.f, |
| 7994 | |
| 7995 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 7996 | 4.f, 4.f, |
| 7997 | 2.f, 3.f, |
| 7998 | |
| 7999 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 8000 | 1.f, 2.f, |
| 8001 | 6.f, 4.f |
| 8002 | }; |
| 8003 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8004 | return BatchNormTestImpl<armnn::DataType::Float32>( |
| 8005 | workloadFactory, memoryManager, |
| 8006 | inputOutputShape, inputValues, expectedOutputValues, |
| 8007 | 0.f, 0, armnn::DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8008 | } |
| 8009 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8010 | LayerTestResult<uint8_t, 4> BatchNormUint8Test( |
| 8011 | armnn::IWorkloadFactory& workloadFactory, |
| 8012 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8013 | { |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 8014 | // BatchSize: 1 |
| 8015 | // Channels: 2 |
| 8016 | // Height: 3 |
| 8017 | // Width: 2 |
| 8018 | |
| 8019 | const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; |
| 8020 | std::vector<float> inputValues |
| 8021 | { |
| 8022 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 8023 | 1.f, 4.f, |
| 8024 | 4.f, 2.f, |
| 8025 | 1.f, 6.f, |
| 8026 | |
| 8027 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 8028 | 1.f, 1.f, |
| 8029 | 4.f, 1.f, |
| 8030 | -2.f, 4.f |
| 8031 | }; |
| 8032 | std::vector<float> expectedOutputValues |
| 8033 | { |
| 8034 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 8035 | 1.f, 4.f, |
| 8036 | 4.f, 2.f, |
| 8037 | 1.f, 6.f, |
| 8038 | |
| 8039 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 8040 | 3.f, 3.f, |
| 8041 | 4.f, 3.f, |
| 8042 | 2.f, 4.f |
| 8043 | }; |
| 8044 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8045 | return BatchNormTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8046 | workloadFactory, memoryManager, |
| 8047 | inputOutputShape, inputValues, expectedOutputValues, |
| 8048 | 1.f/20.f, 50, armnn::DataLayout::NCHW); |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 8049 | } |
| 8050 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8051 | LayerTestResult<uint8_t, 4> BatchNormUint8NhwcTest( |
| 8052 | armnn::IWorkloadFactory& workloadFactory, |
| 8053 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 8eb675e | 2018-10-17 14:43:29 +0100 | [diff] [blame] | 8054 | { |
| 8055 | // BatchSize: 1 |
| 8056 | // Height: 3 |
| 8057 | // Width: 2 |
| 8058 | // Channels: 2 |
| 8059 | |
| 8060 | const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; |
| 8061 | std::vector<float> inputValues |
| 8062 | { |
| 8063 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 8064 | 1.f, 1.f, |
| 8065 | 4.f, 1.f, |
| 8066 | |
| 8067 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 8068 | 4.f, 4.f, |
| 8069 | 2.f, 1.f, |
| 8070 | |
| 8071 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 8072 | 1.f, -2.f, |
| 8073 | 6.f, 4.f |
| 8074 | }; |
| 8075 | std::vector<float> expectedOutputValues |
| 8076 | { |
| 8077 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 8078 | 1.f, 3.f, |
| 8079 | 4.f, 3.f, |
| 8080 | |
| 8081 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 8082 | 4.f, 4.f, |
| 8083 | 2.f, 3.f, |
| 8084 | |
| 8085 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 8086 | 1.f, 2.f, |
| 8087 | 6.f, 4.f |
| 8088 | }; |
| 8089 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8090 | return BatchNormTestImpl<armnn::DataType::QuantisedAsymm8> |
| 8091 | (workloadFactory, memoryManager, |
| 8092 | inputOutputShape, inputValues, expectedOutputValues, |
| 8093 | 1.f/20.f, 50, armnn::DataLayout::NHWC); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8094 | } |
| 8095 | |
Matteo Martincigh | f550713 | 2019-06-04 10:59:47 +0100 | [diff] [blame] | 8096 | LayerTestResult<int16_t, 4> BatchNormInt16Test( |
| 8097 | armnn::IWorkloadFactory& workloadFactory, |
| 8098 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8099 | { |
| 8100 | // BatchSize: 1 |
| 8101 | // Channels: 2 |
| 8102 | // Height: 3 |
| 8103 | // Width: 2 |
| 8104 | |
| 8105 | const armnn::TensorShape inputOutputShape{ 1, 2, 3, 2 }; |
| 8106 | std::vector<float> inputValues |
| 8107 | { |
| 8108 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 8109 | 1.f, 4.f, |
| 8110 | 4.f, 2.f, |
| 8111 | 1.f, 6.f, |
| 8112 | |
| 8113 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 8114 | 1.f, 1.f, |
| 8115 | 4.f, 1.f, |
| 8116 | -2.f, 4.f |
| 8117 | }; |
| 8118 | std::vector<float> expectedOutputValues |
| 8119 | { |
| 8120 | // Batch 0, Channel 0, Height (3) x Width (2) |
| 8121 | 1.f, 4.f, |
| 8122 | 4.f, 2.f, |
| 8123 | 1.f, 6.f, |
| 8124 | |
| 8125 | // Batch 0, Channel 1, Height (3) x Width (2) |
| 8126 | 3.f, 3.f, |
| 8127 | 4.f, 3.f, |
| 8128 | 2.f, 4.f |
| 8129 | }; |
| 8130 | |
| 8131 | return BatchNormTestImpl<armnn::DataType::QuantisedSymm16>( |
| 8132 | workloadFactory, memoryManager, |
| 8133 | inputOutputShape, inputValues, expectedOutputValues, |
| 8134 | 1.f/20.f, 50, armnn::DataLayout::NCHW); |
| 8135 | } |
| 8136 | |
| 8137 | LayerTestResult<int16_t, 4> BatchNormInt16NhwcTest( |
| 8138 | armnn::IWorkloadFactory& workloadFactory, |
| 8139 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8140 | { |
| 8141 | // BatchSize: 1 |
| 8142 | // Height: 3 |
| 8143 | // Width: 2 |
| 8144 | // Channels: 2 |
| 8145 | |
| 8146 | const armnn::TensorShape inputOutputShape{ 1, 3, 2, 2 }; |
| 8147 | std::vector<float> inputValues |
| 8148 | { |
| 8149 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 8150 | 1.f, 1.f, |
| 8151 | 4.f, 1.f, |
| 8152 | |
| 8153 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 8154 | 4.f, 4.f, |
| 8155 | 2.f, 1.f, |
| 8156 | |
| 8157 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 8158 | 1.f, -2.f, |
| 8159 | 6.f, 4.f |
| 8160 | }; |
| 8161 | std::vector<float> expectedOutputValues |
| 8162 | { |
| 8163 | // Batch 0, Height 0, Width (2) x Channel (2) |
| 8164 | 1.f, 3.f, |
| 8165 | 4.f, 3.f, |
| 8166 | |
| 8167 | // Batch 0, Height 1, Width (2) x Channel (2) |
| 8168 | 4.f, 4.f, |
| 8169 | 2.f, 3.f, |
| 8170 | |
| 8171 | // Batch 0, Height 2, Width (2) x Channel (2) |
| 8172 | 1.f, 2.f, |
| 8173 | 6.f, 4.f |
| 8174 | }; |
| 8175 | |
| 8176 | return BatchNormTestImpl<armnn::DataType::QuantisedSymm16> |
| 8177 | (workloadFactory, memoryManager, |
| 8178 | inputOutputShape, inputValues, expectedOutputValues, |
| 8179 | 1.f/20.f, 50, armnn::DataLayout::NHWC); |
| 8180 | } |
| 8181 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 8182 | LayerTestResult<uint8_t, 4> ConstantUint8CustomQuantizationScaleAndOffsetTest( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8183 | armnn::IWorkloadFactory& workloadFactory, |
| 8184 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8185 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8186 | return ConstantTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 2e-6f, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8187 | } |
| 8188 | |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 8189 | LayerTestResult<int16_t, 4> ConstantInt16CustomQuantizationScaleAndOffsetTest( |
| 8190 | armnn::IWorkloadFactory& workloadFactory, |
| 8191 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8192 | { |
| 8193 | return ConstantTestImpl<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager, 2e-6f, 1); |
| 8194 | } |
| 8195 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8196 | LayerTestResult<uint8_t, 1> Concatenation1dUint8Test( |
| 8197 | armnn::IWorkloadFactory& workloadFactory, |
| 8198 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8199 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8200 | return Concatenation1dTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8201 | } |
| 8202 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8203 | LayerTestResult<uint8_t, 2> Concatenation2dDim0Uint8Test( |
| 8204 | armnn::IWorkloadFactory& workloadFactory, |
| 8205 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8206 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8207 | return Concatenation2dDim0TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8208 | } |
| 8209 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8210 | LayerTestResult<uint8_t, 2> Concatenation2dDim1Uint8Test( |
| 8211 | armnn::IWorkloadFactory& workloadFactory, |
| 8212 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8213 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8214 | return Concatenation2dDim1TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8215 | } |
| 8216 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8217 | LayerTestResult<uint8_t, 2> Concatenation2dDim0DiffInputDimsUint8Test( |
| 8218 | armnn::IWorkloadFactory& workloadFactory, |
| 8219 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8220 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8221 | return Concatenation2dDim0DiffInputDimsTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8222 | workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8223 | } |
| 8224 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8225 | LayerTestResult<uint8_t, 2> Concatenation2dDim1DiffInputDimsUint8Test( |
| 8226 | armnn::IWorkloadFactory& workloadFactory, |
| 8227 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8228 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8229 | return Concatenation2dDim1DiffInputDimsTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8230 | workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8231 | } |
| 8232 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8233 | LayerTestResult<uint8_t, 3> Concatenation3dDim0Uint8Test( |
| 8234 | armnn::IWorkloadFactory& workloadFactory, |
| 8235 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8236 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8237 | return Concatenation3dDim0TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8238 | } |
| 8239 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8240 | LayerTestResult<uint8_t, 3> Concatenation3dDim1Uint8Test( |
| 8241 | armnn::IWorkloadFactory& workloadFactory, |
| 8242 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8243 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8244 | return Concatenation3dDim1TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8245 | } |
| 8246 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8247 | LayerTestResult<uint8_t, 3> Concatenation3dDim2Uint8Test( |
| 8248 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8249 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8250 | bool useSubtensor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8251 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8252 | return Concatenation3dDim2TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8253 | workloadFactory, memoryManager, useSubtensor, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8254 | } |
| 8255 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8256 | LayerTestResult<uint8_t, 3> Concatenation3dDim0DiffInputDimsUint8Test( |
| 8257 | armnn::IWorkloadFactory& workloadFactory, |
| 8258 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8259 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8260 | return Concatenation3dDim0TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8261 | } |
| 8262 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8263 | LayerTestResult<uint8_t, 3> Concatenation3dDim1DiffInputDimsUint8Test( |
| 8264 | armnn::IWorkloadFactory& workloadFactory, |
| 8265 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8266 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8267 | return Concatenation3dDim1DiffInputDimsTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8268 | workloadFactory, memoryManager, 0.5f, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8269 | } |
| 8270 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8271 | LayerTestResult<uint8_t, 3> Concatenation3dDim2DiffInputDimsUint8Test( |
| 8272 | armnn::IWorkloadFactory& workloadFactory, |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8273 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8274 | bool useSubtensor) |
| 8275 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8276 | return Concatenation3dDim2DiffInputDimsTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8277 | workloadFactory, memoryManager, useSubtensor, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8278 | } |
| 8279 | |
| 8280 | LayerTestResult<uint8_t, 4> Concatenation4dDim0Uint8Test( |
| 8281 | armnn::IWorkloadFactory& workloadFactory, |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8282 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8283 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8284 | return Concatenation4dDim0TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8285 | } |
| 8286 | |
| 8287 | LayerTestResult<uint8_t, 4> Concatenation4dDim1Uint8Test( |
| 8288 | armnn::IWorkloadFactory& workloadFactory, |
| 8289 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8290 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8291 | return Concatenation4dDim1TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8292 | } |
| 8293 | |
| 8294 | LayerTestResult<uint8_t, 4> Concatenation4dDim2Uint8Test( |
| 8295 | armnn::IWorkloadFactory& workloadFactory, |
| 8296 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8297 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8298 | return Concatenation4dDim2TestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8299 | } |
| 8300 | |
| 8301 | LayerTestResult<uint8_t, 4> Concatenation4dDim3Uint8Test( |
| 8302 | armnn::IWorkloadFactory& workloadFactory, |
| 8303 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, bool useSubtensor) |
| 8304 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8305 | return Concatenation4dDim3TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8306 | workloadFactory, memoryManager, 0.5f, -1, useSubtensor); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8307 | } |
| 8308 | |
| 8309 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim0Uint8Test( |
| 8310 | armnn::IWorkloadFactory& workloadFactory, |
| 8311 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8312 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8313 | return Concatenation4dDiffShapeDim0TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8314 | workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8315 | } |
| 8316 | |
| 8317 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim1Uint8Test( |
| 8318 | armnn::IWorkloadFactory& workloadFactory, |
| 8319 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8320 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8321 | return Concatenation4dDiffShapeDim1TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8322 | workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8323 | } |
| 8324 | |
| 8325 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim2Uint8Test( |
| 8326 | armnn::IWorkloadFactory& workloadFactory, |
| 8327 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 8328 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8329 | return Concatenation4dDiffShapeDim2TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8330 | workloadFactory, memoryManager, 0.5f, -1); |
narpra01 | 5cdda35 | 2018-11-19 15:30:27 +0000 | [diff] [blame] | 8331 | } |
| 8332 | |
| 8333 | LayerTestResult<uint8_t, 4> Concatenation4dDiffShapeDim3Uint8Test( |
| 8334 | armnn::IWorkloadFactory& workloadFactory, |
| 8335 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8336 | bool useSubtensor) |
| 8337 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8338 | return Concatenation4dDiffShapeDim3TestImpl<armnn::DataType::QuantisedAsymm8>( |
| 8339 | workloadFactory, memoryManager, 0.5f, -1, useSubtensor); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8340 | } |
| 8341 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8342 | LayerTestResult<float, 4> SimpleMaxPooling2dSize2x2Stride2x2Test( |
| 8343 | armnn::IWorkloadFactory& workloadFactory, |
| 8344 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8345 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8346 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8347 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<armnn::DataType::Float32>( |
| 8348 | workloadFactory, memoryManager, forceNoPadding); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8349 | } |
| 8350 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8351 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize2x2Stride2x2Uint8Test( |
| 8352 | armnn::IWorkloadFactory& workloadFactory, |
| 8353 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8354 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8355 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8356 | return SimpleMaxPooling2dSize2x2Stride2x2TestCommon<armnn::DataType::QuantisedAsymm8>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8357 | workloadFactory, memoryManager, forceNoPadding, 3.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8358 | } |
| 8359 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8360 | LayerTestResult<float, 4> SimpleMaxPooling2dSize3x3Stride2x4Test( |
| 8361 | armnn::IWorkloadFactory& workloadFactory, |
| 8362 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8363 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8364 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8365 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<armnn::DataType::Float32>( |
| 8366 | workloadFactory, memoryManager, forceNoPadding); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8367 | } |
| 8368 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8369 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dSize3x3Stride2x4Uint8Test( |
| 8370 | armnn::IWorkloadFactory& workloadFactory, |
| 8371 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8372 | bool forceNoPadding) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8373 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8374 | return SimpleMaxPooling2dSize3x3Stride2x4TestCommon<armnn::DataType::QuantisedAsymm8>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8375 | workloadFactory, memoryManager, forceNoPadding, 0.1f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8376 | } |
| 8377 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8378 | LayerTestResult<float, 4> SimpleMaxPooling2dTest( |
| 8379 | armnn::IWorkloadFactory& workloadFactory, |
| 8380 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8381 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8382 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8383 | return SimpleMaxPooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8384 | } |
| 8385 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8386 | LayerTestResult<uint8_t, 4> SimpleMaxPooling2dUint8Test( |
| 8387 | armnn::IWorkloadFactory& workloadFactory, |
| 8388 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8389 | const armnn::DataLayout dataLayout) |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 8390 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8391 | return SimpleMaxPooling2dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, dataLayout); |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 8392 | } |
| 8393 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8394 | LayerTestResult<float, 4> SimpleAveragePooling2dTest( |
| 8395 | armnn::IWorkloadFactory& workloadFactory, |
| 8396 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8397 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8398 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8399 | return SimpleAveragePooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, dataLayout); |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 8400 | } |
| 8401 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8402 | LayerTestResult<uint8_t, 4> SimpleAveragePooling2dUint8Test( |
| 8403 | armnn::IWorkloadFactory& workloadFactory, |
| 8404 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8405 | const armnn::DataLayout dataLayout) |
James Conroy | 6948227 | 2018-10-19 10:41:35 +0100 | [diff] [blame] | 8406 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8407 | return SimpleAveragePooling2dTestCommon<armnn::DataType::QuantisedAsymm8>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8408 | workloadFactory, memoryManager, dataLayout, 0.5, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8409 | } |
| 8410 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8411 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3x2Stride2x2Test( |
| 8412 | armnn::IWorkloadFactory& workloadFactory, |
| 8413 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8414 | bool forceNoPadding) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8415 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8416 | return IgnorePaddingAveragePooling2dSize3x2Stride2x2TestCommon<armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8417 | workloadFactory, memoryManager, forceNoPadding); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8418 | } |
| 8419 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8420 | LayerTestResult<float, 4> LargeTensorsAveragePooling2dTest( |
| 8421 | armnn::IWorkloadFactory& workloadFactory, |
| 8422 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8423 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8424 | return LargeTensorsAveragePooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8425 | } |
| 8426 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8427 | LayerTestResult<uint8_t, 4> LargeTensorsAveragePooling2dUint8Test( |
| 8428 | armnn::IWorkloadFactory& workloadFactory, |
| 8429 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8430 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8431 | return LargeTensorsAveragePooling2dTestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8432 | workloadFactory, memoryManager, 0.5, -1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8433 | } |
| 8434 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8435 | LayerTestResult<float, 4> SimpleL2Pooling2dTest( |
| 8436 | armnn::IWorkloadFactory& workloadFactory, |
| 8437 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8438 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8439 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8440 | return SimpleL2Pooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8441 | } |
| 8442 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8443 | LayerTestResult<uint8_t, 4> SimpleL2Pooling2dUint8Test( |
| 8444 | armnn::IWorkloadFactory& workloadFactory, |
| 8445 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Matthew Bentham | 8800c00 | 2018-11-19 13:19:28 +0000 | [diff] [blame] | 8446 | const armnn::DataLayout dataLayout) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8447 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8448 | return SimpleL2Pooling2dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager, dataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8449 | } |
| 8450 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8451 | LayerTestResult<float, 4> L2Pooling2dSize3Stride1Test( |
| 8452 | armnn::IWorkloadFactory& workloadFactory, |
| 8453 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8454 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8455 | return L2Pooling2dSize3Stride1TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8456 | } |
| 8457 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8458 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride1Uint8Test( |
| 8459 | armnn::IWorkloadFactory& workloadFactory, |
| 8460 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8461 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8462 | return L2Pooling2dSize3Stride1TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8463 | } |
| 8464 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8465 | LayerTestResult<float, 4> L2Pooling2dSize3Stride3Test( |
| 8466 | armnn::IWorkloadFactory& workloadFactory, |
| 8467 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8468 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8469 | return L2Pooling2dSize3Stride3TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8470 | } |
| 8471 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8472 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride3Uint8Test( |
| 8473 | armnn::IWorkloadFactory& workloadFactory, |
| 8474 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8475 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8476 | return L2Pooling2dSize3Stride3TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8477 | } |
| 8478 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8479 | LayerTestResult<float, 4> L2Pooling2dSize3Stride4Test( |
| 8480 | armnn::IWorkloadFactory& workloadFactory, |
| 8481 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8482 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8483 | return L2Pooling2dSize3Stride4TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8484 | } |
| 8485 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8486 | LayerTestResult<uint8_t, 4> L2Pooling2dSize3Stride4Uint8Test( |
| 8487 | armnn::IWorkloadFactory& workloadFactory, |
| 8488 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8489 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8490 | return L2Pooling2dSize3Stride4TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8491 | } |
| 8492 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8493 | LayerTestResult<float, 4> L2Pooling2dSize7Test( |
| 8494 | armnn::IWorkloadFactory& workloadFactory, |
| 8495 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8496 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8497 | return L2Pooling2dSize7TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8498 | } |
| 8499 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8500 | LayerTestResult<uint8_t, 4> L2Pooling2dSize7Uint8Test( |
| 8501 | armnn::IWorkloadFactory& workloadFactory, |
| 8502 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8503 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8504 | return L2Pooling2dSize7TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8505 | } |
| 8506 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8507 | LayerTestResult<float, 4> L2Pooling2dSize9Test( |
| 8508 | armnn::IWorkloadFactory& workloadFactory, |
| 8509 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8510 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8511 | return L2Pooling2dSize9TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8512 | } |
| 8513 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8514 | LayerTestResult<uint8_t, 4> L2Pooling2dSize9Uint8Test( |
| 8515 | armnn::IWorkloadFactory& workloadFactory, |
| 8516 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8517 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8518 | return L2Pooling2dSize9TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8519 | } |
| 8520 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8521 | LayerTestResult<float, 4> AsymmetricNonSquarePooling2dTest( |
| 8522 | armnn::IWorkloadFactory& workloadFactory, |
| 8523 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8524 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8525 | return AsymmetricNonSquarePooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8526 | } |
| 8527 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8528 | LayerTestResult<uint8_t, 4> AsymmetricNonSquarePooling2dUint8Test( |
| 8529 | armnn::IWorkloadFactory& workloadFactory, |
| 8530 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8531 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8532 | return AsymmetricNonSquarePooling2dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8533 | } |
| 8534 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8535 | LayerTestResult<float, 4> ComparePooling2dTest( |
| 8536 | armnn::IWorkloadFactory& workloadFactory, |
| 8537 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8538 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 8539 | armnn::PoolingAlgorithm poolingType) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8540 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8541 | return ComparePooling2dTestCommon<armnn::DataType::Float32>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8542 | workloadFactory, memoryManager, refWorkloadFactory, poolingType); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8543 | } |
| 8544 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8545 | LayerTestResult<uint8_t, 4> ComparePooling2dUint8Test( |
| 8546 | armnn::IWorkloadFactory& workloadFactory, |
| 8547 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8548 | armnn::IWorkloadFactory& refWorkloadFactory, |
| 8549 | armnn::PoolingAlgorithm poolingType) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8550 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8551 | return ComparePooling2dTestCommon<armnn::DataType::QuantisedAsymm8>( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8552 | workloadFactory, memoryManager, refWorkloadFactory, poolingType, 0.1f, 128); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8553 | } |
| 8554 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8555 | LayerTestResult<float, 2> FullyConnectedLargeTest( |
| 8556 | armnn::IWorkloadFactory& workloadFactory, |
| 8557 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8558 | bool transposeWeights) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8559 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8560 | return FullyConnectedLargeTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager, transposeWeights); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8561 | } |
| 8562 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8563 | LayerTestResult<float, 4> IgnorePaddingSimpleMaxPooling2dTest( |
| 8564 | armnn::IWorkloadFactory& workloadFactory, |
| 8565 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8566 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8567 | return IgnorePaddingSimpleMaxPooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8568 | } |
| 8569 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8570 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleMaxPooling2dUint8Test( |
| 8571 | armnn::IWorkloadFactory& workloadFactory, |
| 8572 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8573 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8574 | return IgnorePaddingSimpleMaxPooling2dTestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8575 | workloadFactory, memoryManager, 1.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8576 | } |
| 8577 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8578 | LayerTestResult<float, 4> IgnorePaddingMaxPooling2dSize3Test( |
| 8579 | armnn::IWorkloadFactory& workloadFactory, |
| 8580 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8581 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8582 | return IgnorePaddingMaxPooling2dSize3TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8583 | } |
| 8584 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8585 | LayerTestResult<uint8_t, 4> IgnorePaddingMaxPooling2dSize3Uint8Test( |
| 8586 | armnn::IWorkloadFactory& workloadFactory, |
| 8587 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8588 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8589 | return IgnorePaddingMaxPooling2dSize3TestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8590 | workloadFactory, memoryManager, 1.0f, -5); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8591 | } |
| 8592 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8593 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dTest( |
| 8594 | armnn::IWorkloadFactory& workloadFactory, |
| 8595 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8596 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8597 | return IgnorePaddingSimpleAveragePooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8598 | } |
| 8599 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8600 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dUint8Test( |
| 8601 | armnn::IWorkloadFactory& workloadFactory, |
| 8602 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8603 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8604 | return IgnorePaddingSimpleAveragePooling2dTestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8605 | workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8606 | } |
| 8607 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8608 | LayerTestResult<float, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingTest( |
| 8609 | armnn::IWorkloadFactory& workloadFactory, |
| 8610 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8611 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8612 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<armnn::DataType::Float32>( |
| 8613 | workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8614 | } |
| 8615 | |
| 8616 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleAveragePooling2dNoPaddingUint8Test( |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8617 | armnn::IWorkloadFactory& workloadFactory, |
| 8618 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8619 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8620 | return IgnorePaddingSimpleAveragePooling2dNoPaddingTestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8621 | workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8622 | } |
| 8623 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8624 | LayerTestResult<float, 4> IgnorePaddingAveragePooling2dSize3Test( |
| 8625 | armnn::IWorkloadFactory& workloadFactory, |
| 8626 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8627 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8628 | return IgnorePaddingAveragePooling2dSize3TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8629 | } |
| 8630 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8631 | LayerTestResult<uint8_t, 4> IgnorePaddingAveragePooling2dSize3Uint8Test( |
| 8632 | armnn::IWorkloadFactory& workloadFactory, |
| 8633 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8634 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8635 | return IgnorePaddingAveragePooling2dSize3TestCommon<armnn::DataType::QuantisedAsymm8>( |
| 8636 | workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8637 | } |
| 8638 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8639 | LayerTestResult<float, 4> IgnorePaddingSimpleL2Pooling2dTest( |
| 8640 | armnn::IWorkloadFactory& workloadFactory, |
| 8641 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8642 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8643 | return IgnorePaddingSimpleL2Pooling2dTestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8644 | } |
| 8645 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8646 | LayerTestResult<uint8_t, 4> IgnorePaddingSimpleL2Pooling2dUint8Test( |
| 8647 | armnn::IWorkloadFactory& workloadFactory, |
| 8648 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8649 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8650 | return IgnorePaddingSimpleL2Pooling2dTestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8651 | } |
| 8652 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8653 | LayerTestResult<float, 4> IgnorePaddingL2Pooling2dSize3Test( |
| 8654 | armnn::IWorkloadFactory& workloadFactory, |
| 8655 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8656 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8657 | return IgnorePaddingL2Pooling2dSize3TestCommon<armnn::DataType::Float32>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8658 | } |
| 8659 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8660 | LayerTestResult<uint8_t, 4> IgnorePaddingL2Pooling2dSize3Uint8Test( |
| 8661 | armnn::IWorkloadFactory& workloadFactory, |
| 8662 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8663 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8664 | return IgnorePaddingL2Pooling2dSize3TestCommon<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8665 | } |
| 8666 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8667 | LayerTestResult<float, 4> SimplePermuteFloat32Test( |
| 8668 | armnn::IWorkloadFactory& workloadFactory, |
| 8669 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8670 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8671 | return SimplePermuteFloat32TestCommon(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8672 | }; |
| 8673 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8674 | LayerTestResult<uint8_t, 4> SimplePermuteUint8Test( |
| 8675 | armnn::IWorkloadFactory& workloadFactory, |
| 8676 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8677 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8678 | return SimplePermuteUint8TestCommon(workloadFactory, memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8679 | }; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8680 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8681 | LayerTestResult<float, 4> PermuteFloat32ValueSet1Test( |
| 8682 | armnn::IWorkloadFactory& workloadFactory, |
| 8683 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8684 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8685 | return PermuteFloat32ValueSet1TestCommon(workloadFactory, memoryManager); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8686 | }; |
| 8687 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8688 | LayerTestResult<float, 4> PermuteFloat32ValueSet2Test( |
| 8689 | armnn::IWorkloadFactory& workloadFactory, |
| 8690 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8691 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8692 | return PermuteFloat32ValueSet2TestCommon(workloadFactory, memoryManager); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8693 | }; |
| 8694 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8695 | LayerTestResult<float, 4> PermuteFloat32ValueSet3Test( |
| 8696 | armnn::IWorkloadFactory& workloadFactory, |
| 8697 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 8698 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8699 | return PermuteFloat32ValueSet3TestCommon(workloadFactory, memoryManager); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8700 | }; |
| 8701 | |
| 8702 | namespace |
| 8703 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8704 | |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8705 | template <typename T, std::size_t InputDim, std::size_t OutputDim> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8706 | LayerTestResult<T, OutputDim> MeanTestHelper( |
| 8707 | armnn::IWorkloadFactory& workloadFactory, |
| 8708 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 8709 | const unsigned int* inputShape, |
| 8710 | const std::vector<T>& inputData, |
| 8711 | const std::vector<unsigned int>& axis, |
| 8712 | bool keepDims, |
| 8713 | const unsigned int* outputShape, |
| 8714 | const std::vector<T>& outputData, |
| 8715 | float scale = 1.0f, |
| 8716 | int32_t offset = 0) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8717 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8718 | 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] | 8719 | |
| 8720 | armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType); |
| 8721 | armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType); |
| 8722 | |
| 8723 | inputTensorInfo.SetQuantizationScale(scale); |
| 8724 | inputTensorInfo.SetQuantizationOffset(offset); |
| 8725 | |
| 8726 | outputTensorInfo.SetQuantizationScale(scale); |
| 8727 | outputTensorInfo.SetQuantizationOffset(offset); |
| 8728 | |
| 8729 | auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData); |
| 8730 | |
| 8731 | LayerTestResult<T, OutputDim> result(outputTensorInfo); |
| 8732 | result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData); |
| 8733 | |
| 8734 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 8735 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 8736 | |
| 8737 | armnn::MeanQueueDescriptor data; |
| 8738 | data.m_Parameters.m_Axis = axis; |
| 8739 | data.m_Parameters.m_KeepDims = keepDims; |
| 8740 | armnn::WorkloadInfo info; |
| 8741 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 8742 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 8743 | |
| 8744 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateMean(data, info); |
| 8745 | |
| 8746 | inputHandle->Allocate(); |
| 8747 | outputHandle->Allocate(); |
| 8748 | |
| 8749 | CopyDataToITensorHandle(inputHandle.get(), input.origin()); |
| 8750 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 8751 | workload->PostAllocationConfigure(); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8752 | workload->Execute(); |
| 8753 | |
| 8754 | CopyDataFromITensorHandle(result.output.origin(), outputHandle.get()); |
| 8755 | |
| 8756 | return result; |
| 8757 | } |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8758 | |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8759 | } // anonymous namespace |
| 8760 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8761 | LayerTestResult<uint8_t, 1> MeanUint8SimpleTest( |
| 8762 | armnn::IWorkloadFactory& workloadFactory, |
| 8763 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8764 | { |
| 8765 | const unsigned int inputShape[] = { 3, 2 }; |
| 8766 | const unsigned int outputShape[] = { 1 }; |
| 8767 | |
| 8768 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 8769 | std::vector<uint8_t> output({ 2 }); |
| 8770 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8771 | return MeanTestHelper<uint8_t, 2, 1>( |
| 8772 | workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8773 | } |
| 8774 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8775 | LayerTestResult<uint8_t, 3> MeanUint8SimpleAxisTest( |
| 8776 | armnn::IWorkloadFactory& workloadFactory, |
| 8777 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8778 | { |
| 8779 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 8780 | const unsigned int outputShape[] = { 1, 1, 2 }; |
| 8781 | |
| 8782 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 8783 | std::vector<uint8_t> output({ 2, 2 }); |
| 8784 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8785 | return MeanTestHelper<uint8_t, 4, 3>( |
| 8786 | workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8787 | } |
| 8788 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8789 | LayerTestResult<uint8_t, 4> MeanUint8KeepDimsTest( |
| 8790 | armnn::IWorkloadFactory& workloadFactory, |
| 8791 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8792 | { |
| 8793 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 8794 | const unsigned int outputShape[] = { 1, 1, 1, 2 }; |
| 8795 | |
| 8796 | std::vector<uint8_t> input({ 1, 1, 2, 2, 3, 3 }); |
| 8797 | std::vector<uint8_t> output({ 2, 2 }); |
| 8798 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8799 | return MeanTestHelper<uint8_t, 4, 4>( |
| 8800 | workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8801 | } |
| 8802 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8803 | LayerTestResult<uint8_t, 4> MeanUint8MultipleDimsTest( |
| 8804 | armnn::IWorkloadFactory& workloadFactory, |
| 8805 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8806 | { |
| 8807 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 8808 | const unsigned int outputShape[] = { 1, 3, 1, 1 }; |
| 8809 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8810 | 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] | 8811 | std::vector<uint8_t> output({ 1, 3, 5 }); |
| 8812 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8813 | return MeanTestHelper<uint8_t, 4, 4>( |
| 8814 | workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8815 | } |
| 8816 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8817 | LayerTestResult<uint8_t, 1> MeanVtsUint8Test( |
| 8818 | armnn::IWorkloadFactory& workloadFactory, |
| 8819 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8820 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8821 | const unsigned int inputShape[] = { 4, 3, 2 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8822 | const unsigned int outputShape[] = { 2 }; |
| 8823 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8824 | 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, |
| 8825 | 24 }); |
| 8826 | std::vector<uint8_t> output({ 12, 13 }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8827 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8828 | return MeanTestHelper<uint8_t, 3, 1>(workloadFactory, memoryManager, |
| 8829 | inputShape, input, { 0, 1 }, false, outputShape, |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8830 | output, 0.8f, 5); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8831 | } |
| 8832 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8833 | LayerTestResult<float, 1> MeanFloatSimpleTest( |
| 8834 | armnn::IWorkloadFactory& workloadFactory, |
| 8835 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8836 | { |
| 8837 | const unsigned int inputShape[] = { 3, 2 }; |
| 8838 | const unsigned int outputShape[] = { 1 }; |
| 8839 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8840 | std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }); |
| 8841 | std::vector<float> output({ 2.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8842 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8843 | return MeanTestHelper<float, 2, 1>( |
| 8844 | workloadFactory, memoryManager, inputShape, input, {}, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8845 | } |
| 8846 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8847 | LayerTestResult<float, 3> MeanFloatSimpleAxisTest( |
| 8848 | armnn::IWorkloadFactory& workloadFactory, |
| 8849 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8850 | { |
| 8851 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 8852 | const unsigned int outputShape[] = { 3, 1, 2 }; |
| 8853 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8854 | 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 }); |
| 8855 | 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] | 8856 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8857 | return MeanTestHelper<float, 4, 3>( |
| 8858 | workloadFactory, memoryManager, inputShape, input, { 0 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8859 | } |
| 8860 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8861 | LayerTestResult<float, 4> MeanFloatKeepDimsTest( |
| 8862 | armnn::IWorkloadFactory& workloadFactory, |
| 8863 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8864 | { |
| 8865 | const unsigned int inputShape[] = { 1, 1, 3, 2 }; |
| 8866 | const unsigned int outputShape[] = { 1, 1, 1, 2 }; |
| 8867 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8868 | std::vector<float> input({ 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }); |
| 8869 | std::vector<float> output({ 2.0f, 2.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8870 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8871 | return MeanTestHelper<float, 4, 4>( |
| 8872 | workloadFactory, memoryManager, inputShape, input, { 2 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8873 | } |
| 8874 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8875 | LayerTestResult<float, 4> MeanFloatMultipleDimsTest( |
| 8876 | armnn::IWorkloadFactory& workloadFactory, |
| 8877 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8878 | { |
| 8879 | const unsigned int inputShape[] = { 2, 3, 1, 2 }; |
| 8880 | const unsigned int outputShape[] = { 1, 3, 1, 1 }; |
| 8881 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8882 | 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 }); |
| 8883 | std::vector<float> output({ 1.5f, 3.5f, 5.5f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8884 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8885 | return MeanTestHelper<float, 4, 4>( |
| 8886 | workloadFactory, memoryManager, inputShape, input, { 0, 3 }, true, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8887 | } |
| 8888 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8889 | LayerTestResult<float, 1> MeanVtsFloat1Test( |
| 8890 | armnn::IWorkloadFactory& workloadFactory, |
| 8891 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8892 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8893 | const unsigned int inputShape[] = { 4, 3, 2 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8894 | const unsigned int outputShape[] = { 2 }; |
| 8895 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8896 | 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, |
| 8897 | 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f }); |
| 8898 | std::vector<float> output({ 12.0f, 13.0f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8899 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8900 | return MeanTestHelper<float, 3, 1>( |
| 8901 | workloadFactory, memoryManager, inputShape, input, { 0, 1 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8902 | } |
| 8903 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8904 | LayerTestResult<float, 3> MeanVtsFloat2Test( |
| 8905 | armnn::IWorkloadFactory& workloadFactory, |
| 8906 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8907 | { |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8908 | const unsigned int inputShape[] = { 4, 3, 2 }; |
| 8909 | const unsigned int outputShape[] = { 1, 3, 1 }; |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8910 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8911 | 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, |
| 8912 | 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f }); |
| 8913 | std::vector<float> output({ 10.5f, 12.5f, 14.5f }); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8914 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8915 | return MeanTestHelper<float, 3, 3>( |
| 8916 | workloadFactory, memoryManager, inputShape, input, { 0, 2 }, true, outputShape, output); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8917 | } |
| 8918 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8919 | LayerTestResult<float, 3> MeanVtsFloat3Test( |
| 8920 | armnn::IWorkloadFactory& workloadFactory, |
| 8921 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 8922 | { |
| 8923 | const unsigned int inputShape[] = { 1, 2, 2, 1 }; |
| 8924 | const unsigned int outputShape[] = { 1, 2, 1 }; |
| 8925 | |
| 8926 | std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f }); |
| 8927 | std::vector<float> output({ 1.5f, 3.5f }); |
| 8928 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8929 | return MeanTestHelper<float, 4, 3>( |
| 8930 | workloadFactory, memoryManager, inputShape, input, { 2 }, false, outputShape, output); |
narpra01 | 1e4c31d | 2018-09-28 11:07:51 +0100 | [diff] [blame] | 8931 | } |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 8932 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 8933 | LayerTestResult<float, 4> AdditionAfterMaxPoolTest( |
| 8934 | armnn::IWorkloadFactory& workloadFactory, |
| 8935 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 8936 | { |
| 8937 | // Create Initial Tensor |
| 8938 | // 1, 2, 3 |
| 8939 | // 4, 5, 6 |
| 8940 | // 7, 8, 9 |
| 8941 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8942 | armnn::TensorInfo poolingInputTensorInfo({ 1, 1, 3, 3}, armnn::DataType::Float32); |
| 8943 | armnn::TensorInfo poolingOutputTensorInfo({ 1, 1, 2, 2}, armnn::DataType::Float32); |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 8944 | |
| 8945 | boost::multi_array<float, 4> poolingInput = MakeTensor<float,4>(poolingInputTensorInfo, |
| 8946 | {1, 2, 3, |
| 8947 | 4, 5, 6, |
| 8948 | 7, 8, 9 |
| 8949 | }); |
| 8950 | |
| 8951 | std::unique_ptr<armnn::ITensorHandle> poolingInputHandle = |
| 8952 | workloadFactory.CreateTensorHandle(poolingInputTensorInfo); |
| 8953 | std::unique_ptr<armnn::ITensorHandle> poolingOutputHandle = |
| 8954 | workloadFactory.CreateTensorHandle(poolingOutputTensorInfo); |
| 8955 | |
| 8956 | // Apply MaxPool poolSize = 1x1, stride=2x2 |
| 8957 | // Result = |
| 8958 | // 1, 3 |
| 8959 | // 7, 9 |
| 8960 | armnn::Pooling2dDescriptor descriptor; |
| 8961 | descriptor.m_PoolHeight = 1; |
| 8962 | descriptor.m_PoolWidth = 1; |
| 8963 | descriptor.m_StrideX = 2; |
| 8964 | descriptor.m_StrideY = 2; |
| 8965 | descriptor.m_PoolType = armnn::PoolingAlgorithm::Max; |
| 8966 | |
| 8967 | armnn::Pooling2dQueueDescriptor queueDescriptor; |
| 8968 | queueDescriptor.m_Parameters = descriptor; |
| 8969 | armnn::WorkloadInfo workloadInfo; |
| 8970 | AddInputToWorkload(queueDescriptor, workloadInfo, poolingInputTensorInfo, poolingInputHandle.get()); |
| 8971 | AddOutputToWorkload(queueDescriptor, workloadInfo, poolingOutputTensorInfo, poolingOutputHandle.get()); |
| 8972 | |
| 8973 | // Create the MaxPool |
| 8974 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePooling2d(queueDescriptor, workloadInfo); |
| 8975 | |
| 8976 | //LayerTestResult<float, 4> result(poolingOutputTensorInfo); |
| 8977 | auto shape( GetTensorShapeAsArray<4>(poolingOutputTensorInfo)); |
| 8978 | boost::multi_array<float, 4> resultMaxPool; |
| 8979 | resultMaxPool.resize(shape); |
| 8980 | |
| 8981 | |
| 8982 | // Create addition with another tensor the same size |
| 8983 | // This would be the result to apply a Conv2d with kernel ones(2) and stride 1x1 |
| 8984 | // with the initial tensor. |
| 8985 | // 12, 16 |
| 8986 | // 24, 28 |
| 8987 | |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 8988 | armnn::TensorInfo addInputTensorInfo({ 1,1,2,2}, armnn::DataType::Float32); |
| 8989 | armnn::TensorInfo addOutputTensorInfo({ 1,1,2,2}, armnn::DataType::Float32); |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 8990 | |
| 8991 | boost::multi_array<float, 4> addInput = MakeTensor<float,4>(addInputTensorInfo, |
| 8992 | {12, 16, |
| 8993 | 24, 28, |
| 8994 | }); |
| 8995 | |
| 8996 | // Expected output tensor after MaxPool and Addition. |
| 8997 | LayerTestResult<float,4> addRet(addOutputTensorInfo); |
| 8998 | addRet.outputExpected = MakeTensor<float, 4>(addOutputTensorInfo, std::vector<float>( |
| 8999 | { |
| 9000 | 13, 19, |
| 9001 | 31, 37 |
| 9002 | })); |
| 9003 | |
| 9004 | std::unique_ptr<armnn::ITensorHandle> addInputHandle = workloadFactory.CreateTensorHandle(addInputTensorInfo); |
| 9005 | std::unique_ptr<armnn::ITensorHandle> addOutputHandle = workloadFactory.CreateTensorHandle(addOutputTensorInfo); |
| 9006 | |
| 9007 | armnn::AdditionQueueDescriptor data; |
| 9008 | armnn::WorkloadInfo info; |
| 9009 | |
| 9010 | // Add the output of the MaxPool and the new tensor |
| 9011 | AddInputToWorkload(data, info, poolingOutputTensorInfo, poolingOutputHandle.get()); |
| 9012 | AddInputToWorkload(data, info, addInputTensorInfo, addInputHandle.get()); |
| 9013 | AddOutputToWorkload(data, info, addOutputTensorInfo, addOutputHandle.get()); |
| 9014 | |
| 9015 | std::unique_ptr<armnn::IWorkload> addWorkload = workloadFactory.CreateAddition(data, info); |
| 9016 | |
| 9017 | poolingInputHandle->Allocate(); |
| 9018 | poolingOutputHandle->Allocate(); |
| 9019 | addInputHandle->Allocate(); |
| 9020 | addOutputHandle->Allocate(); |
| 9021 | |
| 9022 | CopyDataToITensorHandle(poolingInputHandle.get(), &poolingInput[0][0][0][0]); |
| 9023 | CopyDataFromITensorHandle(&resultMaxPool[0][0][0][0], poolingOutputHandle.get()); |
| 9024 | |
| 9025 | CopyDataToITensorHandle(poolingOutputHandle.get(), &resultMaxPool[0][0][0][0]); |
| 9026 | CopyDataToITensorHandle(addInputHandle.get(), &addInput[0][0][0][0]); |
| 9027 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 9028 | workload->PostAllocationConfigure(); |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 9029 | workload->Execute(); |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 9030 | addWorkload->PostAllocationConfigure(); |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 9031 | addWorkload->Execute(); |
| 9032 | |
| 9033 | CopyDataFromITensorHandle(&addRet.output[0][0][0][0], addOutputHandle.get()); |
| 9034 | |
Éanna Ó Catháin | 47c1ddb | 2018-10-12 14:24:13 +0100 | [diff] [blame] | 9035 | return addRet; |
| 9036 | } |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9037 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9038 | LayerTestResult<float, 4> SpaceToBatchNdSimpleFloat32Test( |
| 9039 | armnn::IWorkloadFactory& workloadFactory, |
| 9040 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9041 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9042 | return SpaceToBatchNdSimpleTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9043 | } |
| 9044 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9045 | LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsFloat32Test( |
| 9046 | armnn::IWorkloadFactory& workloadFactory, |
| 9047 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9048 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9049 | return SpaceToBatchNdMultiChannelsTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9050 | } |
| 9051 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9052 | LayerTestResult<float, 4> SpaceToBatchNdMultiBlockFloat32Test( |
| 9053 | armnn::IWorkloadFactory& workloadFactory, |
| 9054 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9055 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9056 | return SpaceToBatchNdMultiBlockTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9057 | } |
| 9058 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9059 | LayerTestResult<float, 4> SpaceToBatchNdPaddingFloat32Test( |
| 9060 | armnn::IWorkloadFactory& workloadFactory, |
| 9061 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9062 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9063 | return SpaceToBatchNdPaddingTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9064 | } |
| 9065 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9066 | LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleUint8Test( |
| 9067 | armnn::IWorkloadFactory& workloadFactory, |
| 9068 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9069 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9070 | return SpaceToBatchNdSimpleTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9071 | } |
| 9072 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9073 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsUint8Test( |
| 9074 | armnn::IWorkloadFactory& workloadFactory, |
| 9075 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9076 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9077 | return SpaceToBatchNdMultiChannelsTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9078 | } |
| 9079 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9080 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockUint8Test( |
| 9081 | armnn::IWorkloadFactory& workloadFactory, |
| 9082 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9083 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9084 | return SpaceToBatchNdMultiBlockTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9085 | } |
| 9086 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9087 | LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingUint8Test( |
| 9088 | armnn::IWorkloadFactory& workloadFactory, |
| 9089 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9090 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9091 | return SpaceToBatchNdPaddingTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9092 | } |
| 9093 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9094 | LayerTestResult<float, 4> SpaceToBatchNdSimpleNHWCFloat32Test( |
| 9095 | armnn::IWorkloadFactory& workloadFactory, |
| 9096 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9097 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9098 | return SpaceToBatchNdSimpleNHWCTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9099 | } |
| 9100 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9101 | LayerTestResult<float, 4> SpaceToBatchNdMultiChannelsNHWCFloat32Test( |
| 9102 | armnn::IWorkloadFactory& workloadFactory, |
| 9103 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9104 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9105 | return SpaceToBatchNdMultiChannelsNHWCTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9106 | } |
| 9107 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9108 | LayerTestResult<float, 4> SpaceToBatchNdMultiBlockNHWCFloat32Test( |
| 9109 | armnn::IWorkloadFactory& workloadFactory, |
| 9110 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9111 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9112 | return SpaceToBatchNdMultiBlockNHWCTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9113 | } |
| 9114 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9115 | LayerTestResult<float, 4> SpaceToBatchNdPaddingNHWCFloat32Test( |
| 9116 | armnn::IWorkloadFactory& workloadFactory, |
| 9117 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9118 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9119 | return SpaceToBatchNdPaddingNHWCTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9120 | } |
| 9121 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9122 | LayerTestResult<uint8_t, 4> SpaceToBatchNdSimpleNHWCUint8Test( |
| 9123 | armnn::IWorkloadFactory& workloadFactory, |
| 9124 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9125 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9126 | return SpaceToBatchNdSimpleNHWCTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9127 | } |
| 9128 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9129 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiChannelsNHWCUint8Test( |
| 9130 | armnn::IWorkloadFactory& workloadFactory, |
| 9131 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9132 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9133 | return SpaceToBatchNdMultiChannelsNHWCTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9134 | } |
| 9135 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9136 | LayerTestResult<uint8_t, 4> SpaceToBatchNdMultiBlockNHWCUint8Test( |
| 9137 | armnn::IWorkloadFactory& workloadFactory, |
| 9138 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9139 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9140 | return SpaceToBatchNdMultiBlockNHWCTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9141 | } |
| 9142 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9143 | LayerTestResult<uint8_t, 4> SpaceToBatchNdPaddingNHWCUint8Test( |
| 9144 | armnn::IWorkloadFactory& workloadFactory, |
| 9145 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9146 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9147 | return SpaceToBatchNdPaddingNHWCTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 9148 | } |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9149 | |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 9150 | LayerTestResult<int16_t, 4> SpaceToBatchNdSimpleUint16Test( |
| 9151 | armnn::IWorkloadFactory& workloadFactory, |
| 9152 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9153 | { |
| 9154 | return SpaceToBatchNdSimpleTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9155 | } |
| 9156 | |
| 9157 | LayerTestResult<int16_t, 4> SpaceToBatchNdMultiChannelsUint16Test( |
| 9158 | armnn::IWorkloadFactory& workloadFactory, |
| 9159 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9160 | { |
| 9161 | return SpaceToBatchNdMultiChannelsTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9162 | } |
| 9163 | |
| 9164 | LayerTestResult<int16_t, 4> SpaceToBatchNdMultiBlockUint16Test( |
| 9165 | armnn::IWorkloadFactory& workloadFactory, |
| 9166 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9167 | { |
| 9168 | return SpaceToBatchNdMultiBlockTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9169 | } |
| 9170 | |
| 9171 | LayerTestResult<int16_t, 4> SpaceToBatchNdPaddingUint16Test( |
| 9172 | armnn::IWorkloadFactory& workloadFactory, |
| 9173 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9174 | { |
| 9175 | return SpaceToBatchNdPaddingTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9176 | } |
| 9177 | |
| 9178 | LayerTestResult<int16_t, 4> SpaceToBatchNdSimpleNHWCUint16Test( |
| 9179 | armnn::IWorkloadFactory& workloadFactory, |
| 9180 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9181 | { |
| 9182 | return SpaceToBatchNdSimpleNHWCTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9183 | } |
| 9184 | |
| 9185 | LayerTestResult<int16_t, 4> SpaceToBatchNdMultiChannelsNHWCUint16Test( |
| 9186 | armnn::IWorkloadFactory& workloadFactory, |
| 9187 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9188 | { |
| 9189 | return SpaceToBatchNdMultiChannelsNHWCTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9190 | } |
| 9191 | |
| 9192 | LayerTestResult<int16_t, 4> SpaceToBatchNdMultiBlockNHWCUint16Test( |
| 9193 | armnn::IWorkloadFactory& workloadFactory, |
| 9194 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9195 | { |
| 9196 | return SpaceToBatchNdMultiBlockNHWCTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9197 | } |
| 9198 | |
| 9199 | LayerTestResult<int16_t, 4> SpaceToBatchNdPaddingNHWCUint16Test( |
| 9200 | armnn::IWorkloadFactory& workloadFactory, |
| 9201 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9202 | { |
| 9203 | return SpaceToBatchNdPaddingNHWCTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9204 | } |
| 9205 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9206 | namespace { |
| 9207 | |
| 9208 | template<typename T, std::size_t InputDim, std::size_t OutputDim> |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9209 | LayerTestResult<T, OutputDim> BatchToSpaceNdHelper( |
| 9210 | armnn::IWorkloadFactory &workloadFactory, |
| 9211 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 9212 | const armnn::DataLayout& dataLayout, |
| 9213 | const unsigned int *inputShape, |
| 9214 | const std::vector<T> &inputData, |
| 9215 | const std::vector<unsigned int> &blockShape, |
| 9216 | const std::vector<std::pair<unsigned int, unsigned int>> &crops, |
| 9217 | const unsigned int *outputShape, |
| 9218 | const std::vector<T> &outputData, |
| 9219 | float scale = 1.0f, |
| 9220 | int32_t offset = 0) |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 9221 | { |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9222 | auto dataType = (std::is_same<T, uint8_t>::value ? armnn::DataType::QuantisedAsymm8 : armnn::DataType::Float32); |
| 9223 | |
| 9224 | armnn::TensorInfo inputTensorInfo(InputDim, inputShape, dataType); |
| 9225 | armnn::TensorInfo outputTensorInfo(OutputDim, outputShape, dataType); |
| 9226 | |
| 9227 | inputTensorInfo.SetQuantizationScale(scale); |
| 9228 | inputTensorInfo.SetQuantizationOffset(offset); |
| 9229 | |
| 9230 | outputTensorInfo.SetQuantizationScale(scale); |
| 9231 | outputTensorInfo.SetQuantizationOffset(offset); |
| 9232 | |
| 9233 | auto input = MakeTensor<T, InputDim>(inputTensorInfo, inputData); |
| 9234 | |
| 9235 | LayerTestResult<T, OutputDim> result(outputTensorInfo); |
| 9236 | result.outputExpected = MakeTensor<T, OutputDim>(outputTensorInfo, outputData); |
| 9237 | |
| 9238 | std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); |
| 9239 | std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); |
| 9240 | |
| 9241 | armnn::BatchToSpaceNdQueueDescriptor data; |
| 9242 | data.m_Parameters.m_DataLayout = dataLayout; |
| 9243 | data.m_Parameters.m_BlockShape = blockShape; |
| 9244 | data.m_Parameters.m_Crops = crops; |
| 9245 | armnn::WorkloadInfo info; |
| 9246 | AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); |
| 9247 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 9248 | |
| 9249 | std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateBatchToSpaceNd(data, info); |
| 9250 | |
| 9251 | inputHandle->Allocate(); |
| 9252 | outputHandle->Allocate(); |
| 9253 | |
| 9254 | CopyDataToITensorHandle(inputHandle.get(), input.origin()); |
| 9255 | |
Derek Lamberti | f30f7d3 | 2019-04-09 10:25:02 +0100 | [diff] [blame] | 9256 | workload->PostAllocationConfigure(); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9257 | workload->Execute(); |
| 9258 | |
| 9259 | CopyDataFromITensorHandle(&result.output[0][0][0][0], outputHandle.get()); |
| 9260 | |
| 9261 | return result; |
| 9262 | } |
| 9263 | |
| 9264 | } // anonymous namespace |
| 9265 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9266 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test1( |
| 9267 | armnn::IWorkloadFactory& workloadFactory, |
| 9268 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9269 | { |
| 9270 | const unsigned int inputShape[] = {4, 2, 2, 1}; |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9271 | const unsigned int outputShape[] = {1, 4, 4, 1}; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9272 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9273 | std::vector<float> input({ |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9274 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 9275 | 1.0f, 3.0f, |
| 9276 | // Batch 0, Height 1, Width (2) x Channel (1) |
| 9277 | 9.0f, 11.0f, |
| 9278 | |
| 9279 | |
| 9280 | // Batch 1, Height 0, Width (2) x Channel (1) |
| 9281 | 2.0f, 4.0f, |
| 9282 | // Batch 1, Height 1, Width (2) x Channel (1) |
| 9283 | 10.0f, 12.0f, |
| 9284 | |
| 9285 | |
| 9286 | // Batch 2, Height 0, Width (2) x Channel (1) |
| 9287 | 5.0f, 7.0f, |
| 9288 | // Batch 2, Height 1, Width (2) x Channel (1) |
| 9289 | 13.0f, 15.0f, |
| 9290 | |
| 9291 | // Batch 3, Height 0, Width (2) x Channel (3) |
| 9292 | 6.0f, 8.0f, |
| 9293 | // Batch 3, Height 1, Width (2) x Channel (1) |
| 9294 | 14.0f, 16.0f |
| 9295 | }); |
| 9296 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9297 | std::vector<float> expectedOutput({ |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9298 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 9299 | 5.0f, 6.0f, 7.0f, 8.0f, |
| 9300 | 9.0f, 10.0f, 11.0f, 12.0f, |
| 9301 | 13.0f, 14.0f, 15.0f, 16.0f |
| 9302 | }); |
| 9303 | |
| 9304 | std::vector<unsigned int> blockShape {2, 2}; |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 9305 | 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] | 9306 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9307 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9308 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9309 | crops, outputShape, expectedOutput); |
| 9310 | } |
| 9311 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9312 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test2( |
| 9313 | armnn::IWorkloadFactory& workloadFactory, |
| 9314 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9315 | { |
| 9316 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 9317 | const unsigned int outputShape[] = {1, 2, 2, 1}; |
| 9318 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9319 | std::vector<float> input({ |
| 9320 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 9321 | 1.0f, 2.0f, 3.0f, 4.0f |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9322 | }); |
| 9323 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9324 | std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f}); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9325 | |
| 9326 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 9327 | 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] | 9328 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9329 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9330 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 9331 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9332 | } |
| 9333 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9334 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test3( |
| 9335 | armnn::IWorkloadFactory& workloadFactory, |
| 9336 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9337 | { |
| 9338 | const unsigned int inputShape[] = {4, 1, 1, 3}; |
| 9339 | const unsigned int outputShape[] = {1, 2, 2, 3}; |
| 9340 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9341 | 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}); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9342 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9343 | 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}); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9344 | |
| 9345 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 9346 | 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] | 9347 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9348 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9349 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 9350 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9351 | } |
| 9352 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9353 | LayerTestResult<float, 4> BatchToSpaceNdNhwcFloat32Test4( |
| 9354 | armnn::IWorkloadFactory& workloadFactory, |
| 9355 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9356 | { |
| 9357 | const unsigned int inputShape[] = {8, 1, 3, 1}; |
| 9358 | const unsigned int outputShape[] = {2, 2, 4, 1}; |
| 9359 | |
| 9360 | std::vector<float> input({ |
| 9361 | 0.0f, 1.0f, 3.0f, |
| 9362 | 0.0f, 9.0f, 11.0f, |
| 9363 | 0.0f, 2.0f, 4.0f, |
| 9364 | 0.0f, 10.0f, 12.0f, |
| 9365 | 0.0f, 5.0f, 7.0f, |
| 9366 | 0.0f, 13.0f, 15.0f, |
| 9367 | 0.0f, 6.0f, 8.0f, |
| 9368 | 0.0f, 14.0f, 16.0f |
| 9369 | }); |
| 9370 | |
| 9371 | std::vector<float> expectedOutput({ |
| 9372 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 9373 | 5.0f, 6.0f, 7.0f, 8.0f, |
| 9374 | 9.0f, 10.0f, 11.0f, 12.0f, |
| 9375 | 13.0f, 14.0f, 15.0f, 16.0f |
| 9376 | }); |
| 9377 | |
| 9378 | std::vector<unsigned int> blockShape({2, 2}); |
| 9379 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}}; |
| 9380 | |
| 9381 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9382 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 9383 | crops, outputShape, expectedOutput); |
| 9384 | } |
| 9385 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9386 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test1( |
| 9387 | armnn::IWorkloadFactory &workloadFactory, |
| 9388 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9389 | { |
| 9390 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 9391 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 9392 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9393 | 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}); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9394 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9395 | std::vector<float> expectedOutput({ |
| 9396 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 9397 | 1.0f, 4.0f, |
| 9398 | 7.0f, 10.0f, |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9399 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9400 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 9401 | 2.0f, 5.0f, |
| 9402 | 8.0f, 11.0f, |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9403 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9404 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 9405 | 3.0f, 6.0f, |
| 9406 | 9.0f, 12.0f, |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9407 | }); |
| 9408 | |
| 9409 | std::vector<unsigned int> blockShape({2, 2}); |
Éanna Ó Catháin | 95807ce | 2018-11-12 17:14:43 +0000 | [diff] [blame] | 9410 | 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] | 9411 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9412 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9413 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9414 | crops, outputShape, expectedOutput); |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 9415 | } |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 9416 | |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9417 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test2( |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9418 | armnn::IWorkloadFactory& workloadFactory, |
| 9419 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9420 | { |
| 9421 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 9422 | const unsigned int outputShape[] = {1, 1, 2, 2}; |
| 9423 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9424 | std::vector<float> input({ |
| 9425 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 9426 | 1.0f, 2.0f, 3.0f, 4.0f |
| 9427 | }); |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9428 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9429 | std::vector<float> expectedOutput({1.0f, 2.0f, 3.0f, 4.0f}); |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9430 | |
| 9431 | std::vector<unsigned int> blockShape({2, 2}); |
| 9432 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9433 | |
| 9434 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9435 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9436 | crops, outputShape, expectedOutput); |
| 9437 | } |
| 9438 | |
| 9439 | LayerTestResult<float, 4> BatchToSpaceNdNchwFloat32Test3( |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9440 | armnn::IWorkloadFactory& workloadFactory, |
| 9441 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9442 | { |
| 9443 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 9444 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 9445 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9446 | 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}); |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9447 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9448 | std::vector<float> expectedOutput({ |
| 9449 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 9450 | 1.0f, 7.0f, |
| 9451 | 2.0f, 8.0f, |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9452 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9453 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 9454 | 3.0f, 9.0f, |
| 9455 | 4.0f, 10.0f, |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9456 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9457 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 9458 | 5.0f, 11.0f, |
| 9459 | 6.0f, 12.0f, |
| 9460 | }); |
Mike Kelly | 831faed | 2018-11-28 11:52:08 +0000 | [diff] [blame] | 9461 | |
| 9462 | std::vector<unsigned int> blockShape({2, 2}); |
| 9463 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9464 | |
| 9465 | return BatchToSpaceNdHelper<float, 4, 4>(workloadFactory, memoryManager, |
| 9466 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9467 | crops, outputShape, expectedOutput); |
| 9468 | } |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 9469 | |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9470 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest1( |
| 9471 | armnn::IWorkloadFactory& workloadFactory, |
| 9472 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 9473 | { |
| 9474 | const unsigned int inputShape[] = {4, 2, 2, 1}; |
| 9475 | const unsigned int outputShape[] = {1, 4, 4, 1}; |
| 9476 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9477 | std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); |
| 9478 | std::vector<uint8_t> expectedOutput({1, 5, 2, 6, 9, 13, 10, 14, 3, 7, 4, 8, 11, 15, 12, 16}); |
Éanna Ó Catháin | 262553e | 2018-11-14 11:26:23 +0000 | [diff] [blame] | 9479 | |
| 9480 | std::vector<unsigned int> blockShape({2, 2}); |
| 9481 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9482 | |
Matteo Martincigh | a65b7ae | 2018-11-14 12:39:55 +0000 | [diff] [blame] | 9483 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, armnn::DataLayout::NHWC, inputShape, |
| 9484 | input, blockShape, crops, outputShape, expectedOutput); |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 9485 | } |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9486 | |
Nattapat Chaimanowong | 3ee1422 | 2019-02-27 10:28:09 +0000 | [diff] [blame] | 9487 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest2( |
| 9488 | armnn::IWorkloadFactory& workloadFactory, |
| 9489 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9490 | { |
| 9491 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 9492 | const unsigned int outputShape[] = {1, 2, 2, 1}; |
| 9493 | |
| 9494 | std::vector<uint8_t> input({ |
| 9495 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 9496 | 1, 2, 3, 4 |
| 9497 | }); |
| 9498 | |
| 9499 | std::vector<uint8_t> expectedOutput({1, 2, 3, 4}); |
| 9500 | |
| 9501 | std::vector<unsigned int> blockShape({2, 2}); |
| 9502 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9503 | |
| 9504 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9505 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 9506 | crops, outputShape, expectedOutput); |
| 9507 | } |
| 9508 | |
| 9509 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNhwcUintTest3( |
| 9510 | armnn::IWorkloadFactory& workloadFactory, |
| 9511 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9512 | { |
| 9513 | const unsigned int inputShape[] = {4, 1, 1, 3}; |
| 9514 | const unsigned int outputShape[] = {1, 2, 2, 3}; |
| 9515 | |
| 9516 | std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); |
| 9517 | |
| 9518 | std::vector<uint8_t> expectedOutput({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); |
| 9519 | |
| 9520 | std::vector<unsigned int> blockShape({2, 2}); |
| 9521 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9522 | |
| 9523 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9524 | armnn::DataLayout::NHWC, inputShape, input, blockShape, |
| 9525 | crops, outputShape, expectedOutput); |
| 9526 | } |
| 9527 | |
| 9528 | |
| 9529 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest1( |
| 9530 | armnn::IWorkloadFactory &workloadFactory, |
| 9531 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9532 | { |
| 9533 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 9534 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 9535 | |
| 9536 | std::vector<uint8_t> input({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); |
| 9537 | |
| 9538 | std::vector<uint8_t> expectedOutput({ |
| 9539 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 9540 | 1, 4, |
| 9541 | 7, 10, |
| 9542 | |
| 9543 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 9544 | 2, 5, |
| 9545 | 8, 11, |
| 9546 | |
| 9547 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 9548 | 3, 6, |
| 9549 | 9, 12, |
| 9550 | }); |
| 9551 | |
| 9552 | std::vector<unsigned int> blockShape({2, 2}); |
| 9553 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9554 | |
| 9555 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9556 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9557 | crops, outputShape, expectedOutput); |
| 9558 | } |
| 9559 | |
| 9560 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest2( |
| 9561 | armnn::IWorkloadFactory& workloadFactory, |
| 9562 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9563 | { |
| 9564 | const unsigned int inputShape[] = {4, 1, 1, 1}; |
| 9565 | const unsigned int outputShape[] = {1, 1, 2, 2}; |
| 9566 | |
| 9567 | std::vector<uint8_t> input({ |
| 9568 | // Batch 0, Height 0, Width (2) x Channel (1) |
| 9569 | 1, 2, 3, 4 |
| 9570 | }); |
| 9571 | |
| 9572 | std::vector<uint8_t> expectedOutput({1, 2, 3, 4}); |
| 9573 | |
| 9574 | std::vector<unsigned int> blockShape({2, 2}); |
| 9575 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9576 | |
| 9577 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9578 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9579 | crops, outputShape, expectedOutput); |
| 9580 | } |
| 9581 | |
| 9582 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest3( |
| 9583 | armnn::IWorkloadFactory& workloadFactory, |
| 9584 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9585 | { |
| 9586 | const unsigned int inputShape[] = {4, 3, 1, 1}; |
| 9587 | const unsigned int outputShape[] = {1, 3, 2, 2}; |
| 9588 | |
| 9589 | std::vector<uint8_t> input({1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10, 12}); |
| 9590 | |
| 9591 | std::vector<uint8_t> expectedOutput({ |
| 9592 | // Batch 0, Channel 0, Height (2) x Width (2) |
| 9593 | 1, 7, |
| 9594 | 2, 8, |
| 9595 | |
| 9596 | // Batch 0, Channel 1, Height (2) x Width (2) |
| 9597 | 3, 9, |
| 9598 | 4, 10, |
| 9599 | |
| 9600 | // Batch 0, Channel 2, Height (2) x Width (2) |
| 9601 | 5, 11, |
| 9602 | 6, 12, |
| 9603 | }); |
| 9604 | |
| 9605 | std::vector<unsigned int> blockShape({2, 2}); |
| 9606 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {0, 0}}; |
| 9607 | |
| 9608 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9609 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9610 | crops, outputShape, expectedOutput); |
| 9611 | } |
| 9612 | |
| 9613 | LayerTestResult<uint8_t, 4> BatchToSpaceNdNchwUintTest4( |
| 9614 | armnn::IWorkloadFactory& workloadFactory, |
| 9615 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9616 | { |
| 9617 | const unsigned int inputShape[] = {8, 1, 1, 3}; |
| 9618 | const unsigned int outputShape[] = {2, 1, 2, 4}; |
| 9619 | |
| 9620 | std::vector<uint8_t> input({ |
| 9621 | 0, 1, 3, 0, 9, 11, |
| 9622 | 0, 2, 4, 0, 10, 12, |
| 9623 | 0, 5, 7, 0, 13, 15, |
| 9624 | 0, 6, 8, 0, 14, 16 |
| 9625 | }); |
| 9626 | |
| 9627 | std::vector<uint8_t> expectedOutput({ |
| 9628 | 1, 2, 3, 4, |
| 9629 | 5, 6, 7, 8, |
| 9630 | 9, 10, 11, 12, |
| 9631 | 13, 14, 15, 16 |
| 9632 | }); |
| 9633 | |
| 9634 | std::vector<unsigned int> blockShape({2, 2}); |
| 9635 | std::vector<std::pair<unsigned int, unsigned int>> crops = {{0, 0}, {2, 0}}; |
| 9636 | |
| 9637 | return BatchToSpaceNdHelper<uint8_t, 4, 4>(workloadFactory, memoryManager, |
| 9638 | armnn::DataLayout::NCHW, inputShape, input, blockShape, |
| 9639 | crops, outputShape, expectedOutput); |
| 9640 | } |
| 9641 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9642 | LayerTestResult<float, 4> StridedSlice4DFloat32Test( |
| 9643 | armnn::IWorkloadFactory& workloadFactory, |
| 9644 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9645 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9646 | return StridedSlice4DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9647 | } |
| 9648 | |
| 9649 | LayerTestResult<float, 4> StridedSlice4DReverseFloat32Test( |
| 9650 | armnn::IWorkloadFactory& workloadFactory, |
| 9651 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9652 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9653 | return StridedSlice4DReverseTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9654 | } |
| 9655 | |
| 9656 | LayerTestResult<float, 4> StridedSliceSimpleStrideFloat32Test( |
| 9657 | armnn::IWorkloadFactory& workloadFactory, |
| 9658 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9659 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9660 | return StridedSliceSimpleStrideTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9661 | } |
| 9662 | |
| 9663 | LayerTestResult<float, 4> StridedSliceSimpleRangeMaskFloat32Test( |
| 9664 | armnn::IWorkloadFactory& workloadFactory, |
| 9665 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9666 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9667 | return StridedSliceSimpleRangeMaskTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9668 | } |
| 9669 | |
| 9670 | LayerTestResult<float, 2> StridedSliceShrinkAxisMaskFloat32Test( |
| 9671 | armnn::IWorkloadFactory& workloadFactory, |
| 9672 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9673 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9674 | return StridedSliceShrinkAxisMaskTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9675 | } |
| 9676 | |
| 9677 | LayerTestResult<float, 3> StridedSlice3DFloat32Test( |
| 9678 | armnn::IWorkloadFactory& workloadFactory, |
| 9679 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9680 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9681 | return StridedSlice3DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9682 | } |
| 9683 | |
| 9684 | LayerTestResult<float, 3> StridedSlice3DReverseFloat32Test( |
| 9685 | armnn::IWorkloadFactory& workloadFactory, |
| 9686 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9687 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9688 | return StridedSlice3DReverseTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9689 | } |
| 9690 | |
| 9691 | LayerTestResult<float, 2> StridedSlice2DFloat32Test( |
| 9692 | armnn::IWorkloadFactory& workloadFactory, |
| 9693 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9694 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9695 | return StridedSlice2DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9696 | } |
| 9697 | |
| 9698 | LayerTestResult<float, 2> StridedSlice2DReverseFloat32Test( |
| 9699 | armnn::IWorkloadFactory& workloadFactory, |
| 9700 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9701 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9702 | return StridedSlice2DReverseTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9703 | } |
| 9704 | |
| 9705 | LayerTestResult<uint8_t, 4> StridedSlice4DUint8Test( |
| 9706 | armnn::IWorkloadFactory& workloadFactory, |
| 9707 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9708 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9709 | return StridedSlice4DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9710 | } |
| 9711 | |
| 9712 | LayerTestResult<uint8_t, 4> StridedSlice4DReverseUint8Test( |
| 9713 | armnn::IWorkloadFactory& workloadFactory, |
| 9714 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9715 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9716 | return StridedSlice4DReverseTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9717 | } |
| 9718 | |
| 9719 | LayerTestResult<uint8_t, 4> StridedSliceSimpleStrideUint8Test( |
| 9720 | armnn::IWorkloadFactory& workloadFactory, |
| 9721 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9722 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9723 | return StridedSliceSimpleStrideTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9724 | } |
| 9725 | |
| 9726 | LayerTestResult<uint8_t, 4> StridedSliceSimpleRangeMaskUint8Test( |
| 9727 | armnn::IWorkloadFactory& workloadFactory, |
| 9728 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9729 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9730 | return StridedSliceSimpleRangeMaskTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9731 | } |
| 9732 | |
| 9733 | LayerTestResult<uint8_t, 2> StridedSliceShrinkAxisMaskUint8Test( |
| 9734 | armnn::IWorkloadFactory& workloadFactory, |
| 9735 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9736 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9737 | return StridedSliceShrinkAxisMaskTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9738 | } |
| 9739 | |
| 9740 | LayerTestResult<uint8_t, 3> StridedSlice3DUint8Test( |
| 9741 | armnn::IWorkloadFactory& workloadFactory, |
| 9742 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9743 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9744 | return StridedSlice3DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9745 | } |
| 9746 | |
| 9747 | LayerTestResult<uint8_t, 3> StridedSlice3DReverseUint8Test( |
| 9748 | armnn::IWorkloadFactory& workloadFactory, |
| 9749 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9750 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9751 | return StridedSlice3DReverseTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9752 | } |
| 9753 | |
| 9754 | LayerTestResult<uint8_t, 2> StridedSlice2DUint8Test( |
| 9755 | armnn::IWorkloadFactory& workloadFactory, |
| 9756 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9757 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9758 | return StridedSlice2DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9759 | } |
| 9760 | |
| 9761 | LayerTestResult<uint8_t, 2> StridedSlice2DReverseUint8Test( |
| 9762 | armnn::IWorkloadFactory& workloadFactory, |
| 9763 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9764 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9765 | return StridedSlice2DReverseTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 9766 | } |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9767 | |
Matteo Martincigh | 42666a1 | 2019-05-29 08:53:41 +0100 | [diff] [blame] | 9768 | LayerTestResult<int16_t, 4> StridedSlice4DInt16Test( |
| 9769 | armnn::IWorkloadFactory& workloadFactory, |
| 9770 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9771 | { |
| 9772 | return StridedSlice4DTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9773 | } |
| 9774 | |
| 9775 | LayerTestResult<int16_t, 4> StridedSlice4DReverseInt16Test( |
| 9776 | armnn::IWorkloadFactory& workloadFactory, |
| 9777 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9778 | { |
| 9779 | return StridedSlice4DReverseTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9780 | } |
| 9781 | |
| 9782 | LayerTestResult<int16_t, 4> StridedSliceSimpleStrideInt16Test( |
| 9783 | armnn::IWorkloadFactory& workloadFactory, |
| 9784 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9785 | { |
| 9786 | return StridedSliceSimpleStrideTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9787 | } |
| 9788 | |
| 9789 | LayerTestResult<int16_t, 4> StridedSliceSimpleRangeMaskInt16Test( |
| 9790 | armnn::IWorkloadFactory& workloadFactory, |
| 9791 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9792 | { |
| 9793 | return StridedSliceSimpleRangeMaskTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9794 | } |
| 9795 | |
| 9796 | LayerTestResult<int16_t, 2> StridedSliceShrinkAxisMaskInt16Test( |
| 9797 | armnn::IWorkloadFactory& workloadFactory, |
| 9798 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9799 | { |
| 9800 | return StridedSliceShrinkAxisMaskTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9801 | } |
| 9802 | |
| 9803 | LayerTestResult<int16_t, 3> StridedSlice3DInt16Test( |
| 9804 | armnn::IWorkloadFactory& workloadFactory, |
| 9805 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9806 | { |
| 9807 | return StridedSlice3DTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9808 | } |
| 9809 | |
| 9810 | LayerTestResult<int16_t, 3> StridedSlice3DReverseInt16Test( |
| 9811 | armnn::IWorkloadFactory& workloadFactory, |
| 9812 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9813 | { |
| 9814 | return StridedSlice3DReverseTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9815 | } |
| 9816 | |
| 9817 | LayerTestResult<int16_t, 2> StridedSlice2DInt16Test( |
| 9818 | armnn::IWorkloadFactory& workloadFactory, |
| 9819 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9820 | { |
| 9821 | return StridedSlice2DTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9822 | } |
| 9823 | |
| 9824 | LayerTestResult<int16_t, 2> StridedSlice2DReverseInt16Test( |
| 9825 | armnn::IWorkloadFactory& workloadFactory, |
| 9826 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9827 | { |
| 9828 | return StridedSlice2DReverseTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9829 | } |
| 9830 | |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9831 | LayerTestResult<float, 4> Debug4DFloat32Test( |
| 9832 | armnn::IWorkloadFactory& workloadFactory, |
| 9833 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9834 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9835 | return Debug4DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9836 | } |
| 9837 | |
| 9838 | LayerTestResult<float, 3> Debug3DFloat32Test( |
| 9839 | armnn::IWorkloadFactory& workloadFactory, |
| 9840 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9841 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9842 | return Debug3DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9843 | } |
| 9844 | |
| 9845 | LayerTestResult<float, 2> Debug2DFloat32Test( |
| 9846 | armnn::IWorkloadFactory& workloadFactory, |
| 9847 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9848 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9849 | return Debug2DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9850 | } |
| 9851 | |
| 9852 | LayerTestResult<float, 1> Debug1DFloat32Test( |
| 9853 | armnn::IWorkloadFactory& workloadFactory, |
| 9854 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9855 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9856 | return Debug1DTest<armnn::DataType::Float32>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9857 | } |
| 9858 | |
| 9859 | LayerTestResult<uint8_t, 4> Debug4DUint8Test( |
| 9860 | armnn::IWorkloadFactory& workloadFactory, |
| 9861 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9862 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9863 | return Debug4DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9864 | } |
| 9865 | |
| 9866 | LayerTestResult<uint8_t, 3> Debug3DUint8Test( |
| 9867 | armnn::IWorkloadFactory& workloadFactory, |
| 9868 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9869 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9870 | return Debug3DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9871 | } |
| 9872 | |
| 9873 | LayerTestResult<uint8_t, 2> Debug2DUint8Test( |
| 9874 | armnn::IWorkloadFactory& workloadFactory, |
| 9875 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9876 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9877 | return Debug2DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9878 | } |
| 9879 | |
| 9880 | LayerTestResult<uint8_t, 1> Debug1DUint8Test( |
| 9881 | armnn::IWorkloadFactory& workloadFactory, |
| 9882 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9883 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 9884 | return Debug1DTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 9885 | } |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 9886 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 9887 | LayerTestResult<float, 1> Gather1DParamsFloatTest( |
| 9888 | armnn::IWorkloadFactory& workloadFactory, |
| 9889 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9890 | { |
| 9891 | return Gather1DParamsTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager); |
| 9892 | } |
| 9893 | |
| 9894 | LayerTestResult<uint8_t, 1> Gather1DParamsUint8Test( |
| 9895 | armnn::IWorkloadFactory& workloadFactory, |
| 9896 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9897 | { |
| 9898 | return Gather1DParamsTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9899 | } |
| 9900 | |
| 9901 | LayerTestResult<float, 2> GatherMultiDimParamsFloatTest( |
| 9902 | armnn::IWorkloadFactory& workloadFactory, |
| 9903 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9904 | { |
| 9905 | return GatherMultiDimParamsTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager); |
| 9906 | } |
| 9907 | |
| 9908 | LayerTestResult<uint8_t, 2> GatherMultiDimParamsUint8Test( |
| 9909 | armnn::IWorkloadFactory& workloadFactory, |
| 9910 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9911 | { |
| 9912 | return GatherMultiDimParamsTestImpl<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9913 | } |
| 9914 | |
| 9915 | LayerTestResult<float, 4> GatherMultiDimParamsMultiDimIndicesFloatTest( |
| 9916 | armnn::IWorkloadFactory& workloadFactory, |
| 9917 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9918 | { |
| 9919 | return GatherMultiDimParamsMultiDimIndicesTestImpl<armnn::DataType::Float32>(workloadFactory, memoryManager); |
| 9920 | } |
| 9921 | |
| 9922 | LayerTestResult<uint8_t, 4> GatherMultiDimParamsMultiDimIndicesUint8Test( |
| 9923 | armnn::IWorkloadFactory& workloadFactory, |
| 9924 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9925 | { |
| 9926 | return GatherMultiDimParamsMultiDimIndicesTestImpl<armnn::DataType::QuantisedAsymm8>( |
| 9927 | workloadFactory, memoryManager); |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 9928 | } |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 9929 | |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 9930 | LayerTestResult<float, 4> DequantizeSimpleUint8Test( |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 9931 | armnn::IWorkloadFactory& workloadFactory, |
| 9932 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9933 | { |
| 9934 | return DequantizeSimpleTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9935 | } |
Nattapat Chaimanowong | a0beb3b | 2019-04-01 17:04:53 +0100 | [diff] [blame] | 9936 | |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 9937 | LayerTestResult<float, 4> DequantizeOffsetUint8Test( |
| 9938 | armnn::IWorkloadFactory& workloadFactory, |
| 9939 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9940 | { |
| 9941 | return DequantizeOffsetTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9942 | } |
| 9943 | |
| 9944 | LayerTestResult<float, 4> DequantizeSimpleInt16Test( |
| 9945 | armnn::IWorkloadFactory& workloadFactory, |
| 9946 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9947 | { |
| 9948 | return DequantizeSimpleTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9949 | } |
| 9950 | |
Nattapat Chaimanowong | a0beb3b | 2019-04-01 17:04:53 +0100 | [diff] [blame] | 9951 | LayerTestResult<uint8_t, 4> QuantizeSimpleUint8Test( |
| 9952 | armnn::IWorkloadFactory& workloadFactory, |
| 9953 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9954 | { |
| 9955 | return QuantizeSimpleTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9956 | } |
| 9957 | |
| 9958 | LayerTestResult<uint8_t, 4> QuantizeClampUint8Test( |
| 9959 | armnn::IWorkloadFactory& workloadFactory, |
| 9960 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9961 | { |
| 9962 | return QuantizeClampTest<armnn::DataType::QuantisedAsymm8>(workloadFactory, memoryManager); |
| 9963 | } |
| 9964 | |
| 9965 | LayerTestResult<int16_t, 4> QuantizeClampInt16Test( |
| 9966 | armnn::IWorkloadFactory& workloadFactory, |
| 9967 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 9968 | { |
| 9969 | return QuantizeClampTest<armnn::DataType::QuantisedSymm16>(workloadFactory, memoryManager); |
| 9970 | } |