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