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