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 | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <backendsCommon/WorkloadFactory.hpp> |
| 9 | #include <backendsCommon/OutputHandler.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | |
| 11 | #include <boost/core/ignore_unused.hpp> |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 12 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | template <typename QueueDescriptorType> |
| 18 | constexpr bool IsOperationQueueDescriptor(const QueueDescriptorType&) { return true; } |
| 19 | |
| 20 | template <> |
| 21 | constexpr bool IsOperationQueueDescriptor(const MemCopyQueueDescriptor&) { return false; } |
| 22 | |
| 23 | template <> |
| 24 | constexpr bool IsOperationQueueDescriptor(const ConstantQueueDescriptor&) { return false; } |
| 25 | |
| 26 | template <> |
| 27 | constexpr bool IsOperationQueueDescriptor(const PermuteQueueDescriptor&) { return false; } |
| 28 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 29 | // Reference workload factory. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | class RefWorkloadFactory : public IWorkloadFactory |
| 31 | { |
| 32 | public: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | explicit RefWorkloadFactory(); |
| 34 | virtual ~RefWorkloadFactory() {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 35 | |
David Beck | 79141b9 | 2018-10-23 16:09:36 +0100 | [diff] [blame] | 36 | const BackendId& GetBackendId() const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 38 | static bool IsLayerSupported(const Layer& layer, |
| 39 | Optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | std::string& outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
| 42 | virtual bool SupportsSubTensors() const override { return false; } |
| 43 | |
| 44 | virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, |
| 45 | TensorShape const& subTensorShape, |
| 46 | unsigned int const* subTensorOrigin) const override |
| 47 | { |
| 48 | boost::ignore_unused(parent, subTensorShape, subTensorOrigin); |
| 49 | return nullptr; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 50 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | |
| 52 | virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override; |
| 53 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 54 | virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 55 | DataLayout dataLayout) const override; |
| 56 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | virtual std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor, |
| 58 | const WorkloadInfo& info) const override; |
| 59 | |
| 60 | virtual std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor, |
| 61 | const WorkloadInfo& info) const override; |
| 62 | |
| 63 | virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 64 | const WorkloadInfo& info) const override; |
| 65 | |
| 66 | virtual std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
| 67 | const WorkloadInfo& info) const override; |
| 68 | |
| 69 | virtual std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor, |
| 70 | const WorkloadInfo& info) const override; |
| 71 | |
| 72 | virtual std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor, |
| 73 | const WorkloadInfo& info) const override; |
| 74 | |
| 75 | virtual std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor, |
| 76 | const WorkloadInfo& info) const override; |
| 77 | |
| 78 | virtual std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 79 | const WorkloadInfo& info) const override; |
| 80 | |
| 81 | virtual std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 82 | const WorkloadInfo& info) const override; |
| 83 | |
| 84 | virtual std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor, |
| 85 | const WorkloadInfo& info) const override; |
| 86 | |
| 87 | virtual std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d( |
| 88 | const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const override; |
| 89 | |
| 90 | virtual std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor, |
| 91 | const WorkloadInfo& info) const override; |
| 92 | |
| 93 | virtual std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor, |
| 94 | const WorkloadInfo& info) const override; |
| 95 | |
| 96 | virtual std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor, |
| 97 | const WorkloadInfo& info) const override; |
| 98 | |
| 99 | virtual std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor, |
| 100 | const WorkloadInfo& info) const override; |
| 101 | |
| 102 | virtual std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 103 | const WorkloadInfo& info) const override; |
| 104 | |
| 105 | virtual std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor, |
| 106 | const WorkloadInfo& info) const override; |
| 107 | |
| 108 | virtual std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor, |
| 109 | const WorkloadInfo& info) const override; |
| 110 | |
| 111 | virtual std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 112 | const WorkloadInfo& info) const override; |
| 113 | |
| 114 | virtual std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 115 | const WorkloadInfo& info) const override; |
| 116 | |
| 117 | virtual std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 118 | const WorkloadInfo& info) const override; |
| 119 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 120 | virtual std::unique_ptr<IWorkload> CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor& descriptor, |
| 121 | const WorkloadInfo& info) const override; |
| 122 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 123 | virtual std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor, |
| 124 | const WorkloadInfo& info) const override; |
| 125 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 126 | virtual std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor, |
| 127 | const WorkloadInfo& info) const override; |
| 128 | |
| 129 | virtual std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 130 | const WorkloadInfo& info) const override; |
| 131 | |
| 132 | virtual std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 133 | const WorkloadInfo& info) const override; |
| 134 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 135 | virtual std::unique_ptr<IWorkload> CreateDivision(const DivisionQueueDescriptor& descriptor, |
| 136 | const WorkloadInfo& info) const override; |
| 137 | |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 138 | virtual std::unique_ptr<IWorkload> CreateSubtraction(const SubtractionQueueDescriptor& descriptor, |
| 139 | const WorkloadInfo& info) const override; |
narpra01 | a6bf912 | 2018-09-10 09:50:09 +0100 | [diff] [blame] | 140 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 141 | virtual std::unique_ptr<IWorkload> CreateMaximum(const MaximumQueueDescriptor& descriptor, |
| 142 | const WorkloadInfo& info) const override; |
| 143 | |
narpra01 | a6bf912 | 2018-09-10 09:50:09 +0100 | [diff] [blame] | 144 | virtual std::unique_ptr<IWorkload> CreateMean(const MeanQueueDescriptor& descriptor, |
| 145 | const WorkloadInfo& Info) const override; |
jimfly01 | 2c9322a | 2018-09-19 10:59:49 +0100 | [diff] [blame] | 146 | |
| 147 | virtual std::unique_ptr<IWorkload> CreatePad(const PadQueueDescriptor& descriptor, |
| 148 | const WorkloadInfo& info) const override; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 149 | |
| 150 | virtual std::unique_ptr<IWorkload> CreateBatchToSpaceNd(const BatchToSpaceNdQueueDescriptor& descriptor, |
| 151 | const WorkloadInfo& info) const override; |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 152 | |
| 153 | virtual std::unique_ptr<IWorkload> CreateStridedSlice(const StridedSliceQueueDescriptor& descriptor, |
| 154 | const WorkloadInfo& info) const override; |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 155 | |
| 156 | virtual std::unique_ptr<IWorkload> CreateMinimum(const MinimumQueueDescriptor& descriptor, |
| 157 | const WorkloadInfo& info) const override; |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 158 | |
| 159 | virtual std::unique_ptr<IWorkload> CreateDebug(const DebugQueueDescriptor& descriptor, |
| 160 | const WorkloadInfo& info) const override; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 161 | private: |
| 162 | |
| 163 | template <typename F32Workload, typename U8Workload, typename QueueDescriptorType> |
| 164 | std::unique_ptr<IWorkload> MakeWorkload(const QueueDescriptorType& descriptor, const WorkloadInfo& info) const; |
| 165 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | } // namespace armnn |