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