2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
7 #include <armnn/TensorFwd.hpp>
8 #include <armnn/Optional.hpp>
10 #include <backendsCommon/OutputHandler.hpp>
11 #include <backendsCommon/Workload.hpp>
20 // Workload factory interface for compute backends.
21 class IWorkloadFactory
24 virtual ~IWorkloadFactory() { }
26 virtual const BackendId& GetBackendId() const = 0;
28 static bool IsLayerSupported(const BackendId& backendId,
29 const IConnectableLayer& layer,
30 Optional<DataType> dataType,
31 std::string& outReasonIfUnsupported);
33 static bool IsLayerSupported(const IConnectableLayer& layer,
34 Optional<DataType> dataType,
35 std::string& outReasonIfUnsupported);
37 virtual bool SupportsSubTensors() const = 0;
39 virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
40 TensorShape const& subTensorShape,
41 unsigned int const* subTensorOrigin
44 virtual std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor,
45 const WorkloadInfo& info) const = 0;
47 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const = 0;
49 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
50 DataLayout dataLayout) const = 0;
52 virtual std::unique_ptr<IWorkload> CreateAbs(const AbsQueueDescriptor& descriptor,
53 const WorkloadInfo& info) const;
55 virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor,
56 const WorkloadInfo& info) const;
58 virtual std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor,
59 const WorkloadInfo& info) const;
61 virtual std::unique_ptr<IWorkload> CreateArgMinMax(const ArgMinMaxQueueDescriptor& descriptor,
62 const WorkloadInfo& info) const;
64 virtual std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor,
65 const WorkloadInfo& info) const;
67 virtual std::unique_ptr<IWorkload> CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor,
68 const WorkloadInfo& Info) const;
70 virtual std::unique_ptr<IWorkload> CreateConcat(const ConcatQueueDescriptor& descriptor,
71 const WorkloadInfo& info) const;
73 virtual std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor,
74 const WorkloadInfo& info) const;
76 virtual std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor,
77 const WorkloadInfo& info) const;
79 virtual std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor,
80 const WorkloadInfo& info) const;
82 virtual std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor,
83 const WorkloadInfo& info) const;
85 virtual std::unique_ptr<IWorkload> CreateDebug(const DebugQueueDescriptor& descriptor,
86 const WorkloadInfo& info) const;
88 virtual std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d(
89 const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const;
91 virtual std::unique_ptr<IWorkload> CreateDequantize(const DequantizeQueueDescriptor& descriptor,
92 const WorkloadInfo& info) const;
94 virtual std::unique_ptr<IWorkload> CreateDetectionPostProcess(
95 const DetectionPostProcessQueueDescriptor& descriptor, const WorkloadInfo& info) const;
97 virtual std::unique_ptr<IWorkload> CreateDivision(const DivisionQueueDescriptor& descriptor,
98 const WorkloadInfo& info) const;
100 virtual std::unique_ptr<IWorkload> CreateEqual(const EqualQueueDescriptor& descriptor,
101 const WorkloadInfo& Info) const;
103 virtual std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor,
104 const WorkloadInfo& info) const;
106 virtual std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor,
107 const WorkloadInfo& info) const;
109 virtual std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor,
110 const WorkloadInfo& info) const;
112 virtual std::unique_ptr<IWorkload> CreateGather(const GatherQueueDescriptor& descriptor,
113 const WorkloadInfo& info) const;
115 virtual std::unique_ptr<IWorkload> CreateGreater(const GreaterQueueDescriptor& descriptor,
116 const WorkloadInfo& info) const;
118 virtual std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor,
119 const WorkloadInfo& info) const;
121 virtual std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor,
122 const WorkloadInfo& info) const;
124 virtual std::unique_ptr<IWorkload> CreateMaximum(const MaximumQueueDescriptor& descriptor,
125 const WorkloadInfo& info) const;
127 virtual std::unique_ptr<IWorkload> CreateMean(const MeanQueueDescriptor& descriptor,
128 const WorkloadInfo& Info) const;
130 virtual std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor,
131 const WorkloadInfo& info) const;
133 virtual std::unique_ptr<IWorkload> CreateMemImport(const MemImportQueueDescriptor& descriptor,
134 const WorkloadInfo& info) const;
136 virtual std::unique_ptr<IWorkload> CreateMerge(const MergeQueueDescriptor& descriptor,
137 const WorkloadInfo& info) const;
139 ARMNN_DEPRECATED_MSG("Use CreateConcat instead")
140 virtual std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor,
141 const WorkloadInfo& info) const;
143 virtual std::unique_ptr<IWorkload> CreateMinimum(const MinimumQueueDescriptor& descriptor,
144 const WorkloadInfo& info) const;
146 virtual std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor,
147 const WorkloadInfo& info) const;
149 virtual std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor,
150 const WorkloadInfo& info) const;
152 virtual std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor,
153 const WorkloadInfo& info) const;
155 virtual std::unique_ptr<IWorkload> CreatePad(const PadQueueDescriptor& descriptor,
156 const WorkloadInfo& Info) const;
158 virtual std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor,
159 const WorkloadInfo& info) const;
161 virtual std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor,
162 const WorkloadInfo& info) const;
164 virtual std::unique_ptr<IWorkload> CreatePreCompiled(const PreCompiledQueueDescriptor& descriptor,
165 const WorkloadInfo& info) const;
167 virtual std::unique_ptr<IWorkload> CreatePrelu(const PreluQueueDescriptor& descriptor,
168 const WorkloadInfo& info) const;
170 virtual std::unique_ptr<IWorkload> CreateQuantize(const QuantizeQueueDescriptor& descriptor,
171 const WorkloadInfo& Info) const;
173 virtual std::unique_ptr<IWorkload> CreateQuantizedLstm(const QuantizedLstmQueueDescriptor& descriptor,
174 const WorkloadInfo& info) const;
176 virtual std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor,
177 const WorkloadInfo& info) const;
179 virtual std::unique_ptr<IWorkload> CreateResize(const ResizeQueueDescriptor& descriptor,
180 const WorkloadInfo& info) const;
182 ARMNN_DEPRECATED_MSG("Use CreateResize instead")
183 virtual std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor,
184 const WorkloadInfo& info) const;
186 virtual std::unique_ptr<IWorkload> CreateRsqrt(const RsqrtQueueDescriptor& descriptor,
187 const WorkloadInfo& info) const;
189 virtual std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor,
190 const WorkloadInfo& info) const;
192 virtual std::unique_ptr<IWorkload> CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor,
193 const WorkloadInfo& info) const;
195 virtual std::unique_ptr<IWorkload> CreateSpaceToDepth(const SpaceToDepthQueueDescriptor& descriptor,
196 const WorkloadInfo& info) const;
198 virtual std::unique_ptr<IWorkload> CreateSubtraction(const SubtractionQueueDescriptor& descriptor,
199 const WorkloadInfo& info) const;
201 virtual std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor,
202 const WorkloadInfo& info) const;
204 virtual std::unique_ptr<IWorkload> CreateStack(const StackQueueDescriptor& descriptor,
205 const WorkloadInfo& info) const;
207 virtual std::unique_ptr<IWorkload> CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor,
208 const WorkloadInfo& Info) const;
210 virtual std::unique_ptr<IWorkload> CreateSwitch(const SwitchQueueDescriptor& descriptor,
211 const WorkloadInfo& Info) const;
213 virtual std::unique_ptr<IWorkload> CreateTransposeConvolution2d(
214 const TransposeConvolution2dQueueDescriptor& descriptor,
215 const WorkloadInfo& info) const;