telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 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 | // |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 5 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 6 | #include "NeonBackendId.hpp" |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 7 | #include "NeonTensorHandle.hpp" |
| 8 | #include "NeonWorkloadFactory.hpp" |
| 9 | |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 10 | #include <Layer.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 12 | #include <armnn/Utils.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 13 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 14 | #include <backendsCommon/CpuTensorHandle.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 15 | #include <backendsCommon/MakeWorkloadHelper.hpp> |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 16 | #include <backendsCommon/MemCopyWorkload.hpp> |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 17 | #include <backendsCommon/MemImportWorkload.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 19 | #include <neon/workloads/NeonWorkloadUtils.hpp> |
| 20 | #include <neon/workloads/NeonWorkloads.hpp> |
| 21 | |
| 22 | #include <boost/core/ignore_unused.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 23 | #include <boost/polymorphic_cast.hpp> |
| 24 | |
| 25 | namespace armnn |
| 26 | { |
| 27 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 28 | namespace |
| 29 | { |
| 30 | static const BackendId s_Id{NeonBackendId()}; |
| 31 | } |
| 32 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 33 | bool NeonWorkloadFactory::IsLayerSupported(const Layer& layer, |
| 34 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 35 | std::string& outReasonIfUnsupported) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | { |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 37 | return IWorkloadFactory::IsLayerSupported(s_Id, layer, dataType, outReasonIfUnsupported); |
| 38 | } |
| 39 | |
| 40 | const BackendId& NeonWorkloadFactory::GetBackendId() const |
| 41 | { |
| 42 | return s_Id; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 45 | NeonWorkloadFactory::NeonWorkloadFactory(const std::shared_ptr<NeonMemoryManager>& memoryManager) |
| 46 | : m_MemoryManager(memoryManager) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | std::unique_ptr<ITensorHandle> NeonWorkloadFactory::CreateSubTensorHandle(ITensorHandle& parent, |
| 51 | TensorShape const& subTensorShape, |
| 52 | unsigned int const* subTensorOrigin) const |
| 53 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 54 | const arm_compute::TensorShape shape = armcomputetensorutils::BuildArmComputeTensorShape(subTensorShape); |
| 55 | |
| 56 | arm_compute::Coordinates coords; |
| 57 | coords.set_num_dimensions(subTensorShape.GetNumDimensions()); |
| 58 | for (unsigned int i = 0; i < subTensorShape.GetNumDimensions(); i++) |
| 59 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 60 | // Arm compute indexes tensor coords in reverse order. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 61 | unsigned int revertedIndex = subTensorShape.GetNumDimensions() - i - 1; |
| 62 | coords.set(i, boost::numeric_cast<int>(subTensorOrigin[revertedIndex])); |
| 63 | } |
| 64 | |
Derek Lamberti | 0790dce | 2019-04-15 18:37:35 +0100 | [diff] [blame] | 65 | const arm_compute::TensorShape parentShape = armcomputetensorutils::BuildArmComputeTensorShape(parent.GetShape()); |
| 66 | if (!::arm_compute::error_on_invalid_subtensor(__func__, __FILE__, __LINE__, parentShape, coords, shape)) |
| 67 | { |
| 68 | return nullptr; |
| 69 | } |
| 70 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 71 | return std::make_unique<NeonSubTensorHandle>( |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 72 | boost::polymorphic_downcast<IAclTensorHandle*>(&parent), shape, coords); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | } |
| 74 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 75 | std::unique_ptr<ITensorHandle> NeonWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
| 76 | const bool IsMemoryManaged) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 77 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 78 | auto tensorHandle = std::make_unique<NeonTensorHandle>(tensorInfo); |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 79 | if (IsMemoryManaged) |
| 80 | { |
| 81 | tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup()); |
| 82 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 83 | return tensorHandle; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 86 | std::unique_ptr<ITensorHandle> NeonWorkloadFactory::CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 87 | DataLayout dataLayout, |
| 88 | const bool IsMemoryManaged) const |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 89 | { |
| 90 | auto tensorHandle = std::make_unique<NeonTensorHandle>(tensorInfo, dataLayout); |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 91 | if (IsMemoryManaged) |
| 92 | { |
| 93 | tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup()); |
| 94 | } |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 95 | return tensorHandle; |
| 96 | } |
| 97 | |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 98 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateAbs(const AbsQueueDescriptor& descriptor, |
| 99 | const WorkloadInfo& info) const |
| 100 | { |
| 101 | return std::make_unique<NeonAbsWorkload>(descriptor, info); |
| 102 | } |
| 103 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 104 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 105 | const WorkloadInfo& info) const |
| 106 | { |
Nattapat Chaimanowong | d4b7059 | 2018-10-12 11:21:49 +0100 | [diff] [blame] | 107 | return std::make_unique<NeonActivationWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 110 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateAddition(const AdditionQueueDescriptor& descriptor, |
| 111 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 112 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 113 | return std::make_unique<NeonAdditionWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 116 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor, |
| 117 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 118 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 119 | return std::make_unique<NeonArgMinMaxWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 122 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateBatchNormalization( |
| 123 | const BatchNormalizationQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 124 | { |
| 125 | return std::make_unique<NeonBatchNormalizationWorkload>(descriptor, info); |
| 126 | } |
| 127 | |
| 128 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, |
| 129 | const WorkloadInfo& info) const |
| 130 | { |
| 131 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 132 | } |
| 133 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 134 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateComparison(const ComparisonQueueDescriptor& descriptor, |
| 135 | const WorkloadInfo& info) const |
| 136 | { |
| 137 | if (descriptor.m_Parameters.m_Operation == ComparisonOperation::Greater) |
| 138 | { |
| 139 | GreaterQueueDescriptor greaterQueueDescriptor; |
| 140 | greaterQueueDescriptor.m_Inputs = descriptor.m_Inputs; |
| 141 | greaterQueueDescriptor.m_Outputs = descriptor.m_Outputs; |
| 142 | |
| 143 | return MakeWorkloadHelper<NeonGreaterFloat32Workload, NeonGreaterUint8Workload>(greaterQueueDescriptor, info); |
| 144 | } |
| 145 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 146 | } |
| 147 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 148 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateConcat(const ConcatQueueDescriptor& descriptor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 149 | const WorkloadInfo& info) const |
| 150 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 151 | return std::make_unique<NeonConcatWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 154 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 155 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 156 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 157 | return std::make_unique<NeonConstantWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 160 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateConvertFp16ToFp32( |
| 161 | const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 162 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 163 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 164 | return std::make_unique<NeonConvertFp16ToFp32Workload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 167 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateConvertFp32ToFp16( |
| 168 | const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 169 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 170 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 171 | return std::make_unique<NeonConvertFp32ToFp16Workload>(descriptor, info); |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 172 | } |
| 173 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 174 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateConvolution2d( |
| 175 | const Convolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 176 | { |
Nattapat Chaimanowong | 974b65f | 2018-10-15 15:07:34 +0100 | [diff] [blame] | 177 | return std::make_unique<NeonConvolution2dWorkload>(descriptor, info, |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 178 | m_MemoryManager->GetIntraLayerManager()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 179 | } |
| 180 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 181 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateDebug(const DebugQueueDescriptor& descriptor, |
| 182 | const WorkloadInfo& info) const |
| 183 | { |
| 184 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 185 | } |
| 186 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 187 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateDepthToSpace(const DepthToSpaceQueueDescriptor& descriptor, |
| 188 | const WorkloadInfo& info) const |
| 189 | { |
| 190 | return std::make_unique<NeonDepthToSpaceWorkload>(descriptor, info); |
| 191 | } |
| 192 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 193 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateDepthwiseConvolution2d( |
| 194 | const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 195 | { |
Nattapat Chaimanowong | 7714088 | 2018-10-17 11:12:19 +0100 | [diff] [blame] | 196 | return std::make_unique<NeonDepthwiseConvolutionWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 199 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateDequantize(const DequantizeQueueDescriptor& descriptor, |
| 200 | const WorkloadInfo& info) const |
| 201 | { |
| 202 | return std::make_unique<NeonDequantizeWorkload>(descriptor, info); |
| 203 | } |
| 204 | |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 205 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateDetectionPostProcess( |
| 206 | const armnn::DetectionPostProcessQueueDescriptor& descriptor, const armnn::WorkloadInfo& info) const |
| 207 | { |
| 208 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 209 | } |
| 210 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 211 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateDivision( |
| 212 | const DivisionQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 213 | { |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 214 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 217 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateEqual(const EqualQueueDescriptor& descriptor, |
| 218 | const WorkloadInfo& info) const |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 219 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 220 | boost::ignore_unused(descriptor); |
| 221 | |
| 222 | ComparisonQueueDescriptor comparisonDescriptor; |
| 223 | comparisonDescriptor.m_Parameters = ComparisonDescriptor(ComparisonOperation::Equal); |
| 224 | |
| 225 | return CreateComparison(comparisonDescriptor, info); |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 226 | } |
| 227 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 228 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateFakeQuantization( |
| 229 | const FakeQuantizationQueueDescriptor& descriptor, |
| 230 | const WorkloadInfo& info) const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 231 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 232 | return nullptr; |
| 233 | } |
| 234 | |
| 235 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateFloor(const FloorQueueDescriptor& descriptor, |
| 236 | const WorkloadInfo& info) const |
| 237 | { |
| 238 | return MakeWorkloadHelper<NeonFloorFloatWorkload, NullWorkload>(descriptor, info); |
| 239 | } |
| 240 | |
| 241 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateFullyConnected( |
| 242 | const FullyConnectedQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 243 | { |
| 244 | return MakeWorkloadHelper<NeonFullyConnectedWorkload, NeonFullyConnectedWorkload>( |
| 245 | descriptor, info, m_MemoryManager->GetIntraLayerManager()); |
| 246 | } |
| 247 | |
| 248 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateGather(const armnn::GatherQueueDescriptor& descriptor, |
| 249 | const armnn::WorkloadInfo& info) const |
| 250 | { |
| 251 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 252 | } |
| 253 | |
| 254 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateGreater(const GreaterQueueDescriptor& descriptor, |
| 255 | const WorkloadInfo& info) const |
| 256 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 257 | boost::ignore_unused(descriptor); |
| 258 | |
| 259 | ComparisonQueueDescriptor comparisonDescriptor; |
| 260 | comparisonDescriptor.m_Parameters = ComparisonDescriptor(ComparisonOperation::Greater); |
| 261 | |
| 262 | return CreateComparison(comparisonDescriptor, info); |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateInput(const InputQueueDescriptor& descriptor, |
| 266 | const WorkloadInfo& info) const |
| 267 | { |
| 268 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
| 269 | } |
| 270 | |
| 271 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateInstanceNormalization( |
| 272 | const InstanceNormalizationQueueDescriptor& descriptor, |
| 273 | const WorkloadInfo& info) const |
| 274 | { |
| 275 | return std::make_unique<NeonInstanceNormalizationWorkload>(descriptor, info); |
| 276 | } |
| 277 | |
| 278 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 279 | const WorkloadInfo& info) const |
| 280 | { |
| 281 | return MakeWorkloadHelper<NeonL2NormalizationFloatWorkload, NullWorkload>(descriptor, info, |
| 282 | m_MemoryManager->GetIntraLayerManager()); |
| 283 | } |
| 284 | |
| 285 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateLstm(const LstmQueueDescriptor& descriptor, |
| 286 | const WorkloadInfo& info) const |
| 287 | { |
| 288 | return MakeWorkloadHelper<NeonLstmFloatWorkload, NullWorkload>(descriptor, info); |
| 289 | } |
| 290 | |
| 291 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateMaximum(const MaximumQueueDescriptor& descriptor, |
| 292 | const WorkloadInfo& info) const |
| 293 | { |
| 294 | return std::make_unique<NeonMaximumWorkload>(descriptor, info); |
| 295 | } |
| 296 | |
| 297 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateMean(const MeanQueueDescriptor& descriptor, |
| 298 | const WorkloadInfo& info) const |
| 299 | { |
| 300 | return std::make_unique<NeonMeanWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 304 | const WorkloadInfo& info) const |
| 305 | { |
| 306 | if (descriptor.m_Inputs.empty() || !descriptor.m_Inputs[0]) |
| 307 | { |
| 308 | throw InvalidArgumentException("NeonWorkloadFactory: Invalid null input for MemCopy workload"); |
| 309 | } |
| 310 | |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 311 | return MakeWorkloadHelper<CopyMemGenericWorkload, CopyMemGenericWorkload>(descriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 314 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateMemImport(const MemImportQueueDescriptor& descriptor, |
| 315 | const WorkloadInfo& info) const |
| 316 | { |
| 317 | if (descriptor.m_Inputs.empty() || !descriptor.m_Inputs[0]) |
| 318 | { |
| 319 | throw InvalidArgumentException("NeonWorkloadFactory: Invalid null input for MemImport workload"); |
| 320 | } |
| 321 | |
| 322 | return std::make_unique<ImportMemGenericWorkload>(descriptor, info); |
| 323 | } |
| 324 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 325 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateMerger(const MergerQueueDescriptor& descriptor, |
| 326 | const WorkloadInfo& info) const |
| 327 | { |
| 328 | return CreateConcat(descriptor, info); |
| 329 | } |
| 330 | |
| 331 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateMinimum(const MinimumQueueDescriptor& descriptor, |
| 332 | const WorkloadInfo& info) const |
| 333 | { |
| 334 | return std::make_unique<NeonMinimumWorkload>(descriptor, info); |
| 335 | } |
| 336 | |
| 337 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateMultiplication( |
| 338 | const MultiplicationQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 339 | { |
| 340 | return std::make_unique<NeonMultiplicationWorkload>(descriptor, info); |
| 341 | } |
| 342 | |
| 343 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateNormalization( |
| 344 | const NormalizationQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 345 | { |
| 346 | return MakeWorkloadHelper<NeonNormalizationFloatWorkload, NullWorkload>(descriptor, info, |
| 347 | m_MemoryManager->GetIntraLayerManager()); |
| 348 | } |
| 349 | |
| 350 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateOutput(const OutputQueueDescriptor& descriptor, |
| 351 | const WorkloadInfo& info) const |
| 352 | { |
| 353 | return std::make_unique<CopyMemGenericWorkload>(descriptor, info); |
| 354 | } |
| 355 | |
| 356 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreatePad(const PadQueueDescriptor& descriptor, |
| 357 | const WorkloadInfo& info) const |
| 358 | { |
| 359 | return std::make_unique<NeonPadWorkload>(descriptor, info); |
| 360 | } |
| 361 | |
| 362 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 363 | const WorkloadInfo& info) const |
| 364 | { |
| 365 | return std::make_unique<NeonPermuteWorkload>(descriptor, info); |
| 366 | } |
| 367 | |
| 368 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 369 | const WorkloadInfo& info) const |
| 370 | { |
| 371 | return std::make_unique<NeonPooling2dWorkload>(descriptor, info); |
| 372 | } |
| 373 | |
| 374 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreatePreCompiled(const PreCompiledQueueDescriptor& descriptor, |
| 375 | const WorkloadInfo& info) const |
| 376 | { |
| 377 | return MakeWorkloadHelper<NullWorkload, NullWorkload>(descriptor, info); |
| 378 | } |
| 379 | |
| 380 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreatePrelu(const armnn::PreluQueueDescriptor &descriptor, |
| 381 | const armnn::WorkloadInfo &info) const |
| 382 | { |
| 383 | return std::make_unique<NeonPreluWorkload>(descriptor, info); |
| 384 | } |
| 385 | |
| 386 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateQuantize(const QuantizeQueueDescriptor& descriptor, |
| 387 | const WorkloadInfo& info) const |
| 388 | { |
| 389 | return std::make_unique<NeonQuantizeWorkload>(descriptor, info); |
| 390 | } |
| 391 | |
| 392 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateQuantizedLstm(const QuantizedLstmQueueDescriptor& descriptor, |
| 393 | const WorkloadInfo& info) const |
| 394 | { |
| 395 | return std::make_unique<NeonQuantizedLstmWorkload>(descriptor, info); |
| 396 | } |
| 397 | |
| 398 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 399 | const WorkloadInfo& info) const |
| 400 | { |
| 401 | return std::make_unique<NeonReshapeWorkload>(descriptor, info); |
| 402 | } |
| 403 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 404 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateResize(const ResizeQueueDescriptor& descriptor, |
| 405 | const WorkloadInfo& info) const |
| 406 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 407 | return std::make_unique<NeonResizeWorkload>(descriptor, info); |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 408 | } |
| 409 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 410 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateResizeBilinear( |
| 411 | const ResizeBilinearQueueDescriptor& descriptor, |
| 412 | const WorkloadInfo& info) const |
| 413 | { |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 414 | ResizeQueueDescriptor resizeDescriptor; |
| 415 | resizeDescriptor.m_Inputs = descriptor.m_Inputs; |
| 416 | resizeDescriptor.m_Outputs = descriptor.m_Outputs; |
| 417 | |
| 418 | resizeDescriptor.m_Parameters.m_DataLayout = descriptor.m_Parameters.m_DataLayout; |
| 419 | resizeDescriptor.m_Parameters.m_TargetWidth = descriptor.m_Parameters.m_TargetWidth; |
| 420 | resizeDescriptor.m_Parameters.m_TargetHeight = descriptor.m_Parameters.m_TargetHeight; |
| 421 | |
| 422 | return CreateResize(resizeDescriptor, info); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 425 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateRsqrt(const RsqrtQueueDescriptor &descriptor, |
| 426 | const WorkloadInfo &info) const |
| 427 | { |
Aron Virginas-Tar | 0dd3b43 | 2019-09-10 13:55:09 +0100 | [diff] [blame] | 428 | return std::make_unique<NeonRsqrtWorkload>(descriptor, info); |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 431 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
| 432 | const WorkloadInfo& info) const |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 433 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 434 | return MakeWorkloadHelper<NeonSoftmaxFloatWorkload, NeonSoftmaxUint8Workload>( |
| 435 | descriptor, info, m_MemoryManager->GetIntraLayerManager()); |
Sadik Armagan | 581742d | 2019-08-12 14:11:37 +0100 | [diff] [blame] | 436 | } |
| 437 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 438 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor, |
| 439 | const WorkloadInfo& info) const |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 440 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 441 | return nullptr; |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 444 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateSpaceToDepth( |
| 445 | const armnn::SpaceToDepthQueueDescriptor& descriptor, const armnn::WorkloadInfo& info) const |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 446 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 447 | return std::make_unique<NeonSpaceToDepthWorkload>(descriptor, info); |
| 448 | } |
| 449 | |
| 450 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateSplitter(const SplitterQueueDescriptor& descriptor, |
| 451 | const WorkloadInfo& info) const |
| 452 | { |
| 453 | return std::make_unique<NeonSplitterWorkload>(descriptor, info); |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 456 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateStack(const StackQueueDescriptor& descriptor, |
| 457 | const WorkloadInfo& info) const |
| 458 | { |
| 459 | return std::make_unique<NeonStackWorkload>(descriptor, info); |
| 460 | } |
| 461 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 462 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, |
| 463 | const WorkloadInfo& info) const |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 464 | { |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 465 | return std::make_unique<NeonStridedSliceWorkload>(descriptor, info); |
| 466 | } |
| 467 | |
| 468 | std::unique_ptr<armnn::IWorkload> NeonWorkloadFactory::CreateSubtraction( |
| 469 | const SubtractionQueueDescriptor& descriptor, const WorkloadInfo& info) const |
| 470 | { |
| 471 | return std::make_unique<NeonSubtractionWorkload>(descriptor, info); |
| 472 | } |
| 473 | |
| 474 | std::unique_ptr<IWorkload> NeonWorkloadFactory::CreateTransposeConvolution2d( |
| 475 | const TransposeConvolution2dQueueDescriptor &descriptor, |
| 476 | const WorkloadInfo &info) const |
| 477 | { |
| 478 | return std::make_unique<NeonTransposeConvolution2dWorkload>(descriptor, info, |
| 479 | m_MemoryManager->GetIntraLayerManager()); |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 480 | } |
| 481 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 482 | } // namespace armnn |