David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include <armnn/DescriptorsFwd.hpp> |
David Beck | 5eec11d | 2018-10-04 15:43:17 +0100 | [diff] [blame] | 8 | #include <armnn/Optional.hpp> |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 9 | #include <vector> |
David Beck | 5eec11d | 2018-10-04 15:43:17 +0100 | [diff] [blame] | 10 | #include <cctype> |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 11 | #include <memory> |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | class TensorInfo; |
| 17 | |
| 18 | class ILayerSupport |
| 19 | { |
| 20 | protected: |
| 21 | ILayerSupport() {} |
| 22 | virtual ~ILayerSupport() {} |
| 23 | |
| 24 | public: |
| 25 | virtual bool IsActivationSupported(const TensorInfo& input, |
| 26 | const TensorInfo& output, |
| 27 | const ActivationDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 28 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 29 | |
| 30 | virtual bool IsAdditionSupported(const TensorInfo& input0, |
| 31 | const TensorInfo& input1, |
| 32 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 33 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 34 | |
| 35 | virtual bool IsBatchNormalizationSupported(const TensorInfo& input, |
| 36 | const TensorInfo& output, |
| 37 | const TensorInfo& mean, |
| 38 | const TensorInfo& var, |
| 39 | const TensorInfo& beta, |
| 40 | const TensorInfo& gamma, |
| 41 | const BatchNormalizationDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 42 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 43 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 44 | virtual bool IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 45 | const TensorInfo& output, |
| 46 | const BatchToSpaceNdDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 47 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 48 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 49 | virtual bool IsConstantSupported(const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 50 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 51 | |
| 52 | virtual bool IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 53 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 54 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 55 | |
| 56 | virtual bool IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 57 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 58 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 59 | |
| 60 | virtual bool IsConvolution2dSupported(const TensorInfo& input, |
| 61 | const TensorInfo& output, |
| 62 | const Convolution2dDescriptor& descriptor, |
| 63 | const TensorInfo& weights, |
David Beck | 5eec11d | 2018-10-04 15:43:17 +0100 | [diff] [blame] | 64 | const Optional<TensorInfo>& biases, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 65 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 66 | |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 67 | virtual bool IsDebugSupported(const TensorInfo& input, |
| 68 | const TensorInfo& output, |
Nattapat Chaimanowong | ac5aa1f | 2018-12-05 15:17:18 +0000 | [diff] [blame] | 69 | const DebugDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 70 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Nattapat Chaimanowong | a9a1cf1 | 2018-12-03 16:06:49 +0000 | [diff] [blame] | 71 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 72 | virtual bool IsDepthwiseConvolutionSupported( |
| 73 | const TensorInfo& input, |
| 74 | const TensorInfo& output, |
| 75 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 76 | const TensorInfo& weights, |
| 77 | const Optional<TensorInfo>& biases, |
| 78 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 79 | |
| 80 | virtual bool IsDivisionSupported(const TensorInfo& input0, |
| 81 | const TensorInfo& input1, |
| 82 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 83 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 84 | |
FrancisMurtagh | 2099595 | 2018-12-17 12:11:36 +0000 | [diff] [blame] | 85 | virtual bool IsEqualSupported(const TensorInfo& input0, |
| 86 | const TensorInfo& input1, |
| 87 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 88 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
FrancisMurtagh | 2099595 | 2018-12-17 12:11:36 +0000 | [diff] [blame] | 89 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 90 | virtual bool IsFakeQuantizationSupported(const TensorInfo& input, |
| 91 | const FakeQuantizationDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 92 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 93 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 94 | virtual bool IsFloorSupported(const TensorInfo& input, |
| 95 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 96 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 97 | |
| 98 | virtual bool IsFullyConnectedSupported(const TensorInfo& input, |
| 99 | const TensorInfo& output, |
| 100 | const TensorInfo& weights, |
| 101 | const TensorInfo& biases, |
| 102 | const FullyConnectedDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 103 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 104 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 105 | virtual bool IsInputSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 106 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 107 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 108 | virtual bool IsL2NormalizationSupported(const TensorInfo& input, |
| 109 | const TensorInfo& output, |
| 110 | const L2NormalizationDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 111 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 112 | |
| 113 | virtual bool IsLstmSupported(const TensorInfo& input, |
| 114 | const TensorInfo& outputStateIn, |
| 115 | const TensorInfo& cellStateIn, |
| 116 | const TensorInfo& scratchBuffer, |
| 117 | const TensorInfo& outputStateOut, |
| 118 | const TensorInfo& cellStateOut, |
| 119 | const TensorInfo& output, |
| 120 | const LstmDescriptor& descriptor, |
| 121 | const TensorInfo& inputToForgetWeights, |
| 122 | const TensorInfo& inputToCellWeights, |
| 123 | const TensorInfo& inputToOutputWeights, |
| 124 | const TensorInfo& recurrentToForgetWeights, |
| 125 | const TensorInfo& recurrentToCellWeights, |
| 126 | const TensorInfo& recurrentToOutputWeights, |
| 127 | const TensorInfo& forgetGateBias, |
| 128 | const TensorInfo& cellBias, |
| 129 | const TensorInfo& outputGateBias, |
| 130 | const TensorInfo* inputToInputWeights, |
| 131 | const TensorInfo* recurrentToInputWeights, |
| 132 | const TensorInfo* cellToInputWeights, |
| 133 | const TensorInfo* inputGateBias, |
| 134 | const TensorInfo* projectionWeights, |
| 135 | const TensorInfo* projectionBias, |
| 136 | const TensorInfo* cellToForgetWeights, |
| 137 | const TensorInfo* cellToOutputWeights, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 138 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 139 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 140 | virtual bool IsMaximumSupported(const TensorInfo& input0, |
| 141 | const TensorInfo& input1, |
| 142 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 143 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 144 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 145 | virtual bool IsMeanSupported(const TensorInfo& input, |
| 146 | const TensorInfo& output, |
| 147 | const MeanDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 148 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
| 149 | |
| 150 | virtual bool IsMemCopySupported(const TensorInfo& input, |
| 151 | const TensorInfo& output, |
| 152 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 153 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 154 | virtual bool IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 155 | const TensorInfo& output, |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 156 | const OriginsDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 157 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 158 | |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 159 | virtual bool IsMinimumSupported(const TensorInfo& input0, |
| 160 | const TensorInfo& input1, |
| 161 | const TensorInfo& ouput, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 162 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 163 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 164 | virtual bool IsMultiplicationSupported(const TensorInfo& input0, |
| 165 | const TensorInfo& input1, |
| 166 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 167 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 168 | |
| 169 | virtual bool IsNormalizationSupported(const TensorInfo& input, |
| 170 | const TensorInfo& output, |
| 171 | const NormalizationDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 172 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 173 | |
| 174 | virtual bool IsOutputSupported(const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 175 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 176 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 177 | virtual bool IsPadSupported(const TensorInfo& input, |
| 178 | const TensorInfo& output, |
| 179 | const PadDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 180 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 181 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 182 | virtual bool IsPermuteSupported(const TensorInfo& input, |
| 183 | const TensorInfo& output, |
| 184 | const PermuteDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 185 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 186 | |
| 187 | virtual bool IsPooling2dSupported(const TensorInfo& input, |
| 188 | const TensorInfo& output, |
| 189 | const Pooling2dDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 190 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 191 | |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 192 | virtual bool IsPreCompiledSupported(const TensorInfo& input, |
| 193 | const PreCompiledDescriptor& descriptor, |
| 194 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
| 195 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 196 | virtual bool IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 197 | const ReshapeDescriptor& descriptor, |
| 198 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 199 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 200 | virtual bool IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 201 | const TensorInfo& output, |
| 202 | const SpaceToBatchNdDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 203 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 204 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 205 | virtual bool IsResizeBilinearSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 206 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 207 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 208 | virtual bool IsRsqrtSupported(const TensorInfo& input, |
| 209 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 210 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 211 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 212 | virtual bool IsSoftmaxSupported(const TensorInfo& input, |
| 213 | const TensorInfo& output, |
| 214 | const SoftmaxDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 215 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 216 | |
| 217 | virtual bool IsSplitterSupported(const TensorInfo& input, |
| 218 | const ViewsDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 219 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 220 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 221 | virtual bool IsStridedSliceSupported(const TensorInfo& input, |
| 222 | const TensorInfo& output, |
| 223 | const StridedSliceDescriptor& descriptor, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 224 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 225 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 226 | virtual bool IsSubtractionSupported(const TensorInfo& input0, |
| 227 | const TensorInfo& input1, |
| 228 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 229 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 230 | |
| 231 | virtual bool IsGreaterSupported(const TensorInfo& input0, |
| 232 | const TensorInfo& input1, |
| 233 | const TensorInfo& ouput, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 234 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const = 0; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 235 | }; // class ILayerSupport |
| 236 | |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 237 | using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>; |
| 238 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 239 | } // namespace armnn |