blob: dae58b6d93d6a862d50458ff8fb52b85d315b3f2 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
David Beckdcb751f2018-10-03 11:42:42 +01007#include <armnn/TensorFwd.hpp>
David Beck29c75de2018-10-23 13:35:58 +01008#include <armnn/Optional.hpp>
Matteo Martincighe5b8eb92019-11-28 15:45:42 +00009#include <armnn/backends/ITensorHandle.hpp>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000011#include <backendsCommon/Workload.hpp>
12
13#include <memory>
telsoa014fcda012018-03-09 14:13:49 +000014
15namespace armnn
16{
17
18class Layer;
19
telsoa01c577f2c2018-08-31 09:22:23 +010020// Workload factory interface for compute backends.
telsoa014fcda012018-03-09 14:13:49 +000021class IWorkloadFactory
22{
23public:
24 virtual ~IWorkloadFactory() { }
25
David Beck79141b92018-10-23 16:09:36 +010026 virtual const BackendId& GetBackendId() const = 0;
telsoa014fcda012018-03-09 14:13:49 +000027
David Beck33f0ae02018-10-18 15:13:56 +010028 static bool IsLayerSupported(const BackendId& backendId,
David Beckdcb751f2018-10-03 11:42:42 +010029 const IConnectableLayer& layer,
David Beck29c75de2018-10-23 13:35:58 +010030 Optional<DataType> dataType,
surmeh013537c2c2018-05-18 16:31:43 +010031 std::string& outReasonIfUnsupported);
David Beckdcb751f2018-10-03 11:42:42 +010032
33 static bool IsLayerSupported(const IConnectableLayer& layer,
David Beck29c75de2018-10-23 13:35:58 +010034 Optional<DataType> dataType,
telsoa01c577f2c2018-08-31 09:22:23 +010035 std::string& outReasonIfUnsupported);
telsoa014fcda012018-03-09 14:13:49 +000036
37 virtual bool SupportsSubTensors() const = 0;
38
39 virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
40 TensorShape const& subTensorShape,
41 unsigned int const* subTensorOrigin
42 ) const = 0;
43
44 virtual std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor,
45 const WorkloadInfo& info) const = 0;
46
David Monahan3fb7e102019-08-20 11:25:29 +010047 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
48 const bool IsMemoryManaged = true) const = 0;
telsoa014fcda012018-03-09 14:13:49 +000049
Francis Murtagh351d13d2018-09-24 15:01:18 +010050 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
David Monahan3fb7e102019-08-20 11:25:29 +010051 DataLayout dataLayout,
52 const bool IsMemoryManaged = true) const = 0;
Francis Murtagh351d13d2018-09-24 15:01:18 +010053
josh minor4a3c6102020-01-06 16:40:46 -060054 ARMNN_DEPRECATED_MSG("Use CreateElementwiseUnary instead")
Kevin May868eb142019-09-04 17:29:31 +010055 virtual std::unique_ptr<IWorkload> CreateAbs(const AbsQueueDescriptor& descriptor,
56 const WorkloadInfo& info) const;
57
telsoa014fcda012018-03-09 14:13:49 +000058 virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000059 const WorkloadInfo& info) const;
telsoa014fcda012018-03-09 14:13:49 +000060
61 virtual std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000062 const WorkloadInfo& info) const;
telsoa014fcda012018-03-09 14:13:49 +000063
Nikhil Rajee391d52019-09-05 17:50:44 +010064 virtual std::unique_ptr<IWorkload> CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor,
65 const WorkloadInfo& info) const;
66
telsoa014fcda012018-03-09 14:13:49 +000067 virtual std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000068 const WorkloadInfo& info) const;
telsoa014fcda012018-03-09 14:13:49 +000069
Éanna Ó Catháin4e1e1362018-11-12 11:36:34 +000070 virtual std::unique_ptr<IWorkload> CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000071 const WorkloadInfo& Info) const;
telsoa014fcda012018-03-09 14:13:49 +000072
Aron Virginas-Tar77bfb5e2019-10-16 17:45:38 +010073 virtual std::unique_ptr<IWorkload> CreateComparison(const ComparisonQueueDescriptor& descriptor,
74 const WorkloadInfo& Info) const;
75
Jim Flynne242f2d2019-05-22 14:24:13 +010076 virtual std::unique_ptr<IWorkload> CreateConcat(const ConcatQueueDescriptor& descriptor,
Jim Flynn4ed6c832019-05-20 11:02:46 +010077 const WorkloadInfo& info) const;
78
telsoa014fcda012018-03-09 14:13:49 +000079 virtual std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000080 const WorkloadInfo& info) const;
telsoa01c577f2c2018-08-31 09:22:23 +010081
82 virtual std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000083 const WorkloadInfo& info) const;
telsoa01c577f2c2018-08-31 09:22:23 +010084
85 virtual std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000086 const WorkloadInfo& info) const;
Francis Murtaghe7a86a42018-08-29 12:42:10 +010087
Derek Lambertia9cca6a2019-03-25 15:41:58 +000088 virtual std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor,
89 const WorkloadInfo& info) const;
Matteo Martincigh59a950c2018-12-13 12:48:25 +000090
Nattapat Chaimanowonga9a1cf12018-12-03 16:06:49 +000091 virtual std::unique_ptr<IWorkload> CreateDebug(const DebugQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +000092 const WorkloadInfo& info) const;
Mohamed Nour Abouelseouda1d3c6a2018-12-27 12:39:16 +000093
Aron Virginas-Tardd6247f2019-09-19 14:31:17 +010094 virtual std::unique_ptr<IWorkload> CreateDepthToSpace(const DepthToSpaceQueueDescriptor& descriptor,
95 const WorkloadInfo& info) const;
96
Derek Lambertia9cca6a2019-03-25 15:41:58 +000097 virtual std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d(
98 const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const;
Matteo Martincigh49124022019-01-11 13:25:59 +000099
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000100 virtual std::unique_ptr<IWorkload> CreateDequantize(const DequantizeQueueDescriptor& descriptor,
101 const WorkloadInfo& info) const;
102
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000103 virtual std::unique_ptr<IWorkload> CreateDetectionPostProcess(
104 const DetectionPostProcessQueueDescriptor& descriptor, const WorkloadInfo& info) const;
105
106 virtual std::unique_ptr<IWorkload> CreateDivision(const DivisionQueueDescriptor& descriptor,
107 const WorkloadInfo& info) const;
108
josh minor4a3c6102020-01-06 16:40:46 -0600109 virtual std::unique_ptr<IWorkload> CreateElementwiseUnary(const ElementwiseUnaryQueueDescriptor& descriptor,
110 const WorkloadInfo& Info) const;
111
Aron Virginas-Tar77bfb5e2019-10-16 17:45:38 +0100112 ARMNN_DEPRECATED_MSG("Use CreateComparison instead")
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000113 virtual std::unique_ptr<IWorkload> CreateEqual(const EqualQueueDescriptor& descriptor,
114 const WorkloadInfo& Info) const;
115
116 virtual std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor,
117 const WorkloadInfo& info) const;
118
119 virtual std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor,
120 const WorkloadInfo& info) const;
121
Francis Murtagh43aec582019-05-27 12:14:10 +0100122 virtual std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000123 const WorkloadInfo& info) const;
narpra01b89b05f2019-01-16 09:53:09 +0000124
125 virtual std::unique_ptr<IWorkload> CreateGather(const GatherQueueDescriptor& descriptor,
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000126 const WorkloadInfo& info) const;
127
Aron Virginas-Tar77bfb5e2019-10-16 17:45:38 +0100128 ARMNN_DEPRECATED_MSG("Use CreateComparison instead")
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000129 virtual std::unique_ptr<IWorkload> CreateGreater(const GreaterQueueDescriptor& descriptor,
130 const WorkloadInfo& info) const;
131
Kevin Mayce5045a2019-10-02 14:07:47 +0100132 virtual std::unique_ptr<IWorkload> CreateInstanceNormalization(
133 const InstanceNormalizationQueueDescriptor& descriptor,
134 const WorkloadInfo& info) const;
135
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000136 virtual std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor,
137 const WorkloadInfo& info) const;
138
Aron Virginas-Tarf982dea2019-10-11 14:07:53 +0100139 virtual std::unique_ptr<IWorkload> CreateLogSoftmax(const LogSoftmaxQueueDescriptor& descriptor,
140 const WorkloadInfo& info) const;
141
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000142 virtual std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor,
143 const WorkloadInfo& info) const;
144
145 virtual std::unique_ptr<IWorkload> CreateMaximum(const MaximumQueueDescriptor& descriptor,
146 const WorkloadInfo& info) const;
147
148 virtual std::unique_ptr<IWorkload> CreateMean(const MeanQueueDescriptor& descriptor,
149 const WorkloadInfo& Info) const;
150
151 virtual std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor,
152 const WorkloadInfo& info) const;
153
Derek Lambertif674aa02019-08-01 15:56:25 +0100154 virtual std::unique_ptr<IWorkload> CreateMemImport(const MemImportQueueDescriptor& descriptor,
155 const WorkloadInfo& info) const;
156
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100157 virtual std::unique_ptr<IWorkload> CreateMerge(const MergeQueueDescriptor& descriptor,
158 const WorkloadInfo& info) const;
159
Jim Flynn4ed6c832019-05-20 11:02:46 +0100160 ARMNN_DEPRECATED_MSG("Use CreateConcat instead")
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000161 virtual std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor,
162 const WorkloadInfo& info) const;
163
164 virtual std::unique_ptr<IWorkload> CreateMinimum(const MinimumQueueDescriptor& descriptor,
165 const WorkloadInfo& info) const;
166
167 virtual std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor,
168 const WorkloadInfo& info) const;
169
170 virtual std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor,
171 const WorkloadInfo& info) const;
172
173 virtual std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor,
174 const WorkloadInfo& info) const;
175
176 virtual std::unique_ptr<IWorkload> CreatePad(const PadQueueDescriptor& descriptor,
177 const WorkloadInfo& Info) const;
178
179 virtual std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor,
180 const WorkloadInfo& info) const;
181
182 virtual std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor,
183 const WorkloadInfo& info) const;
184
185 virtual std::unique_ptr<IWorkload> CreatePreCompiled(const PreCompiledQueueDescriptor& descriptor,
186 const WorkloadInfo& info) const;
187
Matteo Martincigh0e406ee2019-06-12 15:42:18 +0100188 virtual std::unique_ptr<IWorkload> CreatePrelu(const PreluQueueDescriptor& descriptor,
189 const WorkloadInfo& info) const;
190
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000191 virtual std::unique_ptr<IWorkload> CreateQuantize(const QuantizeQueueDescriptor& descriptor,
192 const WorkloadInfo& Info) const;
193
James Conroyee18dc82019-07-17 11:27:46 +0100194 virtual std::unique_ptr<IWorkload> CreateQuantizedLstm(const QuantizedLstmQueueDescriptor& descriptor,
195 const WorkloadInfo& info) const;
196
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000197 virtual std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor,
198 const WorkloadInfo& info) const;
199
Teresa Charlina9075df2019-06-27 15:41:57 +0100200 virtual std::unique_ptr<IWorkload> CreateResize(const ResizeQueueDescriptor& descriptor,
201 const WorkloadInfo& info) const;
202
Aron Virginas-Tar169d2f12019-07-01 19:01:44 +0100203 ARMNN_DEPRECATED_MSG("Use CreateResize instead")
204 virtual std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor,
205 const WorkloadInfo& info) const;
206
josh minor4a3c6102020-01-06 16:40:46 -0600207 ARMNN_DEPRECATED_MSG("Use CreateElementwiseUnary instead")
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000208 virtual std::unique_ptr<IWorkload> CreateRsqrt(const RsqrtQueueDescriptor& descriptor,
209 const WorkloadInfo& info) const;
210
Aron Virginas-Tar636ab402019-09-16 14:27:45 +0100211 virtual std::unique_ptr<IWorkload> CreateSlice(const SliceQueueDescriptor& descriptor,
212 const WorkloadInfo& info) const;
213
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000214 virtual std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor,
215 const WorkloadInfo& info) const;
216
217 virtual std::unique_ptr<IWorkload> CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor,
218 const WorkloadInfo& info) const;
219
Aron Virginas-Tar972af152019-06-11 14:14:03 +0100220 virtual std::unique_ptr<IWorkload> CreateSpaceToDepth(const SpaceToDepthQueueDescriptor& descriptor,
221 const WorkloadInfo& info) const;
222
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000223 virtual std::unique_ptr<IWorkload> CreateSubtraction(const SubtractionQueueDescriptor& descriptor,
224 const WorkloadInfo& info) const;
225
226 virtual std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor,
227 const WorkloadInfo& info) const;
228
Matthew Jackson2b8c1da2019-07-04 14:59:16 +0100229 virtual std::unique_ptr<IWorkload> CreateStack(const StackQueueDescriptor& descriptor,
Matthew Jacksond5166102019-07-31 14:06:28 +0100230 const WorkloadInfo& info) const;
Matthew Jackson2b8c1da2019-07-04 14:59:16 +0100231
Derek Lambertia9cca6a2019-03-25 15:41:58 +0000232 virtual std::unique_ptr<IWorkload> CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor,
233 const WorkloadInfo& Info) const;
Sadik Armaganeff363d2019-04-05 15:25:46 +0100234
235 virtual std::unique_ptr<IWorkload> CreateSwitch(const SwitchQueueDescriptor& descriptor,
236 const WorkloadInfo& Info) const;
Aron Virginas-Tar639fb042019-06-20 14:28:19 +0100237
Mike Kellyc9ea45a2020-02-28 18:11:58 +0000238 virtual std::unique_ptr<IWorkload> CreateTranspose(const TransposeQueueDescriptor& descriptor,
239 const WorkloadInfo& info) const;
240
Aron Virginas-Tar639fb042019-06-20 14:28:19 +0100241 virtual std::unique_ptr<IWorkload> CreateTransposeConvolution2d(
242 const TransposeConvolution2dQueueDescriptor& descriptor,
243 const WorkloadInfo& info) const;
telsoa014fcda012018-03-09 14:13:49 +0000244};
245
Aron Virginas-Tar639fb042019-06-20 14:28:19 +0100246} // namespace armnn