Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | fbf0e5b | 2020-08-17 01:01:06 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ConcatTestImpl.hpp" |
| 7 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 8 | #include <QuantizeHelper.hpp> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 9 | #include <ResolveType.hpp> |
| 10 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 11 | |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 12 | #include <armnnUtils/Permute.hpp> |
| 13 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 14 | #include <backendsCommon/test/TensorCopyUtils.hpp> |
| 15 | #include <backendsCommon/test/WorkloadTestUtils.hpp> |
| 16 | |
| 17 | #include <test/TensorHelpers.hpp> |
| 18 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 19 | using namespace armnn; |
| 20 | using namespace armnnUtils; |
| 21 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 22 | // |
| 23 | // Helper functions and templates |
| 24 | // |
| 25 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 26 | OriginsDescriptor CreateDescriptorForConcat( |
| 27 | const std::vector<TensorInfo> & inputTensorInfos, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 28 | unsigned int concatDim) |
| 29 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 30 | std::vector<TensorShape> shapes; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 31 | shapes.reserve(inputTensorInfos.size()); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 32 | for (const TensorInfo& it: inputTensorInfos) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 33 | { |
| 34 | shapes.push_back(it.GetShape()); |
| 35 | } |
| 36 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 37 | return CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), concatDim); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | // |
| 41 | // Concat is only supported for N and C dimensions for NCHW and the inner most dimension |
| 42 | // In case of <4 dimensions we need to make sure that the concat dimensions are at least |
| 43 | // the 3rd slowest iterating one or the inner most dimension. |
| 44 | // |
| 45 | |
| 46 | bool NeedPermuteForConcat( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 47 | const std::vector<TensorInfo> & inputTensorInfos, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 48 | unsigned int concatDim) |
| 49 | { |
| 50 | // See note above. Additionally we expect the input shapes to have the |
| 51 | // same number of dimensions. |
| 52 | unsigned int nDimensions = 0; |
| 53 | |
| 54 | // Determine the number of dimensions as well as sanity check them |
| 55 | // agains test implementation issues. |
| 56 | for (auto && tensorInfo : inputTensorInfos) |
| 57 | { |
| 58 | if (!nDimensions) |
| 59 | { |
| 60 | nDimensions = tensorInfo.GetShape().GetNumDimensions(); |
| 61 | } |
| 62 | else |
| 63 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 64 | ARMNN_ASSERT_MSG(nDimensions == tensorInfo.GetShape().GetNumDimensions(), |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 65 | "Input shapes must have the same number of dimensions"); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return (nDimensions < 3 || (nDimensions == 3 && (nDimensions-concatDim) < 3 && (nDimensions-concatDim) != 1)); |
| 70 | } |
| 71 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 72 | TensorShape ExpandTensorShapeTo3dForPermute(const TensorShape & inputShape) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 73 | { |
| 74 | unsigned int numDims = inputShape.GetNumDimensions(); |
| 75 | if (numDims >= 3) |
| 76 | { |
| 77 | // Nothing to do if the inputShape has at least 3 dimensions. |
| 78 | return inputShape; |
| 79 | } |
| 80 | |
| 81 | std::vector<unsigned int> newDims(size_t(3), 1u); |
| 82 | unsigned int expandedBy = 3 - numDims; |
| 83 | for (unsigned int i=0; i<numDims; ++i) |
| 84 | { |
| 85 | newDims[expandedBy+i] = inputShape[i]; |
| 86 | } |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 87 | return TensorShape(3u, &newDims[0]); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | void Generate3dPermuteVectorForConcat( |
| 91 | unsigned int numDimensions, |
| 92 | unsigned int & concatDim, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 93 | std::pair<PermutationVector, PermutationVector> & permutations) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 94 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 95 | ARMNN_ASSERT_MSG(numDimensions <= 3, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 96 | "Only dimensions 1,2 and 3 are supported by this helper"); |
| 97 | unsigned int expandedBy = 3 - numDimensions; |
| 98 | unsigned int expandedConcatAxis = concatDim + expandedBy; |
| 99 | |
| 100 | if (expandedConcatAxis == 2) |
| 101 | { |
| 102 | concatDim = 0; |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 103 | PermutationVector forwardPermutation({1, 2, 0}); |
| 104 | PermutationVector reversePermutation({2, 0, 1}); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 105 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 106 | } |
| 107 | else if (expandedConcatAxis == 1) |
| 108 | { |
| 109 | concatDim = 0; |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 110 | PermutationVector forwardPermutation({2, 0, 1}); |
| 111 | PermutationVector reversePermutation({1, 2, 0}); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 112 | permutations = std::make_pair(forwardPermutation, reversePermutation); |
| 113 | } |
| 114 | else |
| 115 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 116 | ARMNN_ASSERT(expandedConcatAxis == 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 117 | concatDim = 0; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | template<typename T> void PermuteTensorData( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 122 | IWorkloadFactory& workloadFactory, |
| 123 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 124 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 125 | const PermutationVector& mappings, |
| 126 | TensorInfo & inputTensorInfo, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 127 | const T * inputData, |
| 128 | std::vector<T>& outputData) |
| 129 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 130 | IgnoreUnused(memoryManager); |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 131 | ARMNN_ASSERT_MSG(inputData != nullptr, "inputData must not be null"); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 132 | if (inputData == nullptr) |
| 133 | { |
| 134 | // Nullptr is an error in the test. By returning without doing the concatenation |
| 135 | // I expect the caller to fail the test. It still makes sense to report this as |
| 136 | // an assert for Debug builds. |
| 137 | return; |
| 138 | } |
| 139 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 140 | TensorInfo outputTensorInfo = armnnUtils::Permuted(inputTensorInfo, mappings); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 141 | std::unique_ptr<ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 142 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 143 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 144 | PermuteQueueDescriptor queueDescriptor; |
| 145 | queueDescriptor.m_Parameters = PermuteDescriptor{mappings}; |
| 146 | WorkloadInfo workloadInfo; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 147 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfo, inputHandle.get()); |
| 148 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 149 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 150 | std::unique_ptr<IWorkload> workload = workloadFactory.CreatePermute(queueDescriptor, workloadInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 151 | |
| 152 | inputHandle->Allocate(); |
| 153 | outputHandle->Allocate(); |
| 154 | |
| 155 | CopyDataToITensorHandle(inputHandle.get(), inputData); |
| 156 | |
| 157 | workload->PostAllocationConfigure(); |
| 158 | workload->Execute(); |
| 159 | |
| 160 | outputData.resize(outputTensorInfo.GetNumElements()); |
| 161 | CopyDataFromITensorHandle(&outputData[0], outputHandle.get()); |
| 162 | inputTensorInfo = outputTensorInfo; |
| 163 | } |
| 164 | |
| 165 | // |
| 166 | // Permute the input tensors so we can do a supported concatenation. |
| 167 | // Also treat lower than 3d tensors as 3d by adding dummy 1 dimensions |
| 168 | // at the front. Finally this function tells what the output shape |
| 169 | // of the permuted concatenated tensor is going to be. |
| 170 | // |
| 171 | template<typename T> void PermuteInputsForConcat( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 172 | IWorkloadFactory& workloadFactory, |
| 173 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 174 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 175 | std::vector<TensorInfo> & inputTensorInfos, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 176 | std::vector<T *> & inputData, |
| 177 | std::vector<std::vector<T>> & inputDataStorage, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 178 | PermutationVector & permuteVector, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 179 | unsigned int & concatDim, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 180 | TensorInfo & outputTensorInfo) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 181 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 182 | IgnoreUnused(memoryManager); |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 183 | ARMNN_ASSERT_MSG(inputTensorInfos.size() > 1, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 184 | "Expecting more than one tensor to be concatenated here"); |
| 185 | |
| 186 | unsigned int numDims = 0; |
| 187 | unsigned int nthInput = 0; |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 188 | const PermutationVector identity({0, 1, 2}); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 189 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 190 | std::pair<PermutationVector, PermutationVector> permutations = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 191 | std::make_pair(identity, identity); |
| 192 | |
| 193 | inputDataStorage.resize(inputData.size()); |
| 194 | |
| 195 | for (auto && tensorInfo : inputTensorInfos) |
| 196 | { |
| 197 | if (numDims == 0) |
| 198 | { |
| 199 | numDims = tensorInfo.GetShape().GetNumDimensions(); |
| 200 | Generate3dPermuteVectorForConcat(numDims, concatDim, permutations); |
| 201 | |
| 202 | // Store the reverese permutation. |
| 203 | permuteVector = permutations.second; |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 204 | ARMNN_ASSERT_MSG(!permuteVector.IsEqual(identity), |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 205 | "Test logic error, we don't need permutation, so we shouldn't arrive here"); |
| 206 | } |
| 207 | else |
| 208 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 209 | ARMNN_ASSERT_MSG(numDims == tensorInfo.GetShape().GetNumDimensions(), |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 210 | "All inputs must have the same number of dimensions"); |
| 211 | } |
| 212 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 213 | TensorInfo newTensorInfo = tensorInfo; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 214 | newTensorInfo.SetShape(ExpandTensorShapeTo3dForPermute(tensorInfo.GetShape())); |
| 215 | |
| 216 | PermuteTensorData<T>(workloadFactory, |
| 217 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 218 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 219 | permutations.first, |
| 220 | newTensorInfo, |
| 221 | inputData[nthInput], |
| 222 | inputDataStorage[nthInput]); |
| 223 | |
| 224 | inputData[nthInput] = inputDataStorage[nthInput].data(); |
| 225 | inputTensorInfos[nthInput] = newTensorInfo; |
| 226 | |
| 227 | ++nthInput; |
| 228 | } |
| 229 | |
| 230 | outputTensorInfo.SetShape( |
| 231 | armnnUtils::Permuted( |
| 232 | ExpandTensorShapeTo3dForPermute(outputTensorInfo.GetShape()), |
| 233 | permutations.first)); |
| 234 | } |
| 235 | |
| 236 | // |
| 237 | // This is the pair of PermuteInputsForConcat(...) which permutes back |
| 238 | // the output of the concatenation so we can check it against an expected |
| 239 | // output. |
| 240 | // |
| 241 | template <typename T> void PermuteOutputForConcat( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 242 | IWorkloadFactory& workloadFactory, |
| 243 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 244 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 245 | const TensorInfo & tensorInfo, |
| 246 | const PermutationVector & permuteVector, |
| 247 | std::unique_ptr<ITensorHandle> && inputDataHandle, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 248 | T * data) |
| 249 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 250 | ARMNN_ASSERT_MSG(data != nullptr, "data must not be null"); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 251 | if (data == nullptr) |
| 252 | { |
| 253 | // Nullptr is an error in the test. By returning without doing the permutation |
| 254 | // I expect the caller to fail the test. It still makes sense to report this as |
| 255 | // an assert for Debug builds. |
| 256 | return; |
| 257 | } |
| 258 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 259 | TensorInfo resultTensorInfo = tensorInfo; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 260 | std::vector<T> inputData(tensorInfo.GetNumElements()); |
| 261 | std::vector<T> outputData; |
| 262 | |
| 263 | CopyDataFromITensorHandle(&inputData[0], inputDataHandle.get()); |
| 264 | |
| 265 | PermuteTensorData<T>(workloadFactory, |
| 266 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 267 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 268 | permuteVector, |
| 269 | resultTensorInfo, |
| 270 | &inputData[0], |
| 271 | outputData); |
| 272 | |
| 273 | ::memcpy(data, &outputData[0], sizeof(T)*outputData.size()); |
| 274 | } |
| 275 | |
| 276 | template<typename T> void Concatenate( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 277 | IWorkloadFactory& workloadFactory, |
| 278 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 279 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 280 | std::initializer_list<const TensorInfo> inputTensorInfosOrig, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 281 | std::initializer_list<T *> inputsOrig, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 282 | const TensorInfo& outputTensorInfoOrig, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 283 | T * output, |
| 284 | unsigned int concatDim, |
| 285 | bool useSubtensor) |
| 286 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 287 | ARMNN_ASSERT_MSG(output != nullptr, "output must not be null"); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 288 | if (output == nullptr) |
| 289 | { |
| 290 | // Nullptr is an error in the test. By returning without doing the permutation |
| 291 | // I expect the caller to fail the test. It still makes sense to report this as |
| 292 | // an assert for Debug builds. |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | // Saves a copy of the parameters which we might need to change. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 297 | std::vector<TensorInfo> inputTensorInfos(inputTensorInfosOrig.begin(), inputTensorInfosOrig.end()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 298 | std::vector<T *> inputs = inputsOrig; |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 299 | TensorInfo outputTensorInfo = outputTensorInfoOrig; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 300 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 301 | PermutationVector permuteVector{0, 1, 2}; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 302 | |
| 303 | // Holds and automatically releases memory for the reshaped input data. |
| 304 | std::vector<std::vector<T>> tmpInputDataStorage; |
| 305 | |
| 306 | const size_t inputCount = inputTensorInfos.size(); |
| 307 | |
| 308 | bool needPermuteForConcat = NeedPermuteForConcat(inputTensorInfos, concatDim); |
| 309 | |
| 310 | if (needPermuteForConcat) |
| 311 | { |
| 312 | // |
| 313 | // We need to permute the inputs, because concatenation along |
| 314 | // the requested axis is not supported. |
| 315 | // |
| 316 | PermuteInputsForConcat<T>(workloadFactory, |
| 317 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 318 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 319 | inputTensorInfos, |
| 320 | inputs, |
| 321 | tmpInputDataStorage, |
| 322 | permuteVector, |
| 323 | concatDim, |
| 324 | outputTensorInfo); |
| 325 | } |
| 326 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 327 | WorkloadInfo workloadInfo; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 328 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 329 | std::vector<std::unique_ptr<ITensorHandle>> inputHandles; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 330 | inputHandles.reserve(inputCount); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 331 | |
| 332 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 333 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 334 | ConcatQueueDescriptor queueDescriptor; |
| 335 | OriginsDescriptor viewsDescriptor = CreateDescriptorForConcat(inputTensorInfos, concatDim); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 336 | queueDescriptor.m_Parameters = viewsDescriptor; |
| 337 | |
| 338 | if (useSubtensor) |
| 339 | { |
| 340 | queueDescriptor.m_ViewOrigins.reserve(viewsDescriptor.GetNumViews()); |
| 341 | for (unsigned int i = 0; i < viewsDescriptor.GetNumViews(); ++i) |
| 342 | { |
| 343 | queueDescriptor.m_ViewOrigins.emplace_back(std::vector<unsigned int>(viewsDescriptor.GetViewOrigin(i), |
| 344 | viewsDescriptor.GetViewOrigin(i) + viewsDescriptor.GetNumDimensions())); |
| 345 | } |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 346 | |
| 347 | outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 348 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 349 | const bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 350 | for (unsigned int i = 0; i < inputCount; ++i) |
| 351 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 352 | const TensorInfo& inputTensorInfo = inputTensorInfos[i]; |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 353 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 354 | std::unique_ptr<ITensorHandle> inputHandle = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 355 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 356 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 357 | inputTensorInfo.GetShape(), |
| 358 | queueDescriptor.m_ViewOrigins[i].m_Origin.data()) : |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 359 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo); |
| 360 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 361 | inputHandles.emplace_back(std::move(inputHandle)); |
| 362 | } |
| 363 | |
Teresa Charlin | fbf0e5b | 2020-08-17 01:01:06 +0100 | [diff] [blame] | 364 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 365 | } |
| 366 | else |
| 367 | { |
| 368 | for (unsigned int i = 0; i < inputCount; ++i) |
| 369 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 370 | std::unique_ptr<ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfos[i]); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 371 | inputHandles.emplace_back(std::move(inputHandle)); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | for (unsigned int i = 0; i < inputCount; ++i) |
| 376 | { |
| 377 | AddInputToWorkload(queueDescriptor, workloadInfo, inputTensorInfos[i], inputHandles[i].get()); |
| 378 | } |
| 379 | |
| 380 | AddOutputToWorkload(queueDescriptor, workloadInfo, outputTensorInfo, outputHandle.get()); |
| 381 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 382 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(queueDescriptor, workloadInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 383 | |
| 384 | for (auto& inputHandle : inputHandles) |
| 385 | { |
| 386 | inputHandle->Allocate(); |
| 387 | } |
| 388 | |
| 389 | outputHandle->Allocate(); |
| 390 | |
| 391 | unsigned int nextInputId = 0; |
| 392 | for (auto& inputHandle : inputHandles) |
| 393 | { |
| 394 | CopyDataToITensorHandle(inputHandle.get(), inputs[nextInputId]); |
| 395 | ++nextInputId; |
| 396 | } |
| 397 | |
| 398 | workload->PostAllocationConfigure(); |
| 399 | workload->Execute(); |
| 400 | |
| 401 | if (needPermuteForConcat) |
| 402 | { |
| 403 | PermuteOutputForConcat<T>(workloadFactory, |
| 404 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 405 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 406 | outputTensorInfo, |
| 407 | permuteVector, |
| 408 | std::move(outputHandle), |
| 409 | output); |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | CopyDataFromITensorHandle(output, outputHandle.get()); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | // |
| 418 | // Implementation templates |
| 419 | // |
| 420 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 421 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 422 | LayerTestResult<T, 1> Concat1dTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 423 | IWorkloadFactory& workloadFactory, |
| 424 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 425 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 426 | float qScale, |
| 427 | int32_t qOffset) |
| 428 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 429 | TensorInfo inputTensorInfo({ 3 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 430 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 431 | auto input0 = QuantizedVector<T>({ 1.0f, 2.0f, 3.0f }, qScale, qOffset); |
| 432 | auto input1 = QuantizedVector<T>({ 4.0f, 5.0f, 6.0f }, qScale, qOffset); |
| 433 | auto input2 = QuantizedVector<T>({ 7.0f, 8.0f, 9.0f }, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 434 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 435 | TensorInfo outputTensorInfo({ 9 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 436 | |
| 437 | LayerTestResult<T, 1> result(outputTensorInfo); |
| 438 | |
| 439 | std::vector<T> output; |
| 440 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 441 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 442 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 443 | { input0.data(), input1.data(), input2.data() }, |
| 444 | outputTensorInfo, |
| 445 | output.data(), |
| 446 | 0, |
| 447 | true); |
| 448 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 449 | result.m_ActualData = output; |
| 450 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 451 | { |
| 452 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f |
| 453 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 454 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 455 | |
| 456 | return result; |
| 457 | } |
| 458 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 459 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 460 | LayerTestResult<T, 2> Concat2dTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 461 | IWorkloadFactory& workloadFactory, |
| 462 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 463 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 464 | const TensorInfo& outputTensorInfo, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 465 | unsigned int dimension, |
| 466 | const float qScale, |
| 467 | const int32_t qOffset) |
| 468 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 469 | TensorInfo inputTensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 470 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 471 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 472 | { |
| 473 | // Batch 0 |
| 474 | 1.0f, 2.0f, 3.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 475 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 476 | // Batch 1 |
| 477 | 10.0f, 11.0f, 12.0f, |
| 478 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 479 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 480 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 481 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 482 | { |
| 483 | // Batch 0 |
| 484 | 4.0f, 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 485 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 486 | // Batch 1 |
| 487 | 13.0f, 14.0f, 15.0f, |
| 488 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 489 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 490 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 491 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 492 | { |
| 493 | // Batch 0 |
| 494 | 7.0f, 8.0f, 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 495 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 496 | // Batch 1 |
| 497 | 16.0f, 17.0f, 18.0f, |
| 498 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 499 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 500 | |
| 501 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 502 | |
| 503 | std::vector<T> output; |
| 504 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 505 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 506 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 507 | { input0.data(), input1.data(), input2.data() }, |
| 508 | outputTensorInfo, |
| 509 | output.data(), |
| 510 | dimension, |
| 511 | true); |
| 512 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 513 | result.m_ActualData = output; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 514 | return result; |
| 515 | } |
| 516 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 517 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 518 | LayerTestResult<T, 2> Concat2dDim0TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 519 | IWorkloadFactory& workloadFactory, |
| 520 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 521 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 522 | float qScale, |
| 523 | int32_t qOffset) |
| 524 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 525 | TensorInfo outputTensorInfo({ 6, 3 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 526 | |
| 527 | LayerTestResult<T, 2> result = Concat2dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 528 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 0, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 529 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 530 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 531 | { |
| 532 | // Batch 0 |
| 533 | 1.0f, 2.0f, 3.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 534 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 535 | // Batch 1 |
| 536 | 10.0f, 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 537 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 538 | // Batch 2 |
| 539 | 4.0f, 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 540 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 541 | // Batch 3 |
| 542 | 13.0f, 14.0f, 15.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 543 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 544 | // Batch 4 |
| 545 | 7.0f, 8.0f, 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 546 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 547 | // Batch 5 |
| 548 | 16.0f, 17.0f, 18.0f, |
| 549 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 550 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 551 | |
| 552 | return result; |
| 553 | } |
| 554 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 555 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 556 | LayerTestResult<T, 2> Concat2dDim1TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 557 | IWorkloadFactory& workloadFactory, |
| 558 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 559 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 560 | float qScale, |
| 561 | int32_t qOffset) |
| 562 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 563 | TensorInfo outputTensorInfo({ 2, 9 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 564 | |
| 565 | LayerTestResult<T, 2> result = Concat2dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 566 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 1, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 567 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 568 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 569 | { |
| 570 | // Batch 0 |
| 571 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 572 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 573 | // Batch 1 |
| 574 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f |
| 575 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 576 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 577 | |
| 578 | return result; |
| 579 | } |
| 580 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 581 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 582 | LayerTestResult<T, 2> Concat2dDim0DiffInputDimsTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 583 | IWorkloadFactory& workloadFactory, |
| 584 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 585 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 586 | float qScale, |
| 587 | int32_t qOffset) |
| 588 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 589 | TensorInfo input0TensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 590 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 591 | { |
| 592 | // Batch 0 |
| 593 | 1.0f, 2.0f, 3.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 594 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 595 | // Batch 1 |
| 596 | 10.0f, 11.0f, 12.0f, |
| 597 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 598 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 599 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 600 | TensorInfo input1TensorInfo({ 3, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 601 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 602 | { |
| 603 | // Batch 0 |
| 604 | 4.0f, 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 605 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 606 | // Batch 1 |
| 607 | 13.0f, 14.0f, 15.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 608 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 609 | // Batch 0 |
| 610 | 7.0f, 8.0f, 9.0f, |
| 611 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 612 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 613 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 614 | TensorInfo input2TensorInfo({ 1, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 615 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 616 | { |
| 617 | // Batch 1 |
| 618 | 16.0f, 17.0f, 18.0f, |
| 619 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 620 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 621 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 622 | TensorInfo outputTensorInfo({ 6, 3 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 623 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 624 | |
| 625 | std::vector<T> output; |
| 626 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 627 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 628 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 629 | { input0.data(), input1.data(), input2.data() }, |
| 630 | outputTensorInfo, |
| 631 | output.data(), |
| 632 | 0, |
| 633 | true); |
| 634 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 635 | result.m_ActualData = output; |
| 636 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 637 | { |
| 638 | // Batch 0 |
| 639 | 1.0f, 2.0f, 3.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 640 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 641 | // Batch 1 |
| 642 | 10.0f, 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 643 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 644 | // Batch 2 |
| 645 | 4.0f, 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 646 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 647 | // Batch 3 |
| 648 | 13.0f, 14.0f, 15.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 649 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 650 | // Batch 4 |
| 651 | 7.0f, 8.0f, 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 652 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 653 | // Batch 5 |
| 654 | 16.0f, 17.0f, 18.0f, |
| 655 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 656 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 657 | |
| 658 | return result; |
| 659 | } |
| 660 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 661 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 662 | LayerTestResult<T, 2> Concat2dDim1DiffInputDimsTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 663 | IWorkloadFactory& workloadFactory, |
| 664 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 665 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 666 | float qScale, |
| 667 | int32_t qOffset) |
| 668 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 669 | TensorInfo input0TensorInfo({ 2, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 670 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 671 | { |
| 672 | // Batch 0 |
| 673 | 1.0f, 2.0f, 3.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 674 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 675 | // Batch 1 |
| 676 | 10.0f, 11.0f, 12.0f, |
| 677 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 678 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 679 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 680 | TensorInfo input1TensorInfo({ 2, 5 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 681 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 682 | { |
| 683 | // Batch 0 |
| 684 | 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 685 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 686 | // Batch 1 |
| 687 | 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, |
| 688 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 689 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 690 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 691 | TensorInfo input2TensorInfo({ 2, 1 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 692 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 693 | { |
| 694 | // Batch 0 |
| 695 | 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 696 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 697 | // Batch 1 |
| 698 | 18.0f |
| 699 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 700 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 701 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 702 | TensorInfo outputTensorInfo({ 2, 9 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 703 | LayerTestResult<T, 2> result(outputTensorInfo); |
| 704 | |
| 705 | std::vector<T> output; |
| 706 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 707 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 708 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 709 | { input0.data(), input1.data(), input2.data() }, |
| 710 | outputTensorInfo, |
| 711 | output.data(), |
| 712 | 1, |
| 713 | true); |
| 714 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 715 | result.m_ActualData = output; |
| 716 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 717 | { |
| 718 | // Batch 0 |
| 719 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 720 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 721 | // Batch 1 |
| 722 | 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, |
| 723 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 724 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 725 | |
| 726 | return result; |
| 727 | } |
| 728 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 729 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 730 | LayerTestResult<T, 3> Concat3dTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 731 | IWorkloadFactory& workloadFactory, |
| 732 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 733 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 734 | const TensorInfo& outputTensorInfo, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 735 | unsigned int dimension, |
| 736 | bool useSubtensor, |
| 737 | float qScale, |
| 738 | int32_t qOffset) |
| 739 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 740 | TensorInfo inputTensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 741 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 742 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 743 | { |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 744 | // Batch 0, Channel 0 |
| 745 | 1.0f, 2.0f, |
| 746 | |
| 747 | // Batch 0, Channel 1 |
| 748 | 3.0f, 4.0f, |
| 749 | |
| 750 | // Batch 0, Channel 2 |
| 751 | 5.0f, 6.0f, |
| 752 | |
| 753 | // Batch 1, Channel 0 |
| 754 | 19.0f, 20.0f, |
| 755 | |
| 756 | // Batch 1, Channel 1 |
| 757 | 21.0f, 22.0f, |
| 758 | |
| 759 | // Batch 1, Channel 2 |
| 760 | 23.0f, 24.0f |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 761 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 762 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 763 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 764 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 765 | { |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 766 | // Batch 0, Channel 0 |
| 767 | 7.0f, 8.0f, |
| 768 | |
| 769 | // Batch 0, Channel 1 |
| 770 | 9.0f, 10.0f, |
| 771 | |
| 772 | // Batch 0, Channel 2 |
| 773 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 774 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 775 | // Batch 1, Channel 0 |
| 776 | 25.0f, 26.0f, |
| 777 | |
| 778 | // Batch 1, Channel 1 |
| 779 | 27.0f, 28.0f, |
| 780 | |
| 781 | // Batch 1, Channel 2 |
| 782 | 29.0f, 30.0f |
| 783 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 784 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 785 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 786 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 787 | { |
| 788 | // Batch 0, Channel 0 |
| 789 | 13.0f, 14.0f, |
| 790 | |
| 791 | // Batch 0, Channel 1 |
| 792 | 15.0f, 16.0f, |
| 793 | |
| 794 | // Batch 0, Channel 2 |
| 795 | 17.0f, 18.0f, |
| 796 | |
| 797 | // Batch 1, Channel 0 |
| 798 | 31.0f, 32.0f, |
| 799 | |
| 800 | // Batch 1, Channel 1 |
| 801 | 33.0f, 34.0f, |
| 802 | |
| 803 | // Batch 1, Channel 2 |
| 804 | 35.0f, 36.0f |
| 805 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 806 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 807 | |
| 808 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 809 | |
| 810 | std::vector<T> output; |
| 811 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 812 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 813 | { inputTensorInfo, inputTensorInfo, inputTensorInfo }, |
| 814 | { input0.data(), input1.data(), input2.data() }, |
| 815 | outputTensorInfo, |
| 816 | output.data(), |
| 817 | dimension, |
| 818 | useSubtensor); |
| 819 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 820 | result.m_ActualData = output; |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 821 | return result; |
| 822 | } |
| 823 | |
| 824 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
| 825 | LayerTestResult<T, 3> Concat3dDim0TestImpl( |
| 826 | IWorkloadFactory& workloadFactory, |
| 827 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 828 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 829 | float qScale, |
| 830 | int32_t qOffset) |
| 831 | { |
| 832 | TensorInfo outputTensorInfo({ 6, 3, 2 }, ArmnnType, qScale, qOffset); |
| 833 | |
| 834 | LayerTestResult<T, 3> result = Concat3dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 835 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 0, true, qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 836 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 837 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 838 | { |
| 839 | // Batch 0, Channel 0 |
| 840 | 1.0f, 2.0f, |
| 841 | |
| 842 | // Batch 0, Channel 1 |
| 843 | 3.0f, 4.0f, |
| 844 | |
| 845 | // Batch 0, Channel 2 |
| 846 | 5.0f, 6.0f, |
| 847 | |
| 848 | // Batch 1, Channel 0 |
| 849 | 19.0f, 20.0f, |
| 850 | |
| 851 | // Batch 1, Channel 1 |
| 852 | 21.0f, 22.0f, |
| 853 | |
| 854 | // Batch 1, Channel 2 |
| 855 | 23.0f, 24.0f, |
| 856 | |
| 857 | // Batch 2, Channel 0 |
| 858 | 7.0f, 8.0f, |
| 859 | |
| 860 | // Batch 2, Channel 1 |
| 861 | 9.0f, 10.0f, |
| 862 | |
| 863 | // Batch 2, Channel 2 |
| 864 | 11.0f, 12.0f, |
| 865 | |
| 866 | // Batch 3, Channel 0 |
| 867 | 25.0f, 26.0f, |
| 868 | |
| 869 | // Batch 3, Channel 1 |
| 870 | 27.0f, 28.0f, |
| 871 | |
| 872 | // Batch 3, Channel 2 |
| 873 | 29.0f, 30.0f, |
| 874 | |
| 875 | // Batch 4, Channel 0 |
| 876 | 13.0f, 14.0f, |
| 877 | |
| 878 | // Batch 4, Channel 1 |
| 879 | 15.0f, 16.0f, |
| 880 | |
| 881 | // Batch 4, Channel 2 |
| 882 | 17.0f, 18.0f, |
| 883 | |
| 884 | // Batch 5, Channel 0 |
| 885 | 31.0f, 32.0f, |
| 886 | |
| 887 | // Batch 5, Channel 1 |
| 888 | 33.0f, 34.0f, |
| 889 | |
| 890 | // Batch 5, Channel 2 |
| 891 | 35.0f, 36.0f |
| 892 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 893 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 894 | |
| 895 | return result; |
| 896 | } |
| 897 | |
| 898 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
| 899 | LayerTestResult<T, 3> Concat3dDim1TestImpl( |
| 900 | IWorkloadFactory& workloadFactory, |
| 901 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 902 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 903 | float qScale, |
| 904 | int32_t qOffset) |
| 905 | { |
| 906 | TensorInfo outputTensorInfo({ 2, 9, 2 }, ArmnnType, qScale, qOffset); |
| 907 | |
| 908 | LayerTestResult<T, 3> result = Concat3dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 909 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 1, true, qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 910 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 911 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 912 | { |
| 913 | // Batch 0, Channel 0 |
| 914 | 1.0f, 2.0f, |
| 915 | |
| 916 | // Batch 0, Channel 1 |
| 917 | 3.0f, 4.0f, |
| 918 | |
| 919 | // Batch 0, Channel 2 |
| 920 | 5.0f, 6.0f, |
| 921 | |
| 922 | // Batch 0, Channel 3 |
| 923 | 7.0f, 8.0f, |
| 924 | |
| 925 | // Batch 0, Channel 4 |
| 926 | 9.0f, 10.0f, |
| 927 | |
| 928 | // Batch 0, Channel 5 |
| 929 | 11.0f, 12.0f, |
| 930 | |
| 931 | // Batch 0, Channel 6 |
| 932 | 13.0f, 14.0f, |
| 933 | |
| 934 | // Batch 0, Channel 7 |
| 935 | 15.0f, 16.0f, |
| 936 | |
| 937 | // Batch 0, Channel 8 |
| 938 | 17.0f, 18.0f, |
| 939 | |
| 940 | // Batch 1, Channel 0 |
| 941 | 19.0f, 20.0f, |
| 942 | |
| 943 | // Batch 1, Channel 1 |
| 944 | 21.0f, 22.0f, |
| 945 | |
| 946 | // Batch 1, Channel 2 |
| 947 | 23.0f, 24.0f, |
| 948 | |
| 949 | // Batch 1, Channel 3 |
| 950 | 25.0f, 26.0f, |
| 951 | |
| 952 | // Batch 1, Channel 4 |
| 953 | 27.0f, 28.0f, |
| 954 | |
| 955 | // Batch 1, Channel 5 |
| 956 | 29.0f, 30.0f, |
| 957 | |
| 958 | // Batch 1, Channel 6 |
| 959 | 31.0f, 32.0f, |
| 960 | |
| 961 | // Batch 1, Channel 7 |
| 962 | 33.0f, 34.0f, |
| 963 | |
| 964 | // Batch 1, Channel 8 |
| 965 | 35.0f, 36.0f |
| 966 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 967 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 968 | |
| 969 | return result; |
| 970 | } |
| 971 | |
| 972 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
| 973 | LayerTestResult<T, 3> Concat3dDim2TestImpl( |
| 974 | IWorkloadFactory& workloadFactory, |
| 975 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 976 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 977 | bool useSubtensor, |
| 978 | float qScale, |
| 979 | int32_t qOffset) |
| 980 | { |
| 981 | TensorInfo outputTensorInfo({ 2, 3, 6 }, ArmnnType, qScale, qOffset); |
| 982 | |
| 983 | LayerTestResult<T, 3> result = Concat3dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 984 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 2, useSubtensor, qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 985 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 986 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 987 | { |
| 988 | // Batch 0, Channel 0 |
| 989 | 1.0f, 2.0f, 7.0f, 8.0f, 13.0f, 14.0f, |
| 990 | |
| 991 | // Batch 0, Channel 1 |
| 992 | 3.0f, 4.0f, 9.0f, 10.0f, 15.0f, 16.0f, |
| 993 | |
| 994 | // Batch 0, Channel 2 |
| 995 | 5.0f, 6.0f, 11.0f, 12.0f, 17.0f, 18.0f, |
| 996 | |
| 997 | // Batch 1, Channel 0 |
| 998 | 19.0f, 20.0f, 25.0f, 26.0f, 31.0f, 32.0f, |
| 999 | |
| 1000 | // Batch 1, Channel 1 |
| 1001 | 21.0f, 22.0f, 27.0f, 28.0f, 33.0f, 34.0f, |
| 1002 | |
| 1003 | // Batch 1, Channel 2 |
| 1004 | 23.0f, 24.0f, 29.0f, 30.0f, 35.0f, 36.0f, |
| 1005 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1006 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1007 | |
| 1008 | return result; |
| 1009 | } |
| 1010 | |
| 1011 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
| 1012 | LayerTestResult<T, 3> Concat3dDim0DiffInputDimsTestImpl( |
| 1013 | IWorkloadFactory& workloadFactory, |
| 1014 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1015 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1016 | float qScale, |
| 1017 | int32_t qOffset) |
| 1018 | { |
| 1019 | TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1020 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1021 | { |
| 1022 | // Batch 0, Channel 0 |
| 1023 | 1.0f, 2.0f, |
| 1024 | |
| 1025 | // Batch 0, Channel 1 |
| 1026 | 3.0f, 4.0f, |
| 1027 | |
| 1028 | // Batch 0, Channel 2 |
| 1029 | 5.0f, 6.0f, |
| 1030 | |
| 1031 | // Batch 1, Channel 0 |
| 1032 | 19.0f, 20.0f, |
| 1033 | |
| 1034 | // Batch 1, Channel 1 |
| 1035 | 21.0f, 22.0f, |
| 1036 | |
| 1037 | // Batch 1, Channel 2 |
| 1038 | 23.0f, 24.0f |
| 1039 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1040 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1041 | |
| 1042 | TensorInfo input1TensorInfo({ 1, 3, 2 }, ArmnnType); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1043 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1044 | { |
| 1045 | // Batch 0, Channel 0 |
| 1046 | 7.0f, 8.0f, |
| 1047 | |
| 1048 | // Batch 0, Channel 1 |
| 1049 | 9.0f, 10.0f, |
| 1050 | |
| 1051 | // Batch 0, Channel 2 |
| 1052 | 11.0f, 12.0f, |
| 1053 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1054 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1055 | |
| 1056 | TensorInfo input2TensorInfo({ 3, 3, 2 }, ArmnnType); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1057 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1058 | { |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1059 | // Batch 0, Channel 0 |
| 1060 | 25.0f, 26.0f, |
| 1061 | |
| 1062 | // Batch 0, Channel 1 |
| 1063 | 27.0f, 28.0f, |
| 1064 | |
| 1065 | // Batch 0, Channel 2 |
| 1066 | 29.0f, 30.0f, |
| 1067 | |
| 1068 | // Batch 1, Channel 0 |
| 1069 | 13.0f, 14.0f, |
| 1070 | |
| 1071 | // Batch 1, Channel 1 |
| 1072 | 15.0f, 16.0f, |
| 1073 | |
| 1074 | // Batch 1, Channel 2 |
| 1075 | 17.0f, 18.0f, |
| 1076 | |
| 1077 | // Batch 2, Channel 0 |
| 1078 | 31.0f, 32.0f, |
| 1079 | |
| 1080 | // Batch 2, Channel 1 |
| 1081 | 33.0f, 34.0f, |
| 1082 | |
| 1083 | // Batch 2, Channel 2 |
| 1084 | 35.0f, 36.0f |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1085 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1086 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1087 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1088 | TensorInfo outputTensorInfo({ 6, 3, 2 }, ArmnnType); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1089 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 1090 | |
| 1091 | std::vector<T> output; |
| 1092 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1093 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1094 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 1095 | { input0.data(), input1.data(), input2.data() }, |
| 1096 | outputTensorInfo, |
| 1097 | output.data(), |
| 1098 | 0, |
| 1099 | true); |
| 1100 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1101 | result.m_ActualData = output; |
| 1102 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1103 | { |
| 1104 | // Batch 0, Channel 0 |
| 1105 | 1.0f, 2.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1106 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1107 | // Batch 0, Channel 1 |
| 1108 | 3.0f, 4.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1109 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1110 | // Batch 0, Channel 2 |
| 1111 | 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1112 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1113 | // Batch 1, Channel 0 |
| 1114 | 19.0f, 20.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1115 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1116 | // Batch 1, Channel 1 |
| 1117 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1118 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1119 | // Batch 1, Channel 2 |
| 1120 | 23.0f, 24.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1121 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1122 | // Batch 2, Channel 0 |
| 1123 | 7.0f, 8.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1124 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1125 | // Batch 2, Channel 1 |
| 1126 | 9.0f, 10.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1127 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1128 | // Batch 2, Channel 2 |
| 1129 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1130 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1131 | // Batch 3, Channel 0 |
| 1132 | 25.0f, 26.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1133 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1134 | // Batch 3, Channel 1 |
| 1135 | 27.0f, 28.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1136 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1137 | // Batch 3, Channel 2 |
| 1138 | 29.0f, 30.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1139 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1140 | // Batch 4, Channel 0 |
| 1141 | 13.0f, 14.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1142 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1143 | // Batch 4, Channel 1 |
| 1144 | 15.0f, 16.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1145 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1146 | // Batch 4, Channel 2 |
| 1147 | 17.0f, 18.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1148 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1149 | // Batch 5, Channel 0 |
| 1150 | 31.0f, 32.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1151 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1152 | // Batch 5, Channel 1 |
| 1153 | 33.0f, 34.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1154 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1155 | // Batch 5, Channel 2 |
| 1156 | 35.0f, 36.0f |
| 1157 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1158 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1159 | |
| 1160 | return result; |
| 1161 | } |
| 1162 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1163 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1164 | LayerTestResult<T, 3> Concat3dDim1DiffInputDimsTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1165 | IWorkloadFactory& workloadFactory, |
| 1166 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1167 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1168 | float qScale, |
| 1169 | int32_t qOffset) |
| 1170 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1171 | TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1172 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1173 | { |
| 1174 | // Batch 0, Channel 0 |
| 1175 | 1.0f, 2.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1176 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1177 | // Batch 0, Channel 1 |
| 1178 | 3.0f, 4.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1179 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1180 | // Batch 0, Channel 2 |
| 1181 | 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1182 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1183 | // Batch 1, Channel 0 |
| 1184 | 19.0f, 20.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1185 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1186 | // Batch 1, Channel 1 |
| 1187 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1188 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1189 | // Batch 1, Channel 2 |
| 1190 | 23.0f, 24.0f |
| 1191 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1192 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1193 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1194 | TensorInfo input1TensorInfo({ 2, 4, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1195 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1196 | { |
| 1197 | // Batch 0, Channel 0 |
| 1198 | 7.0f, 8.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1199 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1200 | // Batch 0, Channel 1 |
| 1201 | 9.0f, 10.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1202 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1203 | // Batch 0, Channel 2 |
| 1204 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1205 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1206 | // Batch 0, Channel 3 |
| 1207 | 25.0f, 26.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1208 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1209 | // Batch 1, Channel 0 |
| 1210 | 27.0f, 28.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1211 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1212 | // Batch 1, Channel 1 |
| 1213 | 29.0f, 30.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1214 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1215 | // Batch 1, Channel 2 |
| 1216 | 13.0f, 14.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1217 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1218 | // Batch 1, Channel 3 |
| 1219 | 15.0f, 16.0f, |
| 1220 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1221 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1222 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1223 | TensorInfo input2TensorInfo({ 2, 1, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1224 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1225 | { |
| 1226 | // Batch 0, Channel 0 |
| 1227 | 17.0f, 18.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1228 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1229 | // Batch 1, Channel 0 |
| 1230 | 31.0f, 32.0f, |
| 1231 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1232 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1233 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1234 | TensorInfo outputTensorInfo({ 2, 8, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1235 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 1236 | |
| 1237 | std::vector<T> output; |
| 1238 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1239 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1240 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 1241 | { input0.data(), input1.data(), input2.data() }, |
| 1242 | outputTensorInfo, |
| 1243 | output.data(), |
| 1244 | 1, |
| 1245 | true); |
| 1246 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1247 | result.m_ActualData = output; |
| 1248 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1249 | { |
| 1250 | // Batch 0, Channel 0 |
| 1251 | 1.0f, 2.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1252 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1253 | // Batch 0, Channel 1 |
| 1254 | 3.0f, 4.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1255 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1256 | // Batch 0, Channel 2 |
| 1257 | 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1258 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1259 | // Batch 0, Channel 3 |
| 1260 | 7.0f, 8.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1261 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1262 | // Batch 0, Channel 4 |
| 1263 | 9.0f, 10.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1264 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1265 | // Batch 0, Channel 5 |
| 1266 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1267 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1268 | // Batch 0, Channel 6 |
| 1269 | 25.0f, 26.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1270 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1271 | // Batch 0, Channel 7 |
| 1272 | 17.0f, 18.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1273 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1274 | // Batch 1, Channel 0 |
| 1275 | 19.0f, 20.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1276 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1277 | // Batch 1, Channel 1 |
| 1278 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1279 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1280 | // Batch 1, Channel 2 |
| 1281 | 23.0f, 24.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1282 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1283 | // Batch 1, Channel 3 |
| 1284 | 27.0f, 28.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1285 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1286 | // Batch 1, Channel 4 |
| 1287 | 29.0f, 30.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1288 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1289 | // Batch 1, Channel 5 |
| 1290 | 13.0f, 14.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1291 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1292 | // Batch 1, Channel 6 |
| 1293 | 15.0f, 16.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1294 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1295 | // Batch 1, Channel 7 |
| 1296 | 31.0f, 32.0f, |
| 1297 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1298 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1299 | |
| 1300 | return result; |
| 1301 | } |
| 1302 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1303 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1304 | LayerTestResult<T, 3> Concat3dDim2DiffInputDimsTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1305 | IWorkloadFactory& workloadFactory, |
| 1306 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1307 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1308 | bool useSubtensor, |
| 1309 | float qScale, |
| 1310 | int32_t qOffset) |
| 1311 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1312 | TensorInfo input0TensorInfo({ 2, 3, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1313 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1314 | { |
| 1315 | // Batch 0, Channel 0 |
| 1316 | 1.0f, 2.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1317 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1318 | // Batch 0, Channel 1 |
| 1319 | 3.0f, 4.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1320 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1321 | // Batch 0, Channel 2 |
| 1322 | 5.0f, 6.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1323 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1324 | // Batch 1, Channel 0 |
| 1325 | 19.0f, 20.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1326 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1327 | // Batch 1, Channel 1 |
| 1328 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1329 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1330 | // Batch 1, Channel 2 |
| 1331 | 23.0f, 24.0f |
| 1332 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1333 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1334 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1335 | TensorInfo input1TensorInfo({ 2, 3, 1 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1336 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1337 | { |
| 1338 | // Batch 0, Channel 0 |
| 1339 | 7.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1340 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1341 | // Batch 0, Channel 1 |
| 1342 | 9.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1343 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1344 | // Batch 0, Channel 2 |
| 1345 | 11.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1346 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1347 | // Batch 1, Channel 0 |
| 1348 | 25.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1349 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1350 | // Batch 1, Channel 1 |
| 1351 | 27.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1352 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1353 | // Batch 1, Channel 2 |
| 1354 | 29.0f |
| 1355 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1356 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1357 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1358 | TensorInfo input2TensorInfo({ 2, 3, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1359 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1360 | { |
| 1361 | // Batch 0, Channel 0 |
| 1362 | 13.0f, 14.0f, 50.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1363 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1364 | // Batch 0, Channel 1 |
| 1365 | 15.0f, 16.0f, 51.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1366 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1367 | // Batch 0, Channel 2 |
| 1368 | 17.0f, 18.0f, 52.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1369 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1370 | // Batch 1, Channel 0 |
| 1371 | 31.0f, 32.0f, 53.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1372 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1373 | // Batch 1, Channel 1 |
| 1374 | 33.0f, 34.0f, 54.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1375 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1376 | // Batch 1, Channel 2 |
| 1377 | 35.0f, 36.0f, 55.0f, |
| 1378 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1379 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1380 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1381 | TensorInfo outputTensorInfo({ 2, 3, 6 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1382 | LayerTestResult<T, 3> result(outputTensorInfo); |
| 1383 | |
| 1384 | std::vector<T> output; |
| 1385 | output.resize(outputTensorInfo.GetNumElements()); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1386 | Concatenate<T>(workloadFactory, memoryManager, tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1387 | { input0TensorInfo, input1TensorInfo, input2TensorInfo }, |
| 1388 | { input0.data(), input1.data(), input2.data() }, |
| 1389 | outputTensorInfo, |
| 1390 | output.data(), |
| 1391 | 2, |
| 1392 | useSubtensor); |
| 1393 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1394 | result.m_ActualData = output; |
| 1395 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1396 | { |
| 1397 | // Batch 0, Channel 0 |
| 1398 | 1.0f, 2.0f, 7.0f, 13.0f, 14.0f, 50.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1399 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1400 | // Batch 0, Channel 1 |
| 1401 | 3.0f, 4.0f, 9.0f, 15.0f, 16.0f, 51.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1402 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1403 | // Batch 0, Channel 2 |
| 1404 | 5.0f, 6.0f, 11.0f, 17.0f, 18.0f, 52.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1405 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1406 | // Batch 1, Channel 0 |
| 1407 | 19.0f, 20.0f, 25.0f, 31.0f, 32.0f, 53.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1408 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1409 | // Batch 1, Channel 1 |
| 1410 | 21.0f, 22.0f, 27.0f, 33.0f, 34.0f, 54.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1411 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1412 | // Batch 1, Channel 2 |
| 1413 | 23.0f, 24.0f, 29.0f, 35.0f, 36.0f, 55.0f, |
| 1414 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1415 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1416 | |
| 1417 | return result; |
| 1418 | } |
| 1419 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1420 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1421 | LayerTestResult<T, 4> Concat4dTestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1422 | IWorkloadFactory& workloadFactory, |
| 1423 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1424 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1425 | const TensorInfo& outputTensorInfo, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1426 | unsigned int dimension, |
| 1427 | bool useSubtensor, |
| 1428 | float qScale, |
| 1429 | int32_t qOffset) |
| 1430 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1431 | TensorInfo inputTensorInfo({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1432 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1433 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1434 | { |
| 1435 | 1.0f, 2.0f, |
| 1436 | 3.0f, 4.0f, |
| 1437 | 5.0f, 6.0f, |
| 1438 | 7.0f, 8.0f, |
| 1439 | 9.0f, 10.0f, |
| 1440 | 11.0f, 12.0f |
| 1441 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1442 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1443 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1444 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1445 | { |
| 1446 | 11.0f, 12.0f, |
| 1447 | 13.0f, 14.0f, |
| 1448 | 15.0f, 16.0f, |
| 1449 | 17.0f, 18.0f, |
| 1450 | 19.0f, 20.0f, |
| 1451 | 21.0f, 22.0f |
| 1452 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1453 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1454 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1455 | auto input2 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1456 | { |
| 1457 | 21.0f, 22.0f, |
| 1458 | 23.0f, 24.0f, |
| 1459 | 25.0f, 26.0f, |
| 1460 | 27.0f, 28.0f, |
| 1461 | 29.0f, 30.0f, |
| 1462 | 31.0f, 32.0f |
| 1463 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1464 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1465 | |
| 1466 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1467 | |
| 1468 | std::vector<T> output; |
| 1469 | output.resize(outputTensorInfo.GetNumElements()); |
| 1470 | |
| 1471 | Concatenate<T>(workloadFactory, |
| 1472 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1473 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1474 | {inputTensorInfo, inputTensorInfo, inputTensorInfo}, |
| 1475 | {input0.data(), input1.data(), input2.data()}, |
| 1476 | outputTensorInfo, |
| 1477 | output.data(), |
| 1478 | dimension, |
| 1479 | useSubtensor); |
| 1480 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1481 | result.m_ActualData = output; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1482 | return result; |
| 1483 | } |
| 1484 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1485 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1486 | LayerTestResult<T, 4> Concat4dDim0TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1487 | IWorkloadFactory& workloadFactory, |
| 1488 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1489 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1490 | float qScale, |
| 1491 | int32_t qOffset) |
| 1492 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1493 | TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1494 | |
| 1495 | LayerTestResult<T, 4> result = Concat4dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1496 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 0, true, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1497 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1498 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1499 | { |
| 1500 | 1.0f, 2.0f, |
| 1501 | 3.0f, 4.0f, |
| 1502 | 5.0f, 6.0f, |
| 1503 | 7.0f, 8.0f, |
| 1504 | 9.0f, 10.0f, |
| 1505 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1506 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1507 | 11.0f, 12.0f, |
| 1508 | 13.0f, 14.0f, |
| 1509 | 15.0f, 16.0f, |
| 1510 | 17.0f, 18.0f, |
| 1511 | 19.0f, 20.0f, |
| 1512 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1513 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1514 | 21.0f, 22.0f, |
| 1515 | 23.0f, 24.0f, |
| 1516 | 25.0f, 26.0f, |
| 1517 | 27.0f, 28.0f, |
| 1518 | 29.0f, 30.0f, |
| 1519 | 31.0f, 32.0f |
| 1520 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1521 | qScale, qOffset); |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1522 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1523 | return result; |
| 1524 | } |
| 1525 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1526 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1527 | LayerTestResult<T, 4> Concat4dDim1TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1528 | IWorkloadFactory& workloadFactory, |
| 1529 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1530 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1531 | float qScale, |
| 1532 | int32_t qOffset) |
| 1533 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1534 | TensorInfo outputTensorInfo({ 1, 9, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1535 | |
| 1536 | LayerTestResult<T, 4> result = Concat4dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1537 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 1, true, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1538 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1539 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1540 | { |
| 1541 | 1.0f, 2.0f, |
| 1542 | 3.0f, 4.0f, |
| 1543 | 5.0f, 6.0f, |
| 1544 | 7.0f, 8.0f, |
| 1545 | 9.0f, 10.0f, |
| 1546 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1547 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1548 | 11.0f, 12.0f, |
| 1549 | 13.0f, 14.0f, |
| 1550 | 15.0f, 16.0f, |
| 1551 | 17.0f, 18.0f, |
| 1552 | 19.0f, 20.0f, |
| 1553 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1554 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1555 | 21.0f, 22.0f, |
| 1556 | 23.0f, 24.0f, |
| 1557 | 25.0f, 26.0f, |
| 1558 | 27.0f, 28.0f, |
| 1559 | 29.0f, 30.0f, |
| 1560 | 31.0f, 32.0f |
| 1561 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1562 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1563 | |
| 1564 | return result; |
| 1565 | } |
| 1566 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1567 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1568 | LayerTestResult<T, 4> Concat4dDim2TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1569 | IWorkloadFactory& workloadFactory, |
| 1570 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1571 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1572 | float qScale, |
| 1573 | int32_t qOffset) |
| 1574 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1575 | TensorInfo outputTensorInfo({ 1, 3, 6, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1576 | |
| 1577 | LayerTestResult<T, 4> result = Concat4dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1578 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 2, true, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1579 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1580 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1581 | { |
| 1582 | 1.0f, 2.0f, |
| 1583 | 3.0f, 4.0f, |
| 1584 | 11.0f, 12.0f, |
| 1585 | 13.0f, 14.0f, |
| 1586 | 21.0f, 22.0f, |
| 1587 | 23.0f, 24.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1588 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1589 | 5.0f, 6.0f, |
| 1590 | 7.0f, 8.0f, |
| 1591 | 15.0f, 16.0f, |
| 1592 | 17.0f, 18.0f, |
| 1593 | 25.0f, 26.0f, |
| 1594 | 27.0f, 28.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1595 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1596 | 9.0f, 10.0f, |
| 1597 | 11.0f, 12.0f, |
| 1598 | 19.0f, 20.0f, |
| 1599 | 21.0f, 22.0f, |
| 1600 | 29.0f, 30.0f, |
| 1601 | 31.0f, 32.0f |
| 1602 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1603 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1604 | |
| 1605 | return result; |
| 1606 | } |
| 1607 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1608 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1609 | LayerTestResult<T, 4> Concat4dDim3TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1610 | IWorkloadFactory& workloadFactory, |
| 1611 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1612 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1613 | float qScale, |
| 1614 | int32_t qOffset, |
| 1615 | bool useSubtensor) |
| 1616 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1617 | TensorInfo outputTensorInfo({ 1, 3, 2, 6 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1618 | |
| 1619 | LayerTestResult<T, 4> result = Concat4dTestImpl<ArmnnType>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1620 | workloadFactory, memoryManager, tensorHandleFactory, outputTensorInfo, 3, useSubtensor, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1621 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1622 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1623 | { |
| 1624 | 1.0f, 2.0f, |
| 1625 | 11.0f, 12.0f, |
| 1626 | 21.0f, 22.0f, |
| 1627 | 3.0f, 4.0f, |
| 1628 | 13.0f, 14.0f, |
| 1629 | 23.0f, 24.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1630 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1631 | 5.0f, 6.0f, |
| 1632 | 15.0f, 16.0f, |
| 1633 | 25.0f, 26.0f, |
| 1634 | 7.0f, 8.0f, |
| 1635 | 17.0f, 18.0f, |
| 1636 | 27.0f, 28.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1637 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1638 | 9.0f, 10.0f, |
| 1639 | 19.0f, 20.0f, |
| 1640 | 29.0f, 30.0f, |
| 1641 | 11.0f, 12.0f, |
| 1642 | 21.0f, 22.0f, |
| 1643 | 31.0f, 32.0f |
| 1644 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1645 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1646 | |
| 1647 | return result; |
| 1648 | } |
| 1649 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1650 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1651 | LayerTestResult<T, 4> Concat4dDiffShapeDim0TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1652 | IWorkloadFactory& workloadFactory, |
| 1653 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1654 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1655 | float qScale, |
| 1656 | int32_t qOffset) |
| 1657 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1658 | constexpr unsigned int dimension = 0u; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1659 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1660 | TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1661 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1662 | { |
| 1663 | 1.0f, 2.0f, |
| 1664 | 3.0f, 4.0f, |
| 1665 | 5.0f, 6.0f, |
| 1666 | 7.0f, 8.0f, |
| 1667 | 9.0f, 10.0f, |
| 1668 | 11.0f, 12.0f |
| 1669 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1670 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1671 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1672 | TensorInfo inputTensorInfo1({ 2, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1673 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1674 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1675 | { |
| 1676 | 11.0f, 12.0f, |
| 1677 | 13.0f, 14.0f, |
| 1678 | 15.0f, 16.0f, |
| 1679 | 17.0f, 18.0f, |
| 1680 | 19.0f, 20.0f, |
| 1681 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1682 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1683 | 21.0f, 22.0f, |
| 1684 | 23.0f, 24.0f, |
| 1685 | 25.0f, 26.0f, |
| 1686 | 27.0f, 28.0f, |
| 1687 | 29.0f, 30.0f, |
| 1688 | 31.0f, 32.0f |
| 1689 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1690 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1691 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1692 | TensorInfo outputTensorInfo({ 3, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1693 | |
| 1694 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1695 | |
| 1696 | std::vector<T> output; |
| 1697 | output.resize(outputTensorInfo.GetNumElements()); |
| 1698 | Concatenate<T>(workloadFactory, |
| 1699 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1700 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1701 | {inputTensorInfo0, inputTensorInfo1}, |
| 1702 | {input0.data(), input1.data()}, |
| 1703 | outputTensorInfo, |
| 1704 | output.data(), |
| 1705 | dimension, |
| 1706 | true); |
| 1707 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1708 | result.m_ActualData = output; |
| 1709 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1710 | { |
| 1711 | 1.0f, 2.0f, |
| 1712 | 3.0f, 4.0f, |
| 1713 | 5.0f, 6.0f, |
| 1714 | 7.0f, 8.0f, |
| 1715 | 9.0f, 10.0f, |
| 1716 | 11.0f, 12.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1717 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1718 | 11.0f, 12.0f, |
| 1719 | 13.0f, 14.0f, |
| 1720 | 15.0f, 16.0f, |
| 1721 | 17.0f, 18.0f, |
| 1722 | 19.0f, 20.0f, |
| 1723 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1724 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1725 | 21.0f, 22.0f, |
| 1726 | 23.0f, 24.0f, |
| 1727 | 25.0f, 26.0f, |
| 1728 | 27.0f, 28.0f, |
| 1729 | 29.0f, 30.0f, |
| 1730 | 31.0f, 32.0f |
| 1731 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1732 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1733 | |
| 1734 | return result; |
| 1735 | } |
| 1736 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1737 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1738 | LayerTestResult<T, 4> Concat4dDiffShapeDim1TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1739 | IWorkloadFactory& workloadFactory, |
| 1740 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1741 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1742 | float qScale, |
| 1743 | int32_t qOffset) |
| 1744 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1745 | constexpr unsigned int dimension = 1u; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1746 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1747 | TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1748 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1749 | { |
| 1750 | 1.0f, 2.0f, |
| 1751 | 3.0f, 4.0f, |
| 1752 | 5.0f, 6.0f, |
| 1753 | 7.0f, 8.0f, |
| 1754 | 9.0f, 10.0f, |
| 1755 | 11.0f, 12.0f |
| 1756 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1757 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1758 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1759 | TensorInfo inputTensorInfo1({ 1, 2, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1760 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1761 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1762 | { |
| 1763 | 11.0f, 12.0f, |
| 1764 | 13.0f, 14.0f, |
| 1765 | 15.0f, 16.0f, |
| 1766 | 17.0f, 18.0f, |
| 1767 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1768 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1769 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1770 | TensorInfo outputTensorInfo({ 1, 5, 2, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1771 | |
| 1772 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1773 | |
| 1774 | std::vector<T> output; |
| 1775 | output.resize(outputTensorInfo.GetNumElements()); |
| 1776 | Concatenate<T>(workloadFactory, |
| 1777 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1778 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1779 | {inputTensorInfo0, inputTensorInfo1}, |
| 1780 | {input0.data(), input1.data()}, |
| 1781 | outputTensorInfo, |
| 1782 | output.data(), |
| 1783 | dimension, |
| 1784 | true); |
| 1785 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1786 | result.m_ActualData = output; |
| 1787 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1788 | { |
| 1789 | 1.0f, 2.0f, |
| 1790 | 3.0f, 4.0f, |
| 1791 | 5.0f, 6.0f, |
| 1792 | 7.0f, 8.0f, |
| 1793 | 9.0f, 10.0f, |
| 1794 | 11.0f, 12.0f, |
| 1795 | 11.0f, 12.0f, |
| 1796 | 13.0f, 14.0f, |
| 1797 | 15.0f, 16.0f, |
| 1798 | 17.0f, 18.0f |
| 1799 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1800 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1801 | |
| 1802 | return result; |
| 1803 | } |
| 1804 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1805 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1806 | LayerTestResult<T, 4> Concat4dDiffShapeDim2TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1807 | IWorkloadFactory& workloadFactory, |
| 1808 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1809 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1810 | float qScale, |
| 1811 | int32_t qOffset) |
| 1812 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1813 | constexpr unsigned int dimension = 2u; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1814 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1815 | TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1816 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1817 | { |
| 1818 | 1.0f, 2.0f, |
| 1819 | 3.0f, 4.0f, |
| 1820 | 5.0f, 6.0f, |
| 1821 | 7.0f, 8.0f, |
| 1822 | 9.0f, 10.0f, |
| 1823 | 11.0f, 12.0f |
| 1824 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1825 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1826 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1827 | TensorInfo inputTensorInfo1({ 1, 3, 3, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1828 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1829 | { |
| 1830 | 11.0f, 12.0f, |
| 1831 | 13.0f, 14.0f, |
| 1832 | 15.0f, 16.0f, |
| 1833 | 17.0f, 18.0f, |
| 1834 | 19.0f, 20.0f, |
| 1835 | 21.0f, 22.0f, |
| 1836 | 23.0f, 24.0f, |
| 1837 | 25.0f, 26.0f, |
| 1838 | 27.0f, 28.0f |
| 1839 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1840 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1841 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1842 | TensorInfo outputTensorInfo({ 1, 3, 5, 2 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1843 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1844 | |
| 1845 | std::vector<T> output; |
| 1846 | output.resize(outputTensorInfo.GetNumElements()); |
| 1847 | Concatenate<T>(workloadFactory, |
| 1848 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1849 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1850 | {inputTensorInfo0, inputTensorInfo1}, |
| 1851 | {input0.data(), input1.data()}, |
| 1852 | outputTensorInfo, |
| 1853 | output.data(), |
| 1854 | dimension, |
| 1855 | true); |
| 1856 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1857 | result.m_ActualData = output; |
| 1858 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1859 | { |
| 1860 | 1.0f, 2.0f, |
| 1861 | 3.0f, 4.0f, |
| 1862 | 11.0f, 12.0f, |
| 1863 | 13.0f, 14.0f, |
| 1864 | 15.0f, 16.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1865 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1866 | 5.0f, 6.0f, |
| 1867 | 7.0f, 8.0f, |
| 1868 | 17.0f, 18.0f, |
| 1869 | 19.0f, 20.0f, |
| 1870 | 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1871 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1872 | 9.0f, 10.0f, |
| 1873 | 11.0f, 12.0f, |
| 1874 | 23.0f, 24.0f, |
| 1875 | 25.0f, 26.0f, |
| 1876 | 27.0f, 28.0f |
| 1877 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1878 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1879 | |
| 1880 | return result; |
| 1881 | } |
| 1882 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1883 | template<DataType ArmnnType, typename T = ResolveType<ArmnnType>> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1884 | LayerTestResult<T, 4> Concat4dDiffShapeDim3TestImpl( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1885 | IWorkloadFactory& workloadFactory, |
| 1886 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1887 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1888 | float qScale, |
| 1889 | int32_t qOffset, |
| 1890 | bool useSubtensor) |
| 1891 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1892 | constexpr unsigned int dimension = 3u; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1893 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1894 | TensorInfo inputTensorInfo0({ 1, 3, 2, 2 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1895 | auto input0 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1896 | { |
| 1897 | 1.0f, 2.0f, |
| 1898 | 3.0f, 4.0f, |
| 1899 | 5.0f, 6.0f, |
| 1900 | 7.0f, 8.0f, |
| 1901 | 9.0f, 10.0f, |
| 1902 | 11.0f, 12.0f |
| 1903 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1904 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1905 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1906 | TensorInfo inputTensorInfo1({ 1, 3, 2, 3 }, ArmnnType, qScale, qOffset); |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1907 | auto input1 = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1908 | { |
| 1909 | 11.0f, 12.0f, 13.0f, |
| 1910 | 14.0f, 15.0f, 16.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1911 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1912 | 17.0f, 18.0f, 19.0f, |
| 1913 | 20.0f, 21.0f, 22.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1914 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1915 | 23.0f, 24.0f, 25.0f, |
| 1916 | 26.0f, 27.0f, 28.0f |
| 1917 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1918 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1919 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1920 | TensorInfo outputTensorInfo({ 1, 3, 2, 5 }, ArmnnType, qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1921 | |
| 1922 | LayerTestResult<T, 4> result(outputTensorInfo); |
| 1923 | |
| 1924 | std::vector<T> output; |
| 1925 | output.resize(outputTensorInfo.GetNumElements()); |
| 1926 | Concatenate<T>(workloadFactory, |
| 1927 | memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1928 | tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1929 | {inputTensorInfo0, inputTensorInfo1}, |
| 1930 | {input0.data(), input1.data()}, |
| 1931 | outputTensorInfo, |
| 1932 | output.data(), |
| 1933 | dimension, |
| 1934 | useSubtensor); |
| 1935 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1936 | result.m_ActualData = output; |
| 1937 | result.m_ExpectedData = QuantizedVector<T>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1938 | { |
| 1939 | 1.0f, 2.0f, 11.0f, 12.0f, 13.0f, |
| 1940 | 3.0f, 4.0f, 14.0f, 15.0f, 16.0f, |
| 1941 | 5.0f, 6.0f, 17.0f, 18.0f, 19.0f, |
| 1942 | 7.0f, 8.0f, 20.0f, 21.0f, 22.0f, |
| 1943 | 9.0f, 10.0f, 23.0f, 24.0f, 25.0f, |
| 1944 | 11.0f, 12.0f, 26.0f, 27.0f, 28.0f |
| 1945 | }, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1946 | qScale, qOffset); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1947 | |
| 1948 | return result; |
| 1949 | } |
| 1950 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1951 | template<DataType ArmnnType, typename T> |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1952 | LayerTestResult<T, 3> ConcatDifferentInputOutputQParamTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1953 | IWorkloadFactory& workloadFactory, |
| 1954 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 1955 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1956 | bool useSubtensor) |
| 1957 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 1958 | IgnoreUnused(memoryManager); |
Derek Lamberti | c374ff0 | 2019-12-10 21:57:35 +0000 | [diff] [blame] | 1959 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1960 | // Defines the tensor descriptors. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1961 | TensorInfo outputTensorInfo({ 3, 6, 3 }, ArmnnType); |
| 1962 | TensorInfo inputTensorInfo1({ 3, 6, 2 }, ArmnnType); |
| 1963 | TensorInfo inputTensorInfo2({ 3, 6, 1 }, ArmnnType); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1964 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 1965 | std::vector<TensorShape> inputTensorShapes({inputTensorInfo1.GetShape(), inputTensorInfo2.GetShape()}); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1966 | |
| 1967 | // Quantized input1 tensor. |
| 1968 | const float inputScale1 = 0.5f; |
| 1969 | const int32_t inputOffset1 = 5; |
| 1970 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1971 | std::vector<T> input1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1972 | { |
| 1973 | 1, 2, 3, |
| 1974 | 4, 5, 6, |
| 1975 | 7, 8, 9, |
| 1976 | 10, 11, 12, |
| 1977 | 13, 14, 15, |
| 1978 | 16, 17, 18, |
| 1979 | |
| 1980 | 19, 20, 21, |
| 1981 | 22, 23, 24, |
| 1982 | 25, 26, 27, |
| 1983 | 28, 29, 30, |
| 1984 | 31, 32, 33, |
| 1985 | 34, 35, 36 |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1986 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1987 | |
| 1988 | // Quatized input2 tensor. |
| 1989 | const float inputScale2 = 0.2f; |
| 1990 | const int32_t inputOffset2 = 10; |
| 1991 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 1992 | std::vector<T> input2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 1993 | { |
| 1994 | 37, 38, 39, |
| 1995 | 40, 41, 42, |
| 1996 | 43, 44, 45, |
| 1997 | 46, 47, 48, |
| 1998 | 49, 50, 51, |
| 1999 | 52, 53, 54 |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2000 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2001 | |
| 2002 | // Quantized output tensor. |
| 2003 | const float outputScale = 0.1f; |
| 2004 | const int32_t outputOffset = 20; |
| 2005 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2006 | std::vector<T> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2007 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2008 | std::vector<T> expectedOutput = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2009 | { |
| 2010 | 0, 5, 74, |
| 2011 | 10, 15, 76, |
| 2012 | 20, 25, 78, |
| 2013 | 30, 35, 80, |
| 2014 | 40, 45, 82, |
| 2015 | 50, 55, 84, |
| 2016 | |
| 2017 | 60, 65, 86, |
| 2018 | 70, 75, 88, |
| 2019 | 80, 85, 90, |
| 2020 | 90, 95, 92, |
| 2021 | 100, 105, 94, |
| 2022 | 110, 115, 96, |
| 2023 | |
| 2024 | 120, 125, 98, |
| 2025 | 130, 135, 100, |
| 2026 | 140, 145, 102, |
| 2027 | 150, 155, 104, |
| 2028 | 160, 165, 106, |
| 2029 | 170, 175, 108 |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2030 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2031 | |
| 2032 | outputTensorInfo.SetQuantizationScale(outputScale); |
| 2033 | outputTensorInfo.SetQuantizationOffset(outputOffset); |
| 2034 | inputTensorInfo1.SetQuantizationScale(inputScale1); |
| 2035 | inputTensorInfo1.SetQuantizationOffset(inputOffset1); |
| 2036 | inputTensorInfo2.SetQuantizationScale(inputScale2); |
| 2037 | inputTensorInfo2.SetQuantizationOffset(inputOffset2); |
| 2038 | |
| 2039 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2040 | ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2041 | |
| 2042 | std::vector<unsigned int> wOrigin2 = { 0, 0, 2 }; //Extent of the window is defined by size of input[1]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2043 | ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2044 | |
| 2045 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
| 2046 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2047 | bool subTensorsSupported = useSubtensor && workloadFactory.SupportsSubTensors(); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2048 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2049 | std::unique_ptr<ITensorHandle> inputHandle1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2050 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2051 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 2052 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2053 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2054 | std::unique_ptr<ITensorHandle> inputHandle2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2055 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2056 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 2057 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo2); |
| 2058 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2059 | ConcatQueueDescriptor data; |
| 2060 | OriginsDescriptor desc = CreateDescriptorForConcatenation( |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2061 | inputTensorShapes.begin(),inputTensorShapes.end(), 2); |
| 2062 | data.m_Parameters = desc; |
| 2063 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2064 | WorkloadInfo info; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2065 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2066 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 2067 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2068 | |
| 2069 | data.m_ViewOrigins.push_back(window1); |
| 2070 | data.m_ViewOrigins.push_back(window2); |
| 2071 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2072 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2073 | |
| 2074 | inputHandle1->Allocate(); |
| 2075 | inputHandle2->Allocate(); |
| 2076 | outputHandle->Allocate(); |
| 2077 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2078 | CopyDataToITensorHandle(inputHandle1.get(), input1.data()); |
| 2079 | CopyDataToITensorHandle(inputHandle2.get(), input2.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2080 | |
| 2081 | workload->PostAllocationConfigure(); |
| 2082 | workload->Execute(); |
| 2083 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2084 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2085 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2086 | return LayerTestResult<T, 3>(actualOutput, |
| 2087 | expectedOutput, |
| 2088 | outputHandle->GetShape(), |
| 2089 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2090 | } |
| 2091 | |
| 2092 | // |
| 2093 | // Explicit template specializations |
| 2094 | // |
| 2095 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2096 | template LayerTestResult<ResolveType<DataType::QAsymmU8>, 3> |
| 2097 | ConcatDifferentInputOutputQParamTest<DataType::QAsymmU8>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2098 | IWorkloadFactory& workloadFactory, |
| 2099 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2100 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2101 | bool useSubtensor); |
| 2102 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2103 | template LayerTestResult<ResolveType<DataType::QSymmS16>, 3> |
| 2104 | ConcatDifferentInputOutputQParamTest<DataType::QSymmS16>( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2105 | IWorkloadFactory& workloadFactory, |
| 2106 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2107 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2108 | bool useSubtensor); |
| 2109 | |
| 2110 | // |
| 2111 | // Implementation functions |
| 2112 | // |
| 2113 | |
| 2114 | LayerTestResult<float,3> ConcatTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2115 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2116 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2117 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2118 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2119 | IgnoreUnused(memoryManager); |
Derek Lamberti | c374ff0 | 2019-12-10 21:57:35 +0000 | [diff] [blame] | 2120 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2121 | unsigned int outputWidth = 3; |
| 2122 | unsigned int outputHeight = 6; |
| 2123 | unsigned int outputChannels = 3; |
| 2124 | |
| 2125 | unsigned int inputWidth1 = 3; |
| 2126 | unsigned int inputHeight1 = 6; |
| 2127 | unsigned int inputChannels1 = 2; |
| 2128 | |
| 2129 | unsigned int inputWidth2 = 3; |
| 2130 | unsigned int inputHeight2 = 6; |
| 2131 | unsigned int inputChannels2 = 1; |
| 2132 | |
| 2133 | // Define the tensor descriptors. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2134 | TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, DataType::Float32); |
| 2135 | TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, DataType::Float32); |
| 2136 | TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, DataType::Float32); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2137 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2138 | std::vector<float> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2139 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2140 | std::vector<float> expectedOutput = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2141 | { |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2142 | 1.0f, 2.0f, 3.0f, |
| 2143 | 4.0f, 5.0f, 6.0f, |
| 2144 | 7.0f, 8.0f, 9.0f, |
| 2145 | 10.0f, 11.0f, 12.0f, |
| 2146 | 13.0f, 14.0f, 15.0f, |
| 2147 | 16.0f, 17.0f, 18.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2148 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2149 | 19.0f, 20.0f, 21.0f, |
| 2150 | 22.0f, 23.0f, 24.0f, |
| 2151 | 25.0f, 26.0f, 27.0f, |
| 2152 | 28.0f, 29.0f, 30.0f, |
| 2153 | 31.0f, 32.0f, 33.0f, |
| 2154 | 34.0f, 35.0f, 36.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2155 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2156 | 37.0f, 38.0f, 39.0f, |
| 2157 | 40.0f, 41.0f, 42.0f, |
| 2158 | 43.0f, 44.0f, 45.0f, |
| 2159 | 46.0f, 47.0f, 48.0f, |
| 2160 | 49.0f, 50.0f, 51.0f, |
| 2161 | 52.0f, 53.0f, 54.0f |
| 2162 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2163 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2164 | std::vector<float> input1 = |
| 2165 | { |
| 2166 | 1.0f, 2.0f, 3.0f, |
| 2167 | 4.0f, 5.0f, 6.0f, |
| 2168 | 7.0f, 8.0f, 9.0f, |
| 2169 | 10.0f, 11.0f, 12.0f, |
| 2170 | 13.0f, 14.0f, 15.0f, |
| 2171 | 16.0f, 17.0f, 18.0f, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2172 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2173 | 19.0f, 20.0f, 21.0f, |
| 2174 | 22.0f, 23.0f, 24.0f, |
| 2175 | 25.0f, 26.0f, 27.0f, |
| 2176 | 28.0f, 29.0f, 30.0f, |
| 2177 | 31.0f, 32.0f, 33.0f, |
| 2178 | 34.0f, 35.0f, 36.0f |
| 2179 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2180 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2181 | std::vector<float> input2 = |
| 2182 | { |
| 2183 | 37.0f, 38.0f, 39.0f, |
| 2184 | 40.0f, 41.0f, 42.0f, |
| 2185 | 43.0f, 44.0f, 45.0f, |
| 2186 | 46.0f, 47.0f, 48.0f, |
| 2187 | 49.0f, 50.0f, 51.0f, |
| 2188 | 52.0f, 53.0f, 54.0f, |
| 2189 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2190 | |
| 2191 | std::vector<unsigned int> wOrigin1 = {0, 0, 0}; //Extent of the window is defined by size of input[0]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2192 | ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2193 | |
| 2194 | std::vector<unsigned int> wOrigin2 = {2, 0, 0}; //Extent of the window is defined by size of input[1]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2195 | ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2196 | |
| 2197 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2198 | |
| 2199 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 2200 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2201 | std::unique_ptr<ITensorHandle> inputHandle1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2202 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2203 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 2204 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2205 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2206 | std::unique_ptr<ITensorHandle> inputHandle2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2207 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2208 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 2209 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo2); |
| 2210 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2211 | ConcatQueueDescriptor data; |
| 2212 | WorkloadInfo info; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2213 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2214 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 2215 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2216 | |
| 2217 | data.m_ViewOrigins.push_back(window1); |
| 2218 | data.m_ViewOrigins.push_back(window2); |
| 2219 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2220 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2221 | |
| 2222 | inputHandle1->Allocate(); |
| 2223 | inputHandle2->Allocate(); |
| 2224 | outputHandle->Allocate(); |
| 2225 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2226 | CopyDataToITensorHandle(inputHandle1.get(), input1.data()); |
| 2227 | CopyDataToITensorHandle(inputHandle2.get(), input2.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2228 | |
| 2229 | workload->PostAllocationConfigure(); |
| 2230 | workload->Execute(); |
| 2231 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2232 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2233 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2234 | return LayerTestResult<float, 3>(actualOutput, |
| 2235 | expectedOutput, |
| 2236 | outputHandle->GetShape(), |
| 2237 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2238 | } |
| 2239 | |
| 2240 | LayerTestResult<float, 1> Concat1dTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2241 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2242 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2243 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2244 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2245 | return Concat1dTestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2246 | } |
| 2247 | |
| 2248 | LayerTestResult<float, 2> Concat2dDim0Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2249 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2250 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2251 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2252 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2253 | return Concat2dDim0TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2254 | } |
| 2255 | |
| 2256 | LayerTestResult<float, 2> Concat2dDim1Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2257 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2258 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2259 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2260 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2261 | return Concat2dDim1TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2262 | } |
| 2263 | |
| 2264 | LayerTestResult<float, 2> Concat2dDim0DiffInputDimsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2265 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2266 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2267 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2268 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2269 | return Concat2dDim0DiffInputDimsTestImpl<DataType::Float32>(workloadFactory, memoryManager, |
| 2270 | tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2271 | } |
| 2272 | |
| 2273 | LayerTestResult<float, 2> Concat2dDim1DiffInputDimsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2274 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2275 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2276 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2277 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2278 | return Concat2dDim1DiffInputDimsTestImpl<DataType::Float32>(workloadFactory, |
| 2279 | memoryManager, |
| 2280 | tensorHandleFactory, |
| 2281 | 0.0f, |
| 2282 | 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2283 | } |
| 2284 | |
| 2285 | LayerTestResult<float, 3> Concat3dDim0Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2286 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2287 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2288 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2289 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2290 | return Concat3dDim0TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2291 | } |
| 2292 | |
| 2293 | LayerTestResult<float, 3> Concat3dDim1Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2294 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2295 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2296 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2297 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2298 | return Concat3dDim1TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2299 | } |
| 2300 | |
| 2301 | LayerTestResult<float, 3> Concat3dDim2Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2302 | IWorkloadFactory& workloadFactory, |
| 2303 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2304 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2305 | bool useSubtensor) |
| 2306 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2307 | return Concat3dDim2TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, |
| 2308 | useSubtensor, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2309 | } |
| 2310 | |
| 2311 | LayerTestResult<float, 3> Concat3dDim0DiffInputDimsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2312 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2313 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2314 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2315 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2316 | return Concat3dDim0DiffInputDimsTestImpl<DataType::Float32>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2317 | workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2318 | } |
| 2319 | |
| 2320 | LayerTestResult<float, 3> Concat3dDim1DiffInputDimsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2321 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2322 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2323 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2324 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2325 | return Concat3dDim1DiffInputDimsTestImpl<DataType::Float32>(workloadFactory, memoryManager, |
| 2326 | tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2327 | } |
| 2328 | |
| 2329 | LayerTestResult<float, 3> Concat3dDim2DiffInputDimsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2330 | IWorkloadFactory& workloadFactory, |
| 2331 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2332 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2333 | bool useSubtensor) |
| 2334 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2335 | return Concat3dDim2DiffInputDimsTestImpl<DataType::Float32>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2336 | workloadFactory, memoryManager, tensorHandleFactory, useSubtensor, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2337 | } |
| 2338 | |
| 2339 | LayerTestResult<float, 4> Concat4dDim0Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2340 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2341 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2342 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2343 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2344 | return Concat4dDim0TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | LayerTestResult<float, 4> Concat4dDim1Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2348 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2349 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2350 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2351 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2352 | return Concat4dDim1TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | LayerTestResult<float, 4> Concat4dDim2Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2356 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2357 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2358 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2359 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2360 | return Concat4dDim2TestImpl<DataType::Float32>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2361 | } |
| 2362 | |
| 2363 | LayerTestResult<float, 4> Concat4dDim3Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2364 | IWorkloadFactory& workloadFactory, |
| 2365 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2366 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2367 | bool useSubtensor) |
| 2368 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2369 | return Concat4dDim3TestImpl<DataType::Float32>(workloadFactory, memoryManager, |
| 2370 | tensorHandleFactory, 0.0f, 0, useSubtensor); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2371 | } |
| 2372 | |
| 2373 | LayerTestResult<float, 4> Concat4dDiffShapeDim0Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2374 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2375 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2376 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2377 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2378 | return Concat4dDiffShapeDim0TestImpl<DataType::Float32>(workloadFactory, memoryManager, |
| 2379 | tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | LayerTestResult<float, 4> Concat4dDiffShapeDim1Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2383 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2384 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2385 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2386 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2387 | return Concat4dDiffShapeDim1TestImpl<DataType::Float32>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2388 | workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2389 | } |
| 2390 | |
| 2391 | LayerTestResult<float, 4> Concat4dDiffShapeDim2Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2392 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2393 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2394 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2395 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2396 | return Concat4dDiffShapeDim2TestImpl<DataType::Float32>(workloadFactory, memoryManager, |
| 2397 | tensorHandleFactory, 0.0f, 0); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2398 | } |
| 2399 | |
| 2400 | LayerTestResult<float, 4> Concat4dDiffShapeDim3Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2401 | IWorkloadFactory& workloadFactory, |
| 2402 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2403 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2404 | bool useSubtensor) |
| 2405 | { |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2406 | return Concat4dDiffShapeDim3TestImpl<DataType::Float32>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2407 | workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0, useSubtensor); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2408 | } |
| 2409 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2410 | LayerTestResult<Half, 3> ConcatFloat16Test( |
| 2411 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2412 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2413 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2414 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2415 | return Concat3dDim1TestImpl<DataType::Float16>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 2416 | } |
| 2417 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2418 | LayerTestResult<BFloat16, 3> ConcatBFloat16Test( |
| 2419 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2420 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2421 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2422 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2423 | return Concat3dDim1TestImpl<DataType::BFloat16>(workloadFactory, memoryManager, tensorHandleFactory, 0.0f, 0); |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 2424 | } |
| 2425 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2426 | LayerTestResult<uint8_t, 3> ConcatUint8DifferentQParamsTest( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2427 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2428 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2429 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2430 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2431 | IgnoreUnused(memoryManager); |
Derek Lamberti | c374ff0 | 2019-12-10 21:57:35 +0000 | [diff] [blame] | 2432 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2433 | unsigned int outputWidth = 3; |
| 2434 | unsigned int outputHeight = 6; |
| 2435 | unsigned int outputChannels = 3; |
| 2436 | |
| 2437 | unsigned int inputWidth1 = 3; |
| 2438 | unsigned int inputHeight1 = 6; |
| 2439 | unsigned int inputChannels1 = 2; |
| 2440 | |
| 2441 | unsigned int inputWidth2 = 3; |
| 2442 | unsigned int inputHeight2 = 6; |
| 2443 | unsigned int inputChannels2 = 1; |
| 2444 | |
| 2445 | // Defines the tensor descriptors. |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2446 | TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, DataType::QAsymmU8); |
| 2447 | TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, DataType::QAsymmU8); |
| 2448 | TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, DataType::QAsymmU8); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2449 | |
| 2450 | // Quantized input1 tensor. Range [-3, 1] |
| 2451 | const float inputScale1 = 0.015686f; |
| 2452 | const int32_t inputOffset1 = 192; |
| 2453 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2454 | std::vector<uint8_t> input1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2455 | { |
| 2456 | 1, 2, 3, |
| 2457 | 4, 5, 6, |
| 2458 | 7, 8, 9, |
| 2459 | 10, 11, 12, |
| 2460 | 13, 14, 15, |
| 2461 | 16, 17, 18, |
| 2462 | |
| 2463 | 19, 20, 21, |
| 2464 | 22, 23, 24, |
| 2465 | 25, 26, 27, |
| 2466 | 28, 29, 30, |
| 2467 | 31, 32, 33, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2468 | 34, 35, 36 |
| 2469 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2470 | |
| 2471 | // Quatized input2 tensor. Range [-1, 4] |
| 2472 | const float inputScale2 = 0.019608f; |
| 2473 | const int32_t inputOffset2 = 50; |
| 2474 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2475 | std::vector<uint8_t> input2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2476 | { |
| 2477 | 37, 38, 39, |
| 2478 | 40, 41, 42, |
| 2479 | 43, 44, 45, |
| 2480 | 46, 47, 48, |
| 2481 | 49, 50, 51, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2482 | 52, 53, 54 |
| 2483 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2484 | |
| 2485 | // Output has the same quantization parameters than input1, |
| 2486 | // so that only the requantization of input2 is required |
| 2487 | const float outputScale = 0.015686f; |
| 2488 | const int32_t outputOffset = 192; |
| 2489 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2490 | std::vector<uint8_t> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2491 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2492 | std::vector<uint8_t> expectedOutput = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2493 | { |
| 2494 | 1, 2, 3, |
| 2495 | 4, 5, 6, |
| 2496 | 7, 8, 9, |
| 2497 | 10, 11, 12, |
| 2498 | 13, 14, 15, |
| 2499 | 16, 17, 18, |
| 2500 | |
| 2501 | 19, 20, 21, |
| 2502 | 22, 23, 24, |
| 2503 | 25, 26, 27, |
| 2504 | 28, 29, 30, |
| 2505 | 31, 32, 33, |
| 2506 | 34, 35, 36, |
| 2507 | |
| 2508 | 176, 177, 178, |
| 2509 | 179, 181, 182, |
| 2510 | 183, 184, 186, |
| 2511 | 187, 188, 189, |
| 2512 | 191, 192, 193, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2513 | 195, 196, 197 |
| 2514 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2515 | |
| 2516 | outputTensorInfo.SetQuantizationScale(outputScale); |
| 2517 | outputTensorInfo.SetQuantizationOffset(outputOffset); |
| 2518 | inputTensorInfo1.SetQuantizationScale(inputScale1); |
| 2519 | inputTensorInfo1.SetQuantizationOffset(inputOffset1); |
| 2520 | inputTensorInfo2.SetQuantizationScale(inputScale2); |
| 2521 | inputTensorInfo2.SetQuantizationOffset(inputOffset2); |
| 2522 | |
| 2523 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2524 | ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2525 | |
| 2526 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2527 | ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2528 | |
| 2529 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2530 | |
| 2531 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 2532 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2533 | std::unique_ptr<ITensorHandle> inputHandle1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2534 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2535 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 2536 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2537 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2538 | std::unique_ptr<ITensorHandle> inputHandle2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2539 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2540 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 2541 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo2); |
| 2542 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2543 | ConcatQueueDescriptor data; |
| 2544 | WorkloadInfo info; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2545 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2546 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 2547 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2548 | |
| 2549 | data.m_ViewOrigins.push_back(window1); |
| 2550 | data.m_ViewOrigins.push_back(window2); |
| 2551 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2552 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2553 | |
| 2554 | inputHandle1->Allocate(); |
| 2555 | inputHandle2->Allocate(); |
| 2556 | outputHandle->Allocate(); |
| 2557 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2558 | CopyDataToITensorHandle(inputHandle1.get(), input1.data()); |
| 2559 | CopyDataToITensorHandle(inputHandle2.get(), input2.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2560 | |
| 2561 | workload->PostAllocationConfigure(); |
| 2562 | workload->Execute(); |
| 2563 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2564 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2565 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2566 | return LayerTestResult<uint8_t, 3>(actualOutput, |
| 2567 | expectedOutput, |
| 2568 | outputHandle->GetShape(), |
| 2569 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2570 | } |
| 2571 | |
| 2572 | LayerTestResult<uint8_t, 3> ConcatUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2573 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2574 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2575 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2576 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2577 | IgnoreUnused(memoryManager); |
Derek Lamberti | c374ff0 | 2019-12-10 21:57:35 +0000 | [diff] [blame] | 2578 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2579 | unsigned int outputWidth = 3; |
| 2580 | unsigned int outputHeight = 6; |
| 2581 | unsigned int outputChannels = 3; |
| 2582 | |
| 2583 | unsigned int inputWidth1 = 3; |
| 2584 | unsigned int inputHeight1 = 6; |
| 2585 | unsigned int inputChannels1 = 2; |
| 2586 | |
| 2587 | unsigned int inputWidth2 = 3; |
| 2588 | unsigned int inputHeight2 = 6; |
| 2589 | unsigned int inputChannels2 = 1; |
| 2590 | |
| 2591 | // Defines the tensor descriptors. |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2592 | TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, DataType::QAsymmU8); |
| 2593 | TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, DataType::QAsymmU8); |
| 2594 | TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, DataType::QAsymmU8); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2595 | |
| 2596 | // Arbitrary scale and offsets. They don't really matter as the Concat operator doesn't dequantize/quantize them. |
| 2597 | const float scale = 0.13497836f; |
| 2598 | const int32_t offset = -7; |
| 2599 | |
| 2600 | outputTensorInfo.SetQuantizationScale(scale); |
| 2601 | outputTensorInfo.SetQuantizationOffset(offset); |
| 2602 | inputTensorInfo1.SetQuantizationScale(scale); |
| 2603 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 2604 | inputTensorInfo2.SetQuantizationScale(scale); |
| 2605 | inputTensorInfo2.SetQuantizationOffset(offset); |
| 2606 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2607 | std::vector<uint8_t> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2608 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2609 | std::vector<uint8_t> expectedOutput = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2610 | { |
| 2611 | 1, 2, 3, |
| 2612 | 4, 5, 6, |
| 2613 | 7, 8, 9, |
| 2614 | 10, 11, 12, |
| 2615 | 13, 14, 15, |
| 2616 | 16, 17, 18, |
| 2617 | |
| 2618 | 19, 20, 21, |
| 2619 | 22, 23, 24, |
| 2620 | 25, 26, 27, |
| 2621 | 28, 29, 30, |
| 2622 | 31, 32, 33, |
| 2623 | 34, 35, 36, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2624 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2625 | 37, 38, 39, |
| 2626 | 40, 41, 42, |
| 2627 | 43, 44, 45, |
| 2628 | 46, 47, 48, |
| 2629 | 49, 50, 51, |
| 2630 | 52, 53, 54 |
| 2631 | }; |
| 2632 | |
| 2633 | std::vector<uint8_t> input1 = |
| 2634 | { |
| 2635 | 1, 2, 3, |
| 2636 | 4, 5, 6, |
| 2637 | 7, 8, 9, |
| 2638 | 10, 11, 12, |
| 2639 | 13, 14, 15, |
| 2640 | 16, 17, 18, |
| 2641 | |
| 2642 | 19, 20, 21, |
| 2643 | 22, 23, 24, |
| 2644 | 25, 26, 27, |
| 2645 | 28, 29, 30, |
| 2646 | 31, 32, 33, |
| 2647 | 34, 35, 36 |
| 2648 | }; |
| 2649 | |
| 2650 | std::vector<uint8_t> input2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2651 | { |
| 2652 | 37, 38, 39, |
| 2653 | 40, 41, 42, |
| 2654 | 43, 44, 45, |
| 2655 | 46, 47, 48, |
| 2656 | 49, 50, 51, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2657 | 52, 53, 54 |
| 2658 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2659 | |
| 2660 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2661 | ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2662 | |
| 2663 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2664 | ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2665 | |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2666 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2667 | |
| 2668 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 2669 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2670 | std::unique_ptr<ITensorHandle> inputHandle1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2671 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2672 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 2673 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2674 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2675 | std::unique_ptr<ITensorHandle> inputHandle2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2676 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2677 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 2678 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo2); |
| 2679 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2680 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2681 | ConcatQueueDescriptor data; |
| 2682 | WorkloadInfo info; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2683 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2684 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 2685 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2686 | |
| 2687 | data.m_ViewOrigins.push_back(window1); |
| 2688 | data.m_ViewOrigins.push_back(window2); |
| 2689 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2690 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2691 | |
| 2692 | inputHandle1->Allocate(); |
| 2693 | inputHandle2->Allocate(); |
| 2694 | outputHandle->Allocate(); |
| 2695 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2696 | CopyDataToITensorHandle(inputHandle1.get(), input1.data()); |
| 2697 | CopyDataToITensorHandle(inputHandle2.get(), input2.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2698 | |
| 2699 | workload->PostAllocationConfigure(); |
| 2700 | workload->Execute(); |
| 2701 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2702 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2703 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2704 | return LayerTestResult<uint8_t, 3>(actualOutput, |
| 2705 | expectedOutput, |
| 2706 | outputHandle->GetShape(), |
| 2707 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2708 | } |
| 2709 | |
| 2710 | LayerTestResult<uint16_t, 3> ConcatUint16Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2711 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2712 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2713 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2714 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 2715 | IgnoreUnused(memoryManager); |
Derek Lamberti | c374ff0 | 2019-12-10 21:57:35 +0000 | [diff] [blame] | 2716 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2717 | unsigned int outputWidth = 3; |
| 2718 | unsigned int outputHeight = 6; |
| 2719 | unsigned int outputChannels = 3; |
| 2720 | |
| 2721 | unsigned int inputWidth1 = 3; |
| 2722 | unsigned int inputHeight1 = 6; |
| 2723 | unsigned int inputChannels1 = 2; |
| 2724 | |
| 2725 | unsigned int inputWidth2 = 3; |
| 2726 | unsigned int inputHeight2 = 6; |
| 2727 | unsigned int inputChannels2 = 1; |
| 2728 | |
| 2729 | // Defines the tensor descriptors. |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2730 | TensorInfo outputTensorInfo({ outputChannels, outputHeight, outputWidth }, DataType::QSymmS16); |
| 2731 | TensorInfo inputTensorInfo1({ inputChannels1, inputHeight1, inputWidth1 }, DataType::QSymmS16); |
| 2732 | TensorInfo inputTensorInfo2({ inputChannels2, inputHeight2, inputWidth2 }, DataType::QSymmS16); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2733 | |
| 2734 | // Arbitrary scale and offsets. They don't really matter as the Concat operator doesn't dequantize/quantize them. |
| 2735 | const float scale = 0.13497836f; |
| 2736 | const int32_t offset = -7; |
| 2737 | |
| 2738 | outputTensorInfo.SetQuantizationScale(scale); |
| 2739 | outputTensorInfo.SetQuantizationOffset(offset); |
| 2740 | inputTensorInfo1.SetQuantizationScale(scale); |
| 2741 | inputTensorInfo1.SetQuantizationOffset(offset); |
| 2742 | inputTensorInfo2.SetQuantizationScale(scale); |
| 2743 | inputTensorInfo2.SetQuantizationOffset(offset); |
| 2744 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2745 | std::vector<uint16_t> actualOutput(outputTensorInfo.GetNumElements()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2746 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2747 | std::vector<uint16_t> expectedOutput = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2748 | { |
| 2749 | 1, 2, 3, |
| 2750 | 4, 5, 6, |
| 2751 | 7, 8, 9, |
| 2752 | 10, 11, 12, |
| 2753 | 13, 14, 15, |
| 2754 | 16, 17, 18, |
| 2755 | |
| 2756 | 19, 20, 21, |
| 2757 | 22, 23, 24, |
| 2758 | 25, 26, 27, |
| 2759 | 28, 29, 30, |
| 2760 | 31, 32, 33, |
| 2761 | 34, 35, 36, |
| 2762 | |
| 2763 | 37, 38, 39, |
| 2764 | 40, 41, 42, |
| 2765 | 43, 44, 45, |
| 2766 | 46, 47, 48, |
| 2767 | 49, 50, 51, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2768 | 52, 53, 54 |
| 2769 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2770 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2771 | std::vector<uint16_t> input1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2772 | { |
| 2773 | 1, 2, 3, |
| 2774 | 4, 5, 6, |
| 2775 | 7, 8, 9, |
| 2776 | 10, 11, 12, |
| 2777 | 13, 14, 15, |
| 2778 | 16, 17, 18, |
| 2779 | |
| 2780 | 19, 20, 21, |
| 2781 | 22, 23, 24, |
| 2782 | 25, 26, 27, |
| 2783 | 28, 29, 30, |
| 2784 | 31, 32, 33, |
| 2785 | 34, 35, 36, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2786 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2787 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2788 | std::vector<uint16_t> input2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2789 | { |
| 2790 | 37, 38, 39, |
| 2791 | 40, 41, 42, |
| 2792 | 43, 44, 45, |
| 2793 | 46, 47, 48, |
| 2794 | 49, 50, 51, |
| 2795 | 52, 53, 54, |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2796 | }; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2797 | |
| 2798 | std::vector<unsigned int> wOrigin1 = { 0, 0, 0 }; //Extent of the window is defined by size of input[0]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2799 | ConcatQueueDescriptor::ViewOrigin window1(wOrigin1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2800 | |
| 2801 | std::vector<unsigned int> wOrigin2 = { 2, 0, 0 }; //Extent of the window is defined by size of input[1]. |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2802 | ConcatQueueDescriptor::ViewOrigin window2(wOrigin2); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2803 | |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2804 | |
| 2805 | std::unique_ptr<ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2806 | |
| 2807 | bool subTensorsSupported = workloadFactory.SupportsSubTensors(); |
| 2808 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2809 | std::unique_ptr<ITensorHandle> inputHandle1 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2810 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2811 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo1.GetShape(), wOrigin1.data()) : |
| 2812 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2813 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2814 | std::unique_ptr<ITensorHandle> inputHandle2 = |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2815 | subTensorsSupported ? |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2816 | tensorHandleFactory.CreateSubTensorHandle(*outputHandle, inputTensorInfo2.GetShape(), wOrigin2.data()) : |
| 2817 | tensorHandleFactory.CreateTensorHandle(inputTensorInfo2); |
| 2818 | |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2819 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2820 | ConcatQueueDescriptor data; |
| 2821 | WorkloadInfo info; |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2822 | AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get()); |
| 2823 | AddInputToWorkload(data, info, inputTensorInfo2, inputHandle2.get()); |
| 2824 | AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); |
| 2825 | |
| 2826 | data.m_ViewOrigins.push_back(window1); |
| 2827 | data.m_ViewOrigins.push_back(window2); |
| 2828 | |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2829 | std::unique_ptr<IWorkload> workload = workloadFactory.CreateConcat(data, info); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2830 | |
| 2831 | inputHandle1->Allocate(); |
| 2832 | inputHandle2->Allocate(); |
| 2833 | outputHandle->Allocate(); |
| 2834 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2835 | CopyDataToITensorHandle(inputHandle1.get(), input1.data()); |
| 2836 | CopyDataToITensorHandle(inputHandle2.get(), input2.data()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2837 | |
| 2838 | workload->PostAllocationConfigure(); |
| 2839 | workload->Execute(); |
| 2840 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2841 | CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2842 | |
Sadik Armagan | 483c811 | 2021-06-01 09:24:52 +0100 | [diff] [blame] | 2843 | return LayerTestResult<uint16_t, 3>(actualOutput, |
| 2844 | expectedOutput, |
| 2845 | outputHandle->GetShape(), |
| 2846 | outputTensorInfo.GetShape()); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2847 | } |
| 2848 | |
| 2849 | LayerTestResult<uint8_t, 1> Concat1dUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2850 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2851 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2852 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2853 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2854 | return Concat1dTestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2855 | } |
| 2856 | |
| 2857 | LayerTestResult<uint8_t, 2> Concat2dDim0Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2858 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2859 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2860 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2861 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2862 | return Concat2dDim0TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2863 | } |
| 2864 | |
| 2865 | LayerTestResult<uint8_t, 2> Concat2dDim1Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2866 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2867 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2868 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2869 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2870 | return Concat2dDim1TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2871 | } |
| 2872 | |
| 2873 | LayerTestResult<uint8_t, 2> Concat2dDim0DiffInputDimsUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2874 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2875 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2876 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2877 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2878 | return Concat2dDim0DiffInputDimsTestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2879 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2880 | } |
| 2881 | |
| 2882 | LayerTestResult<uint8_t, 2> Concat2dDim1DiffInputDimsUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2883 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2884 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2885 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2886 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2887 | return Concat2dDim1DiffInputDimsTestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2888 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2889 | } |
| 2890 | |
| 2891 | LayerTestResult<uint8_t, 3> Concat3dDim0Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2892 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2893 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2894 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2895 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2896 | return Concat3dDim0TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2897 | } |
| 2898 | |
| 2899 | LayerTestResult<uint8_t, 3> Concat3dDim1Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2900 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2901 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2902 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2903 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2904 | return Concat3dDim1TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2905 | } |
| 2906 | |
| 2907 | LayerTestResult<uint8_t, 3> Concat3dDim2Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2908 | IWorkloadFactory& workloadFactory, |
| 2909 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2910 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2911 | bool useSubtensor) |
| 2912 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2913 | return Concat3dDim2TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2914 | workloadFactory, memoryManager, tensorHandleFactory, useSubtensor, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2915 | } |
| 2916 | |
| 2917 | LayerTestResult<uint8_t, 3> Concat3dDim0DiffInputDimsUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2918 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2919 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2920 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2921 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2922 | return Concat3dDim0TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2923 | } |
| 2924 | |
| 2925 | LayerTestResult<uint8_t, 3> Concat3dDim1DiffInputDimsUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2926 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2927 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2928 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2929 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2930 | return Concat3dDim1DiffInputDimsTestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2931 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2932 | } |
| 2933 | |
| 2934 | LayerTestResult<uint8_t, 3> Concat3dDim2DiffInputDimsUint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2935 | IWorkloadFactory& workloadFactory, |
| 2936 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2937 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2938 | bool useSubtensor) |
| 2939 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2940 | return Concat3dDim2DiffInputDimsTestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2941 | workloadFactory, memoryManager, tensorHandleFactory, useSubtensor, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2942 | } |
| 2943 | |
| 2944 | LayerTestResult<uint8_t, 4> Concat4dDim0Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2945 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2946 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2947 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2948 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2949 | return Concat4dDim0TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2950 | } |
| 2951 | |
| 2952 | LayerTestResult<uint8_t, 4> Concat4dDim1Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2953 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2954 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2955 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2956 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2957 | return Concat4dDim1TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2958 | } |
| 2959 | |
| 2960 | LayerTestResult<uint8_t, 4> Concat4dDim2Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2961 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2962 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2963 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2964 | { |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2965 | return Concat4dDim2TestImpl<DataType::QAsymmU8>(workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2966 | } |
| 2967 | |
| 2968 | LayerTestResult<uint8_t, 4> Concat4dDim3Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2969 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2970 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2971 | const armnn::ITensorHandleFactory& tensorHandleFactory, bool useSubtensor) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2972 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2973 | return Concat4dDim3TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2974 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1, useSubtensor); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2975 | } |
| 2976 | |
| 2977 | LayerTestResult<uint8_t, 4> Concat4dDiffShapeDim0Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2978 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2979 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2980 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2981 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2982 | return Concat4dDiffShapeDim0TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2983 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2984 | } |
| 2985 | |
| 2986 | LayerTestResult<uint8_t, 4> Concat4dDiffShapeDim1Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2987 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2988 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2989 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2990 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 2991 | return Concat4dDiffShapeDim1TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2992 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2993 | } |
| 2994 | |
| 2995 | LayerTestResult<uint8_t, 4> Concat4dDiffShapeDim2Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 2996 | IWorkloadFactory& workloadFactory, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 2997 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 2998 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 2999 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 3000 | return Concat4dDiffShapeDim2TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 3001 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 3002 | } |
| 3003 | |
| 3004 | LayerTestResult<uint8_t, 4> Concat4dDiffShapeDim3Uint8Test( |
Aron Virginas-Tar | 48623a0 | 2019-10-22 10:00:28 +0100 | [diff] [blame] | 3005 | IWorkloadFactory& workloadFactory, |
| 3006 | const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 3007 | const armnn::ITensorHandleFactory& tensorHandleFactory, |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 3008 | bool useSubtensor) |
| 3009 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 3010 | return Concat4dDiffShapeDim3TestImpl<DataType::QAsymmU8>( |
Keith Davis | f500d6c | 2020-08-31 08:32:55 +0100 | [diff] [blame] | 3011 | workloadFactory, memoryManager, tensorHandleFactory, 0.5f, -1, useSubtensor); |
Aron Virginas-Tar | 00d306e | 2019-08-28 18:08:46 +0100 | [diff] [blame] | 3012 | } |