Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 5 | #include <Layer.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 6 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 7 | #include <backendsCommon/MemCopyWorkload.hpp> |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 8 | #include <backendsCommon/MemImportWorkload.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <backendsCommon/MakeWorkloadHelper.hpp> |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 10 | #include <reference/workloads/RefFillWorkload.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | #include "RefWorkloadFactory.hpp" |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 12 | #include "RefBackendId.hpp" |
David Beck | b4540be | 2018-09-24 13:18:27 +0100 | [diff] [blame] | 13 | #include "workloads/RefWorkloads.hpp" |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 14 | #include "RefTensorHandle.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 16 | |
| 17 | namespace armnn |
| 18 | { |
| 19 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 20 | namespace |
| 21 | { |
| 22 | static const BackendId s_Id{RefBackendId()}; |
| 23 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | template <typename F32Workload, typename U8Workload, typename QueueDescriptorType> |
| 25 | std::unique_ptr<IWorkload> RefWorkloadFactory::MakeWorkload(const QueueDescriptorType& descriptor, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 26 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | { |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 28 | return MakeWorkloadHelper<NullWorkload, F32Workload, U8Workload, NullWorkload, NullWorkload, NullWorkload> |
| 29 | (descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 32 | template <DataType ArmnnType> |
| 33 | bool IsDataType(const WorkloadInfo& info) |
Jim Flynn | 82fbe7c | 2019-04-02 15:19:08 +0100 | [diff] [blame] | 34 | { |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 35 | auto checkType = [](const TensorInfo& tensorInfo) {return tensorInfo.GetDataType() == ArmnnType;}; |
| 36 | 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] | 37 | if (it != std::end(info.m_InputTensorInfos)) |
| 38 | { |
| 39 | return true; |
| 40 | } |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 41 | 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] | 42 | if (it != std::end(info.m_OutputTensorInfos)) |
| 43 | { |
| 44 | return true; |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 49 | bool IsSigned32(const WorkloadInfo& info) |
| 50 | { |
| 51 | return IsDataType<DataType::Signed32>(info); |
| 52 | } |
| 53 | |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 54 | bool IsBFloat16(const WorkloadInfo& info) |
| 55 | { |
| 56 | return IsDataType<DataType::BFloat16>(info); |
| 57 | } |
| 58 | |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 59 | bool IsFloat16(const WorkloadInfo& info) |
| 60 | { |
| 61 | return IsDataType<DataType::Float16>(info); |
| 62 | } |
| 63 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 64 | bool IsQSymmS16(const WorkloadInfo& info) |
nikraj01 | 99a6631 | 2019-06-06 10:31:27 +0100 | [diff] [blame] | 65 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 66 | return IsDataType<DataType::QSymmS16>(info); |
nikraj01 | 99a6631 | 2019-06-06 10:31:27 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 69 | bool IsQSymmS8(const WorkloadInfo& info) |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 70 | { |
| 71 | return IsDataType<DataType::QSymmS8>(info); |
| 72 | } |
| 73 | |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 74 | bool IsQAsymmS8(const WorkloadInfo& info) |
| 75 | { |
| 76 | return IsDataType<DataType::QAsymmS8>(info); |
| 77 | } |
| 78 | |
| 79 | bool IsQAsymmU8(const WorkloadInfo& info) |
| 80 | { |
| 81 | return IsDataType<DataType::QAsymmU8>(info); |
| 82 | } |
| 83 | |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 84 | RefWorkloadFactory::RefWorkloadFactory(const std::shared_ptr<RefMemoryManager>& memoryManager) |
| 85 | : m_MemoryManager(memoryManager) |
| 86 | { |
| 87 | } |
| 88 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 89 | RefWorkloadFactory::RefWorkloadFactory() |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 90 | : m_MemoryManager(new RefMemoryManager()) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 91 | { |
| 92 | } |
| 93 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 94 | const BackendId& RefWorkloadFactory::GetBackendId() const |
| 95 | { |
| 96 | return s_Id; |
| 97 | } |
| 98 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 99 | bool RefWorkloadFactory::IsLayerSupported(const Layer& layer, |
| 100 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 101 | std::string& outReasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 102 | { |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 103 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 106 | bool RefWorkloadFactory::IsLayerSupported(const IConnectableLayer& layer, |
| 107 | Optional<DataType> dataType, |
| 108 | std::string& outReasonIfUnsupported, |
| 109 | const ModelOptions& modelOptions) |
| 110 | { |
| 111 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported, modelOptions); |
| 112 | } |
| 113 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 114 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 115 | const bool isMemoryManaged) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 116 | { |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 117 | // For Ref it is okay to make the TensorHandle memory managed as it can also store a pointer |
| 118 | // to unmanaged memory. This also ensures memory alignment. |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 119 | IgnoreUnused(isMemoryManaged); |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 120 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 121 | } |
| 122 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 123 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 124 | DataLayout dataLayout, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 125 | const bool isMemoryManaged) const |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 126 | { |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 127 | // For Ref it is okay to make the TensorHandle memory managed as it can also store a pointer |
| 128 | // to unmanaged memory. This also ensures memory alignment. |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 129 | IgnoreUnused(isMemoryManaged, dataLayout); |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 130 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 133 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateAbs(const AbsQueueDescriptor& descriptor, |
| 134 | const WorkloadInfo& info) const |
| 135 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 136 | IgnoreUnused(descriptor); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 137 | ElementwiseUnaryQueueDescriptor elementwiseUnaryDescriptor; |
| 138 | elementwiseUnaryDescriptor.m_Parameters.m_Operation = UnaryOperation::Abs; |
| 139 | |
| 140 | return CreateElementwiseUnary(elementwiseUnaryDescriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 144 | const WorkloadInfo& info) const |
| 145 | { |
| 146 | return std::make_unique<RefActivationWorkload>(descriptor, info); |
| 147 | } |
| 148 | |
| 149 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateAddition(const AdditionQueueDescriptor& descriptor, |
| 150 | const WorkloadInfo& info) const |
| 151 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 152 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 153 | { |
| 154 | return std::make_unique<RefAdditionWorkload<int32_t>>(descriptor, info); |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | return std::make_unique<RefAdditionWorkload<float>>(descriptor, info); |
| 159 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor, |
| 163 | const WorkloadInfo& info) const |
| 164 | { |
| 165 | return std::make_unique<RefArgMinMaxWorkload>(descriptor, info); |
| 166 | } |
| 167 | |
| 168 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateBatchNormalization( |
| 169 | const BatchNormalizationQueueDescriptor& descriptor, |
| 170 | const WorkloadInfo& info) const |
| 171 | { |
| 172 | return std::make_unique<RefBatchNormalizationWorkload>(descriptor, info); |
| 173 | } |
| 174 | |
| 175 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, |
| 176 | const WorkloadInfo& info) const |
| 177 | { |
| 178 | return std::make_unique<RefBatchToSpaceNdWorkload>(descriptor, info); |
| 179 | } |
| 180 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 181 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateComparison(const ComparisonQueueDescriptor& descriptor, |
| 182 | const WorkloadInfo& info) const |
| 183 | { |
| 184 | return std::make_unique<RefComparisonWorkload>(descriptor, info); |
| 185 | } |
| 186 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 187 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConcat(const ConcatQueueDescriptor& descriptor, |
| 188 | const WorkloadInfo& info) const |
| 189 | { |
| 190 | return std::make_unique<RefConcatWorkload>(descriptor, info); |
| 191 | } |
| 192 | |
| 193 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 194 | const WorkloadInfo& info) const |
| 195 | { |
| 196 | return std::make_unique<RefConstantWorkload>(descriptor, info); |
| 197 | } |
| 198 | |
Narumol Prangnawarat | 7ddbbae | 2020-03-13 10:26:05 +0000 | [diff] [blame] | 199 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertBf16ToFp32( |
| 200 | const ConvertBf16ToFp32QueueDescriptor& descriptor, |
| 201 | const WorkloadInfo& info) const |
| 202 | { |
| 203 | return std::make_unique<RefConvertBf16ToFp32Workload>(descriptor, info); |
| 204 | } |
| 205 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 206 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp16ToFp32( |
| 207 | const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 208 | const WorkloadInfo& info) const |
| 209 | { |
| 210 | return std::make_unique<RefConvertFp16ToFp32Workload>(descriptor, info); |
| 211 | } |
| 212 | |
Narumol Prangnawarat | ea54a01 | 2020-03-16 16:36:10 +0000 | [diff] [blame] | 213 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp32ToBf16( |
| 214 | const ConvertFp32ToBf16QueueDescriptor& descriptor, |
| 215 | const WorkloadInfo& info) const |
| 216 | { |
| 217 | return std::make_unique<RefConvertFp32ToBf16Workload>(descriptor, info); |
| 218 | } |
| 219 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 220 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvertFp32ToFp16( |
| 221 | const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 222 | const WorkloadInfo& info) const |
| 223 | { |
| 224 | return std::make_unique<RefConvertFp32ToFp16Workload>(descriptor, info); |
| 225 | } |
| 226 | |
| 227 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor, |
| 228 | const WorkloadInfo& info) const |
| 229 | { |
| 230 | return std::make_unique<RefConvolution2dWorkload>(descriptor, info); |
| 231 | } |
| 232 | |
| 233 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDebug(const DebugQueueDescriptor& descriptor, |
| 234 | const WorkloadInfo& info) const |
| 235 | { |
Narumol Prangnawarat | 403a185 | 2020-03-12 14:24:13 +0000 | [diff] [blame] | 236 | if (IsBFloat16(info)) |
| 237 | { |
| 238 | return std::make_unique<RefDebugBFloat16Workload>(descriptor, info); |
| 239 | } |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 240 | if (IsFloat16(info)) |
| 241 | { |
| 242 | return std::make_unique<RefDebugFloat16Workload>(descriptor, info); |
| 243 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 244 | if (IsQSymmS16(info)) |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 245 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 246 | return std::make_unique<RefDebugQSymmS16Workload>(descriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 247 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 248 | if (IsQSymmS8(info)) |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 249 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 250 | return std::make_unique<RefDebugQSymmS8Workload>(descriptor, info); |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 251 | } |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 252 | if (IsQAsymmU8(info)) |
| 253 | { |
| 254 | return std::make_unique<RefDebugQAsymmU8Workload>(descriptor, info); |
| 255 | } |
| 256 | if (IsQAsymmS8(info)) |
| 257 | { |
| 258 | return std::make_unique<RefDebugQAsymmS8Workload>(descriptor, info); |
| 259 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 260 | if (IsSigned32(info)) |
Narumol Prangnawarat | d2d917d | 2020-01-09 10:16:39 +0000 | [diff] [blame] | 261 | { |
| 262 | return std::make_unique<RefDebugSigned32Workload>(descriptor, info); |
| 263 | } |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 264 | |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 265 | return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(descriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDepthToSpace(const DepthToSpaceQueueDescriptor& descriptor, |
| 269 | const WorkloadInfo& info) const |
| 270 | { |
| 271 | return std::make_unique<RefDepthToSpaceWorkload>(descriptor, info); |
| 272 | } |
| 273 | |
| 274 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDepthwiseConvolution2d( |
| 275 | const DepthwiseConvolution2dQueueDescriptor& descriptor, |
| 276 | const WorkloadInfo& info) const |
| 277 | { |
| 278 | return std::make_unique<RefDepthwiseConvolution2dWorkload>(descriptor, info); |
| 279 | } |
| 280 | |
| 281 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDequantize(const DequantizeQueueDescriptor& descriptor, |
| 282 | const WorkloadInfo& info) const |
| 283 | { |
| 284 | return std::make_unique<RefDequantizeWorkload>(descriptor, info); |
| 285 | } |
| 286 | |
| 287 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDetectionPostProcess( |
| 288 | const DetectionPostProcessQueueDescriptor& descriptor, |
| 289 | const WorkloadInfo& info) const |
| 290 | { |
| 291 | return std::make_unique<RefDetectionPostProcessWorkload>(descriptor, info); |
| 292 | } |
| 293 | |
| 294 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateDivision(const DivisionQueueDescriptor& descriptor, |
| 295 | const WorkloadInfo& info) const |
| 296 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 297 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 298 | { |
| 299 | return std::make_unique<RefDivisionWorkload<int32_t>>(descriptor, info); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | return std::make_unique<RefDivisionWorkload<float>>(descriptor, info); |
| 304 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 305 | } |
| 306 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 307 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateElementwiseUnary(const ElementwiseUnaryQueueDescriptor& descriptor, |
| 308 | const WorkloadInfo& info) const |
| 309 | { |
| 310 | return std::make_unique<RefElementwiseUnaryWorkload>(descriptor, info); |
| 311 | } |
| 312 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 313 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateEqual(const EqualQueueDescriptor& descriptor, |
| 314 | const WorkloadInfo& info) const |
| 315 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 316 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 317 | ComparisonQueueDescriptor comparisonDescriptor; |
| 318 | comparisonDescriptor.m_Parameters.m_Operation = ComparisonOperation::Equal; |
| 319 | |
| 320 | return CreateComparison(comparisonDescriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 323 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor, |
| 324 | const WorkloadInfo& info) const |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 325 | { |
| 326 | return MakeWorkload<RefFakeQuantizationFloat32Workload, NullWorkload>(descriptor, info); |
| 327 | } |
| 328 | |
Ryan OShea | f4bfa6a | 2020-06-10 11:33:37 +0100 | [diff] [blame] | 329 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFill(const FillQueueDescriptor& descriptor, |
| 330 | const WorkloadInfo& info) const |
| 331 | { |
| 332 | return std::make_unique<RefFillWorkload>(descriptor, info); |
| 333 | } |
| 334 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 335 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFloor(const FloorQueueDescriptor& descriptor, |
| 336 | const WorkloadInfo& info) const |
| 337 | { |
Francis Murtagh | e8ac133 | 2020-07-30 18:03:40 +0100 | [diff] [blame] | 338 | if(IsQuantizedType(info.m_InputTensorInfos[0].GetDataType())) |
| 339 | { |
| 340 | return nullptr; |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | return std::make_unique<RefFloorWorkload>(descriptor, info); |
| 345 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateFullyConnected( |
| 349 | const FullyConnectedQueueDescriptor& descriptor, |
| 350 | const WorkloadInfo& info) const |
| 351 | { |
| 352 | return std::make_unique<RefFullyConnectedWorkload>(descriptor, info); |
| 353 | } |
| 354 | |
| 355 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateGather(const GatherQueueDescriptor& descriptor, |
| 356 | const WorkloadInfo& info) const |
| 357 | { |
| 358 | return std::make_unique<RefGatherWorkload>(descriptor, info); |
| 359 | } |
| 360 | |
| 361 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateGreater(const GreaterQueueDescriptor& descriptor, |
| 362 | const WorkloadInfo& info) const |
| 363 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 364 | IgnoreUnused(descriptor); |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 365 | ComparisonQueueDescriptor comparisonDescriptor; |
| 366 | comparisonDescriptor.m_Parameters.m_Operation = ComparisonOperation::Greater; |
| 367 | |
| 368 | return CreateComparison(comparisonDescriptor, info); |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 369 | } |
| 370 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 371 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateInput(const InputQueueDescriptor& descriptor, |
| 372 | const WorkloadInfo& info) const |
| 373 | { |
| 374 | if (info.m_InputTensorInfos.empty() ) |
| 375 | { |
| 376 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Input cannot be zero length"); |
| 377 | } |
| 378 | if (info.m_OutputTensorInfos.empty()) |
| 379 | { |
| 380 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Output cannot be zero length"); |
| 381 | } |
| 382 | |
| 383 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 384 | { |
| 385 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: data input and output differ in byte count."); |
| 386 | } |
| 387 | |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 388 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 391 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateInstanceNormalization( |
| 392 | const InstanceNormalizationQueueDescriptor& descriptor, |
| 393 | const WorkloadInfo& info) const |
| 394 | { |
| 395 | return std::make_unique<RefInstanceNormalizationWorkload>(descriptor, info); |
| 396 | } |
| 397 | |
| 398 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 399 | const WorkloadInfo& info) const |
| 400 | { |
| 401 | return std::make_unique<RefL2NormalizationWorkload>(descriptor, info); |
| 402 | } |
| 403 | |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 404 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLogicalBinary(const LogicalBinaryQueueDescriptor& descriptor, |
| 405 | const WorkloadInfo& info) const |
| 406 | { |
| 407 | return std::make_unique<RefLogicalBinaryWorkload>(descriptor, info); |
| 408 | } |
| 409 | |
| 410 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLogicalUnary(const ElementwiseUnaryQueueDescriptor& descriptor, |
| 411 | const WorkloadInfo& info) const |
| 412 | { |
| 413 | return std::make_unique<RefLogicalUnaryWorkload>(descriptor, info); |
| 414 | } |
| 415 | |
| 416 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 417 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLogSoftmax(const LogSoftmaxQueueDescriptor& descriptor, |
| 418 | const WorkloadInfo& info) const |
| 419 | { |
| 420 | return std::make_unique<RefLogSoftmaxWorkload>(descriptor, info); |
| 421 | } |
| 422 | |
| 423 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateLstm(const LstmQueueDescriptor& descriptor, |
| 424 | const WorkloadInfo& info) const |
| 425 | { |
| 426 | return std::make_unique<RefLstmWorkload>(descriptor, info); |
| 427 | } |
| 428 | |
| 429 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMaximum(const MaximumQueueDescriptor& descriptor, |
| 430 | const WorkloadInfo& info) const |
| 431 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 432 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 433 | { |
| 434 | return std::make_unique<RefMaximumWorkload<int32_t>>(descriptor, info); |
| 435 | } |
| 436 | else |
| 437 | { |
| 438 | return std::make_unique<RefMaximumWorkload<float>>(descriptor, info); |
| 439 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMean(const MeanQueueDescriptor& descriptor, |
| 443 | const WorkloadInfo& info) const |
| 444 | { |
| 445 | return std::make_unique<RefMeanWorkload>(descriptor, info); |
| 446 | } |
| 447 | |
| 448 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 449 | const WorkloadInfo& info) const |
| 450 | { |
| 451 | if (descriptor.m_Inputs.empty()) |
| 452 | { |
| 453 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemCopy() expected an input tensor."); |
| 454 | } |
| 455 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
| 456 | } |
| 457 | |
| 458 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMemImport(const MemImportQueueDescriptor& descriptor, |
| 459 | const WorkloadInfo& info) const |
| 460 | { |
| 461 | if (descriptor.m_Inputs.empty()) |
| 462 | { |
| 463 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemImport() expected an input tensor."); |
| 464 | } |
| 465 | return std::make_unique<ImportMemGenericWorkload>(descriptor, info); |
| 466 | } |
| 467 | |
| 468 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMerger(const MergerQueueDescriptor& descriptor, |
| 469 | const WorkloadInfo& info) const |
| 470 | { |
| 471 | return CreateConcat(descriptor, info); |
| 472 | } |
| 473 | |
| 474 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMinimum(const MinimumQueueDescriptor& descriptor, |
| 475 | const WorkloadInfo& info) const |
| 476 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 477 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 478 | { |
| 479 | return std::make_unique<RefMinimumWorkload<int32_t>>(descriptor, info); |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | return std::make_unique<RefMinimumWorkload<float>>(descriptor, info); |
| 484 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateMultiplication(const MultiplicationQueueDescriptor& descriptor, |
| 488 | const WorkloadInfo& info) const |
| 489 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 490 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 491 | { |
| 492 | return std::make_unique<RefMultiplicationWorkload<int32_t>>(descriptor, info); |
| 493 | } |
| 494 | else |
| 495 | { |
| 496 | return std::make_unique<RefMultiplicationWorkload<float>>(descriptor, info); |
| 497 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateNormalization(const NormalizationQueueDescriptor& descriptor, |
| 501 | const WorkloadInfo& info) const |
| 502 | { |
| 503 | return std::make_unique<RefNormalizationWorkload>(descriptor, info); |
| 504 | } |
| 505 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 506 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateOutput(const OutputQueueDescriptor& descriptor, |
| 507 | const WorkloadInfo& info) const |
| 508 | { |
| 509 | if (info.m_InputTensorInfos.empty() ) |
| 510 | { |
| 511 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Input cannot be zero length"); |
| 512 | } |
| 513 | if (info.m_OutputTensorInfos.empty()) |
| 514 | { |
| 515 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Output cannot be zero length"); |
| 516 | } |
| 517 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 518 | { |
| 519 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: data input and output differ in byte count."); |
| 520 | } |
| 521 | |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 522 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 525 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePad(const PadQueueDescriptor& descriptor, |
| 526 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 527 | { |
Sadik Armagan | 041b3c0 | 2020-06-04 10:32:18 +0100 | [diff] [blame] | 528 | return std::make_unique<RefPadWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 529 | } |
| 530 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 531 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 532 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 533 | { |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 534 | if (IsQSymmS16(info)) |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 535 | { |
| 536 | return std::make_unique<RefPermuteQSymm16Workload>(descriptor, info); |
| 537 | } |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 538 | else if (IsBFloat16(info)) |
| 539 | { |
| 540 | return std::make_unique<RefPermuteBFloat16Workload>(descriptor, info); |
| 541 | } |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 542 | else if (IsQAsymmS8(info)) |
| 543 | { |
| 544 | return std::make_unique<RefPermuteQAsymmS8Workload>(descriptor, info); |
| 545 | } |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 546 | return MakeWorkloadHelper<RefPermuteFloat16Workload, RefPermuteFloat32Workload, RefPermuteQAsymm8Workload, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 547 | NullWorkload, NullWorkload, NullWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 550 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 551 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 552 | { |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 553 | return std::make_unique<RefPooling2dWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 556 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePreCompiled(const PreCompiledQueueDescriptor& /*descriptor*/, |
| 557 | const WorkloadInfo& /*info*/) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 558 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 559 | return nullptr; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 560 | } |
| 561 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 562 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreatePrelu(const PreluQueueDescriptor& descriptor, |
| 563 | const WorkloadInfo& info) const |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 564 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 565 | return std::make_unique<RefPreluWorkload>(descriptor, info); |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 566 | } |
| 567 | |
James Conroy | 4f1f899 | 2020-04-29 20:01:10 +0100 | [diff] [blame] | 568 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateQLstm(const QLstmQueueDescriptor& descriptor, |
| 569 | const WorkloadInfo& info) const |
| 570 | { |
| 571 | return std::make_unique<RefQLstmWorkload>(descriptor, info); |
| 572 | } |
| 573 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 574 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateQuantize(const QuantizeQueueDescriptor& descriptor, |
| 575 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 576 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 577 | return std::make_unique<RefQuantizeWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 578 | } |
| 579 | |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 580 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateRank(const RankQueueDescriptor& descriptor, |
| 581 | const WorkloadInfo& info) const |
| 582 | { |
| 583 | return std::make_unique<RefRankWorkload>(descriptor, info); |
| 584 | } |
| 585 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 586 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 587 | const WorkloadInfo& info) const |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 588 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 589 | return std::make_unique<RefReshapeWorkload>(descriptor, info); |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 590 | } |
| 591 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 592 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateResize(const ResizeQueueDescriptor& descriptor, |
| 593 | const WorkloadInfo& info) const |
| 594 | { |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 595 | return std::make_unique<RefResizeWorkload>(descriptor, info); |
| 596 | } |
| 597 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 598 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor, |
| 599 | const WorkloadInfo& info) const |
| 600 | { |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 601 | ResizeQueueDescriptor resizeDescriptor; |
| 602 | resizeDescriptor.m_Parameters.m_Method = ResizeMethod::Bilinear; |
| 603 | resizeDescriptor.m_Parameters.m_DataLayout = descriptor.m_Parameters.m_DataLayout; |
| 604 | resizeDescriptor.m_Parameters.m_TargetWidth = descriptor.m_Parameters.m_TargetWidth; |
| 605 | resizeDescriptor.m_Parameters.m_TargetHeight = descriptor.m_Parameters.m_TargetHeight; |
| 606 | |
| 607 | return CreateResize(resizeDescriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 610 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateRsqrt(const RsqrtQueueDescriptor& descriptor, |
| 611 | const WorkloadInfo& info) const |
| 612 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 613 | IgnoreUnused(descriptor); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 614 | ElementwiseUnaryQueueDescriptor elementwiseUnaryDescriptor; |
| 615 | elementwiseUnaryDescriptor.m_Parameters.m_Operation = UnaryOperation::Rsqrt; |
| 616 | |
| 617 | return CreateElementwiseUnary(elementwiseUnaryDescriptor, info); |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 620 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSlice(const SliceQueueDescriptor& descriptor, |
| 621 | const WorkloadInfo& info) const |
| 622 | { |
| 623 | return std::make_unique<RefSliceWorkload>(descriptor, info); |
| 624 | } |
| 625 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 626 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
| 627 | const WorkloadInfo& info) const |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 628 | { |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 629 | return std::make_unique<RefSoftmaxWorkload>(descriptor, info); |
| 630 | } |
| 631 | |
| 632 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor, |
| 633 | const WorkloadInfo& info) const |
| 634 | { |
| 635 | return std::make_unique<RefSpaceToBatchNdWorkload>(descriptor, info); |
| 636 | } |
| 637 | |
| 638 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSpaceToDepth(const SpaceToDepthQueueDescriptor& descriptor, |
| 639 | const WorkloadInfo& info) const |
| 640 | { |
| 641 | return std::make_unique<RefSpaceToDepthWorkload>(descriptor, info); |
| 642 | } |
| 643 | |
| 644 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSplitter(const SplitterQueueDescriptor& descriptor, |
| 645 | const WorkloadInfo& info) const |
| 646 | { |
| 647 | return std::make_unique<RefSplitterWorkload>(descriptor, info); |
| 648 | } |
| 649 | |
| 650 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateStack(const StackQueueDescriptor& descriptor, |
| 651 | const WorkloadInfo& info) const |
| 652 | { |
| 653 | return std::make_unique<RefStackWorkload>(descriptor, info); |
| 654 | } |
| 655 | |
| 656 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, |
| 657 | const WorkloadInfo& info) const |
| 658 | { |
| 659 | return std::make_unique<RefStridedSliceWorkload>(descriptor, info); |
| 660 | } |
| 661 | |
| 662 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateSubtraction(const SubtractionQueueDescriptor& descriptor, |
| 663 | const WorkloadInfo& info) const |
| 664 | { |
Finn Williams | cbd2c23 | 2020-06-22 15:58:32 +0100 | [diff] [blame] | 665 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 666 | { |
| 667 | return std::make_unique<RefSubtractionWorkload<int32_t>>(descriptor, info); |
| 668 | } |
| 669 | else |
| 670 | { |
| 671 | return std::make_unique<RefSubtractionWorkload<float>>(descriptor, info); |
| 672 | } |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 673 | } |
| 674 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 675 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateTranspose(const TransposeQueueDescriptor& descriptor, |
| 676 | const WorkloadInfo& info) const |
| 677 | { |
| 678 | if (IsQSymmS16(info)) |
| 679 | { |
| 680 | return std::make_unique<RefTransposeQSymm16Workload>(descriptor, info); |
| 681 | } |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 682 | else if (IsBFloat16(info)) |
| 683 | { |
| 684 | return std::make_unique<RefTransposeBFloat16Workload>(descriptor, info); |
| 685 | } |
Sadik Armagan | 303980c | 2020-04-17 12:45:14 +0100 | [diff] [blame] | 686 | else if (IsQAsymmS8(info)) |
| 687 | { |
| 688 | return std::make_unique<RefTransposeQAsymmS8Workload>(descriptor, info); |
| 689 | } |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 690 | return MakeWorkloadHelper<RefTransposeFloat16Workload, RefTransposeFloat32Workload, RefTransposeQAsymm8Workload, |
| 691 | NullWorkload, NullWorkload, NullWorkload>(descriptor, info); |
| 692 | } |
| 693 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 694 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateTransposeConvolution2d( |
| 695 | const TransposeConvolution2dQueueDescriptor& descriptor, |
| 696 | const WorkloadInfo& info) const |
| 697 | { |
| 698 | return std::make_unique<RefTransposeConvolution2dWorkload>(descriptor, info); |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 699 | } |
| 700 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 701 | } // namespace armnn |