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, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 28 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
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, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 33 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
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, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 42 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
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, |
| 47 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 48 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 49 | virtual bool IsConstantSupported(const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 50 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 51 | |
| 52 | virtual bool IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 53 | const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 54 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 55 | |
| 56 | virtual bool IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 57 | const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 58 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
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, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 65 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 66 | |
| 67 | virtual bool IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 68 | const TensorInfo& output, |
| 69 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 70 | const TensorInfo& weights, |
David Beck | 5eec11d | 2018-10-04 15:43:17 +0100 | [diff] [blame] | 71 | const Optional<TensorInfo>& biases, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 72 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 73 | |
| 74 | virtual bool IsDivisionSupported(const TensorInfo& input0, |
| 75 | const TensorInfo& input1, |
| 76 | const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 77 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 78 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 79 | virtual bool IsFakeQuantizationSupported(const TensorInfo& input, |
| 80 | const FakeQuantizationDescriptor& descriptor, |
| 81 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 82 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 83 | virtual bool IsFloorSupported(const TensorInfo& input, |
| 84 | const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 85 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 86 | |
| 87 | virtual bool IsFullyConnectedSupported(const TensorInfo& input, |
| 88 | const TensorInfo& output, |
| 89 | const TensorInfo& weights, |
| 90 | const TensorInfo& biases, |
| 91 | const FullyConnectedDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 92 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
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 IsInputSupported(const TensorInfo& input, |
| 95 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 96 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 97 | virtual bool IsL2NormalizationSupported(const TensorInfo& input, |
| 98 | const TensorInfo& output, |
| 99 | const L2NormalizationDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 100 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 101 | |
| 102 | virtual bool IsLstmSupported(const TensorInfo& input, |
| 103 | const TensorInfo& outputStateIn, |
| 104 | const TensorInfo& cellStateIn, |
| 105 | const TensorInfo& scratchBuffer, |
| 106 | const TensorInfo& outputStateOut, |
| 107 | const TensorInfo& cellStateOut, |
| 108 | const TensorInfo& output, |
| 109 | const LstmDescriptor& descriptor, |
| 110 | const TensorInfo& inputToForgetWeights, |
| 111 | const TensorInfo& inputToCellWeights, |
| 112 | const TensorInfo& inputToOutputWeights, |
| 113 | const TensorInfo& recurrentToForgetWeights, |
| 114 | const TensorInfo& recurrentToCellWeights, |
| 115 | const TensorInfo& recurrentToOutputWeights, |
| 116 | const TensorInfo& forgetGateBias, |
| 117 | const TensorInfo& cellBias, |
| 118 | const TensorInfo& outputGateBias, |
| 119 | const TensorInfo* inputToInputWeights, |
| 120 | const TensorInfo* recurrentToInputWeights, |
| 121 | const TensorInfo* cellToInputWeights, |
| 122 | const TensorInfo* inputGateBias, |
| 123 | const TensorInfo* projectionWeights, |
| 124 | const TensorInfo* projectionBias, |
| 125 | const TensorInfo* cellToForgetWeights, |
| 126 | const TensorInfo* cellToOutputWeights, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 127 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 128 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 129 | virtual bool IsMeanSupported(const TensorInfo& input, |
| 130 | const TensorInfo& output, |
| 131 | const MeanDescriptor& descriptor, |
| 132 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 133 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 134 | virtual bool IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 135 | const TensorInfo& output, |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 136 | const OriginsDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 137 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 138 | |
| 139 | virtual bool IsMultiplicationSupported(const TensorInfo& input0, |
| 140 | const TensorInfo& input1, |
| 141 | const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 142 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 143 | |
| 144 | virtual bool IsNormalizationSupported(const TensorInfo& input, |
| 145 | const TensorInfo& output, |
| 146 | const NormalizationDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 147 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 148 | |
| 149 | virtual bool IsOutputSupported(const TensorInfo& output, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 150 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 151 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 152 | virtual bool IsPadSupported(const TensorInfo& input, |
| 153 | const TensorInfo& output, |
| 154 | const PadDescriptor& descriptor, |
| 155 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 156 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 157 | virtual bool IsPermuteSupported(const TensorInfo& input, |
| 158 | const TensorInfo& output, |
| 159 | const PermuteDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 160 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 161 | |
| 162 | virtual bool IsPooling2dSupported(const TensorInfo& input, |
| 163 | const TensorInfo& output, |
| 164 | const Pooling2dDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 165 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 166 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 167 | virtual bool IsReshapeSupported(const TensorInfo& input, |
| 168 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 169 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 170 | virtual bool IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 171 | const TensorInfo& output, |
| 172 | const SpaceToBatchNdDescriptor& descriptor, |
| 173 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 174 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 175 | virtual bool IsResizeBilinearSupported(const TensorInfo& input, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 176 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 177 | |
| 178 | virtual bool IsSoftmaxSupported(const TensorInfo& input, |
| 179 | const TensorInfo& output, |
| 180 | const SoftmaxDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 181 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 182 | |
| 183 | virtual bool IsSplitterSupported(const TensorInfo& input, |
| 184 | const ViewsDescriptor& descriptor, |
arovir01 | d6c10ed | 2018-10-05 15:46:51 +0100 | [diff] [blame] | 185 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 186 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 187 | virtual bool IsStridedSliceSupported(const TensorInfo& input, |
| 188 | const TensorInfo& output, |
| 189 | const StridedSliceDescriptor& descriptor, |
| 190 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
| 191 | |
arovir01 | 537a0b6 | 2018-10-08 12:01:04 +0100 | [diff] [blame] | 192 | virtual bool IsSubtractionSupported(const TensorInfo& input0, |
| 193 | const TensorInfo& input1, |
| 194 | const TensorInfo& output, |
| 195 | Optional<std::string&> reasonIfUnsupported = EmptyOptional()) const; |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 196 | }; // class ILayerSupport |
| 197 | |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 198 | using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>; |
| 199 | |
David Beck | e97c6e0 | 2018-10-03 13:09:28 +0100 | [diff] [blame] | 200 | } // namespace armnn |