Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Tianle Cheng | 2828818 | 2024-02-23 17:56:54 +0000 | [diff] [blame] | 2 | // Copyright © 2017-2024 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 5 | #include <Layer.hpp> |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 6 | |
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> |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 9 | #include <armnn/backends/MemCopyWorkload.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 10 | #include <armnn/backends/TensorHandle.hpp> |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 11 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | #include "RefWorkloadFactory.hpp" |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 13 | #include "RefBackendId.hpp" |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 14 | #include "RefTensorHandle.hpp" |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 15 | #include "workloads/RefWorkloads.hpp" |
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> |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 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 | } |
John Mcloughlin | 4cf29d6 | 2023-09-25 14:10:32 +0100 | [diff] [blame] | 48 | bool IsSigned64(const WorkloadInfo& info) |
| 49 | { |
| 50 | return IsDataType<DataType::Signed64>(info); |
| 51 | } |
Keith Davis | 0c2eeac | 2020-02-11 16:51:50 +0000 | [diff] [blame] | 52 | bool IsSigned32(const WorkloadInfo& info) |
| 53 | { |
| 54 | return IsDataType<DataType::Signed32>(info); |
| 55 | } |
Narumol Prangnawarat | 44179c3 | 2020-03-11 14:51:27 +0000 | [diff] [blame] | 56 | bool IsBFloat16(const WorkloadInfo& info) |
| 57 | { |
| 58 | return IsDataType<DataType::BFloat16>(info); |
| 59 | } |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 60 | bool IsFloat16(const WorkloadInfo& info) |
| 61 | { |
| 62 | return IsDataType<DataType::Float16>(info); |
| 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 | } |
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 | } |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 72 | bool IsQAsymmS8(const WorkloadInfo& info) |
| 73 | { |
| 74 | return IsDataType<DataType::QAsymmS8>(info); |
| 75 | } |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 76 | bool IsQAsymmU8(const WorkloadInfo& info) |
| 77 | { |
| 78 | return IsDataType<DataType::QAsymmU8>(info); |
| 79 | } |
Colm Donelan | 693acb4 | 2024-04-19 15:02:09 +0100 | [diff] [blame] | 80 | bool IsBoolean(const WorkloadInfo& info) |
| 81 | { |
| 82 | return IsDataType<DataType::Boolean>(info); |
| 83 | } |
Keith Davis | 67e6c54 | 2020-02-19 10:08:33 +0000 | [diff] [blame] | 84 | |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 85 | RefWorkloadFactory::RefWorkloadFactory(const std::shared_ptr<RefMemoryManager>& memoryManager) |
| 86 | : m_MemoryManager(memoryManager) |
| 87 | { |
| 88 | } |
| 89 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 90 | RefWorkloadFactory::RefWorkloadFactory() |
Matthew Bentham | 7c1603a | 2019-06-21 17:22:23 +0100 | [diff] [blame] | 91 | : m_MemoryManager(new RefMemoryManager()) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 92 | { |
| 93 | } |
| 94 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 95 | const BackendId& RefWorkloadFactory::GetBackendId() const |
| 96 | { |
| 97 | return s_Id; |
| 98 | } |
| 99 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 100 | bool RefWorkloadFactory::IsLayerSupported(const Layer& layer, |
| 101 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 102 | std::string& outReasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | { |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 104 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 107 | bool RefWorkloadFactory::IsLayerSupported(const IConnectableLayer& layer, |
| 108 | Optional<DataType> dataType, |
| 109 | std::string& outReasonIfUnsupported, |
| 110 | const ModelOptions& modelOptions) |
| 111 | { |
| 112 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported, modelOptions); |
| 113 | } |
| 114 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 115 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 116 | const bool isMemoryManaged) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 117 | { |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 118 | if (isMemoryManaged) |
| 119 | { |
| 120 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 121 | } |
| 122 | else |
| 123 | { |
Matthew Bentham | c30abd8 | 2022-11-23 12:11:32 +0000 | [diff] [blame] | 124 | return std::make_unique<RefTensorHandle>(tensorInfo); |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 125 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 128 | std::unique_ptr<ITensorHandle> RefWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 129 | DataLayout dataLayout, |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 130 | const bool isMemoryManaged) const |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 131 | { |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 132 | // For Ref it is okay to make the TensorHandle memory managed as it can also store a pointer |
| 133 | // to unmanaged memory. This also ensures memory alignment. |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 134 | IgnoreUnused(isMemoryManaged, dataLayout); |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 135 | |
| 136 | if (isMemoryManaged) |
| 137 | { |
| 138 | return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager); |
| 139 | } |
| 140 | else |
| 141 | { |
Matthew Bentham | c30abd8 | 2022-11-23 12:11:32 +0000 | [diff] [blame] | 142 | return std::make_unique<RefTensorHandle>(tensorInfo); |
Finn Williams | b1aad42 | 2021-10-28 19:07:32 +0100 | [diff] [blame] | 143 | } |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 144 | } |
| 145 | |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 146 | std::unique_ptr<IWorkload> RefWorkloadFactory::CreateWorkload(LayerType type, |
| 147 | const QueueDescriptor& descriptor, |
| 148 | const WorkloadInfo& info) const |
| 149 | { |
| 150 | switch(type) |
| 151 | { |
| 152 | case LayerType::Activation : |
| 153 | { |
| 154 | auto activationQueueDescriptor = PolymorphicDowncast<const ActivationQueueDescriptor*>(&descriptor); |
| 155 | return std::make_unique<RefActivationWorkload>(*activationQueueDescriptor, info); |
| 156 | } |
| 157 | case LayerType::Addition : |
| 158 | { |
| 159 | auto additionQueueDescriptor = PolymorphicDowncast<const AdditionQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 160 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 161 | { |
| 162 | return std::make_unique<RefAdditionWorkload<int32_t>>(*additionQueueDescriptor, info); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | return std::make_unique<RefAdditionWorkload<float>>(*additionQueueDescriptor, info); |
| 167 | } |
| 168 | } |
| 169 | case LayerType::ArgMinMax : |
| 170 | { |
| 171 | auto argMinMaxQueueDescriptor = PolymorphicDowncast<const ArgMinMaxQueueDescriptor*>(&descriptor); |
| 172 | return std::make_unique<RefArgMinMaxWorkload>(*argMinMaxQueueDescriptor, info); |
| 173 | } |
Samuel Yap | 6b47809 | 2022-07-06 15:36:03 +0100 | [diff] [blame] | 174 | case LayerType::BatchMatMul: |
| 175 | { |
| 176 | auto batchMatMulQueueDescriptor = PolymorphicDowncast<const BatchMatMulQueueDescriptor*>(&descriptor); |
| 177 | return std::make_unique<RefBatchMatMulWorkload>(*batchMatMulQueueDescriptor, info); |
| 178 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 179 | case LayerType::BatchNormalization : |
| 180 | { |
| 181 | auto batchNormQueueDescriptor = PolymorphicDowncast<const BatchNormalizationQueueDescriptor*>(&descriptor); |
| 182 | return std::make_unique<RefBatchNormalizationWorkload>(*batchNormQueueDescriptor, info); |
| 183 | } |
| 184 | case LayerType::BatchToSpaceNd : |
| 185 | { |
| 186 | auto batchToSpaceNdQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 187 | = PolymorphicDowncast<const BatchToSpaceNdQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 188 | return std::make_unique<RefBatchToSpaceNdWorkload>(*batchToSpaceNdQueueDescriptor, info); |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 189 | } |
Idriss Chaouch | 98e383e | 2023-08-28 14:28:31 +0100 | [diff] [blame] | 190 | case LayerType::BroadcastTo: |
| 191 | { |
| 192 | auto broadcastToQueueDescriptor = PolymorphicDowncast<const BroadcastToQueueDescriptor*>(&descriptor); |
| 193 | return std::make_unique<RefBroadcastToWorkload>(*broadcastToQueueDescriptor, info); |
| 194 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 195 | case LayerType::Cast : |
| 196 | { |
| 197 | auto castQueueDescriptor = PolymorphicDowncast<const CastQueueDescriptor*>(&descriptor); |
| 198 | return std::make_unique<RefCastWorkload>(*castQueueDescriptor, info); |
| 199 | } |
| 200 | case LayerType::ChannelShuffle : |
| 201 | { |
| 202 | auto channelShuffleQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 203 | = PolymorphicDowncast<const ChannelShuffleQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 204 | return std::make_unique<RefChannelShuffleWorkload>(*channelShuffleQueueDescriptor, info); |
| 205 | } |
| 206 | case LayerType::Comparison : |
| 207 | { |
| 208 | auto comparisonQueueDescriptor = PolymorphicDowncast<const ComparisonQueueDescriptor*>(&descriptor); |
| 209 | return std::make_unique<RefComparisonWorkload>(*comparisonQueueDescriptor, info); |
| 210 | } |
| 211 | case LayerType::Concat : |
| 212 | { |
| 213 | auto concatQueueDescriptor = PolymorphicDowncast<const ConcatQueueDescriptor*>(&descriptor); |
| 214 | return std::make_unique<RefConcatWorkload>(*concatQueueDescriptor, info); |
| 215 | } |
| 216 | case LayerType::Constant : |
| 217 | { |
| 218 | auto constantQueueDescriptor = PolymorphicDowncast<const ConstantQueueDescriptor*>(&descriptor); |
| 219 | return std::make_unique<RefConstantWorkload>(*constantQueueDescriptor, info); |
| 220 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 221 | case LayerType::ConvertFp16ToFp32: |
| 222 | { |
| 223 | auto convertFp16ToFp32QueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 224 | = PolymorphicDowncast<const ConvertFp16ToFp32QueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 225 | return std::make_unique<RefConvertFp16ToFp32Workload>(*convertFp16ToFp32QueueDescriptor, info); |
| 226 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 227 | case LayerType::ConvertFp32ToFp16: |
| 228 | { |
| 229 | auto convertFp32ToFp16QueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 230 | = PolymorphicDowncast<const ConvertFp32ToFp16QueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 231 | return std::make_unique<RefConvertFp32ToFp16Workload>(*convertFp32ToFp16QueueDescriptor, info); |
| 232 | } |
| 233 | case LayerType::Convolution2d: |
| 234 | { |
| 235 | auto convolution2dQueueDescriptor = PolymorphicDowncast<const Convolution2dQueueDescriptor*>(&descriptor); |
| 236 | return std::make_unique<RefConvolution2dWorkload>(*convolution2dQueueDescriptor, info); |
| 237 | } |
| 238 | case LayerType::Convolution3d: |
| 239 | { |
| 240 | auto convolution3dQueueDescriptor = PolymorphicDowncast<const Convolution3dQueueDescriptor*>(&descriptor); |
| 241 | return std::make_unique<RefConvolution3dWorkload>(*convolution3dQueueDescriptor, info); |
| 242 | } |
| 243 | case LayerType::Debug: |
| 244 | { |
| 245 | auto debugQueueDescriptor = PolymorphicDowncast<const DebugQueueDescriptor*>(&descriptor); |
| 246 | if (IsBFloat16(info)) |
| 247 | { |
| 248 | return std::make_unique<RefDebugBFloat16Workload>(*debugQueueDescriptor, info); |
| 249 | } |
| 250 | if (IsFloat16(info)) |
| 251 | { |
| 252 | return std::make_unique<RefDebugFloat16Workload>(*debugQueueDescriptor, info); |
| 253 | } |
| 254 | if (IsQSymmS16(info)) |
| 255 | { |
| 256 | return std::make_unique<RefDebugQSymmS16Workload>(*debugQueueDescriptor, info); |
| 257 | } |
| 258 | if (IsQSymmS8(info)) |
| 259 | { |
| 260 | return std::make_unique<RefDebugQSymmS8Workload>(*debugQueueDescriptor, info); |
| 261 | } |
| 262 | if (IsQAsymmU8(info)) |
| 263 | { |
| 264 | return std::make_unique<RefDebugQAsymmU8Workload>(*debugQueueDescriptor, info); |
| 265 | } |
| 266 | if (IsQAsymmS8(info)) |
| 267 | { |
| 268 | return std::make_unique<RefDebugQAsymmS8Workload>(*debugQueueDescriptor, info); |
| 269 | } |
| 270 | if (IsSigned32(info)) |
| 271 | { |
| 272 | return std::make_unique<RefDebugSigned32Workload>(*debugQueueDescriptor, info); |
| 273 | } |
John Mcloughlin | 4cf29d6 | 2023-09-25 14:10:32 +0100 | [diff] [blame] | 274 | if (IsSigned64(info)) |
| 275 | { |
| 276 | return std::make_unique<RefDebugSigned64Workload>(*debugQueueDescriptor, info); |
| 277 | } |
Colm Donelan | 693acb4 | 2024-04-19 15:02:09 +0100 | [diff] [blame] | 278 | if (IsBoolean(info)) |
| 279 | { |
| 280 | return std::make_unique<RefDebugBooleanWorkload>(*debugQueueDescriptor, info); |
| 281 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 282 | return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(*debugQueueDescriptor, info); |
| 283 | } |
| 284 | case LayerType::DepthToSpace: |
| 285 | { |
| 286 | auto depthToSpaceQueueDescriptor = PolymorphicDowncast<const DepthToSpaceQueueDescriptor*>(&descriptor); |
| 287 | return std::make_unique<RefDepthToSpaceWorkload>(*depthToSpaceQueueDescriptor, info); |
| 288 | } |
| 289 | case LayerType::DepthwiseConvolution2d: |
| 290 | { |
| 291 | auto depthwiseConvolution2DQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 292 | = PolymorphicDowncast<const DepthwiseConvolution2dQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 293 | return std::make_unique<RefDepthwiseConvolution2dWorkload>(*depthwiseConvolution2DQueueDescriptor, info); |
| 294 | } |
| 295 | case LayerType::Dequantize: |
| 296 | { |
| 297 | auto dequantizeQueueDescriptor = PolymorphicDowncast<const DequantizeQueueDescriptor*>(&descriptor); |
| 298 | return std::make_unique<RefDequantizeWorkload>(*dequantizeQueueDescriptor, info); |
| 299 | } |
| 300 | case LayerType::DetectionPostProcess: |
| 301 | { |
| 302 | auto detectionPostProcessQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 303 | = PolymorphicDowncast<const DetectionPostProcessQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 304 | return std::make_unique<RefDetectionPostProcessWorkload>(*detectionPostProcessQueueDescriptor, info); |
| 305 | } |
| 306 | case LayerType::Division: |
| 307 | { |
| 308 | auto divisionQueueDescriptor = PolymorphicDowncast<const DivisionQueueDescriptor*>(&descriptor); |
| 309 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 310 | { |
| 311 | return std::make_unique<RefDivisionWorkload<int32_t>>(*divisionQueueDescriptor, info); |
| 312 | } |
| 313 | else |
| 314 | { |
| 315 | return std::make_unique<RefDivisionWorkload<float>>(*divisionQueueDescriptor, info); |
| 316 | } |
| 317 | } |
Mike Kelly | 3ec3077 | 2023-03-08 13:47:17 +0000 | [diff] [blame] | 318 | case LayerType::ElementwiseBinary: |
| 319 | { |
| 320 | auto elementwiseBinaryQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 321 | = PolymorphicDowncast<const ElementwiseBinaryQueueDescriptor*>(&descriptor); |
Mike Kelly | 3ec3077 | 2023-03-08 13:47:17 +0000 | [diff] [blame] | 322 | return std::make_unique<RefElementwiseBinaryWorkload>(*elementwiseBinaryQueueDescriptor, info); |
| 323 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 324 | case LayerType::ElementwiseUnary: |
| 325 | { |
| 326 | auto elementwiseUnaryQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 327 | = PolymorphicDowncast<const ElementwiseUnaryQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 328 | if ((*elementwiseUnaryQueueDescriptor).m_Parameters.m_Operation == UnaryOperation::LogicalNot) |
| 329 | { |
| 330 | return std::make_unique<RefLogicalUnaryWorkload>(*elementwiseUnaryQueueDescriptor, info); |
| 331 | } |
| 332 | return std::make_unique<RefElementwiseUnaryWorkload>(*elementwiseUnaryQueueDescriptor, info); |
| 333 | } |
| 334 | case LayerType::FakeQuantization: |
| 335 | { |
| 336 | auto fakeQuantizationQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 337 | = PolymorphicDowncast<const FakeQuantizationQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 338 | return std::make_unique<RefFakeQuantizationFloat32Workload>(*fakeQuantizationQueueDescriptor, info); |
| 339 | } |
| 340 | case LayerType::Fill: |
| 341 | { |
| 342 | auto fillQueueDescriptor = PolymorphicDowncast<const FillQueueDescriptor*>(&descriptor); |
| 343 | return std::make_unique<RefFillWorkload>(*fillQueueDescriptor, info); |
| 344 | } |
| 345 | case LayerType::Floor: |
| 346 | { |
| 347 | auto floorQueueDescriptor = PolymorphicDowncast<const FloorQueueDescriptor*>(&descriptor); |
| 348 | if(IsQuantizedType(info.m_InputTensorInfos[0].GetDataType())) |
| 349 | { |
| 350 | return nullptr; |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | return std::make_unique<RefFloorWorkload>(*floorQueueDescriptor, info); |
| 355 | } |
| 356 | } |
| 357 | case LayerType::FullyConnected: |
| 358 | { |
| 359 | auto fullyConnectedQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 360 | = PolymorphicDowncast<const FullyConnectedQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 361 | return std::make_unique<RefFullyConnectedWorkload>(*fullyConnectedQueueDescriptor, info); |
| 362 | } |
| 363 | case LayerType::Gather: |
| 364 | { |
| 365 | auto gatherQueueDescriptor = PolymorphicDowncast<const GatherQueueDescriptor*>(&descriptor); |
| 366 | return std::make_unique<RefGatherWorkload>(*gatherQueueDescriptor, info); |
| 367 | } |
Teresa Charlin | b2d3ec5 | 2022-04-12 22:07:09 +0100 | [diff] [blame] | 368 | case LayerType::GatherNd: |
| 369 | { |
| 370 | auto gatherNdQueueDescriptor = PolymorphicDowncast<const GatherNdQueueDescriptor*>(&descriptor); |
| 371 | return std::make_unique<RefGatherNdWorkload>(*gatherNdQueueDescriptor, info); |
| 372 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 373 | case LayerType::Input: |
| 374 | { |
| 375 | auto inputQueueDescriptor = PolymorphicDowncast<const InputQueueDescriptor*>(&descriptor); |
| 376 | if (info.m_InputTensorInfos.empty() ) |
| 377 | { |
| 378 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Input cannot be zero length"); |
| 379 | } |
| 380 | if (info.m_OutputTensorInfos.empty()) |
| 381 | { |
| 382 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: Output cannot be zero length"); |
| 383 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 384 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 385 | { |
| 386 | throw InvalidArgumentException("RefWorkloadFactory::CreateInput: " |
| 387 | "data input and output differ in byte count."); |
| 388 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 389 | return std::make_unique<CopyMemGenericWorkload>(*inputQueueDescriptor, info); |
| 390 | } |
| 391 | case LayerType::InstanceNormalization: |
| 392 | { |
| 393 | auto instanceNormalizationQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 394 | = PolymorphicDowncast<const InstanceNormalizationQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 395 | return std::make_unique<RefInstanceNormalizationWorkload>(*instanceNormalizationQueueDescriptor, info); |
| 396 | } |
| 397 | case LayerType::L2Normalization: |
| 398 | { |
| 399 | auto l2NormalizationQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 400 | = PolymorphicDowncast<const L2NormalizationQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 401 | return std::make_unique<RefL2NormalizationWorkload>(*l2NormalizationQueueDescriptor, info); |
| 402 | } |
| 403 | case LayerType::LogicalBinary: |
| 404 | { |
| 405 | auto logicalBinaryQueueDescriptor = PolymorphicDowncast<const LogicalBinaryQueueDescriptor*>(&descriptor); |
| 406 | return std::make_unique<RefLogicalBinaryWorkload>(*logicalBinaryQueueDescriptor, info); |
| 407 | } |
| 408 | case LayerType::LogSoftmax: |
| 409 | { |
| 410 | auto logSoftmaxQueueDescriptor = PolymorphicDowncast<const LogSoftmaxQueueDescriptor*>(&descriptor); |
| 411 | return std::make_unique<RefLogSoftmaxWorkload>(*logSoftmaxQueueDescriptor, info); |
| 412 | } |
| 413 | case LayerType::Lstm: |
| 414 | { |
| 415 | auto lstmQueueDescriptor = PolymorphicDowncast<const LstmQueueDescriptor*>(&descriptor); |
| 416 | return std::make_unique<RefLstmWorkload>(*lstmQueueDescriptor, info); |
| 417 | } |
| 418 | case LayerType::Maximum: |
| 419 | { |
| 420 | auto maximumQueueDescriptor = PolymorphicDowncast<const MaximumQueueDescriptor*>(&descriptor); |
| 421 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 422 | { |
| 423 | return std::make_unique<RefMaximumWorkload<int32_t>>(*maximumQueueDescriptor, info); |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | return std::make_unique<RefMaximumWorkload<float>>(*maximumQueueDescriptor, info); |
| 428 | } |
| 429 | } |
| 430 | case LayerType::Mean: |
| 431 | { |
| 432 | auto meanQueueDescriptor = PolymorphicDowncast<const MeanQueueDescriptor*>(&descriptor); |
| 433 | return std::make_unique<RefMeanWorkload>(*meanQueueDescriptor, info); |
| 434 | } |
| 435 | case LayerType::MemCopy: |
| 436 | { |
| 437 | auto memCopyQueueDescriptor = PolymorphicDowncast<const MemCopyQueueDescriptor*>(&descriptor); |
| 438 | if (descriptor.m_Inputs.empty()) |
| 439 | { |
| 440 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemCopy() expected an input tensor."); |
| 441 | } |
| 442 | return std::make_unique<CopyMemGenericWorkload>(*memCopyQueueDescriptor, info); |
| 443 | } |
| 444 | case LayerType::MemImport: |
| 445 | { |
| 446 | auto memImportQueueDescriptor = PolymorphicDowncast<const MemImportQueueDescriptor*>(&descriptor); |
| 447 | if (descriptor.m_Inputs.empty()) |
| 448 | { |
| 449 | throw InvalidArgumentException("RefWorkloadFactory: CreateMemImport() expected an input tensor."); |
| 450 | } |
| 451 | return std::make_unique<ImportMemGenericWorkload>(*memImportQueueDescriptor, info); |
| 452 | } |
| 453 | case LayerType::Minimum: |
| 454 | { |
| 455 | auto minimumQueueDescriptor = PolymorphicDowncast<const MinimumQueueDescriptor*>(&descriptor); |
| 456 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 457 | { |
| 458 | return std::make_unique<RefMinimumWorkload<int32_t>>(*minimumQueueDescriptor, info); |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | return std::make_unique<RefMinimumWorkload<float>>(*minimumQueueDescriptor, info); |
| 463 | } |
| 464 | } |
| 465 | case LayerType::Multiplication: |
| 466 | { |
| 467 | auto multiplicationQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 468 | = PolymorphicDowncast<const MultiplicationQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 469 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 470 | { |
| 471 | return std::make_unique<RefMultiplicationWorkload<int32_t>>(*multiplicationQueueDescriptor, info); |
| 472 | } |
| 473 | else |
| 474 | { |
| 475 | return std::make_unique<RefMultiplicationWorkload<float>>(*multiplicationQueueDescriptor, info); |
| 476 | } |
| 477 | } |
| 478 | case LayerType::Normalization: |
| 479 | { |
| 480 | auto normalizationQueueDescriptor = PolymorphicDowncast<const NormalizationQueueDescriptor*>(&descriptor); |
| 481 | return std::make_unique<RefNormalizationWorkload>(*normalizationQueueDescriptor, info); |
| 482 | } |
| 483 | case LayerType::Output: |
| 484 | { |
| 485 | auto outputQueueDescriptor = PolymorphicDowncast<const OutputQueueDescriptor*>(&descriptor); |
| 486 | if (info.m_InputTensorInfos.empty() ) |
| 487 | { |
| 488 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Input cannot be zero length"); |
| 489 | } |
| 490 | if (info.m_OutputTensorInfos.empty()) |
| 491 | { |
| 492 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: Output cannot be zero length"); |
| 493 | } |
| 494 | if (info.m_InputTensorInfos[0].GetNumBytes() != info.m_OutputTensorInfos[0].GetNumBytes()) |
| 495 | { |
| 496 | throw InvalidArgumentException("RefWorkloadFactory::CreateOutput: data input and output " |
| 497 | "differ in byte count."); |
| 498 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 499 | return std::make_unique<CopyMemGenericWorkload>(*outputQueueDescriptor, info); |
| 500 | } |
| 501 | case LayerType::Pad: |
| 502 | { |
| 503 | auto padQueueDescriptor = PolymorphicDowncast<const PadQueueDescriptor*>(&descriptor); |
| 504 | return std::make_unique<RefPadWorkload>(*padQueueDescriptor, info); |
| 505 | } |
| 506 | case LayerType::Permute: |
| 507 | { |
| 508 | auto permuteQueueDescriptor = PolymorphicDowncast<const PermuteQueueDescriptor*>(&descriptor); |
| 509 | if (IsQSymmS16(info)) |
| 510 | { |
| 511 | return std::make_unique<RefPermuteQSymm16Workload>(*permuteQueueDescriptor, info); |
| 512 | } |
| 513 | else if (IsBFloat16(info)) |
| 514 | { |
| 515 | return std::make_unique<RefPermuteBFloat16Workload>(*permuteQueueDescriptor, info); |
| 516 | } |
| 517 | else if (IsQAsymmS8(info)) |
| 518 | { |
| 519 | return std::make_unique<RefPermuteQAsymmS8Workload>(*permuteQueueDescriptor, info); |
| 520 | } |
| 521 | return MakeWorkloadHelper<RefPermuteFloat16Workload, RefPermuteFloat32Workload, RefPermuteQAsymm8Workload, |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 522 | NullWorkload, NullWorkload, NullWorkload>(*permuteQueueDescriptor, info); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 523 | } |
| 524 | case LayerType::Pooling2d: |
| 525 | { |
| 526 | auto pooling2dQueueDescriptor = PolymorphicDowncast<const Pooling2dQueueDescriptor*>(&descriptor); |
| 527 | return std::make_unique<RefPooling2dWorkload>(*pooling2dQueueDescriptor, info); |
| 528 | } |
| 529 | case LayerType::Pooling3d: |
| 530 | { |
| 531 | auto pooling3dQueueDescriptor = PolymorphicDowncast<const Pooling3dQueueDescriptor*>(&descriptor); |
| 532 | return std::make_unique<RefPooling3dWorkload>(*pooling3dQueueDescriptor, info); |
| 533 | } |
| 534 | case LayerType::PreCompiled: |
| 535 | { |
| 536 | return nullptr; |
| 537 | } |
| 538 | case LayerType::Prelu: |
| 539 | { |
| 540 | auto preluQueueDescriptor = PolymorphicDowncast<const PreluQueueDescriptor*>(&descriptor); |
| 541 | return std::make_unique<RefPreluWorkload>(*preluQueueDescriptor, info); |
| 542 | } |
| 543 | case LayerType::QLstm: |
| 544 | { |
| 545 | auto qlstmQueueDescriptor = PolymorphicDowncast<const QLstmQueueDescriptor*>(&descriptor); |
| 546 | return std::make_unique<RefQLstmWorkload>(*qlstmQueueDescriptor, info); |
| 547 | } |
| 548 | case LayerType::Quantize: |
| 549 | { |
| 550 | auto quantizeQueueDescriptor = PolymorphicDowncast<const QuantizeQueueDescriptor*>(&descriptor); |
| 551 | return std::make_unique<RefQuantizeWorkload>(*quantizeQueueDescriptor, info); |
| 552 | } |
| 553 | case LayerType::Rank: |
| 554 | { |
| 555 | auto rankQueueDescriptor = PolymorphicDowncast<const RankQueueDescriptor*>(&descriptor); |
| 556 | return std::make_unique<RefRankWorkload>(*rankQueueDescriptor, info); |
| 557 | } |
| 558 | case LayerType::Reduce: |
| 559 | { |
| 560 | auto reduceQueueDescriptor = PolymorphicDowncast<const ReduceQueueDescriptor*>(&descriptor); |
| 561 | return std::make_unique<RefReduceWorkload>(*reduceQueueDescriptor, info); |
| 562 | } |
| 563 | case LayerType::Reshape: |
| 564 | { |
| 565 | auto reshapeQueueDescriptor = PolymorphicDowncast<const ReshapeQueueDescriptor*>(&descriptor); |
| 566 | return std::make_unique<RefReshapeWorkload>(*reshapeQueueDescriptor, info); |
| 567 | } |
| 568 | case LayerType::Resize: |
| 569 | { |
| 570 | auto resizeQueueDescriptor = PolymorphicDowncast<const ResizeQueueDescriptor*>(&descriptor); |
| 571 | return std::make_unique<RefResizeWorkload>(*resizeQueueDescriptor, info); |
| 572 | } |
Tianle Cheng | 988354d | 2023-06-28 13:20:47 +0100 | [diff] [blame] | 573 | case LayerType::ReverseV2: |
| 574 | { |
| 575 | auto reverseV2QueueDescriptor = PolymorphicDowncast<const ReverseV2QueueDescriptor*>(&descriptor); |
| 576 | return std::make_unique<RefReverseV2Workload>(*reverseV2QueueDescriptor, info); |
| 577 | } |
Tianle Cheng | 2828818 | 2024-02-23 17:56:54 +0000 | [diff] [blame] | 578 | case LayerType::ScatterNd: |
| 579 | { |
| 580 | auto scatterQueueDescriptor = PolymorphicDowncast<const ScatterNdQueueDescriptor*>(&descriptor); |
| 581 | return std::make_unique<RefScatterNdWorkload>(*scatterQueueDescriptor, info); |
| 582 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 583 | case LayerType::Shape: |
| 584 | { |
| 585 | auto shapeQueueDescriptor = PolymorphicDowncast<const ShapeQueueDescriptor*>(&descriptor); |
| 586 | return std::make_unique<RefShapeWorkload>(*shapeQueueDescriptor, info); |
| 587 | } |
| 588 | case LayerType::Slice: |
| 589 | { |
| 590 | auto sliceQueueDescriptor = PolymorphicDowncast<const SliceQueueDescriptor*>(&descriptor); |
| 591 | return std::make_unique<RefSliceWorkload>(*sliceQueueDescriptor, info); |
| 592 | } |
| 593 | case LayerType::Softmax: |
| 594 | { |
| 595 | auto softmaxQueueDescriptor = PolymorphicDowncast<const SoftmaxQueueDescriptor*>(&descriptor); |
| 596 | return std::make_unique<RefSoftmaxWorkload>(*softmaxQueueDescriptor, info); |
| 597 | } |
| 598 | case LayerType::SpaceToBatchNd: |
| 599 | { |
| 600 | auto spaceToBatchNdQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 601 | = PolymorphicDowncast<const SpaceToBatchNdQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 602 | return std::make_unique<RefSpaceToBatchNdWorkload>(*spaceToBatchNdQueueDescriptor, info); |
| 603 | } |
| 604 | case LayerType::SpaceToDepth: |
| 605 | { |
| 606 | auto spaceToDepthQueueDescriptor = PolymorphicDowncast<const SpaceToDepthQueueDescriptor*>(&descriptor); |
| 607 | return std::make_unique<RefSpaceToDepthWorkload>(*spaceToDepthQueueDescriptor, info); |
| 608 | } |
| 609 | case LayerType::Splitter: |
| 610 | { |
| 611 | auto splitterQueueDescriptor = PolymorphicDowncast<const SplitterQueueDescriptor*>(&descriptor); |
| 612 | return std::make_unique<RefSplitterWorkload>(*splitterQueueDescriptor, info); |
| 613 | } |
| 614 | case LayerType::Stack: |
| 615 | { |
| 616 | auto stackQueueDescriptor = PolymorphicDowncast<const StackQueueDescriptor*>(&descriptor); |
| 617 | return std::make_unique<RefStackWorkload>(*stackQueueDescriptor, info); |
| 618 | } |
| 619 | case LayerType::StridedSlice: |
| 620 | { |
| 621 | auto stridedSliceQueueDescriptor = PolymorphicDowncast<const StridedSliceQueueDescriptor*>(&descriptor); |
| 622 | return std::make_unique<RefStridedSliceWorkload>(*stridedSliceQueueDescriptor, info); |
| 623 | } |
| 624 | case LayerType::Subtraction: |
| 625 | { |
| 626 | auto subtractionQueueDescriptor = PolymorphicDowncast<const SubtractionQueueDescriptor*>(&descriptor); |
| 627 | if (info.m_InputTensorInfos[0].GetDataType() == armnn::DataType::Signed32) |
| 628 | { |
| 629 | return std::make_unique<RefSubtractionWorkload<int32_t>>(*subtractionQueueDescriptor, info); |
| 630 | } |
| 631 | else |
| 632 | { |
| 633 | return std::make_unique<RefSubtractionWorkload<float>>(*subtractionQueueDescriptor, info); |
| 634 | } |
| 635 | } |
Teresa Charlin | 79a06a5 | 2023-07-13 17:16:45 +0100 | [diff] [blame] | 636 | case LayerType::Tile: |
| 637 | { |
| 638 | auto tileQueueDescriptor = PolymorphicDowncast<const TileQueueDescriptor*>(&descriptor); |
| 639 | return std::make_unique<RefTileWorkload>(*tileQueueDescriptor, info); |
| 640 | } |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 641 | case LayerType::Transpose: |
| 642 | { |
| 643 | auto transposeQueueDescriptor = PolymorphicDowncast<const TransposeQueueDescriptor*>(&descriptor); |
| 644 | if (IsQSymmS16(info)) |
| 645 | { |
| 646 | return std::make_unique<RefTransposeQSymm16Workload>(*transposeQueueDescriptor, info); |
| 647 | } |
| 648 | else if (IsBFloat16(info)) |
| 649 | { |
| 650 | return std::make_unique<RefTransposeBFloat16Workload>(*transposeQueueDescriptor, info); |
| 651 | } |
| 652 | else if (IsQAsymmS8(info)) |
| 653 | { |
| 654 | return std::make_unique<RefTransposeQAsymmS8Workload>(*transposeQueueDescriptor, info); |
| 655 | } |
| 656 | return MakeWorkloadHelper<RefTransposeFloat16Workload, RefTransposeFloat32Workload, |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 657 | RefTransposeQAsymm8Workload, NullWorkload, NullWorkload, NullWorkload> |
| 658 | (*transposeQueueDescriptor, info); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 659 | } |
| 660 | case LayerType::TransposeConvolution2d: |
| 661 | { |
| 662 | auto transposeConvolution2dQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 663 | = PolymorphicDowncast<const TransposeConvolution2dQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 664 | return std::make_unique<RefTransposeConvolution2dWorkload>(*transposeConvolution2dQueueDescriptor, info); |
| 665 | } |
| 666 | case LayerType::UnidirectionalSequenceLstm: |
| 667 | { |
| 668 | auto unidirectionalSequenceLstmQueueDescriptor |
Cian McGriskin | 7894ef9 | 2023-08-01 14:04:09 +0100 | [diff] [blame] | 669 | = PolymorphicDowncast<const UnidirectionalSequenceLstmQueueDescriptor*>(&descriptor); |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 670 | return std::make_unique<RefUnidirectionalSequenceLstmWorkload>(*unidirectionalSequenceLstmQueueDescriptor, |
| 671 | info); |
| 672 | } |
| 673 | default: |
| 674 | return nullptr; |
| 675 | } |
| 676 | } |
| 677 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 678 | } // namespace armnn |