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 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 7 | #include <memory> |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 8 | #include <armnn/TensorFwd.hpp> |
| 9 | #include <backends/OutputHandler.hpp> |
| 10 | #include <backends/Workload.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 11 | #include <boost/optional.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | class Layer; |
| 17 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 18 | // Workload factory interface for compute backends. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 19 | class IWorkloadFactory |
| 20 | { |
| 21 | public: |
| 22 | virtual ~IWorkloadFactory() { } |
| 23 | |
| 24 | virtual Compute GetCompute() const = 0; |
| 25 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 26 | /// Informs the memory manager that the network is finalized and ready for execution. |
| 27 | virtual void Finalize() { } |
| 28 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 29 | /// Inform the memory manager to release the memory |
| 30 | virtual void Release() { } |
| 31 | |
| 32 | /// Inform the memory manager to acquire memory |
| 33 | virtual void Acquire() { } |
| 34 | |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 35 | static bool IsLayerSupported(const BackendId& backendId, |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 36 | const IConnectableLayer& layer, |
| 37 | boost::optional<DataType> dataType, |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 38 | std::string& outReasonIfUnsupported); |
David Beck | dcb751f | 2018-10-03 11:42:42 +0100 | [diff] [blame] | 39 | |
| 40 | static bool IsLayerSupported(const IConnectableLayer& layer, |
| 41 | boost::optional<DataType> dataType, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 42 | std::string& outReasonIfUnsupported); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | |
| 44 | virtual bool SupportsSubTensors() const = 0; |
| 45 | |
| 46 | virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, |
| 47 | TensorShape const& subTensorShape, |
| 48 | unsigned int const* subTensorOrigin |
| 49 | ) const = 0; |
| 50 | |
| 51 | virtual std::unique_ptr<IWorkload> CreateInput(const InputQueueDescriptor& descriptor, |
| 52 | const WorkloadInfo& info) const = 0; |
| 53 | |
| 54 | virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const = 0; |
| 55 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 56 | virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, |
| 57 | DataLayout dataLayout) const = 0; |
| 58 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 59 | virtual std::unique_ptr<IWorkload> CreateOutput(const OutputQueueDescriptor& descriptor, |
| 60 | const WorkloadInfo& info) const = 0; |
| 61 | |
| 62 | virtual std::unique_ptr<IWorkload> CreateActivation(const ActivationQueueDescriptor& descriptor, |
| 63 | const WorkloadInfo& info) const = 0; |
| 64 | |
| 65 | virtual std::unique_ptr<IWorkload> CreateSoftmax(const SoftmaxQueueDescriptor& descriptor, |
| 66 | const WorkloadInfo& info) const = 0; |
| 67 | |
| 68 | virtual std::unique_ptr<IWorkload> CreateSplitter(const SplitterQueueDescriptor& descriptor, |
| 69 | const WorkloadInfo& info) const = 0; |
| 70 | |
| 71 | virtual std::unique_ptr<IWorkload> CreateMerger(const MergerQueueDescriptor& descriptor, |
| 72 | const WorkloadInfo& info) const = 0; |
| 73 | |
| 74 | virtual std::unique_ptr<IWorkload> CreateFullyConnected(const FullyConnectedQueueDescriptor& descriptor, |
| 75 | const WorkloadInfo& info) const = 0; |
| 76 | |
| 77 | virtual std::unique_ptr<IWorkload> CreatePermute(const PermuteQueueDescriptor& descriptor, |
| 78 | const WorkloadInfo& info) const = 0; |
| 79 | |
| 80 | virtual std::unique_ptr<IWorkload> CreatePooling2d(const Pooling2dQueueDescriptor& descriptor, |
| 81 | const WorkloadInfo& info) const = 0; |
| 82 | |
| 83 | virtual std::unique_ptr<IWorkload> CreateConvolution2d(const Convolution2dQueueDescriptor& descriptor, |
| 84 | const WorkloadInfo& info) const = 0; |
| 85 | |
| 86 | virtual std::unique_ptr<IWorkload> CreateDepthwiseConvolution2d( |
| 87 | const DepthwiseConvolution2dQueueDescriptor& descriptor, const WorkloadInfo& info) const = 0; |
| 88 | |
| 89 | virtual std::unique_ptr<IWorkload> CreateNormalization(const NormalizationQueueDescriptor& descriptor, |
| 90 | const WorkloadInfo& info) const = 0; |
| 91 | |
| 92 | virtual std::unique_ptr<IWorkload> CreateAddition(const AdditionQueueDescriptor& descriptor, |
| 93 | const WorkloadInfo& info) const = 0; |
| 94 | |
| 95 | virtual std::unique_ptr<IWorkload> CreateMultiplication(const MultiplicationQueueDescriptor& descriptor, |
| 96 | const WorkloadInfo& info) const = 0; |
| 97 | |
| 98 | virtual std::unique_ptr<IWorkload> CreateBatchNormalization(const BatchNormalizationQueueDescriptor& descriptor, |
| 99 | const WorkloadInfo& info) const = 0; |
| 100 | |
| 101 | virtual std::unique_ptr<IWorkload> CreateMemCopy(const MemCopyQueueDescriptor& descriptor, |
| 102 | const WorkloadInfo& info) const = 0; |
| 103 | |
| 104 | virtual std::unique_ptr<IWorkload> CreateResizeBilinear(const ResizeBilinearQueueDescriptor& descriptor, |
| 105 | const WorkloadInfo& info) const = 0; |
| 106 | |
| 107 | virtual std::unique_ptr<IWorkload> CreateFakeQuantization(const FakeQuantizationQueueDescriptor& descriptor, |
| 108 | const WorkloadInfo& info) const = 0; |
| 109 | |
| 110 | virtual std::unique_ptr<IWorkload> CreateL2Normalization(const L2NormalizationQueueDescriptor& descriptor, |
| 111 | const WorkloadInfo& info) const = 0; |
| 112 | |
| 113 | virtual std::unique_ptr<IWorkload> CreateConstant(const ConstantQueueDescriptor& descriptor, |
| 114 | const WorkloadInfo& info) const = 0; |
| 115 | |
| 116 | virtual std::unique_ptr<IWorkload> CreateReshape(const ReshapeQueueDescriptor& descriptor, |
| 117 | const WorkloadInfo& info) const = 0; |
| 118 | |
| 119 | virtual std::unique_ptr<IWorkload> CreateFloor(const FloorQueueDescriptor& descriptor, |
| 120 | const WorkloadInfo& info) const = 0; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 121 | |
| 122 | virtual std::unique_ptr<IWorkload> CreateLstm(const LstmQueueDescriptor& descriptor, |
| 123 | const WorkloadInfo& info) const = 0; |
| 124 | |
| 125 | virtual std::unique_ptr<IWorkload> CreateConvertFp16ToFp32(const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 126 | const WorkloadInfo& info) const = 0; |
| 127 | |
| 128 | virtual std::unique_ptr<IWorkload> CreateConvertFp32ToFp16(const ConvertFp32ToFp16QueueDescriptor& descriptor, |
| 129 | const WorkloadInfo& info) const = 0; |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 130 | |
| 131 | virtual std::unique_ptr<IWorkload> CreateDivision(const DivisionQueueDescriptor& descriptor, |
| 132 | const WorkloadInfo& info) const = 0; |
David Beck | c2044fe | 2018-09-05 15:00:38 +0100 | [diff] [blame] | 133 | |
| 134 | virtual std::unique_ptr<IWorkload> CreateSubtraction(const SubtractionQueueDescriptor& descriptor, |
| 135 | const WorkloadInfo& info) const = 0; |
narpra01 | a6bf912 | 2018-09-10 09:50:09 +0100 | [diff] [blame] | 136 | |
| 137 | virtual std::unique_ptr<IWorkload> CreateMean(const MeanQueueDescriptor& descriptor, |
| 138 | const WorkloadInfo& Info) const = 0; |
jimfly01 | 2c9322a | 2018-09-19 10:59:49 +0100 | [diff] [blame] | 139 | |
| 140 | virtual std::unique_ptr<IWorkload> CreatePad(const PadQueueDescriptor& descriptor, |
| 141 | const WorkloadInfo& Info) const = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 144 | } //namespace armnn |