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 | // |
| 5 | #pragma once |
| 6 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 7 | #include <armnn/Optional.hpp> |
Aron Virginas-Tar | 6057895 | 2018-10-31 11:04:01 +0000 | [diff] [blame] | 8 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <backendsCommon/OutputHandler.hpp> |
Aron Virginas-Tar | 6057895 | 2018-10-31 11:04:01 +0000 | [diff] [blame] | 10 | #include <aclCommon/BaseMemoryManager.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 11 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | #include <boost/core/ignore_unused.hpp> |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 13 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | // Neon workload factory. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | class NeonWorkloadFactory : public IWorkloadFactory |
| 19 | { |
| 20 | public: |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 21 | NeonWorkloadFactory(const std::shared_ptr<NeonMemoryManager>& memoryManager); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 23 | const BackendId& GetBackendId() const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 25 | static bool IsLayerSupported(const Layer& layer, |
| 26 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 27 | std::string& outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 28 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 29 | bool SupportsSubTensors() const override { return true; } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 31 | std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, |
| 32 | TensorShape const& subTensorShape, |
| 33 | unsigned int const* subTensorOrigin) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 34 | |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 35 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 36 | const bool IsMemoryManaged = true) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 38 | std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
David Monahan | 3fb7e10 | 2019-08-20 11:25:29 +0100 | [diff] [blame] | 39 | DataLayout dataLayout, |
| 40 | const bool IsMemoryManaged = true) const override; |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 41 | |
Aron Virginas-Tar | 914e4db | 2019-09-09 13:36:45 +0100 | [diff] [blame] | 42 | std::unique_ptr<IWorkload> CreateAbs(const AbsQueueDescriptor& descriptor, |
| 43 | const WorkloadInfo& info) const override; |
| 44 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 45 | std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 46 | const WorkloadInfo& info) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 48 | std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor, |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 49 | const WorkloadInfo& info) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 51 | std::unique_ptr<IWorkload> CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor, |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 52 | const WorkloadInfo& info) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 54 | std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor, |
| 55 | const WorkloadInfo& info) const override; |
| 56 | |
| 57 | std::unique_ptr<IWorkload> CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, |
| 58 | const WorkloadInfo& Info) const override; |
| 59 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 60 | std::unique_ptr<IWorkload> CreateComparison(const ComparisonQueueDescriptor& descriptor, |
| 61 | const WorkloadInfo& Info) const override; |
| 62 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 63 | std::unique_ptr<IWorkload> CreateConcat(const ConcatQueueDescriptor& descriptor, |
| 64 | const WorkloadInfo& info) const override; |
| 65 | |
| 66 | std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 67 | const WorkloadInfo& info) const override; |
| 68 | |
| 69 | std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 70 | const WorkloadInfo& info) const override; |
| 71 | |
| 72 | std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 73 | const WorkloadInfo& info) const override; |
Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 74 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 75 | std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 76 | const WorkloadInfo& info) const override; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 77 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 78 | std::unique_ptr<IWorkload> CreateDebug(const DebugQueueDescriptor& descriptor, |
| 79 | const WorkloadInfo& info) const override; |
| 80 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 81 | std::unique_ptr<IWorkload> CreateDepthToSpace(const DepthToSpaceQueueDescriptor& descriptor, |
| 82 | const WorkloadInfo& info) const override; |
| 83 | |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 84 | std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d(const DepthwiseConvolution2dQueueDescriptor& descriptor, |
| 85 | const WorkloadInfo& info) const override; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 86 | |
Narumol Prangnawarat | 01961a7 | 2019-05-30 16:47:12 +0100 | [diff] [blame] | 87 | std::unique_ptr<IWorkload> CreateDequantize(const DequantizeQueueDescriptor& descriptor, |
| 88 | const WorkloadInfo& info) const override; |
| 89 | |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 90 | std::unique_ptr<IWorkload> CreateDetectionPostProcess(const DetectionPostProcessQueueDescriptor& descriptor, |
| 91 | const WorkloadInfo& info) const override; |
| 92 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 93 | std::unique_ptr<IWorkload> CreateDivision(const DivisionQueueDescriptor& descriptor, |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 94 | const WorkloadInfo& info) const override; |
| 95 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 96 | ARMNN_DEPRECATED_MSG("Use CreateComparison instead") |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 97 | std::unique_ptr<IWorkload> CreateEqual(const EqualQueueDescriptor& descriptor, |
| 98 | const WorkloadInfo& info) const override; |
| 99 | |
| 100 | std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor, |
| 101 | const WorkloadInfo& info) const override; |
| 102 | |
| 103 | std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor, |
| 104 | const WorkloadInfo& info) const override; |
| 105 | |
| 106 | std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor, |
| 107 | const WorkloadInfo& info) const override; |
| 108 | |
| 109 | std::unique_ptr<IWorkload> CreateGather(const GatherQueueDescriptor& descriptor, |
| 110 | const WorkloadInfo& info) const override; |
| 111 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 112 | ARMNN_DEPRECATED_MSG("Use CreateComparison instead") |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 113 | std::unique_ptr<IWorkload> CreateGreater(const GreaterQueueDescriptor& descriptor, |
| 114 | const WorkloadInfo& info) const override; |
| 115 | |
| 116 | std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor, |
| 117 | const WorkloadInfo& info) const override; |
| 118 | |
| 119 | std::unique_ptr<IWorkload> CreateInstanceNormalization(const InstanceNormalizationQueueDescriptor& descriptor, |
| 120 | const WorkloadInfo& info) const override; |
| 121 | |
| 122 | std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 123 | const WorkloadInfo& info) const override; |
| 124 | |
| 125 | std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor, |
| 126 | const WorkloadInfo& info) const override; |
| 127 | |
| 128 | std::unique_ptr<IWorkload> CreateMaximum(const MaximumQueueDescriptor& descriptor, |
| 129 | const WorkloadInfo& info) const override; |
| 130 | |
| 131 | std::unique_ptr<IWorkload> CreateMean(const MeanQueueDescriptor& descriptor, |
| 132 | const WorkloadInfo& Info) const override; |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 133 | |
| 134 | std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 135 | const WorkloadInfo& info) const override; |
| 136 | |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 137 | std::unique_ptr<IWorkload> CreateMemImport(const MemImportQueueDescriptor& descriptor, |
| 138 | const WorkloadInfo& info) const override; |
| 139 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 140 | ARMNN_DEPRECATED_MSG("Use CreateConcat instead") |
| 141 | std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor, |
| 142 | const WorkloadInfo& info) const override; |
| 143 | |
| 144 | std::unique_ptr<IWorkload> CreateMinimum(const MinimumQueueDescriptor& descriptor, |
| 145 | const WorkloadInfo& info) const override; |
| 146 | |
| 147 | std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor, |
| 148 | const WorkloadInfo& info) const override; |
| 149 | |
| 150 | std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor, |
| 151 | const WorkloadInfo& info) const override; |
| 152 | |
| 153 | std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor, |
| 154 | const WorkloadInfo& info) const override; |
| 155 | |
| 156 | std::unique_ptr<IWorkload> CreatePad(const PadQueueDescriptor& descriptor, |
| 157 | const WorkloadInfo& info) const override; |
| 158 | |
| 159 | std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 160 | const WorkloadInfo& info) const override; |
| 161 | |
| 162 | std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 163 | const WorkloadInfo& info) const override; |
| 164 | |
| 165 | std::unique_ptr<IWorkload> CreatePreCompiled(const PreCompiledQueueDescriptor& descriptor, |
| 166 | const WorkloadInfo& info) const override; |
| 167 | |
| 168 | std::unique_ptr<IWorkload> CreatePrelu(const PreluQueueDescriptor& descriptor, |
| 169 | const WorkloadInfo& info) const override; |
| 170 | |
| 171 | std::unique_ptr<IWorkload> CreateQuantize(const QuantizeQueueDescriptor& descriptor, |
| 172 | const WorkloadInfo& info) const override; |
| 173 | |
| 174 | std::unique_ptr<IWorkload> CreateQuantizedLstm(const QuantizedLstmQueueDescriptor& descriptor, |
| 175 | const WorkloadInfo& info) const override; |
| 176 | |
| 177 | std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 178 | const WorkloadInfo& info) const override; |
| 179 | |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 180 | std::unique_ptr<IWorkload> CreateResize(const ResizeQueueDescriptor& descriptor, |
| 181 | const WorkloadInfo& info) const override; |
| 182 | |
| 183 | ARMNN_DEPRECATED_MSG("Use CreateResize instead") |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 184 | std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor, |
| 185 | const WorkloadInfo& info) const override; |
| 186 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 187 | std::unique_ptr<IWorkload> CreateRsqrt(const RsqrtQueueDescriptor& descriptor, |
| 188 | const WorkloadInfo& info) const override; |
Sadik Armagan | cd5571c | 2019-05-31 10:19:03 +0100 | [diff] [blame] | 189 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 190 | std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 191 | const WorkloadInfo& info) const override; |
| 192 | |
| 193 | std::unique_ptr<IWorkload> CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor, |
| 194 | const WorkloadInfo& info) const override; |
| 195 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 196 | std::unique_ptr<IWorkload> CreateSpaceToDepth(const SpaceToDepthQueueDescriptor& descriptor, |
| 197 | const WorkloadInfo& info) const override; |
| 198 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 199 | std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor, |
Matteo Martincigh | 3d6898c | 2019-01-15 16:11:44 +0000 | [diff] [blame] | 200 | const WorkloadInfo& info) const override; |
| 201 | |
Matthew Jackson | 87f65ea | 2019-08-01 10:01:34 +0100 | [diff] [blame] | 202 | std::unique_ptr<IWorkload> CreateStack(const StackQueueDescriptor& descriptor, |
| 203 | const WorkloadInfo& info) const override; |
| 204 | |
Sadik Armagan | 0d4863d | 2019-10-09 14:26:32 +0100 | [diff] [blame] | 205 | std::unique_ptr<IWorkload> CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, |
| 206 | const WorkloadInfo& info) const override; |
| 207 | |
| 208 | std::unique_ptr<IWorkload> CreateSubtraction(const SubtractionQueueDescriptor& descriptor, |
| 209 | const WorkloadInfo& info) const override; |
| 210 | |
| 211 | std::unique_ptr<IWorkload> CreateTransposeConvolution2d(const TransposeConvolution2dQueueDescriptor& descriptor, |
| 212 | const WorkloadInfo& info) const override; |
James Conroy | d47a064 | 2019-09-17 14:22:06 +0100 | [diff] [blame] | 213 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 214 | private: |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 215 | mutable std::shared_ptr<NeonMemoryManager> m_MemoryManager; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 216 | }; |
| 217 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 218 | } // namespace armnn |