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