Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 5 | #include <Layer.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 6 | #include <armnn/backends/MemCopyWorkload.hpp> |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 7 | #include <backendsCommon/MemImportWorkload.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <backendsCommon/MakeWorkloadHelper.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 9 | #include <armnn/backends/TensorHandle.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | #include "RefWorkloadFactory.hpp" |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 11 | #include "RefBackendId.hpp" |
David Beck | b4540be | 2018-09-24 13:18:27 +0100 | [diff] [blame] | 12 | #include "workloads/RefWorkloads.hpp" |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 13 | #include "RefTensorHandle.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
| 16 | namespace armnn |
| 17 | { |
| 18 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 19 | namespace |
| 20 | { |
| 21 | static const BackendId s_Id{RefBackendId()}; |
| 22 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 23 | template <typename F32Workload, typename U8Workload, typename QueueDescriptorType> |
| 24 | std::unique_ptr<IWorkload> RefWorkloadFactory::MakeWorkload(const QueueDescriptorType& descriptor, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 25 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | { |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 27 | return MakeWorkloadHelper<NullWorkload, F32Workload, U8Workload, NullWorkload, NullWorkload, NullWorkload> |
| 28 | (descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 31 | template <DataType ArmnnType> |
| 32 | bool IsDataType(const WorkloadInfo& info) |
Jim Flynn | 82fbe7c | 2019-04-02 15:19:08 +0100 | [diff] [blame] | 33 | { |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 34 | auto checkType = [](const TensorInfo& tensorInfo) {return tensorInfo.GetDataType() == ArmnnType;}; |
| 35 | auto it = std::find_if(std::begin(info.m_InputTensorInfos), std::end(info.m_InputTensorInfos), checkType); |
Jim Flynn | 82fbe7c | 2019-04-02 15:19:08 +0100 | [diff] [blame] | 36 | if (it != std::end(info.m_InputTensorInfos)) |
| 37 | { |
| 38 | return true; |
| 39 | } |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 40 | it = std::find_if(std::begin(info.m_OutputTensorInfos), std::end(info.m_OutputTensorInfos), checkType); |
Jim Flynn | 82fbe7c | 2019-04-02 15:19:08 +0100 | [diff] [blame] | 41 | if (it != std::end(info.m_OutputTensorInfos)) |
| 42 | { |
| 43 | return true; |
| 44 | } |
| 45 | return false; |
| 46 | } |
| 47 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 48 | bool IsSigned32(const WorkloadInfo& info) |
| 49 | { |
| 50 | return IsDataType<DataType::Signed32>(info); |
| 51 | } |
| 52 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 53 | bool IsBFloat16(const WorkloadInfo& info) |
| 54 | { |
| 55 | return IsDataType<DataType::BFloat16>(info); |
| 56 | } |
| 57 | |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 58 | bool IsFloat16(const WorkloadInfo& info) |
| 59 | { |
| 60 | return IsDataType<DataType::Float16>(info); |
| 61 | } |
| 62 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 63 | bool IsQSymmS16(const WorkloadInfo& info) |
nikraj01 | 99a6631 | 2019-06-06 10:31:27 +0100 | [diff] [blame] | 64 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 65 | return IsDataType<DataType::QSymmS16>(info); |
nikraj01 | 99a6631 | 2019-06-06 10:31:27 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 68 | bool IsQSymmS8(const WorkloadInfo& info) |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 69 | { |
| 70 | return IsDataType<DataType::QSymmS8>(info); |
| 71 | } |
| 72 | |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 73 | bool IsQAsymmS8(const WorkloadInfo& info) |
| 74 | { |
| 75 | return IsDataType<DataType::QAsymmS8>(info); |
| 76 | } |
| 77 | |
| 78 | bool IsQAsymmU8(const WorkloadInfo& info) |
| 79 | { |
| 80 | return IsDataType<DataType::QAsymmU8>(info); |
| 81 | } |
| 82 | |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 83 | RefWorkloadFactory::RefWorkloadFactory(const std::shared_ptr<RefMemoryManager>& memoryManager) |
| 84 | : m_MemoryManager(memoryManager) |
| 85 | { |
| 86 | } |
| 87 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 88 | RefWorkloadFactory::RefWorkloadFactory() |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 89 | : m_MemoryManager(new RefMemoryManager()) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | { |
| 91 | } |
| 92 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 93 | const BackendId& RefWorkloadFactory::GetBackendId() const |
| 94 | { |
| 95 | return s_Id; |
| 96 | } |
| 97 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 98 | bool RefWorkloadFactory::IsLayerSupported(const Layer& layer, |
| 99 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 100 | std::string& outReasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 101 | { |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 102 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 105 | bool RefWorkloadFactory::IsLayerSupported(const IConnectableLayer& layer, |
| 106 | Optional<DataType> dataType, |
| 107 | std::string& outReasonIfUnsupported, |
| 108 | const ModelOptions& modelOptions) |
| 109 | { |
| 110 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported, modelOptions); |
| 111 | } |
| 112 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 113 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 114 | const bool isMemoryManaged) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 115 | { |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 116 | if (isMemoryManaged) |
| 117 | { |
| 118 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 119 | } |
| 120 | else |
| 121 | { |
| 122 | return std::make_unique<RefTensorHandle>(tensorInfo, static_cast<unsigned int>(MemorySource::Malloc)); |
| 123 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 126 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 127 | DataLayout dataLayout, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 128 | const bool isMemoryManaged) const |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 129 | { |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 130 | // For Ref it is okay to make the TensorHandle memory managed as it can also store a pointer |
| 131 | // to unmanaged memory. This also ensures memory alignment. |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 132 | IgnoreUnused(isMemoryManaged, dataLayout); |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 133 | |
| 134 | if (isMemoryManaged) |
| 135 | { |
| 136 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | return std::make_unique<RefTensorHandle>(tensorInfo, static_cast<unsigned int>(MemorySource::Malloc)); |
| 141 | } |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 144 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateWorkload(LayerType type, |
| 145 | const QueueDescriptor& descriptor, |
| 146 | const WorkloadInfo& info) const |
| 147 | { |
| 148 | switch(type) |
| 149 | { |
| 150 | case LayerType::Activation : |
| 151 | { |
| 152 | auto activationQueueDescriptor = PolymorphicDowncast<const ActivationQueueDescriptor*>(&descriptor); |
| 153 | return std::make_unique<RefActivationWorkload>(*activationQueueDescriptor, info); |
| 154 | } |
| 155 | case LayerType::Addition : |
| 156 | { |
| 157 | auto additionQueueDescriptor = PolymorphicDowncast<const AdditionQueueDescriptor*>(&descriptor); |
| 158 | |
| 159 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 160 | { |
| 161 | return std::make_unique<RefAdditionWorkload<int32_t>>(*additionQueueDescriptor, info); |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | return std::make_unique<RefAdditionWorkload<float>>(*additionQueueDescriptor, info); |
| 166 | } |
| 167 | } |
| 168 | case LayerType::ArgMinMax : |
| 169 | { |
| 170 | auto argMinMaxQueueDescriptor = PolymorphicDowncast<const ArgMinMaxQueueDescriptor*>(&descriptor); |
| 171 | return std::make_unique<RefArgMinMaxWorkload>(*argMinMaxQueueDescriptor, info); |
| 172 | } |
| 173 | case LayerType::BatchNormalization : |
| 174 | { |
| 175 | auto batchNormQueueDescriptor = PolymorphicDowncast<const BatchNormalizationQueueDescriptor*>(&descriptor); |
| 176 | return std::make_unique<RefBatchNormalizationWorkload>(*batchNormQueueDescriptor, info); |
| 177 | } |
| 178 | case LayerType::BatchToSpaceNd : |
| 179 | { |
| 180 | auto batchToSpaceNdQueueDescriptor |
| 181 | = PolymorphicDowncast<const BatchToSpaceNdQueueDescriptor*>(&descriptor); |
| 182 | return std::make_unique<RefBatchToSpaceNdWorkload>(*batchToSpaceNdQueueDescriptor, info); |
| 183 | } |
| 184 | case LayerType::Cast : |
| 185 | { |
| 186 | auto castQueueDescriptor = PolymorphicDowncast<const CastQueueDescriptor*>(&descriptor); |
| 187 | return std::make_unique<RefCastWorkload>(*castQueueDescriptor, info); |
| 188 | } |
| 189 | case LayerType::ChannelShuffle : |
| 190 | { |
| 191 | auto channelShuffleQueueDescriptor |
| 192 | = PolymorphicDowncast<const ChannelShuffleQueueDescriptor*>(&descriptor); |
| 193 | return std::make_unique<RefChannelShuffleWorkload>(*channelShuffleQueueDescriptor, info); |
| 194 | } |
| 195 | case LayerType::Comparison : |
| 196 | { |
| 197 | auto comparisonQueueDescriptor = PolymorphicDowncast<const ComparisonQueueDescriptor*>(&descriptor); |
| 198 | return std::make_unique<RefComparisonWorkload>(*comparisonQueueDescriptor, info); |
| 199 | } |
| 200 | case LayerType::Concat : |
| 201 | { |
| 202 | auto concatQueueDescriptor = PolymorphicDowncast<const ConcatQueueDescriptor*>(&descriptor); |
| 203 | return std::make_unique<RefConcatWorkload>(*concatQueueDescriptor, info); |
| 204 | } |
| 205 | case LayerType::Constant : |
| 206 | { |
| 207 | auto constantQueueDescriptor = PolymorphicDowncast<const ConstantQueueDescriptor*>(&descriptor); |
| 208 | return std::make_unique<RefConstantWorkload>(*constantQueueDescriptor, info); |
| 209 | } |
| 210 | case LayerType::ConvertBf16ToFp32 : |
| 211 | { |
| 212 | auto convertBf16ToFp32QueueDescriptor |
| 213 | = PolymorphicDowncast<const ConvertBf16ToFp32QueueDescriptor*>(&descriptor); |
| 214 | return std::make_unique<RefConvertBf16ToFp32Workload>(*convertBf16ToFp32QueueDescriptor, info); |
| 215 | } |
| 216 | case LayerType::ConvertFp16ToFp32: |
| 217 | { |
| 218 | auto convertFp16ToFp32QueueDescriptor |
| 219 | = PolymorphicDowncast<const ConvertFp16ToFp32QueueDescriptor*>(&descriptor); |
| 220 | return std::make_unique<RefConvertFp16ToFp32Workload>(*convertFp16ToFp32QueueDescriptor, info); |
| 221 | } |
| 222 | case LayerType::ConvertFp32ToBf16: |
| 223 | { |
| 224 | auto convertFp32ToBf16QueueDescriptor |
| 225 | = PolymorphicDowncast<const ConvertFp32ToBf16QueueDescriptor*>(&descriptor); |
| 226 | return std::make_unique<RefConvertFp32ToBf16Workload>(*convertFp32ToBf16QueueDescriptor, info); |
| 227 | } |
| 228 | case LayerType::ConvertFp32ToFp16: |
| 229 | { |
| 230 | auto convertFp32ToFp16QueueDescriptor |
| 231 | = PolymorphicDowncast<const ConvertFp32ToFp16QueueDescriptor*>(&descriptor); |
| 232 | return std::make_unique<RefConvertFp32ToFp16Workload>(*convertFp32ToFp16QueueDescriptor, info); |
| 233 | } |
| 234 | case LayerType::Convolution2d: |
| 235 | { |
| 236 | auto convolution2dQueueDescriptor = PolymorphicDowncast<const Convolution2dQueueDescriptor*>(&descriptor); |
| 237 | return std::make_unique<RefConvolution2dWorkload>(*convolution2dQueueDescriptor, info); |
| 238 | } |
| 239 | case LayerType::Convolution3d: |
| 240 | { |
| 241 | auto convolution3dQueueDescriptor = PolymorphicDowncast<const Convolution3dQueueDescriptor*>(&descriptor); |
| 242 | return std::make_unique<RefConvolution3dWorkload>(*convolution3dQueueDescriptor, info); |
| 243 | } |
| 244 | case LayerType::Debug: |
| 245 | { |
| 246 | auto debugQueueDescriptor = PolymorphicDowncast<const DebugQueueDescriptor*>(&descriptor); |
| 247 | if (IsBFloat16(info)) |
| 248 | { |
| 249 | return std::make_unique<RefDebugBFloat16Workload>(*debugQueueDescriptor, info); |
| 250 | } |
| 251 | if (IsFloat16(info)) |
| 252 | { |
| 253 | return std::make_unique<RefDebugFloat16Workload>(*debugQueueDescriptor, info); |
| 254 | } |
| 255 | if (IsQSymmS16(info)) |
| 256 | { |
| 257 | return std::make_unique<RefDebugQSymmS16Workload>(*debugQueueDescriptor, info); |
| 258 | } |
| 259 | if (IsQSymmS8(info)) |
| 260 | { |
| 261 | return std::make_unique<RefDebugQSymmS8Workload>(*debugQueueDescriptor, info); |
| 262 | } |
| 263 | if (IsQAsymmU8(info)) |
| 264 | { |
| 265 | return std::make_unique<RefDebugQAsymmU8Workload>(*debugQueueDescriptor, info); |
| 266 | } |
| 267 | if (IsQAsymmS8(info)) |
| 268 | { |
| 269 | return std::make_unique<RefDebugQAsymmS8Workload>(*debugQueueDescriptor, info); |
| 270 | } |
| 271 | if (IsSigned32(info)) |
| 272 | { |
| 273 | return std::make_unique<RefDebugSigned32Workload>(*debugQueueDescriptor, info); |
| 274 | } |
| 275 | |
| 276 | return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(*debugQueueDescriptor, info); |
| 277 | } |
| 278 | case LayerType::DepthToSpace: |
| 279 | { |
| 280 | auto depthToSpaceQueueDescriptor = PolymorphicDowncast<const DepthToSpaceQueueDescriptor*>(&descriptor); |
| 281 | return std::make_unique<RefDepthToSpaceWorkload>(*depthToSpaceQueueDescriptor, info); |
| 282 | } |
| 283 | case LayerType::DepthwiseConvolution2d: |
| 284 | { |
| 285 | auto depthwiseConvolution2DQueueDescriptor |
| 286 | = PolymorphicDowncast<const DepthwiseConvolution2dQueueDescriptor*>(&descriptor); |
| 287 | return std::make_unique<RefDepthwiseConvolution2dWorkload>(*depthwiseConvolution2DQueueDescriptor, info); |
| 288 | } |
| 289 | case LayerType::Dequantize: |
| 290 | { |
| 291 | auto dequantizeQueueDescriptor = PolymorphicDowncast<const DequantizeQueueDescriptor*>(&descriptor); |
| 292 | return std::make_unique<RefDequantizeWorkload>(*dequantizeQueueDescriptor, info); |
| 293 | } |
| 294 | case LayerType::DetectionPostProcess: |
| 295 | { |
| 296 | auto detectionPostProcessQueueDescriptor |
| 297 | = PolymorphicDowncast<const DetectionPostProcessQueueDescriptor*>(&descriptor); |
| 298 | return std::make_unique<RefDetectionPostProcessWorkload>(*detectionPostProcessQueueDescriptor, info); |
| 299 | } |
| 300 | case LayerType::Division: |
| 301 | { |
| 302 | auto divisionQueueDescriptor = PolymorphicDowncast<const DivisionQueueDescriptor*>(&descriptor); |
| 303 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 304 | { |
| 305 | return std::make_unique<RefDivisionWorkload<int32_t>>(*divisionQueueDescriptor, info); |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | return std::make_unique<RefDivisionWorkload<float>>(*divisionQueueDescriptor, info); |
| 310 | } |
| 311 | } |
| 312 | case LayerType::ElementwiseUnary: |
| 313 | { |
| 314 | auto elementwiseUnaryQueueDescriptor |
| 315 | = PolymorphicDowncast<const ElementwiseUnaryQueueDescriptor*>(&descriptor); |
| 316 | if ((*elementwiseUnaryQueueDescriptor).m_Parameters.m_Operation == UnaryOperation::LogicalNot) |
| 317 | { |
| 318 | return std::make_unique<RefLogicalUnaryWorkload>(*elementwiseUnaryQueueDescriptor, info); |
| 319 | } |
| 320 | return std::make_unique<RefElementwiseUnaryWorkload>(*elementwiseUnaryQueueDescriptor, info); |
| 321 | } |
| 322 | case LayerType::FakeQuantization: |
| 323 | { |
| 324 | auto fakeQuantizationQueueDescriptor |
| 325 | = PolymorphicDowncast<const FakeQuantizationQueueDescriptor*>(&descriptor); |
| 326 | return std::make_unique<RefFakeQuantizationFloat32Workload>(*fakeQuantizationQueueDescriptor, info); |
| 327 | } |
| 328 | case LayerType::Fill: |
| 329 | { |
| 330 | auto fillQueueDescriptor = PolymorphicDowncast<const FillQueueDescriptor*>(&descriptor); |
| 331 | return std::make_unique<RefFillWorkload>(*fillQueueDescriptor, info); |
| 332 | } |
| 333 | case LayerType::Floor: |
| 334 | { |
| 335 | auto floorQueueDescriptor = PolymorphicDowncast<const FloorQueueDescriptor*>(&descriptor); |
| 336 | if(IsQuantizedType(info.m_InputTensorInfos[0].GetDataType())) |
| 337 | { |
| 338 | return nullptr; |
| 339 | } |
| 340 | else |
| 341 | { |
| 342 | return std::make_unique<RefFloorWorkload>(*floorQueueDescriptor, info); |
| 343 | } |
| 344 | } |
| 345 | case LayerType::FullyConnected: |
| 346 | { |
| 347 | auto fullyConnectedQueueDescriptor |
| 348 | = PolymorphicDowncast<const FullyConnectedQueueDescriptor*>(&descriptor); |
| 349 | return std::make_unique<RefFullyConnectedWorkload>(*fullyConnectedQueueDescriptor, info); |
| 350 | } |
| 351 | case LayerType::Gather: |
| 352 | { |
| 353 | auto gatherQueueDescriptor = PolymorphicDowncast<const GatherQueueDescriptor*>(&descriptor); |
| 354 | return std::make_unique<RefGatherWorkload>(*gatherQueueDescriptor, info); |
| 355 | } |
Teresa Charlin | b2d3ec5 | 2022-04-12 22:07:09 +0100 | [diff] [blame] | 356 | case LayerType::GatherNd: |
| 357 | { |
| 358 | auto gatherNdQueueDescriptor = PolymorphicDowncast<const GatherNdQueueDescriptor*>(&descriptor); |
| 359 | return std::make_unique<RefGatherNdWorkload>(*gatherNdQueueDescriptor, info); |
| 360 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 361 | case LayerType::Input: |
| 362 | { |
| 363 | auto inputQueueDescriptor = PolymorphicDowncast<const InputQueueDescriptor*>(&descriptor); |
| 364 | if (info.m_InputTensorInfos.empty() ) |
| 365 | { |
| 366 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Input cannot be zero length"); |
| 367 | } |
| 368 | if (info.m_OutputTensorInfos.empty()) |
| 369 | { |
| 370 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Output cannot be zero length"); |
| 371 | } |
| 372 | |
| 373 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 374 | { |
| 375 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: " |
| 376 | "data input and output differ in byte count."); |
| 377 | } |
| 378 | |
| 379 | return std::make_unique<CopyMemGenericWorkload>(*inputQueueDescriptor, info); |
| 380 | } |
| 381 | case LayerType::InstanceNormalization: |
| 382 | { |
| 383 | auto instanceNormalizationQueueDescriptor |
| 384 | = PolymorphicDowncast<const InstanceNormalizationQueueDescriptor*>(&descriptor); |
| 385 | return std::make_unique<RefInstanceNormalizationWorkload>(*instanceNormalizationQueueDescriptor, info); |
| 386 | } |
| 387 | case LayerType::L2Normalization: |
| 388 | { |
| 389 | auto l2NormalizationQueueDescriptor |
| 390 | = PolymorphicDowncast<const L2NormalizationQueueDescriptor*>(&descriptor); |
| 391 | return std::make_unique<RefL2NormalizationWorkload>(*l2NormalizationQueueDescriptor, info); |
| 392 | } |
| 393 | case LayerType::LogicalBinary: |
| 394 | { |
| 395 | auto logicalBinaryQueueDescriptor = PolymorphicDowncast<const LogicalBinaryQueueDescriptor*>(&descriptor); |
| 396 | return std::make_unique<RefLogicalBinaryWorkload>(*logicalBinaryQueueDescriptor, info); |
| 397 | } |
| 398 | case LayerType::LogSoftmax: |
| 399 | { |
| 400 | auto logSoftmaxQueueDescriptor = PolymorphicDowncast<const LogSoftmaxQueueDescriptor*>(&descriptor); |
| 401 | return std::make_unique<RefLogSoftmaxWorkload>(*logSoftmaxQueueDescriptor, info); |
| 402 | } |
| 403 | case LayerType::Lstm: |
| 404 | { |
| 405 | auto lstmQueueDescriptor = PolymorphicDowncast<const LstmQueueDescriptor*>(&descriptor); |
| 406 | return std::make_unique<RefLstmWorkload>(*lstmQueueDescriptor, info); |
| 407 | } |
| 408 | case LayerType::Maximum: |
| 409 | { |
| 410 | auto maximumQueueDescriptor = PolymorphicDowncast<const MaximumQueueDescriptor*>(&descriptor); |
| 411 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 412 | { |
| 413 | return std::make_unique<RefMaximumWorkload<int32_t>>(*maximumQueueDescriptor, info); |
| 414 | } |
| 415 | else |
| 416 | { |
| 417 | return std::make_unique<RefMaximumWorkload<float>>(*maximumQueueDescriptor, info); |
| 418 | } |
| 419 | } |
| 420 | case LayerType::Mean: |
| 421 | { |
| 422 | auto meanQueueDescriptor = PolymorphicDowncast<const MeanQueueDescriptor*>(&descriptor); |
| 423 | return std::make_unique<RefMeanWorkload>(*meanQueueDescriptor, info); |
| 424 | } |
| 425 | case LayerType::MemCopy: |
| 426 | { |
| 427 | auto memCopyQueueDescriptor = PolymorphicDowncast<const MemCopyQueueDescriptor*>(&descriptor); |
| 428 | if (descriptor.m_Inputs.empty()) |
| 429 | { |
| 430 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemCopy() expected an input tensor."); |
| 431 | } |
| 432 | return std::make_unique<CopyMemGenericWorkload>(*memCopyQueueDescriptor, info); |
| 433 | } |
| 434 | case LayerType::MemImport: |
| 435 | { |
| 436 | auto memImportQueueDescriptor = PolymorphicDowncast<const MemImportQueueDescriptor*>(&descriptor); |
| 437 | if (descriptor.m_Inputs.empty()) |
| 438 | { |
| 439 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemImport() expected an input tensor."); |
| 440 | } |
| 441 | return std::make_unique<ImportMemGenericWorkload>(*memImportQueueDescriptor, info); |
| 442 | } |
| 443 | case LayerType::Minimum: |
| 444 | { |
| 445 | auto minimumQueueDescriptor = PolymorphicDowncast<const MinimumQueueDescriptor*>(&descriptor); |
| 446 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 447 | { |
| 448 | return std::make_unique<RefMinimumWorkload<int32_t>>(*minimumQueueDescriptor, info); |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | return std::make_unique<RefMinimumWorkload<float>>(*minimumQueueDescriptor, info); |
| 453 | } |
| 454 | } |
| 455 | case LayerType::Multiplication: |
| 456 | { |
| 457 | auto multiplicationQueueDescriptor |
| 458 | = PolymorphicDowncast<const MultiplicationQueueDescriptor*>(&descriptor); |
| 459 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 460 | { |
| 461 | return std::make_unique<RefMultiplicationWorkload<int32_t>>(*multiplicationQueueDescriptor, info); |
| 462 | } |
| 463 | else |
| 464 | { |
| 465 | return std::make_unique<RefMultiplicationWorkload<float>>(*multiplicationQueueDescriptor, info); |
| 466 | } |
| 467 | } |
| 468 | case LayerType::Normalization: |
| 469 | { |
| 470 | auto normalizationQueueDescriptor = PolymorphicDowncast<const NormalizationQueueDescriptor*>(&descriptor); |
| 471 | return std::make_unique<RefNormalizationWorkload>(*normalizationQueueDescriptor, info); |
| 472 | } |
| 473 | case LayerType::Output: |
| 474 | { |
| 475 | auto outputQueueDescriptor = PolymorphicDowncast<const OutputQueueDescriptor*>(&descriptor); |
| 476 | if (info.m_InputTensorInfos.empty() ) |
| 477 | { |
| 478 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Input cannot be zero length"); |
| 479 | } |
| 480 | if (info.m_OutputTensorInfos.empty()) |
| 481 | { |
| 482 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Output cannot be zero length"); |
| 483 | } |
| 484 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 485 | { |
| 486 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: data input and output " |
| 487 | "differ in byte count."); |
| 488 | } |
| 489 | |
| 490 | return std::make_unique<CopyMemGenericWorkload>(*outputQueueDescriptor, info); |
| 491 | } |
| 492 | case LayerType::Pad: |
| 493 | { |
| 494 | auto padQueueDescriptor = PolymorphicDowncast<const PadQueueDescriptor*>(&descriptor); |
| 495 | return std::make_unique<RefPadWorkload>(*padQueueDescriptor, info); |
| 496 | } |
| 497 | case LayerType::Permute: |
| 498 | { |
| 499 | auto permuteQueueDescriptor = PolymorphicDowncast<const PermuteQueueDescriptor*>(&descriptor); |
| 500 | if (IsQSymmS16(info)) |
| 501 | { |
| 502 | return std::make_unique<RefPermuteQSymm16Workload>(*permuteQueueDescriptor, info); |
| 503 | } |
| 504 | else if (IsBFloat16(info)) |
| 505 | { |
| 506 | return std::make_unique<RefPermuteBFloat16Workload>(*permuteQueueDescriptor, info); |
| 507 | } |
| 508 | else if (IsQAsymmS8(info)) |
| 509 | { |
| 510 | return std::make_unique<RefPermuteQAsymmS8Workload>(*permuteQueueDescriptor, info); |
| 511 | } |
| 512 | return MakeWorkloadHelper<RefPermuteFloat16Workload, RefPermuteFloat32Workload, RefPermuteQAsymm8Workload, |
| 513 | NullWorkload, NullWorkload, NullWorkload>(*permuteQueueDescriptor, info); |
| 514 | } |
| 515 | case LayerType::Pooling2d: |
| 516 | { |
| 517 | auto pooling2dQueueDescriptor = PolymorphicDowncast<const Pooling2dQueueDescriptor*>(&descriptor); |
| 518 | return std::make_unique<RefPooling2dWorkload>(*pooling2dQueueDescriptor, info); |
| 519 | } |
| 520 | case LayerType::Pooling3d: |
| 521 | { |
| 522 | auto pooling3dQueueDescriptor = PolymorphicDowncast<const Pooling3dQueueDescriptor*>(&descriptor); |
| 523 | return std::make_unique<RefPooling3dWorkload>(*pooling3dQueueDescriptor, info); |
| 524 | } |
| 525 | case LayerType::PreCompiled: |
| 526 | { |
| 527 | return nullptr; |
| 528 | } |
| 529 | case LayerType::Prelu: |
| 530 | { |
| 531 | auto preluQueueDescriptor = PolymorphicDowncast<const PreluQueueDescriptor*>(&descriptor); |
| 532 | return std::make_unique<RefPreluWorkload>(*preluQueueDescriptor, info); |
| 533 | } |
| 534 | case LayerType::QLstm: |
| 535 | { |
| 536 | auto qlstmQueueDescriptor = PolymorphicDowncast<const QLstmQueueDescriptor*>(&descriptor); |
| 537 | return std::make_unique<RefQLstmWorkload>(*qlstmQueueDescriptor, info); |
| 538 | } |
| 539 | case LayerType::Quantize: |
| 540 | { |
| 541 | auto quantizeQueueDescriptor = PolymorphicDowncast<const QuantizeQueueDescriptor*>(&descriptor); |
| 542 | return std::make_unique<RefQuantizeWorkload>(*quantizeQueueDescriptor, info); |
| 543 | } |
| 544 | case LayerType::Rank: |
| 545 | { |
| 546 | auto rankQueueDescriptor = PolymorphicDowncast<const RankQueueDescriptor*>(&descriptor); |
| 547 | return std::make_unique<RefRankWorkload>(*rankQueueDescriptor, info); |
| 548 | } |
| 549 | case LayerType::Reduce: |
| 550 | { |
| 551 | auto reduceQueueDescriptor = PolymorphicDowncast<const ReduceQueueDescriptor*>(&descriptor); |
| 552 | return std::make_unique<RefReduceWorkload>(*reduceQueueDescriptor, info); |
| 553 | } |
| 554 | case LayerType::Reshape: |
| 555 | { |
| 556 | auto reshapeQueueDescriptor = PolymorphicDowncast<const ReshapeQueueDescriptor*>(&descriptor); |
| 557 | return std::make_unique<RefReshapeWorkload>(*reshapeQueueDescriptor, info); |
| 558 | } |
| 559 | case LayerType::Resize: |
| 560 | { |
| 561 | auto resizeQueueDescriptor = PolymorphicDowncast<const ResizeQueueDescriptor*>(&descriptor); |
| 562 | return std::make_unique<RefResizeWorkload>(*resizeQueueDescriptor, info); |
| 563 | } |
| 564 | case LayerType::Shape: |
| 565 | { |
| 566 | auto shapeQueueDescriptor = PolymorphicDowncast<const ShapeQueueDescriptor*>(&descriptor); |
| 567 | return std::make_unique<RefShapeWorkload>(*shapeQueueDescriptor, info); |
| 568 | } |
| 569 | case LayerType::Slice: |
| 570 | { |
| 571 | auto sliceQueueDescriptor = PolymorphicDowncast<const SliceQueueDescriptor*>(&descriptor); |
| 572 | return std::make_unique<RefSliceWorkload>(*sliceQueueDescriptor, info); |
| 573 | } |
| 574 | case LayerType::Softmax: |
| 575 | { |
| 576 | auto softmaxQueueDescriptor = PolymorphicDowncast<const SoftmaxQueueDescriptor*>(&descriptor); |
| 577 | return std::make_unique<RefSoftmaxWorkload>(*softmaxQueueDescriptor, info); |
| 578 | } |
| 579 | case LayerType::SpaceToBatchNd: |
| 580 | { |
| 581 | auto spaceToBatchNdQueueDescriptor |
| 582 | = PolymorphicDowncast<const SpaceToBatchNdQueueDescriptor*>(&descriptor); |
| 583 | return std::make_unique<RefSpaceToBatchNdWorkload>(*spaceToBatchNdQueueDescriptor, info); |
| 584 | } |
| 585 | case LayerType::SpaceToDepth: |
| 586 | { |
| 587 | auto spaceToDepthQueueDescriptor = PolymorphicDowncast<const SpaceToDepthQueueDescriptor*>(&descriptor); |
| 588 | return std::make_unique<RefSpaceToDepthWorkload>(*spaceToDepthQueueDescriptor, info); |
| 589 | } |
| 590 | case LayerType::Splitter: |
| 591 | { |
| 592 | auto splitterQueueDescriptor = PolymorphicDowncast<const SplitterQueueDescriptor*>(&descriptor); |
| 593 | return std::make_unique<RefSplitterWorkload>(*splitterQueueDescriptor, info); |
| 594 | } |
| 595 | case LayerType::Stack: |
| 596 | { |
| 597 | auto stackQueueDescriptor = PolymorphicDowncast<const StackQueueDescriptor*>(&descriptor); |
| 598 | return std::make_unique<RefStackWorkload>(*stackQueueDescriptor, info); |
| 599 | } |
| 600 | case LayerType::StridedSlice: |
| 601 | { |
| 602 | auto stridedSliceQueueDescriptor = PolymorphicDowncast<const StridedSliceQueueDescriptor*>(&descriptor); |
| 603 | return std::make_unique<RefStridedSliceWorkload>(*stridedSliceQueueDescriptor, info); |
| 604 | } |
| 605 | case LayerType::Subtraction: |
| 606 | { |
| 607 | auto subtractionQueueDescriptor = PolymorphicDowncast<const SubtractionQueueDescriptor*>(&descriptor); |
| 608 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 609 | { |
| 610 | return std::make_unique<RefSubtractionWorkload<int32_t>>(*subtractionQueueDescriptor, info); |
| 611 | } |
| 612 | else |
| 613 | { |
| 614 | return std::make_unique<RefSubtractionWorkload<float>>(*subtractionQueueDescriptor, info); |
| 615 | } |
| 616 | } |
| 617 | case LayerType::Transpose: |
| 618 | { |
| 619 | auto transposeQueueDescriptor = PolymorphicDowncast<const TransposeQueueDescriptor*>(&descriptor); |
| 620 | if (IsQSymmS16(info)) |
| 621 | { |
| 622 | return std::make_unique<RefTransposeQSymm16Workload>(*transposeQueueDescriptor, info); |
| 623 | } |
| 624 | else if (IsBFloat16(info)) |
| 625 | { |
| 626 | return std::make_unique<RefTransposeBFloat16Workload>(*transposeQueueDescriptor, info); |
| 627 | } |
| 628 | else if (IsQAsymmS8(info)) |
| 629 | { |
| 630 | return std::make_unique<RefTransposeQAsymmS8Workload>(*transposeQueueDescriptor, info); |
| 631 | } |
| 632 | return MakeWorkloadHelper<RefTransposeFloat16Workload, RefTransposeFloat32Workload, |
| 633 | RefTransposeQAsymm8Workload, NullWorkload, NullWorkload, NullWorkload> |
| 634 | (*transposeQueueDescriptor, info); |
| 635 | } |
| 636 | case LayerType::TransposeConvolution2d: |
| 637 | { |
| 638 | auto transposeConvolution2dQueueDescriptor |
| 639 | = PolymorphicDowncast<const TransposeConvolution2dQueueDescriptor*>(&descriptor); |
| 640 | return std::make_unique<RefTransposeConvolution2dWorkload>(*transposeConvolution2dQueueDescriptor, info); |
| 641 | } |
| 642 | case LayerType::UnidirectionalSequenceLstm: |
| 643 | { |
| 644 | auto unidirectionalSequenceLstmQueueDescriptor |
| 645 | = PolymorphicDowncast<const UnidirectionalSequenceLstmQueueDescriptor*>(&descriptor); |
| 646 | return std::make_unique<RefUnidirectionalSequenceLstmWorkload>(*unidirectionalSequenceLstmQueueDescriptor, |
| 647 | info); |
| 648 | } |
| 649 | default: |
| 650 | return nullptr; |
| 651 | } |
| 652 | } |
| 653 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 654 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 655 | const WorkloadInfo& info) const |
| 656 | { |
| 657 | return std::make_unique<RefActivationWorkload>(descriptor, info); |
| 658 | } |
| 659 | |
| 660 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateAddition(const AdditionQueueDescriptor& descriptor, |
| 661 | const WorkloadInfo& info) const |
| 662 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 663 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 664 | { |
| 665 | return std::make_unique<RefAdditionWorkload<int32_t>>(descriptor, info); |
| 666 | } |
| 667 | else |
| 668 | { |
| 669 | return std::make_unique<RefAdditionWorkload<float>>(descriptor, info); |
| 670 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor, |
| 674 | const WorkloadInfo& info) const |
| 675 | { |
| 676 | return std::make_unique<RefArgMinMaxWorkload>(descriptor, info); |
| 677 | } |
| 678 | |
| 679 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateBatchNormalization( |
| 680 | const BatchNormalizationQueueDescriptor& descriptor, |
| 681 | const WorkloadInfo& info) const |
| 682 | { |
| 683 | return std::make_unique<RefBatchNormalizationWorkload>(descriptor, info); |
| 684 | } |
| 685 | |
| 686 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, |
| 687 | const WorkloadInfo& info) const |
| 688 | { |
| 689 | return std::make_unique<RefBatchToSpaceNdWorkload>(descriptor, info); |
| 690 | } |
| 691 | |
mathad01 | b392e98 | 2021-04-07 12:07:30 +0100 | [diff] [blame] | 692 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateCast(const CastQueueDescriptor& descriptor, |
| 693 | const WorkloadInfo& info) const |
| 694 | { |
| 695 | return std::make_unique<RefCastWorkload>(descriptor, info); |
| 696 | } |
| 697 | |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 698 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateChannelShuffle(const ChannelShuffleQueueDescriptor &descriptor, |
| 699 | const WorkloadInfo &info) const |
| 700 | { |
| 701 | return std::make_unique<RefChannelShuffleWorkload>(descriptor,info); |
| 702 | } |
| 703 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 704 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateComparison(const ComparisonQueueDescriptor& descriptor, |
| 705 | const WorkloadInfo& info) const |
| 706 | { |
| 707 | return std::make_unique<RefComparisonWorkload>(descriptor, info); |
| 708 | } |
| 709 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 710 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConcat(const ConcatQueueDescriptor& descriptor, |
| 711 | const WorkloadInfo& info) const |
| 712 | { |
| 713 | return std::make_unique<RefConcatWorkload>(descriptor, info); |
| 714 | } |
| 715 | |
| 716 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 717 | const WorkloadInfo& info) const |
| 718 | { |
| 719 | return std::make_unique<RefConstantWorkload>(descriptor, info); |
| 720 | } |
| 721 | |
Narumol Prangnawarat | 7ddbbae | 2020-03-13 10:26:05 +0000 | [diff] [blame] | 722 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertBf16ToFp32( |
| 723 | const ConvertBf16ToFp32QueueDescriptor& descriptor, |
| 724 | const WorkloadInfo& info) const |
| 725 | { |
| 726 | return std::make_unique<RefConvertBf16ToFp32Workload>(descriptor, info); |
| 727 | } |
| 728 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 729 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp16ToFp32( |
| 730 | const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 731 | const WorkloadInfo& info) const |
| 732 | { |
| 733 | return std::make_unique<RefConvertFp16ToFp32Workload>(descriptor, info); |
| 734 | } |
| 735 | |
Narumol Prangnawarat | ea54a01 | 2020-03-16 16:36:10 +0000 | [diff] [blame] | 736 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp32ToBf16( |
| 737 | const ConvertFp32ToBf16QueueDescriptor& descriptor, |
| 738 | const WorkloadInfo& info) const |
| 739 | { |
| 740 | return std::make_unique<RefConvertFp32ToBf16Workload>(descriptor, info); |
| 741 | } |
| 742 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 743 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp32ToFp16( |
| 744 | const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 745 | const WorkloadInfo& info) const |
| 746 | { |
| 747 | return std::make_unique<RefConvertFp32ToFp16Workload>(descriptor, info); |
| 748 | } |
| 749 | |
| 750 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor, |
| 751 | const WorkloadInfo& info) const |
| 752 | { |
| 753 | return std::make_unique<RefConvolution2dWorkload>(descriptor, info); |
| 754 | } |
| 755 | |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 756 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvolution3d(const Convolution3dQueueDescriptor& descriptor, |
| 757 | const WorkloadInfo& info) const |
| 758 | { |
| 759 | return std::make_unique<RefConvolution3dWorkload>(descriptor, info); |
| 760 | } |
| 761 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 762 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDebug(const DebugQueueDescriptor& descriptor, |
| 763 | const WorkloadInfo& info) const |
| 764 | { |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 765 | if (IsBFloat16(info)) |
| 766 | { |
| 767 | return std::make_unique<RefDebugBFloat16Workload>(descriptor, info); |
| 768 | } |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 769 | if (IsFloat16(info)) |
| 770 | { |
| 771 | return std::make_unique<RefDebugFloat16Workload>(descriptor, info); |
| 772 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 773 | if (IsQSymmS16(info)) |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 774 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 775 | return std::make_unique<RefDebugQSymmS16Workload>(descriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 776 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 777 | if (IsQSymmS8(info)) |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 778 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 779 | return std::make_unique<RefDebugQSymmS8Workload>(descriptor, info); |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 780 | } |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 781 | if (IsQAsymmU8(info)) |
| 782 | { |
| 783 | return std::make_unique<RefDebugQAsymmU8Workload>(descriptor, info); |
| 784 | } |
| 785 | if (IsQAsymmS8(info)) |
| 786 | { |
| 787 | return std::make_unique<RefDebugQAsymmS8Workload>(descriptor, info); |
| 788 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 789 | if (IsSigned32(info)) |
Narumol Prangnawarat | d2d917d | 2020-01-09 10:16:39 +0000 | [diff] [blame] | 790 | { |
| 791 | return std::make_unique<RefDebugSigned32Workload>(descriptor, info); |
| 792 | } |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 793 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 794 | return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(descriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDepthToSpace(const DepthToSpaceQueueDescriptor& descriptor, |
| 798 | const WorkloadInfo& info) const |
| 799 | { |
| 800 | return std::make_unique<RefDepthToSpaceWorkload>(descriptor, info); |
| 801 | } |
| 802 | |
| 803 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDepthwiseConvolution2d( |
| 804 | const DepthwiseConvolution2dQueueDescriptor& descriptor, |
| 805 | const WorkloadInfo& info) const |
| 806 | { |
| 807 | return std::make_unique<RefDepthwiseConvolution2dWorkload>(descriptor, info); |
| 808 | } |
| 809 | |
| 810 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDequantize(const DequantizeQueueDescriptor& descriptor, |
| 811 | const WorkloadInfo& info) const |
| 812 | { |
| 813 | return std::make_unique<RefDequantizeWorkload>(descriptor, info); |
| 814 | } |
| 815 | |
| 816 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDetectionPostProcess( |
| 817 | const DetectionPostProcessQueueDescriptor& descriptor, |
| 818 | const WorkloadInfo& info) const |
| 819 | { |
| 820 | return std::make_unique<RefDetectionPostProcessWorkload>(descriptor, info); |
| 821 | } |
| 822 | |
| 823 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDivision(const DivisionQueueDescriptor& descriptor, |
| 824 | const WorkloadInfo& info) const |
| 825 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 826 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 827 | { |
| 828 | return std::make_unique<RefDivisionWorkload<int32_t>>(descriptor, info); |
| 829 | } |
| 830 | else |
| 831 | { |
| 832 | return std::make_unique<RefDivisionWorkload<float>>(descriptor, info); |
| 833 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 834 | } |
| 835 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 836 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateElementwiseUnary(const ElementwiseUnaryQueueDescriptor& descriptor, |
| 837 | const WorkloadInfo& info) const |
| 838 | { |
Narumol Prangnawarat | 0c95f4c | 2020-11-18 16:52:07 +0000 | [diff] [blame] | 839 | if (descriptor.m_Parameters.m_Operation == UnaryOperation::LogicalNot) |
| 840 | { |
| 841 | return std::make_unique<RefLogicalUnaryWorkload>(descriptor, info); |
| 842 | } |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 843 | return std::make_unique<RefElementwiseUnaryWorkload>(descriptor, info); |
| 844 | } |
| 845 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 846 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor, |
| 847 | const WorkloadInfo& info) const |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 848 | { |
| 849 | return MakeWorkload<RefFakeQuantizationFloat32Workload, NullWorkload>(descriptor, info); |
| 850 | } |
| 851 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 852 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFill(const FillQueueDescriptor& descriptor, |
| 853 | const WorkloadInfo& info) const |
| 854 | { |
| 855 | return std::make_unique<RefFillWorkload>(descriptor, info); |
| 856 | } |
| 857 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 858 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFloor(const FloorQueueDescriptor& descriptor, |
| 859 | const WorkloadInfo& info) const |
| 860 | { |
Francis Murtagh | e8ac133 | 2020-07-30 18:03:40 +0100 | [diff] [blame] | 861 | if(IsQuantizedType(info.m_InputTensorInfos[0].GetDataType())) |
| 862 | { |
| 863 | return nullptr; |
| 864 | } |
| 865 | else |
| 866 | { |
| 867 | return std::make_unique<RefFloorWorkload>(descriptor, info); |
| 868 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFullyConnected( |
| 872 | const FullyConnectedQueueDescriptor& descriptor, |
| 873 | const WorkloadInfo& info) const |
| 874 | { |
| 875 | return std::make_unique<RefFullyConnectedWorkload>(descriptor, info); |
| 876 | } |
| 877 | |
| 878 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateGather(const GatherQueueDescriptor& descriptor, |
| 879 | const WorkloadInfo& info) const |
| 880 | { |
| 881 | return std::make_unique<RefGatherWorkload>(descriptor, info); |
| 882 | } |
| 883 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 884 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateInput(const InputQueueDescriptor& descriptor, |
| 885 | const WorkloadInfo& info) const |
| 886 | { |
| 887 | if (info.m_InputTensorInfos.empty() ) |
| 888 | { |
| 889 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Input cannot be zero length"); |
| 890 | } |
| 891 | if (info.m_OutputTensorInfos.empty()) |
| 892 | { |
| 893 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Output cannot be zero length"); |
| 894 | } |
| 895 | |
| 896 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 897 | { |
| 898 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: data input and output differ in byte count."); |
| 899 | } |
| 900 | |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 901 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 904 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateInstanceNormalization( |
| 905 | const InstanceNormalizationQueueDescriptor& descriptor, |
| 906 | const WorkloadInfo& info) const |
| 907 | { |
| 908 | return std::make_unique<RefInstanceNormalizationWorkload>(descriptor, info); |
| 909 | } |
| 910 | |
| 911 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 912 | const WorkloadInfo& info) const |
| 913 | { |
| 914 | return std::make_unique<RefL2NormalizationWorkload>(descriptor, info); |
| 915 | } |
| 916 | |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 917 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLogicalBinary(const LogicalBinaryQueueDescriptor& descriptor, |
| 918 | const WorkloadInfo& info) const |
| 919 | { |
| 920 | return std::make_unique<RefLogicalBinaryWorkload>(descriptor, info); |
| 921 | } |
| 922 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 923 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLogSoftmax(const LogSoftmaxQueueDescriptor& descriptor, |
| 924 | const WorkloadInfo& info) const |
| 925 | { |
| 926 | return std::make_unique<RefLogSoftmaxWorkload>(descriptor, info); |
| 927 | } |
| 928 | |
| 929 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLstm(const LstmQueueDescriptor& descriptor, |
| 930 | const WorkloadInfo& info) const |
| 931 | { |
| 932 | return std::make_unique<RefLstmWorkload>(descriptor, info); |
| 933 | } |
| 934 | |
| 935 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMaximum(const MaximumQueueDescriptor& descriptor, |
| 936 | const WorkloadInfo& info) const |
| 937 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 938 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 939 | { |
| 940 | return std::make_unique<RefMaximumWorkload<int32_t>>(descriptor, info); |
| 941 | } |
| 942 | else |
| 943 | { |
| 944 | return std::make_unique<RefMaximumWorkload<float>>(descriptor, info); |
| 945 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMean(const MeanQueueDescriptor& descriptor, |
| 949 | const WorkloadInfo& info) const |
| 950 | { |
| 951 | return std::make_unique<RefMeanWorkload>(descriptor, info); |
| 952 | } |
| 953 | |
| 954 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 955 | const WorkloadInfo& info) const |
| 956 | { |
| 957 | if (descriptor.m_Inputs.empty()) |
| 958 | { |
| 959 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemCopy() expected an input tensor."); |
| 960 | } |
| 961 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
| 962 | } |
| 963 | |
| 964 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMemImport(const MemImportQueueDescriptor& descriptor, |
| 965 | const WorkloadInfo& info) const |
| 966 | { |
| 967 | if (descriptor.m_Inputs.empty()) |
| 968 | { |
| 969 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemImport() expected an input tensor."); |
| 970 | } |
| 971 | return std::make_unique<ImportMemGenericWorkload>(descriptor, info); |
| 972 | } |
| 973 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 974 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMinimum(const MinimumQueueDescriptor& descriptor, |
| 975 | const WorkloadInfo& info) const |
| 976 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 977 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 978 | { |
| 979 | return std::make_unique<RefMinimumWorkload<int32_t>>(descriptor, info); |
| 980 | } |
| 981 | else |
| 982 | { |
| 983 | return std::make_unique<RefMinimumWorkload<float>>(descriptor, info); |
| 984 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMultiplication(const MultiplicationQueueDescriptor& descriptor, |
| 988 | const WorkloadInfo& info) const |
| 989 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 990 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 991 | { |
| 992 | return std::make_unique<RefMultiplicationWorkload<int32_t>>(descriptor, info); |
| 993 | } |
| 994 | else |
| 995 | { |
| 996 | return std::make_unique<RefMultiplicationWorkload<float>>(descriptor, info); |
| 997 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateNormalization(const NormalizationQueueDescriptor& descriptor, |
| 1001 | const WorkloadInfo& info) const |
| 1002 | { |
| 1003 | return std::make_unique<RefNormalizationWorkload>(descriptor, info); |
| 1004 | } |
| 1005 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1006 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateOutput(const OutputQueueDescriptor& descriptor, |
| 1007 | const WorkloadInfo& info) const |
| 1008 | { |
| 1009 | if (info.m_InputTensorInfos.empty() ) |
| 1010 | { |
| 1011 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Input cannot be zero length"); |
| 1012 | } |
| 1013 | if (info.m_OutputTensorInfos.empty()) |
| 1014 | { |
| 1015 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Output cannot be zero length"); |
| 1016 | } |
| 1017 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 1018 | { |
| 1019 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: data input and output differ in byte count."); |
| 1020 | } |
| 1021 | |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1022 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1023 | } |
| 1024 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1025 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePad(const PadQueueDescriptor& descriptor, |
| 1026 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1027 | { |
Sadik Armagan | 041b3c0 | 2020-06-04 10:32:18 +0100 | [diff] [blame] | 1028 | return std::make_unique<RefPadWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1031 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 1032 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1033 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 1034 | if (IsQSymmS16(info)) |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1035 | { |
| 1036 | return std::make_unique<RefPermuteQSymm16Workload>(descriptor, info); |
| 1037 | } |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1038 | else if (IsBFloat16(info)) |
| 1039 | { |
| 1040 | return std::make_unique<RefPermuteBFloat16Workload>(descriptor, info); |
| 1041 | } |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1042 | else if (IsQAsymmS8(info)) |
| 1043 | { |
| 1044 | return std::make_unique<RefPermuteQAsymmS8Workload>(descriptor, info); |
| 1045 | } |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1046 | return MakeWorkloadHelper<RefPermuteFloat16Workload, RefPermuteFloat32Workload, RefPermuteQAsymm8Workload, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1047 | NullWorkload, NullWorkload, NullWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1050 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 1051 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1052 | { |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1053 | return std::make_unique<RefPooling2dWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
Tamás Nyíri | 7b885b3 | 2021-10-26 14:47:57 +0100 | [diff] [blame] | 1056 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePooling3d(const Pooling3dQueueDescriptor& descriptor, |
| 1057 | const WorkloadInfo& info) const |
| 1058 | { |
| 1059 | return std::make_unique<RefPooling3dWorkload>(descriptor, info); |
| 1060 | } |
| 1061 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1062 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePreCompiled(const PreCompiledQueueDescriptor& /*descriptor*/, |
| 1063 | const WorkloadInfo& /*info*/) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1064 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1065 | return nullptr; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1068 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePrelu(const PreluQueueDescriptor& descriptor, |
| 1069 | const WorkloadInfo& info) const |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1070 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1071 | return std::make_unique<RefPreluWorkload>(descriptor, info); |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 1072 | } |
| 1073 | |
James Conroy | 4f1f899 | 2020-04-29 20:01:10 +0100 | [diff] [blame] | 1074 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateQLstm(const QLstmQueueDescriptor& descriptor, |
| 1075 | const WorkloadInfo& info) const |
| 1076 | { |
| 1077 | return std::make_unique<RefQLstmWorkload>(descriptor, info); |
| 1078 | } |
| 1079 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1080 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateQuantize(const QuantizeQueueDescriptor& descriptor, |
| 1081 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1082 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1083 | return std::make_unique<RefQuantizeWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 1086 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateRank(const RankQueueDescriptor& descriptor, |
| 1087 | const WorkloadInfo& info) const |
| 1088 | { |
| 1089 | return std::make_unique<RefRankWorkload>(descriptor, info); |
| 1090 | } |
| 1091 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 1092 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateReduce(const ReduceQueueDescriptor& descriptor, |
| 1093 | const WorkloadInfo& info) const |
| 1094 | { |
| 1095 | return std::make_unique<RefReduceWorkload>(descriptor, info); |
| 1096 | } |
| 1097 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1098 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 1099 | const WorkloadInfo& info) const |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 1100 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1101 | return std::make_unique<RefReshapeWorkload>(descriptor, info); |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 1102 | } |
| 1103 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1104 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateResize(const ResizeQueueDescriptor& descriptor, |
| 1105 | const WorkloadInfo& info) const |
| 1106 | { |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1107 | return std::make_unique<RefResizeWorkload>(descriptor, info); |
| 1108 | } |
| 1109 | |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 1110 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateShape(const ShapeQueueDescriptor& descriptor, |
| 1111 | const WorkloadInfo& info) const |
| 1112 | { |
| 1113 | return std::make_unique<RefShapeWorkload>(descriptor, info); |
| 1114 | } |
| 1115 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1116 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSlice(const SliceQueueDescriptor& descriptor, |
| 1117 | const WorkloadInfo& info) const |
| 1118 | { |
| 1119 | return std::make_unique<RefSliceWorkload>(descriptor, info); |
| 1120 | } |
| 1121 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1122 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
| 1123 | const WorkloadInfo& info) const |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1124 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1125 | return std::make_unique<RefSoftmaxWorkload>(descriptor, info); |
| 1126 | } |
| 1127 | |
| 1128 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor, |
| 1129 | const WorkloadInfo& info) const |
| 1130 | { |
| 1131 | return std::make_unique<RefSpaceToBatchNdWorkload>(descriptor, info); |
| 1132 | } |
| 1133 | |
| 1134 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSpaceToDepth(const SpaceToDepthQueueDescriptor& descriptor, |
| 1135 | const WorkloadInfo& info) const |
| 1136 | { |
| 1137 | return std::make_unique<RefSpaceToDepthWorkload>(descriptor, info); |
| 1138 | } |
| 1139 | |
| 1140 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSplitter(const SplitterQueueDescriptor& descriptor, |
| 1141 | const WorkloadInfo& info) const |
| 1142 | { |
| 1143 | return std::make_unique<RefSplitterWorkload>(descriptor, info); |
| 1144 | } |
| 1145 | |
| 1146 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateStack(const StackQueueDescriptor& descriptor, |
| 1147 | const WorkloadInfo& info) const |
| 1148 | { |
| 1149 | return std::make_unique<RefStackWorkload>(descriptor, info); |
| 1150 | } |
| 1151 | |
| 1152 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, |
| 1153 | const WorkloadInfo& info) const |
| 1154 | { |
| 1155 | return std::make_unique<RefStridedSliceWorkload>(descriptor, info); |
| 1156 | } |
| 1157 | |
| 1158 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSubtraction(const SubtractionQueueDescriptor& descriptor, |
| 1159 | const WorkloadInfo& info) const |
| 1160 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 1161 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 1162 | { |
| 1163 | return std::make_unique<RefSubtractionWorkload<int32_t>>(descriptor, info); |
| 1164 | } |
| 1165 | else |
| 1166 | { |
| 1167 | return std::make_unique<RefSubtractionWorkload<float>>(descriptor, info); |
| 1168 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1169 | } |
| 1170 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1171 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateTranspose(const TransposeQueueDescriptor& descriptor, |
| 1172 | const WorkloadInfo& info) const |
| 1173 | { |
| 1174 | if (IsQSymmS16(info)) |
| 1175 | { |
| 1176 | return std::make_unique<RefTransposeQSymm16Workload>(descriptor, info); |
| 1177 | } |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 1178 | else if (IsBFloat16(info)) |
| 1179 | { |
| 1180 | return std::make_unique<RefTransposeBFloat16Workload>(descriptor, info); |
| 1181 | } |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 1182 | else if (IsQAsymmS8(info)) |
| 1183 | { |
| 1184 | return std::make_unique<RefTransposeQAsymmS8Workload>(descriptor, info); |
| 1185 | } |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1186 | return MakeWorkloadHelper<RefTransposeFloat16Workload, RefTransposeFloat32Workload, RefTransposeQAsymm8Workload, |
| 1187 | NullWorkload, NullWorkload, NullWorkload>(descriptor, info); |
| 1188 | } |
| 1189 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1190 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateTransposeConvolution2d( |
| 1191 | const TransposeConvolution2dQueueDescriptor& descriptor, |
| 1192 | const WorkloadInfo& info) const |
| 1193 | { |
| 1194 | return std::make_unique<RefTransposeConvolution2dWorkload>(descriptor, info); |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 1195 | } |
| 1196 | |
Narumol Prangnawarat | e5339e7 | 2021-07-28 17:33:28 +0100 | [diff] [blame] | 1197 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateUnidirectionalSequenceLstm( |
| 1198 | const UnidirectionalSequenceLstmQueueDescriptor& descriptor, |
| 1199 | const WorkloadInfo& info) const |
| 1200 | { |
| 1201 | return std::make_unique<RefUnidirectionalSequenceLstmWorkload>(descriptor, info);; |
| 1202 | } |
| 1203 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 1204 | } // namespace armnn |