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