Release 18.08
[platform/upstream/armnn.git] / src / armnn / backends / ClWorkloadFactory.hpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5 #pragma once
6
7 #include "OutputHandler.hpp"
8
9 #include "armnn/IRuntime.hpp"
10 #include <boost/optional.hpp>
11
12 #include "memory/BaseMemoryManager.hpp"
13
14 namespace armnn
15 {
16
17 // ARM Compute OpenCL workload factory.
18 class ClWorkloadFactory : public IWorkloadFactory
19 {
20 public:
21     ClWorkloadFactory();
22
23     virtual Compute GetCompute() const override { return Compute::GpuAcc; }
24
25     static bool IsLayerSupported(const Layer& layer, boost::optional<DataType> dataType,
26                                  std::string& outReasonIfUnsupported);
27
28     virtual bool SupportsSubTensors() const override { return true; }
29
30     virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle&      parent,
31                                                                  TensorShape const&   subTensorShape,
32                                                                  unsigned int const* subTensorOrigin) const override;
33
34     virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override;
35
36     virtual std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor,
37                                                    const WorkloadInfo& info) const override;
38
39     virtual std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor,
40                                                     const WorkloadInfo& info) const override;
41
42     virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor,
43                                                         const WorkloadInfo&              info) const override;
44
45     virtual std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor,
46                                                      const WorkloadInfo&           info) const override;
47
48     virtual std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor,
49                                                       const WorkloadInfo&            info) const override;
50
51     virtual std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor,
52                                                     const WorkloadInfo&          info) const override;
53
54     virtual std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor,
55                                                             const WorkloadInfo&                  info) const override;
56
57     virtual std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor,
58                                                      const WorkloadInfo&           info) const override;
59
60     virtual std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor,
61                                                        const WorkloadInfo&           info) const override;
62
63     virtual std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor,
64                                                            const WorkloadInfo&               info) const override;
65
66     virtual std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d(
67         const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const override;
68
69     virtual std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor,
70                                                            const WorkloadInfo&                 info) const override;
71
72     virtual std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor,
73                                                       const WorkloadInfo&            info) const override;
74
75     virtual std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor,
76                                                             const WorkloadInfo&                  info) const override;
77
78     virtual std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor,
79                                                                 const WorkloadInfo& info) const override;
80
81     virtual std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor,
82                                                      const WorkloadInfo& info) const override;
83
84     virtual std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor,
85                                                             const WorkloadInfo& info) const override;
86
87     virtual std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor,
88                                                               const WorkloadInfo& info) const override;
89
90     virtual std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor,
91                                                              const WorkloadInfo& info) const override;
92
93     virtual std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor,
94                                                       const WorkloadInfo& info) const override;
95
96     virtual std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor,
97                                                      const WorkloadInfo& info) const override;
98
99     virtual std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor,
100                                                    const WorkloadInfo& info) const override;
101
102     virtual std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor,
103                                                   const WorkloadInfo& info) const override;
104
105     virtual std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor,
106                                                                const WorkloadInfo& info) const override;
107
108     virtual std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor,
109                                                                const WorkloadInfo& info) const override;
110
111     virtual void Finalize() override;
112
113     virtual void Release() override;
114
115     virtual void Acquire() override;
116
117 private:
118
119 #ifdef ARMCOMPUTECL_ENABLED
120     mutable ClMemoryManager m_MemoryManager;
121 #endif
122 };
123
124 } // namespace armnn