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