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 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 6 | #include "RefLayerSupport.hpp" |
David Beck | 3e9e115 | 2018-10-17 14:17:50 +0100 | [diff] [blame] | 7 | #include "RefBackendId.hpp" |
David Beck | 3cc9a62 | 2018-10-12 10:38:31 +0100 | [diff] [blame] | 8 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include <armnn/Types.hpp> |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 10 | #include <armnn/Descriptors.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 11 | #include <armnn/BackendRegistry.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 13 | #include <armnnUtils/DataLayoutIndexed.hpp> |
| 14 | |
| 15 | #include <InternalTypes.hpp> |
| 16 | #include <LayerSupportCommon.hpp> |
| 17 | |
Derek Lamberti | f674aa0 | 2019-08-01 15:56:25 +0100 | [diff] [blame] | 18 | #include <backendsCommon/LayerSupportRules.hpp> |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 19 | |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 20 | #include <boost/cast.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 21 | #include <boost/core/ignore_unused.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 23 | #include <vector> |
| 24 | #include <algorithm> |
| 25 | #include <array> |
| 26 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | using namespace boost; |
| 28 | |
| 29 | namespace armnn |
| 30 | { |
| 31 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 32 | namespace |
| 33 | { |
| 34 | |
| 35 | template<typename Float32Func, typename Uint8Func, typename ... Params> |
| 36 | bool IsSupportedForDataTypeRef(Optional<std::string&> reasonIfUnsupported, |
| 37 | DataType dataType, |
| 38 | Float32Func floatFuncPtr, |
| 39 | Uint8Func uint8FuncPtr, |
| 40 | Params&&... params) |
| 41 | { |
| 42 | return IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 43 | dataType, |
| 44 | &FalseFunc<Params...>, |
| 45 | floatFuncPtr, |
| 46 | uint8FuncPtr, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 47 | &FalseFunc<Params...>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 48 | &FalseFunc<Params...>, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 49 | std::forward<Params>(params)...); |
| 50 | } |
| 51 | |
| 52 | } // anonymous namespace |
| 53 | |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 54 | namespace |
| 55 | { |
| 56 | |
| 57 | std::string CreateIncorrectDimensionsErrorMsg(unsigned int expected, |
| 58 | unsigned int actual, |
| 59 | std::string& layerStr, |
| 60 | std::string& tensorName) |
| 61 | { |
| 62 | std::string errorMsg = "Reference " + layerStr + ": Expected " + std::to_string(expected) + " dimensions but got" + |
| 63 | " " + std::to_string(actual) + " dimensions instead, for the '" + tensorName + "' tensor."; |
| 64 | |
| 65 | return errorMsg; |
| 66 | } |
| 67 | |
| 68 | } // anonymous namespace |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 69 | |
Sadik Armagan | 9199e58 | 2019-09-05 17:35:31 +0100 | [diff] [blame] | 70 | bool RefLayerSupport::IsAbsSupported(const TensorInfo& input, const TensorInfo& output, |
| 71 | Optional<std::string&> reasonIfUnsupported) const |
| 72 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 73 | return IsElementwiseUnarySupported(input, |
| 74 | output, |
| 75 | ElementwiseUnaryDescriptor(UnaryOperation::Abs), |
| 76 | reasonIfUnsupported); |
Sadik Armagan | 9199e58 | 2019-09-05 17:35:31 +0100 | [diff] [blame] | 77 | } |
| 78 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 79 | bool RefLayerSupport::IsActivationSupported(const TensorInfo& input, |
| 80 | const TensorInfo& output, |
| 81 | const ActivationDescriptor& descriptor, |
| 82 | Optional<std::string&> reasonIfUnsupported) const |
| 83 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 84 | bool supported = true; |
| 85 | |
| 86 | // Define supported types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 87 | std::array<DataType,4> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 88 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 89 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 90 | DataType::QAsymmU8, |
| 91 | DataType::QSymmS16 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 95 | "Reference activation: input type not supported."); |
| 96 | |
| 97 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 98 | "Reference activation: output type not supported."); |
| 99 | |
| 100 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 101 | "Reference activation: input and output types mismatched."); |
| 102 | |
| 103 | supported &= CheckSupportRule(ShapesAreSameRank(input, output), reasonIfUnsupported, |
| 104 | "Reference activation: input and output shapes are of different rank."); |
| 105 | |
| 106 | |
| 107 | struct ActivationFunctionSupported : public Rule |
| 108 | { |
| 109 | ActivationFunctionSupported(const ActivationDescriptor& desc) |
| 110 | { |
| 111 | switch(desc.m_Function) |
| 112 | { |
| 113 | case ActivationFunction::Abs: |
| 114 | case ActivationFunction::BoundedReLu: |
| 115 | case ActivationFunction::LeakyReLu: |
| 116 | case ActivationFunction::Linear: |
| 117 | case ActivationFunction::ReLu: |
| 118 | case ActivationFunction::Sigmoid: |
| 119 | case ActivationFunction::SoftReLu: |
| 120 | case ActivationFunction::Sqrt: |
| 121 | case ActivationFunction::Square: |
| 122 | case ActivationFunction::TanH: |
| 123 | { |
| 124 | m_Res = true; |
| 125 | break; |
| 126 | } |
| 127 | default: |
| 128 | { |
| 129 | m_Res = false; |
| 130 | break; |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | }; |
| 135 | |
| 136 | // Function is supported |
| 137 | supported &= CheckSupportRule(ActivationFunctionSupported(descriptor), reasonIfUnsupported, |
| 138 | "Reference activation: function not supported."); |
| 139 | |
| 140 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | bool RefLayerSupport::IsAdditionSupported(const TensorInfo& input0, |
| 144 | const TensorInfo& input1, |
| 145 | const TensorInfo& output, |
| 146 | Optional<std::string&> reasonIfUnsupported) const |
| 147 | { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 148 | bool supported = true; |
| 149 | |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 150 | std::array<DataType,5> supportedTypes = { |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 151 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 152 | DataType::Float16, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 153 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 154 | DataType::QAsymmU8, |
| 155 | DataType::QSymmS16 |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 159 | "Reference addition: input 0 is not a supported type."); |
| 160 | |
| 161 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 162 | "Reference addition: input 1 is not a supported type."); |
| 163 | |
| 164 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 165 | "Reference addition: output is not a supported type."); |
| 166 | |
| 167 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 168 | "Reference addition: input 0 and Input 1 types are mismatched"); |
| 169 | |
| 170 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 171 | "Reference addition: input and output types are mismatched"); |
| 172 | |
| 173 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 174 | "Reference addition: shapes are not suitable for implicit broadcast."); |
| 175 | |
| 176 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 177 | } |
| 178 | |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 179 | bool RefLayerSupport::IsArgMinMaxSupported(const armnn::TensorInfo &input, const armnn::TensorInfo &output, |
| 180 | const armnn::ArgMinMaxDescriptor &descriptor, |
| 181 | armnn::Optional<std::string &> reasonIfUnsupported) const |
| 182 | { |
| 183 | ignore_unused(descriptor); |
| 184 | |
Francis Murtagh | 1939df5 | 2019-11-13 15:21:09 +0000 | [diff] [blame] | 185 | std::array<DataType, 4> supportedTypes = |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 186 | { |
| 187 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 188 | DataType::QAsymmU8, |
| 189 | DataType::QSymmS16, |
Francis Murtagh | 1939df5 | 2019-11-13 15:21:09 +0000 | [diff] [blame] | 190 | DataType::Signed32 |
Nikhil Raj | 68c2c90 | 2019-09-19 11:21:11 +0100 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | bool supported = true; |
| 194 | |
| 195 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 196 | "Reference ArgMinMax: input is not a supported type."); |
| 197 | supported &= CheckSupportRule(TypeIs(output, DataType::Signed32), reasonIfUnsupported, |
| 198 | "Reference ArgMinMax: output type not supported"); |
| 199 | |
| 200 | return supported; |
| 201 | } |
| 202 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 203 | bool RefLayerSupport::IsBatchNormalizationSupported(const TensorInfo& input, |
| 204 | const TensorInfo& output, |
| 205 | const TensorInfo& mean, |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 206 | const TensorInfo& variance, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 207 | const TensorInfo& beta, |
| 208 | const TensorInfo& gamma, |
| 209 | const BatchNormalizationDescriptor& descriptor, |
| 210 | Optional<std::string&> reasonIfUnsupported) const |
| 211 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 212 | ignore_unused(descriptor); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 213 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 214 | std::array<DataType, 4> supportedTypes = |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 215 | { |
| 216 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 217 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 218 | DataType::QAsymmU8, |
| 219 | DataType::QSymmS16 |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | bool supported = true; |
| 223 | |
| 224 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 225 | "Reference batch normalization: input is not a supported type."); |
| 226 | |
| 227 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 228 | "Reference batch normalization: output is not a supported type."); |
| 229 | |
| 230 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 231 | "Reference batch normalization: input and output types are mismatched"); |
| 232 | |
| 233 | supported &= CheckSupportRule(TypeAnyOf(mean, supportedTypes), reasonIfUnsupported, |
| 234 | "Reference batch normalization: mean is not a supported type."); |
| 235 | |
| 236 | supported &= CheckSupportRule(TypeAnyOf(variance, supportedTypes), reasonIfUnsupported, |
| 237 | "Reference batch normalization: variance is not a supported type."); |
| 238 | |
| 239 | supported &= CheckSupportRule(TypeAnyOf(beta, supportedTypes), reasonIfUnsupported, |
| 240 | "Reference batch normalization: beta is not a supported type."); |
| 241 | |
| 242 | supported &= CheckSupportRule(TypeAnyOf(gamma, supportedTypes), reasonIfUnsupported, |
| 243 | "Reference batch normalization: gamma is not a supported type."); |
| 244 | |
| 245 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 246 | } |
| 247 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 248 | bool RefLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input, |
| 249 | const TensorInfo& output, |
| 250 | const BatchToSpaceNdDescriptor& descriptor, |
| 251 | Optional<std::string&> reasonIfUnsupported) const |
| 252 | { |
| 253 | ignore_unused(descriptor); |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 254 | |
| 255 | bool supported = true; |
| 256 | |
| 257 | std::string batchToSpaceNdLayerStr = "batchToSpaceNd"; |
| 258 | std::string inputTensorStr = "input"; |
| 259 | std::string outputTensorStr = "output"; |
| 260 | |
| 261 | // Define supported types. |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 262 | std::array<DataType,4> supportedTypes = |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 263 | { |
| 264 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 265 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 266 | DataType::QAsymmU8, |
| 267 | DataType::QSymmS16 |
Francis Murtagh | d0dfe17 | 2019-06-25 10:57:10 +0100 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 271 | "Reference BatchToSpaceNd: input type not supported."); |
| 272 | |
| 273 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 274 | "Reference BatchToSpaceNd: output type not supported."); |
| 275 | |
| 276 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 277 | "Reference BatchToSpaceNd: input and output types mismatched."); |
| 278 | |
| 279 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 4), |
| 280 | reasonIfUnsupported, |
| 281 | CreateIncorrectDimensionsErrorMsg(4, |
| 282 | output.GetNumDimensions(), |
| 283 | batchToSpaceNdLayerStr, |
| 284 | outputTensorStr).data()); |
| 285 | |
| 286 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(input, 4), |
| 287 | reasonIfUnsupported, |
| 288 | CreateIncorrectDimensionsErrorMsg(4, |
| 289 | input.GetNumDimensions(), |
| 290 | batchToSpaceNdLayerStr, |
| 291 | inputTensorStr).data()); |
| 292 | |
| 293 | return supported; |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 296 | bool RefLayerSupport::IsComparisonSupported(const TensorInfo& input0, |
| 297 | const TensorInfo& input1, |
| 298 | const TensorInfo& output, |
| 299 | const ComparisonDescriptor& descriptor, |
| 300 | Optional<std::string&> reasonIfUnsupported) const |
| 301 | { |
| 302 | boost::ignore_unused(descriptor); |
| 303 | |
| 304 | std::array<DataType, 4> supportedInputTypes = |
| 305 | { |
| 306 | DataType::Float32, |
| 307 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 308 | DataType::QAsymmU8, |
| 309 | DataType::QSymmS16 |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | bool supported = true; |
| 313 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedInputTypes), reasonIfUnsupported, |
| 314 | "Reference comparison: input 0 is not a supported type"); |
| 315 | |
| 316 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 317 | "Reference comparison: input 0 and Input 1 types are mismatched"); |
| 318 | |
| 319 | supported &= CheckSupportRule(TypeIs(output, DataType::Boolean), reasonIfUnsupported, |
| 320 | "Reference comparison: output is not of type Boolean"); |
| 321 | |
| 322 | return supported; |
| 323 | } |
| 324 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 325 | bool RefLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs, |
| 326 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 327 | const ConcatDescriptor& descriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 328 | Optional<std::string&> reasonIfUnsupported) const |
| 329 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 330 | ignore_unused(descriptor); |
| 331 | |
| 332 | bool supported = true; |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 333 | std::array<DataType,5> supportedTypes = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 334 | { |
| 335 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 336 | DataType::Float16, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 337 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 338 | DataType::QAsymmU8, |
| 339 | DataType::QSymmS16 |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 343 | "Reference concatenation: output type not supported"); |
| 344 | for (const TensorInfo* input : inputs) |
| 345 | { |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 346 | BOOST_ASSERT(input != nullptr); |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 347 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 348 | "Reference concatenation: input type not supported"); |
| 349 | |
| 350 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 351 | "Reference concatenation: input and output types mismatched."); |
| 352 | } |
| 353 | |
| 354 | return supported; |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 355 | } |
| 356 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 357 | bool RefLayerSupport::IsConstantSupported(const TensorInfo& output, |
| 358 | Optional<std::string&> reasonIfUnsupported) const |
| 359 | { |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 360 | std::array<DataType,5> supportedTypes = |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 361 | { |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 362 | DataType::Float32, |
| 363 | DataType::Signed32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 364 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 365 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 366 | DataType::QSymmS16 |
Nina Drozd | 58ef2c6 | 2019-05-16 12:09:18 +0100 | [diff] [blame] | 367 | }; |
| 368 | |
| 369 | return CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 370 | "Reference constant: output is not a supported type."); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | bool RefLayerSupport::IsConvertFp16ToFp32Supported(const TensorInfo& input, |
| 374 | const TensorInfo& output, |
| 375 | Optional<std::string&> reasonIfUnsupported) const |
| 376 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 377 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 378 | input.GetDataType(), |
| 379 | &TrueFunc<>, |
| 380 | &FalseInputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 381 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 382 | &FalseFuncI32<>, |
| 383 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 384 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 385 | output.GetDataType(), |
| 386 | &FalseOutputFuncF16<>, |
| 387 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 388 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 389 | &FalseFuncI32<>, |
| 390 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | bool RefLayerSupport::IsConvertFp32ToFp16Supported(const TensorInfo& input, |
| 394 | const TensorInfo& output, |
| 395 | Optional<std::string&> reasonIfUnsupported) const |
| 396 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 397 | return (IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 398 | input.GetDataType(), |
| 399 | &FalseInputFuncF16<>, |
| 400 | &TrueFunc<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 401 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 402 | &FalseFuncI32<>, |
| 403 | &FalseFuncU8<>) && |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 404 | IsSupportedForDataTypeGeneric(reasonIfUnsupported, |
| 405 | output.GetDataType(), |
| 406 | &TrueFunc<>, |
| 407 | &FalseOutputFuncF32<>, |
narpra01 | db2b160 | 2019-01-23 15:23:11 +0000 | [diff] [blame] | 408 | &FalseFuncU8<>, |
kevmay01 | 2b4d88e | 2019-01-24 14:05:09 +0000 | [diff] [blame] | 409 | &FalseFuncI32<>, |
| 410 | &FalseFuncU8<>)); |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | bool RefLayerSupport::IsConvolution2dSupported(const TensorInfo& input, |
| 414 | const TensorInfo& output, |
| 415 | const Convolution2dDescriptor& descriptor, |
| 416 | const TensorInfo& weights, |
| 417 | const Optional<TensorInfo>& biases, |
| 418 | Optional<std::string&> reasonIfUnsupported) const |
| 419 | { |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 420 | bool supported = true; |
| 421 | |
| 422 | // Define supported types. |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 423 | std::array<DataType,5> supportedTypes = |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 424 | { |
| 425 | DataType::Float32, |
| 426 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 427 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 428 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 429 | DataType::QSymmS16 |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 430 | }; |
| 431 | |
| 432 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 433 | "Reference Convolution2d: input is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 434 | |
| 435 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 436 | "Reference Convolution2d: output is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 437 | |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 438 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 439 | "Reference Convolution2d: input and output types mismatched."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 440 | |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 441 | const DataType inputType = input.GetDataType(); |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 442 | if (inputType == DataType::QAsymmU8) |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 443 | { |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 444 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
| 445 | std::array<DataType, 3> supportedWeightTypes = |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 446 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 447 | DataType::QAsymmU8, |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 448 | DataType::QSymmS8, |
| 449 | DataType::QuantizedSymm8PerAxis // deprecated |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 450 | }; |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 451 | ARMNN_NO_DEPRECATE_WARN_END |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 452 | |
| 453 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 454 | "Reference Convolution2d: weights type not supported for quantized input."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 455 | } |
| 456 | else |
| 457 | { |
| 458 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 459 | "Reference Convolution2d: weights is not a supported type."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 460 | |
| 461 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 462 | "Reference Convolution2d: input and weights types mismatched."); |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 463 | } |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 464 | |
| 465 | if (biases.has_value()) |
| 466 | { |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 467 | std::array<DataType,3> biasesSupportedTypes = |
| 468 | { |
| 469 | DataType::Float32, |
| 470 | DataType::Float16, |
| 471 | DataType::Signed32 |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 472 | }; |
Aron Virginas-Tar | 5edc881 | 2019-11-05 18:00:21 +0000 | [diff] [blame] | 473 | |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 474 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 475 | "Reference Convolution2d: biases is not a supported type."); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 476 | } |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 477 | ignore_unused(descriptor); |
Mike Kelly | 2f80f6e | 2019-05-16 12:41:34 +0100 | [diff] [blame] | 478 | |
| 479 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 480 | } |
| 481 | |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 482 | bool RefLayerSupport::IsDebugSupported(const TensorInfo& input, |
| 483 | const TensorInfo& output, |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 484 | Optional<std::string&> reasonIfUnsupported) const |
| 485 | { |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 486 | bool supported = true; |
| 487 | |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 488 | std::array<DataType, 6> supportedTypes = |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 489 | { |
Aron Virginas-Tar | db1a283 | 2019-11-12 16:15:11 +0000 | [diff] [blame] | 490 | DataType::Float16, |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 491 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 492 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 493 | DataType::QSymmS8, |
Narumol Prangnawarat | d2d917d | 2020-01-09 10:16:39 +0000 | [diff] [blame] | 494 | DataType::QSymmS16, |
| 495 | DataType::Signed32 |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 496 | }; |
| 497 | |
| 498 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 499 | "Reference for Debug layer: input type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 500 | |
| 501 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 502 | "Reference for Debug layer: output type not supported"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 503 | |
| 504 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 505 | "Reference for Debug layer: input and output types are mismatched"); |
Narumol Prangnawarat | 47cfee9 | 2019-07-04 10:29:00 +0100 | [diff] [blame] | 506 | |
| 507 | return supported; |
Nattapat Chaimanowong | cfdcadf | 2018-12-06 11:54:33 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 510 | bool RefLayerSupport::IsDepthToSpaceSupported(const TensorInfo& input, |
| 511 | const TensorInfo& output, |
| 512 | const DepthToSpaceDescriptor& descriptor, |
| 513 | Optional<std::string&> reasonIfUnsupported) const |
| 514 | { |
| 515 | ignore_unused(descriptor); |
| 516 | bool supported = true; |
| 517 | |
| 518 | std::array<DataType,4> supportedTypes = |
| 519 | { |
| 520 | DataType::Float32, |
| 521 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 522 | DataType::QAsymmU8, |
| 523 | DataType::QSymmS16 |
Aron Virginas-Tar | 73f6642 | 2019-09-23 19:11:59 +0100 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 527 | "Reference DepthToSpace: input type not supported"); |
| 528 | |
| 529 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 530 | "Reference DepthToSpace: output type not supported"); |
| 531 | |
| 532 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 533 | "Reference DepthToSpace: input and output types are mismatched"); |
| 534 | |
| 535 | return supported; |
| 536 | } |
| 537 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 538 | bool RefLayerSupport::IsDepthwiseConvolutionSupported(const TensorInfo& input, |
| 539 | const TensorInfo& output, |
| 540 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 541 | const TensorInfo& weights, |
| 542 | const Optional<TensorInfo>& biases, |
| 543 | Optional<std::string&> reasonIfUnsupported) const |
| 544 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 545 | bool supported = true; |
| 546 | |
| 547 | // Define supported types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 548 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 549 | { |
| 550 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 551 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 552 | DataType::QAsymmU8, |
| 553 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 557 | "Reference DepthwiseConvolution2d: input is not a supported type."); |
| 558 | |
| 559 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 560 | "Reference DepthwiseConvolution2d: output is not a supported type."); |
| 561 | |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 562 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 563 | "Reference DepthwiseConvolution2d: input and output types mismatched."); |
| 564 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 565 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
| 566 | std::array<DataType, 3> supportedWeightTypes = |
| 567 | { |
| 568 | DataType::QAsymmU8, |
| 569 | DataType::QSymmS8, |
| 570 | DataType::QuantizedSymm8PerAxis // deprecated |
| 571 | }; |
| 572 | ARMNN_NO_DEPRECATE_WARN_END |
| 573 | |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 574 | const DataType inputType = input.GetDataType(); |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 575 | if (inputType == DataType::QAsymmU8) |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 576 | { |
Teresa Charlin | d8df026 | 2019-11-11 12:28:15 +0000 | [diff] [blame] | 577 | |
| 578 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 579 | "Reference convolution2d: weights type not supported for quantized input."); |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 584 | "Reference DepthwiseConvolution2d: weights is not a supported type."); |
| 585 | |
| 586 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 587 | "Reference DepthwiseConvolution2d: input and weights types mismatched."); |
| 588 | } |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 589 | |
| 590 | if (biases.has_value()) |
| 591 | { |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 592 | std::array<DataType,3> biasesSupportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 593 | { |
| 594 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 595 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 596 | DataType::Signed32 |
| 597 | }; |
| 598 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 599 | "Reference DepthwiseConvolution2d: biases is not a supported type."); |
| 600 | } |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 601 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 602 | |
| 603 | return supported; |
| 604 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 605 | } |
| 606 | |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 607 | bool RefLayerSupport::IsDequantizeSupported(const TensorInfo& input, |
| 608 | const TensorInfo& output, |
| 609 | Optional<std::string&> reasonIfUnsupported) const |
| 610 | { |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 611 | bool supported = true; |
| 612 | |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame^] | 613 | std::array<DataType,4> supportedInputTypes = { |
| 614 | DataType::QAsymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 615 | DataType::QAsymmU8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 616 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 617 | DataType::QSymmS16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 618 | }; |
| 619 | |
| 620 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 621 | "Reference for Dequantize layer: input type not supported."); |
| 622 | |
| 623 | supported &= CheckSupportRule( TypeNotPerAxisQuantized(input), reasonIfUnsupported, |
| 624 | "Reference for Dequantize layer: per-axis quantized input not support ."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 625 | |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 626 | supported &= CheckSupportRule(TypeNotPerAxisQuantized(input), reasonIfUnsupported, |
| 627 | "Reference dequantize: per-axis quantized input not support ."); |
| 628 | |
Jan Eilers | f710793 | 2019-11-01 11:09:36 +0000 | [diff] [blame] | 629 | std::array<DataType,2> supportedOutputTypes = { |
| 630 | DataType::Float32, |
| 631 | DataType::Float16 |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 632 | }; |
| 633 | |
| 634 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 635 | "Reference for Dequantize layer: output type not supported."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 636 | |
| 637 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 638 | "Reference for Dequantize layer: input/output shapes have different num total " |
| 639 | "elements."); |
Nattapat Chaimanowong | afa4e3a | 2019-04-02 11:41:45 +0100 | [diff] [blame] | 640 | |
| 641 | return supported; |
Nattapat Chaimanowong | 8a54ac0 | 2019-03-29 15:25:04 +0000 | [diff] [blame] | 642 | } |
| 643 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 644 | bool RefLayerSupport::IsDetectionPostProcessSupported(const TensorInfo& boxEncodings, |
| 645 | const TensorInfo& scores, |
| 646 | const TensorInfo& anchors, |
| 647 | const TensorInfo& detectionBoxes, |
| 648 | const TensorInfo& detectionClasses, |
| 649 | const TensorInfo& detectionScores, |
| 650 | const TensorInfo& numDetections, |
| 651 | const DetectionPostProcessDescriptor& descriptor, |
| 652 | Optional<std::string&> reasonIfUnsupported) const |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 653 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 654 | boost::ignore_unused(anchors, detectionBoxes, detectionClasses, detectionScores, numDetections, descriptor); |
| 655 | |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 656 | bool supported = true; |
| 657 | |
Mike Kelly | 4992c34 | 2019-08-14 11:33:11 +0100 | [diff] [blame] | 658 | std::array<DataType,3> supportedInputTypes = |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 659 | { |
| 660 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 661 | DataType::QAsymmU8, |
| 662 | DataType::QSymmS16 |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 663 | }; |
| 664 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 665 | supported &= CheckSupportRule(TypeAnyOf(boxEncodings, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 666 | "Reference DetectionPostProcess: input 0 is not a supported type."); |
| 667 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 668 | supported &= CheckSupportRule(TypeAnyOf(scores, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 669 | "Reference DetectionPostProcess: input 1 is not a supported type."); |
| 670 | |
| 671 | return supported; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 674 | bool RefLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 675 | const TensorInfo& output, |
| 676 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 677 | const TensorInfo& weights, |
| 678 | const Optional<TensorInfo>& biases, |
| 679 | Optional<std::string&> reasonIfUnsupported) const |
| 680 | { |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 681 | return IsDepthwiseConvolutionSupported(input, output, descriptor, weights, biases, reasonIfUnsupported); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 682 | } |
| 683 | |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 684 | bool RefLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 685 | const TensorInfo& input1, |
| 686 | const TensorInfo& output, |
| 687 | Optional<std::string&> reasonIfUnsupported) const |
| 688 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 689 | bool supported = true; |
| 690 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 691 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 692 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 693 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 694 | DataType::QAsymmU8, |
| 695 | DataType::QSymmS16 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 696 | }; |
| 697 | |
| 698 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 699 | "Reference division: input 0 is not a supported type."); |
| 700 | |
| 701 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 702 | "Reference division: input 1 is not a supported type."); |
| 703 | |
| 704 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 705 | "Reference division: output is not a supported type."); |
| 706 | |
| 707 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 708 | "Reference division: input 0 and Input 1 types are mismatched"); |
| 709 | |
| 710 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 711 | "Reference division: input and output types are mismatched"); |
| 712 | |
| 713 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 714 | "Reference division: shapes are not suitable for implicit broadcast."); |
| 715 | |
| 716 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 717 | } |
| 718 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 719 | bool RefLayerSupport::IsElementwiseUnarySupported(const TensorInfo& input, |
| 720 | const TensorInfo& output, |
| 721 | const ElementwiseUnaryDescriptor& descriptor, |
| 722 | Optional<std::string&> reasonIfUnsupported) const |
| 723 | { |
| 724 | boost::ignore_unused(descriptor); |
| 725 | |
| 726 | std::array<DataType, 4> supportedTypes = |
| 727 | { |
| 728 | DataType::Float32, |
| 729 | DataType::Float16, |
| 730 | DataType::QAsymmU8, |
| 731 | DataType::QSymmS16 |
| 732 | }; |
| 733 | |
| 734 | bool supported = true; |
| 735 | |
| 736 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 737 | "Reference elementwise unary: input type not supported"); |
| 738 | |
| 739 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 740 | "Reference elementwise unary: output type not supported"); |
| 741 | |
| 742 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 743 | "Reference elementwise unary: input and output types not matching"); |
| 744 | |
| 745 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 746 | "Reference elementwise unary: input and output shapes" |
| 747 | "have different number of total elements"); |
| 748 | |
| 749 | return supported; |
| 750 | } |
| 751 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 752 | bool RefLayerSupport::IsEqualSupported(const TensorInfo& input0, |
| 753 | const TensorInfo& input1, |
| 754 | const TensorInfo& output, |
| 755 | Optional<std::string&> reasonIfUnsupported) const |
| 756 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 757 | return IsComparisonSupported(input0, |
| 758 | input1, |
| 759 | output, |
| 760 | ComparisonDescriptor(ComparisonOperation::Equal), |
| 761 | reasonIfUnsupported); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 762 | } |
| 763 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 764 | bool RefLayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, |
| 765 | const FakeQuantizationDescriptor& descriptor, |
| 766 | Optional<std::string&> reasonIfUnsupported) const |
| 767 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 768 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 769 | bool supported = true; |
| 770 | |
| 771 | std::array<DataType,1> supportedTypes = |
| 772 | { |
| 773 | DataType::Float32 |
| 774 | }; |
| 775 | |
| 776 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 777 | "Reference fake quantization: input type not supported."); |
| 778 | |
| 779 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | bool RefLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 783 | const TensorInfo& output, |
| 784 | Optional<std::string&> reasonIfUnsupported) const |
| 785 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 786 | ignore_unused(output); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 787 | bool supported = true; |
| 788 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 789 | std::array<DataType,3> supportedTypes = |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 790 | { |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 791 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 792 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 793 | DataType::QSymmS16 |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 794 | }; |
| 795 | |
| 796 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 797 | "Reference Floor: input type not supported."); |
| 798 | |
| 799 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 800 | "Reference Floor: output type not supported."); |
| 801 | |
| 802 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | bool RefLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 806 | const TensorInfo& output, |
| 807 | const TensorInfo& weights, |
| 808 | const TensorInfo& biases, |
| 809 | const FullyConnectedDescriptor& descriptor, |
| 810 | Optional<std::string&> reasonIfUnsupported) const |
| 811 | { |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 812 | bool supported = true; |
| 813 | |
| 814 | // Define supported types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 815 | std::array<DataType,4> supportedTypes = |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 816 | { |
| 817 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 818 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 819 | DataType::QAsymmU8, |
| 820 | DataType::QSymmS16 |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 821 | }; |
| 822 | |
| 823 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 824 | "Reference Fully Connected: input type not supported."); |
| 825 | |
| 826 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 827 | "Reference Fully Connected: output type not supported."); |
| 828 | |
| 829 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 830 | "Reference Fully Connected: input and output types mismatched."); |
| 831 | |
| 832 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 833 | "Reference Fully Connected: weights type not supported."); |
| 834 | |
| 835 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 836 | "Reference Fully Connected: input and weight types mismatched."); |
| 837 | |
| 838 | if (descriptor.m_BiasEnabled) |
| 839 | { |
| 840 | // Defined supported types for bias |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 841 | std::array<DataType, 3> |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 842 | supportedBiasTypes = |
| 843 | { |
| 844 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 845 | DataType::Float16, |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 846 | DataType::Signed32 |
| 847 | }; |
| 848 | |
| 849 | supported &= CheckSupportRule(TypeAnyOf(biases, supportedBiasTypes), reasonIfUnsupported, |
| 850 | "Reference Fully Connected: bias type not supported."); |
| 851 | |
| 852 | supported &= CheckSupportRule(BiasAndWeightsTypesMatch(biases, weights), reasonIfUnsupported, |
| 853 | "Reference Fully Connected: bias and weight types mismatch."); |
| 854 | |
| 855 | supported &= CheckSupportRule(BiasAndWeightsTypesCompatible(weights, supportedBiasTypes), reasonIfUnsupported, |
| 856 | "Reference Fully Connected: bias type inferred from weights is incompatible."); |
| 857 | |
| 858 | } |
| 859 | |
| 860 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 861 | } |
| 862 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 863 | bool RefLayerSupport::IsGatherSupported(const armnn::TensorInfo& input0, |
| 864 | const armnn::TensorInfo& input1, |
| 865 | const armnn::TensorInfo& output, |
| 866 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 867 | { |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 868 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 869 | std::array<DataType,4> supportedTypes = |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 870 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 871 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 872 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 873 | DataType::QAsymmU8, |
| 874 | DataType::QSymmS16 |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 875 | }; |
| 876 | |
| 877 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 878 | "Reference Gather: input type not supported"); |
| 879 | |
| 880 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 881 | "Reference Gather: output type not supported"); |
| 882 | |
| 883 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 884 | "Reference Gather: indices (input1) type not supported"); |
| 885 | |
| 886 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 887 | "Reference Gather: input and output types not matching"); |
| 888 | |
| 889 | return supported; |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 890 | } |
| 891 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 892 | bool RefLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 893 | const TensorInfo& input1, |
| 894 | const TensorInfo& output, |
| 895 | Optional<std::string&> reasonIfUnsupported) const |
| 896 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 897 | return IsComparisonSupported(input0, |
| 898 | input1, |
| 899 | output, |
| 900 | ComparisonDescriptor(ComparisonOperation::Greater), |
| 901 | reasonIfUnsupported); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 904 | bool RefLayerSupport::IsInputSupported(const TensorInfo& /*input*/, |
| 905 | Optional<std::string&> /*reasonIfUnsupported*/) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 906 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 907 | return true; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 908 | } |
| 909 | |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 910 | bool RefLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 911 | const TensorInfo& output, |
| 912 | const InstanceNormalizationDescriptor& descriptor, |
| 913 | Optional<std::string&> reasonIfUnsupported) const |
| 914 | { |
| 915 | ignore_unused(descriptor); |
| 916 | // Define supported types |
| 917 | std::array<DataType, 4> supportedTypes = |
| 918 | { |
| 919 | DataType::Float32, |
| 920 | DataType::Float16 |
| 921 | }; |
| 922 | |
| 923 | bool supported = true; |
| 924 | |
| 925 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 926 | "Reference Instance Normalization: input type not supported."); |
| 927 | |
| 928 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 929 | "Reference Instance Normalization: output type not supported."); |
| 930 | |
| 931 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 932 | "Reference Instance Normalization: input and output types mismatched."); |
| 933 | |
| 934 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 935 | "Reference Instance Normalization: input and output shapes have different " |
| 936 | "num total elements."); |
| 937 | |
| 938 | return supported; |
| 939 | } |
| 940 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 941 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 942 | const TensorInfo& output, |
| 943 | const L2NormalizationDescriptor& descriptor, |
| 944 | Optional<std::string&> reasonIfUnsupported) const |
| 945 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 946 | ignore_unused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 947 | // Define supported types |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 948 | std::array<DataType, 4> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 949 | { |
| 950 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 951 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 952 | DataType::QAsymmU8, |
| 953 | DataType::QSymmS16 |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 954 | }; |
| 955 | |
| 956 | bool supported = true; |
| 957 | |
| 958 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 959 | "Reference L2normalization: input type not supported."); |
| 960 | |
| 961 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 962 | "Reference L2normalization: output type not supported."); |
| 963 | |
| 964 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 965 | "Reference L2normalization: input and output types mismatched."); |
| 966 | |
| 967 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 968 | "Reference L2normalization: input and output shapes have different " |
| 969 | "num total elements."); |
| 970 | |
| 971 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 972 | } |
| 973 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 974 | bool RefLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 975 | const TensorInfo& output, |
| 976 | const LogSoftmaxDescriptor& descriptor, |
| 977 | Optional<std::string&> reasonIfUnsupported) const |
| 978 | { |
| 979 | ignore_unused(descriptor); |
| 980 | |
| 981 | std::array<DataType, 2> supportedTypes = |
| 982 | { |
| 983 | DataType::Float32, |
| 984 | DataType::Float16 |
| 985 | }; |
| 986 | |
| 987 | bool supported = true; |
| 988 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 989 | "Reference LogSoftmax: input type not supported"); |
| 990 | |
| 991 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 992 | "Reference LogSoftmax: output type not supported"); |
| 993 | |
| 994 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 995 | "Reference LogSoftmax: input and output types do not match"); |
| 996 | |
| 997 | return supported; |
| 998 | } |
| 999 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1000 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 1001 | const TensorInfo& outputStateIn, |
| 1002 | const TensorInfo& cellStateIn, |
| 1003 | const TensorInfo& scratchBuffer, |
| 1004 | const TensorInfo& outputStateOut, |
| 1005 | const TensorInfo& cellStateOut, |
| 1006 | const TensorInfo& output, |
| 1007 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1008 | const LstmInputParamsInfo& paramsInfo, |
| 1009 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1010 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1011 | ignore_unused(descriptor); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1012 | ignore_unused(paramsInfo); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1013 | |
| 1014 | bool supported = true; |
| 1015 | |
| 1016 | std::array<DataType,2> supportedTypes = { |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 1017 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1018 | DataType::QSymmS16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1019 | }; |
| 1020 | |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1021 | // check inputs and outputs |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1022 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1023 | "Reference Lstm: input is not a supported type."); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1024 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 1025 | "Reference Lstm: input and outputStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1026 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 1027 | "Reference Lstm: input and cellStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1028 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 1029 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1030 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 1031 | "Reference Lstm: input and outputStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1032 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 1033 | "Reference Lstm: input and cellStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1034 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1035 | "Reference Lstm: input and output types are mismatched"); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1036 | // check layer parameters |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1037 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1038 | "Reference Lstm: input and InputToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1039 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1040 | "Reference Lstm: input and InputToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1041 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1042 | "Reference Lstm: input and InputToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1043 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1044 | "Reference Lstm: input and RecurrentToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1045 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1046 | "Reference Lstm: input and RecurrentToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1047 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1048 | "Reference Lstm: input and RecurrentToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1049 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1050 | "Reference Lstm: input and ForgetGateBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1051 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1052 | "Reference Lstm: input and CellBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1053 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1054 | "Reference Lstm: input and OutputGateBias types are mismatched"); |
| 1055 | if (!descriptor.m_CifgEnabled) |
| 1056 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1057 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToInputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1058 | "Reference Lstm: input and InputToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1059 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1060 | reasonIfUnsupported, |
| 1061 | "Reference Lstm: input and RecurrentToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1062 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1063 | "Reference Lstm: input and InputGateBias types are mismatched"); |
| 1064 | if (descriptor.m_PeepholeEnabled) |
| 1065 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1066 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1067 | reasonIfUnsupported, |
| 1068 | "Reference Lstm: input and CellToInputWeights types are mismatched"); |
| 1069 | } |
| 1070 | } |
| 1071 | if (descriptor.m_PeepholeEnabled) |
| 1072 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1073 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1074 | "Reference Lstm: input and CellToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1075 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1076 | "Reference Lstm: input and CellToOutputWeights types are mismatched"); |
| 1077 | } |
| 1078 | if (descriptor.m_ProjectionEnabled) |
| 1079 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1080 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1081 | "Reference Lstm: input and mProjectionWeights types are mismatched"); |
| 1082 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 1083 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1084 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1085 | "Reference Lstm: input and ProjectionBias types are mismatched"); |
| 1086 | } |
| 1087 | } |
| 1088 | if (descriptor.m_LayerNormEnabled) |
| 1089 | { |
| 1090 | if (!descriptor.m_CifgEnabled) |
| 1091 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1092 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1093 | reasonIfUnsupported, |
| 1094 | "Reference Lstm: input and InputLayerNormWeights types are mismatched"); |
| 1095 | } |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1096 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1097 | reasonIfUnsupported, |
| 1098 | "Reference Lstm: input and ForgetLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1099 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1100 | reasonIfUnsupported, |
| 1101 | "Reference Lstm: input and CellLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1102 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1103 | reasonIfUnsupported, |
| 1104 | "Reference Lstm: input and OutputLayerNormWeights types are mismatched"); |
| 1105 | } |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1106 | |
| 1107 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1108 | } |
| 1109 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1110 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1111 | const TensorInfo& input1, |
| 1112 | const TensorInfo& output, |
| 1113 | Optional<std::string&> reasonIfUnsupported) const |
| 1114 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1115 | bool supported = true; |
| 1116 | |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1117 | std::array<DataType,5> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1118 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1119 | DataType::Float16, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1120 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1121 | DataType::QAsymmU8, |
| 1122 | DataType::QSymmS16 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1123 | }; |
| 1124 | |
| 1125 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1126 | "Reference maximum: input 0 is not a supported type."); |
| 1127 | |
| 1128 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1129 | "Reference maximum: input 1 is not a supported type."); |
| 1130 | |
| 1131 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1132 | "Reference maximum: output is not a supported type."); |
| 1133 | |
| 1134 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1135 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 1136 | |
| 1137 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1138 | "Reference maximum: input and output types are mismatched"); |
| 1139 | |
| 1140 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1141 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 1142 | |
| 1143 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1146 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1147 | const TensorInfo& output, |
| 1148 | const MeanDescriptor& descriptor, |
| 1149 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1150 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1151 | bool supported = true; |
| 1152 | std::string meanLayerStr = "Mean"; |
| 1153 | std::string outputTensorStr = "output"; |
| 1154 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1155 | std::array<DataType,4> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1156 | { |
| 1157 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1158 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1159 | DataType::QAsymmU8, |
| 1160 | DataType::QSymmS16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1161 | }; |
| 1162 | |
| 1163 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1164 | "Reference Mean: input type not supported."); |
| 1165 | |
| 1166 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1167 | "Reference Mean: input and output types are mismatched"); |
| 1168 | |
| 1169 | if (descriptor.m_KeepDims) |
| 1170 | { |
| 1171 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 1172 | reasonIfUnsupported, |
| 1173 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 1174 | output.GetNumDimensions(), |
| 1175 | meanLayerStr, outputTensorStr).data()); |
| 1176 | } |
| 1177 | else if (descriptor.m_Axis.empty()) |
| 1178 | { |
| 1179 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1180 | reasonIfUnsupported, |
| 1181 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1182 | meanLayerStr, outputTensorStr).data()); |
| 1183 | } |
| 1184 | else |
| 1185 | { |
| 1186 | auto outputDim = input.GetNumDimensions() - boost::numeric_cast<unsigned int>(descriptor.m_Axis.size()); |
| 1187 | |
| 1188 | if (outputDim > 0) |
| 1189 | { |
| 1190 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 1191 | reasonIfUnsupported, |
| 1192 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 1193 | meanLayerStr, outputTensorStr).data()); |
| 1194 | } |
| 1195 | else |
| 1196 | { |
| 1197 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1198 | reasonIfUnsupported, |
| 1199 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1200 | meanLayerStr, outputTensorStr).data()); |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1205 | } |
| 1206 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1207 | bool RefLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 1208 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1209 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1210 | Optional<std::string&> reasonIfUnsupported) const |
| 1211 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1212 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1213 | } |
| 1214 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1215 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1216 | const TensorInfo &output, |
| 1217 | Optional<std::string &> reasonIfUnsupported) const |
| 1218 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1219 | bool supported = true; |
| 1220 | |
| 1221 | std::array<DataType,5> supportedTypes = |
| 1222 | { |
| 1223 | DataType::Float32, |
| 1224 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1225 | DataType::QAsymmU8, |
| 1226 | DataType::QSymmS16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1227 | DataType::Boolean |
| 1228 | }; |
| 1229 | |
| 1230 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1231 | "Reference MemCopy: input type not supported"); |
| 1232 | |
| 1233 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1234 | "Reference MemCopy: output type not supported"); |
| 1235 | |
| 1236 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1237 | "Reference MemCopy: input and output types are mismatched"); |
| 1238 | |
| 1239 | return supported; |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1240 | } |
| 1241 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1242 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1243 | const TensorInfo& input1, |
| 1244 | const TensorInfo& output, |
| 1245 | Optional<std::string&> reasonIfUnsupported) const |
| 1246 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1247 | bool supported = true; |
| 1248 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1249 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1250 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1251 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1252 | DataType::QAsymmU8, |
| 1253 | DataType::QSymmS16 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1254 | }; |
| 1255 | |
| 1256 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1257 | "Reference minimum: input 0 is not a supported type."); |
| 1258 | |
| 1259 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1260 | "Reference minimum: input 1 is not a supported type."); |
| 1261 | |
| 1262 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1263 | "Reference minimum: output is not a supported type."); |
| 1264 | |
| 1265 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1266 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 1267 | |
| 1268 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1269 | "Reference minimum: input and output types are mismatched"); |
| 1270 | |
| 1271 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1272 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 1273 | |
| 1274 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1277 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1278 | const TensorInfo& input1, |
| 1279 | const TensorInfo& output, |
| 1280 | Optional<std::string&> reasonIfUnsupported) const |
| 1281 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1282 | bool supported = true; |
| 1283 | |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1284 | std::array<DataType,5> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1285 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1286 | DataType::Float16, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1287 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1288 | DataType::QAsymmU8, |
| 1289 | DataType::QSymmS16 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1290 | }; |
| 1291 | |
| 1292 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1293 | "Reference multiplication: input 0 is not a supported type."); |
| 1294 | |
| 1295 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1296 | "Reference multiplication: input 1 is not a supported type."); |
| 1297 | |
| 1298 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1299 | "Reference multiplication: output is not a supported type."); |
| 1300 | |
| 1301 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1302 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 1303 | |
| 1304 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1305 | "Reference multiplication: input and output types are mismatched"); |
| 1306 | |
| 1307 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1308 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 1309 | |
| 1310 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1314 | const TensorInfo& output, |
| 1315 | const NormalizationDescriptor& descriptor, |
| 1316 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1317 | { |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1318 | ignore_unused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1319 | |
| 1320 | // Define supported types |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1321 | std::array<DataType, 4> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1322 | { |
| 1323 | DataType::Float16, |
| 1324 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1325 | DataType::QAsymmU8, |
| 1326 | DataType::QSymmS16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1327 | }; |
| 1328 | |
| 1329 | bool supported = true; |
| 1330 | |
| 1331 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1332 | "Reference normalization: input type not supported."); |
| 1333 | |
| 1334 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1335 | "Reference normalization: output type not supported."); |
| 1336 | |
| 1337 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1338 | "Reference normalization: input and output shapes have different " |
| 1339 | "num total elements."); |
| 1340 | |
| 1341 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1342 | } |
| 1343 | |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1344 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& /*output*/, |
| 1345 | Optional<std::string&> /*reasonIfUnsupported*/) const |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1346 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1347 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1351 | const TensorInfo& output, |
| 1352 | const PadDescriptor& descriptor, |
| 1353 | Optional<std::string&> reasonIfUnsupported) const |
| 1354 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1355 | ignore_unused(descriptor); |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1356 | bool supported = true; |
| 1357 | |
| 1358 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1359 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1360 | { |
| 1361 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1362 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1363 | DataType::QAsymmU8, |
| 1364 | DataType::QSymmS16 |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1365 | }; |
| 1366 | |
| 1367 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1368 | "Reference pad: input is not a supported type."); |
| 1369 | |
| 1370 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1371 | "Reference pad: output is not a supported type."); |
| 1372 | |
| 1373 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1374 | "Reference pad: input and output types are mismatched."); |
| 1375 | |
| 1376 | return supported; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1377 | } |
| 1378 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1379 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1380 | const TensorInfo& output, |
| 1381 | const PermuteDescriptor& descriptor, |
| 1382 | Optional<std::string&> reasonIfUnsupported) const |
| 1383 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1384 | ignore_unused(descriptor); |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1385 | bool supported = true; |
| 1386 | |
| 1387 | // Define supported output and inputs types. |
| 1388 | std::array<DataType,3> supportedTypes = |
| 1389 | { |
| 1390 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1391 | DataType::QAsymmU8, |
| 1392 | DataType::QSymmS16 |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1393 | }; |
| 1394 | |
| 1395 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1396 | "Reference permute: input is not a supported type."); |
| 1397 | |
| 1398 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1399 | "Reference permute: output is not a supported type."); |
| 1400 | |
| 1401 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1402 | "Reference permute: input and output types are mismatched."); |
| 1403 | |
| 1404 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1405 | } |
| 1406 | |
| 1407 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1408 | const TensorInfo& output, |
| 1409 | const Pooling2dDescriptor& descriptor, |
| 1410 | Optional<std::string&> reasonIfUnsupported) const |
| 1411 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1412 | ignore_unused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1413 | bool supported = true; |
| 1414 | |
| 1415 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1416 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1417 | { |
| 1418 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1419 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1420 | DataType::QAsymmU8, |
| 1421 | DataType::QSymmS16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1422 | }; |
| 1423 | |
| 1424 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1425 | "Reference poolind2d: input is not a supported type."); |
| 1426 | |
| 1427 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1428 | "Reference poolind2d: output is not a supported type."); |
| 1429 | |
| 1430 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1431 | "Reference poolind2d: input and output types are mismatched."); |
| 1432 | |
| 1433 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1434 | } |
| 1435 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1436 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1437 | const TensorInfo& output, |
| 1438 | Optional<std::string&> reasonIfUnsupported) const |
| 1439 | { |
| 1440 | bool supported = true; |
| 1441 | |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1442 | // Define supported input types. |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame^] | 1443 | std::array<DataType,6> supportedInputTypes = { |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 1444 | DataType::Float32, |
Keith Davis | 3d8bc97 | 2020-02-04 09:31:47 +0000 | [diff] [blame] | 1445 | DataType::Float16, |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame^] | 1446 | DataType::QAsymmS8, |
Keith Davis | 5e51cd8 | 2020-01-29 16:52:59 +0000 | [diff] [blame] | 1447 | DataType::QAsymmU8, |
| 1448 | DataType::QSymmS8, |
| 1449 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1450 | }; |
| 1451 | |
| 1452 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 1453 | "Reference quantize: input type not supported."); |
| 1454 | |
| 1455 | // Define supported output types. |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame^] | 1456 | std::array<DataType,4> supportedOutputTypes = { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1457 | DataType::QAsymmU8, |
Ryan OShea | 9add120 | 2020-02-07 10:06:33 +0000 | [diff] [blame^] | 1458 | DataType::QAsymmS8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1459 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1460 | DataType::QSymmS16 |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1461 | }; |
| 1462 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1463 | "Reference quantize: output type not supported."); |
| 1464 | |
| 1465 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1466 | "Reference quantize: input and output shapes have different num total elements."); |
| 1467 | |
| 1468 | return supported; |
| 1469 | } |
| 1470 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1471 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 1472 | const TensorInfo& output, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1473 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1474 | Optional<std::string&> reasonIfUnsupported) const |
| 1475 | { |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 1476 | ignore_unused(output); |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1477 | ignore_unused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1478 | // Define supported output types. |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1479 | std::array<DataType,6> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1480 | { |
| 1481 | DataType::Float32, |
| 1482 | DataType::Float16, |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1483 | DataType::Signed32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1484 | DataType::QAsymmU8, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1485 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1486 | DataType::QSymmS16 |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1487 | }; |
| 1488 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 1489 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1490 | } |
| 1491 | |
| 1492 | bool RefLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 1493 | const TensorInfo& output, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1494 | Optional<std::string&> reasonIfUnsupported) const |
| 1495 | { |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1496 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1497 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1498 | { |
| 1499 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1500 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1501 | DataType::QAsymmU8, |
| 1502 | DataType::QSymmS16 |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1503 | }; |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1504 | |
| 1505 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1506 | "Reference ResizeBilinear: input type not supported"); |
| 1507 | |
| 1508 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1509 | "Reference ResizeBilinear: output type not supported"); |
| 1510 | |
| 1511 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1512 | "Reference ResizeBilinear: input and output types not matching"); |
| 1513 | |
| 1514 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1515 | } |
| 1516 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1517 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1518 | const TensorInfo& output, |
| 1519 | const ResizeDescriptor& descriptor, |
| 1520 | Optional<std::string&> reasonIfUnsupported) const |
| 1521 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1522 | boost::ignore_unused(descriptor); |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1523 | bool supported = true; |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1524 | std::array<DataType,5> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1525 | { |
| 1526 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1527 | DataType::Float16, |
Keith Davis | 5204aa8 | 2020-01-27 15:24:59 +0000 | [diff] [blame] | 1528 | DataType::QSymmS8, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1529 | DataType::QAsymmU8, |
| 1530 | DataType::QSymmS16 |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1531 | }; |
| 1532 | |
| 1533 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1534 | "Reference Resize: input type not supported"); |
| 1535 | |
| 1536 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1537 | "Reference Resize: output type not supported"); |
| 1538 | |
| 1539 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1540 | "Reference Resize: input and output types not matching"); |
| 1541 | |
| 1542 | return supported; |
| 1543 | } |
| 1544 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1545 | bool RefLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 1546 | const TensorInfo& output, |
| 1547 | Optional<std::string&> reasonIfUnsupported) const |
| 1548 | { |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 1549 | return IsElementwiseUnarySupported(input, |
| 1550 | output, |
| 1551 | ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt), |
| 1552 | reasonIfUnsupported); |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1553 | } |
| 1554 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1555 | bool RefLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 1556 | const TensorInfo& output, |
| 1557 | const SliceDescriptor& descriptor, |
| 1558 | Optional<std::string&> reasonIfUnsupported) const |
| 1559 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1560 | boost::ignore_unused(descriptor); |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1561 | bool supported = true; |
| 1562 | |
| 1563 | std::array<DataType, 3> supportedTypes = |
| 1564 | { |
| 1565 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1566 | DataType::QAsymmU8, |
| 1567 | DataType::QSymmS16 |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1568 | }; |
| 1569 | |
| 1570 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1571 | "Reference Slice: input type not supported"); |
| 1572 | |
| 1573 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1574 | "Reference Slice: output type not supported"); |
| 1575 | |
| 1576 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1577 | "Reference Slice: input and output types are mismatched"); |
| 1578 | |
| 1579 | return supported; |
| 1580 | } |
| 1581 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1582 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 1583 | const TensorInfo& output, |
| 1584 | const SoftmaxDescriptor& descriptor, |
| 1585 | Optional<std::string&> reasonIfUnsupported) const |
| 1586 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1587 | boost::ignore_unused(descriptor); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1588 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1589 | std::array<DataType,4> supportedTypes = |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1590 | { |
| 1591 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1592 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1593 | DataType::QAsymmU8, |
| 1594 | DataType::QSymmS16 |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1595 | }; |
| 1596 | |
| 1597 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1598 | "Reference Softmax: output type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1599 | |
| 1600 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1601 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1602 | |
| 1603 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1604 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1605 | |
| 1606 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1607 | } |
| 1608 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1609 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 1610 | const TensorInfo& output, |
| 1611 | const SpaceToBatchNdDescriptor& descriptor, |
| 1612 | Optional<std::string&> reasonIfUnsupported) const |
| 1613 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1614 | boost::ignore_unused(descriptor); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1615 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1616 | std::array<DataType,4> supportedTypes = |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1617 | { |
| 1618 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1619 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1620 | DataType::QAsymmU8, |
| 1621 | DataType::QSymmS16 |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1622 | }; |
| 1623 | |
| 1624 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1625 | "Reference SpaceToBatchNd: input type not supported"); |
| 1626 | |
| 1627 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1628 | "Reference SpaceToBatchNd: output type not supported"); |
| 1629 | |
| 1630 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1631 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 1632 | |
| 1633 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1634 | } |
| 1635 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1636 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 1637 | const TensorInfo& output, |
| 1638 | const SpaceToDepthDescriptor& descriptor, |
| 1639 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1640 | { |
| 1641 | |
| 1642 | ignore_unused(descriptor); |
| 1643 | bool supported = true; |
| 1644 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1645 | std::array<DataType,4> supportedTypes = |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1646 | { |
| 1647 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1648 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1649 | DataType::QAsymmU8, |
| 1650 | DataType::QSymmS16 |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1651 | }; |
| 1652 | |
| 1653 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1654 | "Reference SpaceToDepth: input type not supported"); |
| 1655 | |
| 1656 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1657 | "Reference SpaceToDepth: output type not supported"); |
| 1658 | |
| 1659 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1660 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 1661 | |
| 1662 | return supported; |
| 1663 | } |
| 1664 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1665 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1666 | const ViewsDescriptor& descriptor, |
| 1667 | Optional<std::string&> reasonIfUnsupported) const |
| 1668 | { |
| 1669 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1670 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1671 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1672 | { |
| 1673 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1674 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1675 | DataType::QAsymmU8, |
| 1676 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1677 | }; |
| 1678 | |
| 1679 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1680 | "Reference splitter: input type not supported"); |
| 1681 | |
| 1682 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1683 | } |
| 1684 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1685 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1686 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 1687 | const ViewsDescriptor& descriptor, |
| 1688 | Optional<std::string&> reasonIfUnsupported) const |
| 1689 | { |
| 1690 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1691 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1692 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1693 | { |
| 1694 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1695 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1696 | DataType::QAsymmU8, |
| 1697 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1698 | }; |
| 1699 | |
| 1700 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1701 | "Reference splitter: output type not supported"); |
| 1702 | for (const TensorInfo output : outputs) |
| 1703 | { |
| 1704 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1705 | "Reference splitter: input type not supported"); |
| 1706 | |
| 1707 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1708 | "Reference splitter: input and output types mismatched."); |
| 1709 | } |
| 1710 | |
| 1711 | return supported; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1712 | } |
| 1713 | |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1714 | bool RefLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 1715 | const TensorInfo& output, |
| 1716 | const StackDescriptor& descriptor, |
| 1717 | Optional<std::string&> reasonIfUnsupported) const |
| 1718 | { |
| 1719 | ignore_unused(descriptor); |
| 1720 | |
| 1721 | bool supported = true; |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1722 | std::array<DataType,4> supportedTypes = |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1723 | { |
| 1724 | DataType::Float32, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1725 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1726 | DataType::QAsymmU8, |
| 1727 | DataType::QSymmS16 |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1728 | }; |
| 1729 | |
| 1730 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1731 | "Reference stack: output type not supported"); |
| 1732 | for (const TensorInfo* input : inputs) |
| 1733 | { |
| 1734 | BOOST_ASSERT(input != nullptr); |
| 1735 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 1736 | "Reference stack: input type not supported"); |
| 1737 | |
| 1738 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 1739 | "Reference stack: input and output types mismatched."); |
| 1740 | } |
| 1741 | |
| 1742 | return supported; |
| 1743 | } |
| 1744 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1745 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 1746 | const TensorInfo& output, |
| 1747 | const StridedSliceDescriptor& descriptor, |
| 1748 | Optional<std::string&> reasonIfUnsupported) const |
| 1749 | { |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1750 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1751 | bool supported = true; |
| 1752 | |
| 1753 | std::array<DataType,3> supportedTypes = |
| 1754 | { |
| 1755 | DataType::Float32, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1756 | DataType::QAsymmU8, |
| 1757 | DataType::QSymmS16 |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1758 | }; |
| 1759 | |
| 1760 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1761 | "Reference StridedSlice: input type not supported"); |
| 1762 | |
| 1763 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1764 | "Reference StridedSlice: output type not supported"); |
| 1765 | |
| 1766 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1767 | "Reference StridedSlice: input and output types are mismatched"); |
| 1768 | |
| 1769 | return supported; |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1770 | } |
| 1771 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1772 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 1773 | const TensorInfo& input1, |
| 1774 | const TensorInfo& output, |
| 1775 | Optional<std::string&> reasonIfUnsupported) const |
| 1776 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1777 | bool supported = true; |
| 1778 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1779 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1780 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1781 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1782 | DataType::QAsymmU8, |
| 1783 | DataType::QSymmS16 |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1784 | }; |
| 1785 | |
| 1786 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1787 | "Reference subtraction: input 0 is not a supported type."); |
| 1788 | |
| 1789 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1790 | "Reference subtraction: input 1 is not a supported type."); |
| 1791 | |
| 1792 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1793 | "Reference subtraction: output is not a supported type."); |
| 1794 | |
| 1795 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1796 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 1797 | |
| 1798 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1799 | "Reference subtraction: input and output types are mismatched"); |
| 1800 | |
| 1801 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1802 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 1803 | |
| 1804 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1805 | } |
| 1806 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1807 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 1808 | const TensorInfo& alpha, |
| 1809 | const TensorInfo& output, |
| 1810 | Optional<std::string&> reasonIfUnsupported) const |
| 1811 | { |
| 1812 | bool supported = true; |
| 1813 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1814 | std::array<DataType, 4> supportedTypes |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1815 | { |
| 1816 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1817 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1818 | DataType::QAsymmU8, |
| 1819 | DataType::QSymmS16 |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1820 | }; |
| 1821 | |
| 1822 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1823 | "PReLU: input is not a supported type."); |
| 1824 | |
| 1825 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 1826 | "PReLU: alpha is not a supported type."); |
| 1827 | |
| 1828 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1829 | "PReLU: output is not a supported type."); |
| 1830 | |
| 1831 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 1832 | "PReLU: input, alpha and output types are mismatched"); |
| 1833 | |
| 1834 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 1835 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 1836 | |
| 1837 | return supported; |
| 1838 | } |
| 1839 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1840 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 1841 | const TensorInfo& output, |
| 1842 | const TransposeConvolution2dDescriptor& descriptor, |
| 1843 | const TensorInfo& weights, |
| 1844 | const Optional<TensorInfo>& biases, |
| 1845 | Optional<std::string&> reasonIfUnsupported) const |
| 1846 | { |
Derek Lamberti | 901ea11 | 2019-12-10 22:07:09 +0000 | [diff] [blame] | 1847 | boost::ignore_unused(descriptor); |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1848 | bool supported = true; |
| 1849 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1850 | std::array<DataType,4> supportedTypes = |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1851 | { |
| 1852 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1853 | DataType::Float16, |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1854 | DataType::QAsymmU8, |
| 1855 | DataType::QSymmS16 |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1856 | }; |
| 1857 | |
| 1858 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1859 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 1860 | |
| 1861 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1862 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 1863 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1864 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1865 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 1866 | |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1867 | |
| 1868 | const DataType inputType = input.GetDataType(); |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1869 | if (inputType == DataType::QAsymmU8) |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1870 | { |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 1871 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
| 1872 | std::array<DataType, 3> supportedWeightTypes = |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1873 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 1874 | DataType::QAsymmU8, |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 1875 | DataType::QSymmS8, |
| 1876 | DataType::QuantizedSymm8PerAxis //Deprecated |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1877 | }; |
Derek Lamberti | d466a54 | 2020-01-22 15:37:29 +0000 | [diff] [blame] | 1878 | ARMNN_NO_DEPRECATE_WARN_END |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1879 | |
| 1880 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 1881 | "Reference TransposeConvolution2d: weights type not supported for " |
| 1882 | "quantized input."); |
| 1883 | } |
| 1884 | else |
| 1885 | { |
| 1886 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1887 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 1888 | |
| 1889 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1890 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 1891 | } |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1892 | |
| 1893 | if (biases.has_value()) |
| 1894 | { |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1895 | std::array<DataType,3> biasesSupportedTypes = |
Aron Virginas-Tar | 651aafe | 2019-08-05 11:52:05 +0100 | [diff] [blame] | 1896 | { |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1897 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1898 | DataType::Float16, |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1899 | DataType::Signed32 |
| 1900 | }; |
| 1901 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1902 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 1903 | } |
| 1904 | |
| 1905 | return supported; |
| 1906 | } |
| 1907 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1908 | } // namespace armnn |