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 | { |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 651 | bool supported = true; |
| 652 | |
Mike Kelly | 4992c34 | 2019-08-14 11:33:11 +0100 | [diff] [blame] | 653 | std::array<DataType,3> supportedInputTypes = |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 654 | { |
| 655 | DataType::Float32, |
| 656 | DataType::QuantisedAsymm8, |
| 657 | DataType::QuantisedSymm16 |
| 658 | }; |
| 659 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 660 | supported &= CheckSupportRule(TypeAnyOf(boxEncodings, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 661 | "Reference DetectionPostProcess: input 0 is not a supported type."); |
| 662 | |
Derek Lamberti | 6a5e5e8 | 2019-12-05 14:41:20 +0000 | [diff] [blame] | 663 | supported &= CheckSupportRule(TypeAnyOf(scores, supportedInputTypes), reasonIfUnsupported, |
Aron Virginas-Tar | a37e1bd | 2019-06-06 16:08:30 +0100 | [diff] [blame] | 664 | "Reference DetectionPostProcess: input 1 is not a supported type."); |
| 665 | |
| 666 | return supported; |
Narumol Prangnawarat | bc67cef | 2019-01-31 15:31:54 +0000 | [diff] [blame] | 667 | } |
| 668 | |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 669 | bool RefLayerSupport::IsDilatedDepthwiseConvolutionSupported(const TensorInfo& input, |
| 670 | const TensorInfo& output, |
| 671 | const DepthwiseConvolution2dDescriptor& descriptor, |
| 672 | const TensorInfo& weights, |
| 673 | const Optional<TensorInfo>& biases, |
| 674 | Optional<std::string&> reasonIfUnsupported) const |
| 675 | { |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 676 | return IsDepthwiseConvolutionSupported(input, output, descriptor, weights, biases, reasonIfUnsupported); |
Pablo Tello | f0bd683 | 2019-04-26 17:58:13 +0100 | [diff] [blame] | 677 | } |
| 678 | |
Aron Virginas-Tar | aece4ed | 2019-06-14 17:00:09 +0100 | [diff] [blame] | 679 | bool RefLayerSupport::IsDivisionSupported(const TensorInfo& input0, |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 680 | const TensorInfo& input1, |
| 681 | const TensorInfo& output, |
| 682 | Optional<std::string&> reasonIfUnsupported) const |
| 683 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 684 | bool supported = true; |
| 685 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 686 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 687 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 688 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 689 | DataType::QuantisedAsymm8, |
| 690 | DataType::QuantisedSymm16 |
| 691 | }; |
| 692 | |
| 693 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 694 | "Reference division: input 0 is not a supported type."); |
| 695 | |
| 696 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 697 | "Reference division: input 1 is not a supported type."); |
| 698 | |
| 699 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 700 | "Reference division: output is not a supported type."); |
| 701 | |
| 702 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 703 | "Reference division: input 0 and Input 1 types are mismatched"); |
| 704 | |
| 705 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 706 | "Reference division: input and output types are mismatched"); |
| 707 | |
| 708 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 709 | "Reference division: shapes are not suitable for implicit broadcast."); |
| 710 | |
| 711 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 712 | } |
| 713 | |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 714 | bool RefLayerSupport::IsEqualSupported(const TensorInfo& input0, |
| 715 | const TensorInfo& input1, |
| 716 | const TensorInfo& output, |
| 717 | Optional<std::string&> reasonIfUnsupported) const |
| 718 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 719 | return IsComparisonSupported(input0, |
| 720 | input1, |
| 721 | output, |
| 722 | ComparisonDescriptor(ComparisonOperation::Equal), |
| 723 | reasonIfUnsupported); |
FrancisMurtagh | 30cdfca | 2018-12-18 12:57:35 +0000 | [diff] [blame] | 724 | } |
| 725 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 726 | bool RefLayerSupport::IsFakeQuantizationSupported(const TensorInfo& input, |
| 727 | const FakeQuantizationDescriptor& descriptor, |
| 728 | Optional<std::string&> reasonIfUnsupported) const |
| 729 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 730 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 731 | bool supported = true; |
| 732 | |
| 733 | std::array<DataType,1> supportedTypes = |
| 734 | { |
| 735 | DataType::Float32 |
| 736 | }; |
| 737 | |
| 738 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 739 | "Reference fake quantization: input type not supported."); |
| 740 | |
| 741 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | bool RefLayerSupport::IsFloorSupported(const TensorInfo& input, |
| 745 | const TensorInfo& output, |
| 746 | Optional<std::string&> reasonIfUnsupported) const |
| 747 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 748 | ignore_unused(output); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 749 | bool supported = true; |
| 750 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 751 | std::array<DataType,3> supportedTypes = |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 752 | { |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 753 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 754 | DataType::Float16, |
James Conroy | b40d710 | 2019-06-04 12:32:09 +0100 | [diff] [blame] | 755 | DataType::QuantisedSymm16 |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 756 | }; |
| 757 | |
| 758 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 759 | "Reference Floor: input type not supported."); |
| 760 | |
| 761 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 762 | "Reference Floor: output type not supported."); |
| 763 | |
| 764 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | bool RefLayerSupport::IsFullyConnectedSupported(const TensorInfo& input, |
| 768 | const TensorInfo& output, |
| 769 | const TensorInfo& weights, |
| 770 | const TensorInfo& biases, |
| 771 | const FullyConnectedDescriptor& descriptor, |
| 772 | Optional<std::string&> reasonIfUnsupported) const |
| 773 | { |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 774 | bool supported = true; |
| 775 | |
| 776 | // Define supported types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 777 | std::array<DataType,4> supportedTypes = |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 778 | { |
| 779 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 780 | DataType::Float16, |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 781 | DataType::QuantisedAsymm8, |
| 782 | DataType::QuantisedSymm16 |
| 783 | }; |
| 784 | |
| 785 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 786 | "Reference Fully Connected: input type not supported."); |
| 787 | |
| 788 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 789 | "Reference Fully Connected: output type not supported."); |
| 790 | |
| 791 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 792 | "Reference Fully Connected: input and output types mismatched."); |
| 793 | |
| 794 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 795 | "Reference Fully Connected: weights type not supported."); |
| 796 | |
| 797 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 798 | "Reference Fully Connected: input and weight types mismatched."); |
| 799 | |
| 800 | if (descriptor.m_BiasEnabled) |
| 801 | { |
| 802 | // Defined supported types for bias |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 803 | std::array<DataType, 3> |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 804 | supportedBiasTypes = |
| 805 | { |
| 806 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 807 | DataType::Float16, |
Francis Murtagh | 46c09d0 | 2019-05-28 08:15:28 +0100 | [diff] [blame] | 808 | DataType::Signed32 |
| 809 | }; |
| 810 | |
| 811 | supported &= CheckSupportRule(TypeAnyOf(biases, supportedBiasTypes), reasonIfUnsupported, |
| 812 | "Reference Fully Connected: bias type not supported."); |
| 813 | |
| 814 | supported &= CheckSupportRule(BiasAndWeightsTypesMatch(biases, weights), reasonIfUnsupported, |
| 815 | "Reference Fully Connected: bias and weight types mismatch."); |
| 816 | |
| 817 | supported &= CheckSupportRule(BiasAndWeightsTypesCompatible(weights, supportedBiasTypes), reasonIfUnsupported, |
| 818 | "Reference Fully Connected: bias type inferred from weights is incompatible."); |
| 819 | |
| 820 | } |
| 821 | |
| 822 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 823 | } |
| 824 | |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 825 | bool RefLayerSupport::IsGatherSupported(const armnn::TensorInfo& input0, |
| 826 | const armnn::TensorInfo& input1, |
| 827 | const armnn::TensorInfo& output, |
| 828 | armnn::Optional<std::string&> reasonIfUnsupported) const |
| 829 | { |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 830 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 831 | std::array<DataType,4> supportedTypes = |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 832 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 833 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 834 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 835 | DataType::QuantisedAsymm8, |
| 836 | DataType::QuantisedSymm16 |
Ellen Norris-Thompson | e0dbedf | 2019-06-24 09:23:38 +0100 | [diff] [blame] | 837 | }; |
| 838 | |
| 839 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 840 | "Reference Gather: input type not supported"); |
| 841 | |
| 842 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 843 | "Reference Gather: output type not supported"); |
| 844 | |
| 845 | supported &= CheckSupportRule(TypeIs(input1, DataType::Signed32), reasonIfUnsupported, |
| 846 | "Reference Gather: indices (input1) type not supported"); |
| 847 | |
| 848 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 849 | "Reference Gather: input and output types not matching"); |
| 850 | |
| 851 | return supported; |
narpra01 | 4951d84 | 2019-01-18 16:53:53 +0000 | [diff] [blame] | 852 | } |
| 853 | |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 854 | bool RefLayerSupport::IsGreaterSupported(const TensorInfo& input0, |
| 855 | const TensorInfo& input1, |
| 856 | const TensorInfo& output, |
| 857 | Optional<std::string&> reasonIfUnsupported) const |
| 858 | { |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 859 | return IsComparisonSupported(input0, |
| 860 | input1, |
| 861 | output, |
| 862 | ComparisonDescriptor(ComparisonOperation::Greater), |
| 863 | reasonIfUnsupported); |
FrancisMurtagh | 878f023 | 2018-12-19 10:56:15 +0000 | [diff] [blame] | 864 | } |
| 865 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 866 | bool RefLayerSupport::IsInputSupported(const TensorInfo& input, |
| 867 | Optional<std::string&> reasonIfUnsupported) const |
| 868 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 869 | return true; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 870 | } |
| 871 | |
Kevin May | 09ca49c | 2019-10-09 12:37:34 +0100 | [diff] [blame] | 872 | bool RefLayerSupport::IsInstanceNormalizationSupported(const TensorInfo& input, |
| 873 | const TensorInfo& output, |
| 874 | const InstanceNormalizationDescriptor& descriptor, |
| 875 | Optional<std::string&> reasonIfUnsupported) const |
| 876 | { |
| 877 | ignore_unused(descriptor); |
| 878 | // Define supported types |
| 879 | std::array<DataType, 4> supportedTypes = |
| 880 | { |
| 881 | DataType::Float32, |
| 882 | DataType::Float16 |
| 883 | }; |
| 884 | |
| 885 | bool supported = true; |
| 886 | |
| 887 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 888 | "Reference Instance Normalization: input type not supported."); |
| 889 | |
| 890 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 891 | "Reference Instance Normalization: output type not supported."); |
| 892 | |
| 893 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 894 | "Reference Instance Normalization: input and output types mismatched."); |
| 895 | |
| 896 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 897 | "Reference Instance Normalization: input and output shapes have different " |
| 898 | "num total elements."); |
| 899 | |
| 900 | return supported; |
| 901 | } |
| 902 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 903 | bool RefLayerSupport::IsL2NormalizationSupported(const TensorInfo& input, |
| 904 | const TensorInfo& output, |
| 905 | const L2NormalizationDescriptor& descriptor, |
| 906 | Optional<std::string&> reasonIfUnsupported) const |
| 907 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 908 | ignore_unused(descriptor); |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 909 | // Define supported types |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 910 | std::array<DataType, 4> supportedTypes = |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 911 | { |
| 912 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 913 | DataType::Float16, |
Ferran Balaguer | c6138d8 | 2019-06-13 17:23:50 +0100 | [diff] [blame] | 914 | DataType::QuantisedAsymm8, |
Ferran Balaguer | d73d14f | 2019-06-10 10:29:54 +0100 | [diff] [blame] | 915 | DataType::QuantisedSymm16 |
| 916 | }; |
| 917 | |
| 918 | bool supported = true; |
| 919 | |
| 920 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 921 | "Reference L2normalization: input type not supported."); |
| 922 | |
| 923 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 924 | "Reference L2normalization: output type not supported."); |
| 925 | |
| 926 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 927 | "Reference L2normalization: input and output types mismatched."); |
| 928 | |
| 929 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 930 | "Reference L2normalization: input and output shapes have different " |
| 931 | "num total elements."); |
| 932 | |
| 933 | return supported; |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 934 | } |
| 935 | |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 936 | bool RefLayerSupport::IsLogSoftmaxSupported(const TensorInfo& input, |
| 937 | const TensorInfo& output, |
| 938 | const LogSoftmaxDescriptor& descriptor, |
| 939 | Optional<std::string&> reasonIfUnsupported) const |
| 940 | { |
| 941 | ignore_unused(descriptor); |
| 942 | |
| 943 | std::array<DataType, 2> supportedTypes = |
| 944 | { |
| 945 | DataType::Float32, |
| 946 | DataType::Float16 |
| 947 | }; |
| 948 | |
| 949 | bool supported = true; |
| 950 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 951 | "Reference LogSoftmax: input type not supported"); |
| 952 | |
| 953 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 954 | "Reference LogSoftmax: output type not supported"); |
| 955 | |
| 956 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 957 | "Reference LogSoftmax: input and output types do not match"); |
| 958 | |
| 959 | return supported; |
| 960 | } |
| 961 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 962 | bool RefLayerSupport::IsLstmSupported(const TensorInfo& input, |
| 963 | const TensorInfo& outputStateIn, |
| 964 | const TensorInfo& cellStateIn, |
| 965 | const TensorInfo& scratchBuffer, |
| 966 | const TensorInfo& outputStateOut, |
| 967 | const TensorInfo& cellStateOut, |
| 968 | const TensorInfo& output, |
| 969 | const LstmDescriptor& descriptor, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 970 | const LstmInputParamsInfo& paramsInfo, |
| 971 | Optional<std::string&> reasonIfUnsupported) const |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 972 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 973 | ignore_unused(descriptor); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 974 | ignore_unused(paramsInfo); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 975 | |
| 976 | bool supported = true; |
| 977 | |
| 978 | std::array<DataType,2> supportedTypes = { |
Conor Kennedy | b9971c9 | 2019-05-07 07:14:23 +0100 | [diff] [blame] | 979 | DataType::Float32, |
| 980 | DataType::QuantisedSymm16 |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 981 | }; |
| 982 | |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 983 | // check inputs and outputs |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 984 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 985 | "Reference Lstm: input is not a supported type."); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 986 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateIn), reasonIfUnsupported, |
| 987 | "Reference Lstm: input and outputStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 988 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateIn), reasonIfUnsupported, |
| 989 | "Reference Lstm: input and cellStateIn types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 990 | supported &= CheckSupportRule(TypesAreEqual(input, scratchBuffer), reasonIfUnsupported, |
| 991 | "Reference Lstm: input and scratchBuffer types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 992 | supported &= CheckSupportRule(TypesAreEqual(input, outputStateOut), reasonIfUnsupported, |
| 993 | "Reference Lstm: input and outputStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 994 | supported &= CheckSupportRule(TypesAreEqual(input, cellStateOut), reasonIfUnsupported, |
| 995 | "Reference Lstm: input and cellStateOut types are mismatched"); |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 996 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 997 | "Reference Lstm: input and output types are mismatched"); |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 998 | // check layer parameters |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 999 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1000 | "Reference Lstm: input and InputToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1001 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1002 | "Reference Lstm: input and InputToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1003 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1004 | "Reference Lstm: input and InputToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1005 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1006 | "Reference Lstm: input and RecurrentToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1007 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToCellWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1008 | "Reference Lstm: input and RecurrentToCellWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1009 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1010 | "Reference Lstm: input and RecurrentToOutputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1011 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1012 | "Reference Lstm: input and ForgetGateBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1013 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1014 | "Reference Lstm: input and CellBias types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1015 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1016 | "Reference Lstm: input and OutputGateBias types are mismatched"); |
| 1017 | if (!descriptor.m_CifgEnabled) |
| 1018 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1019 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputToInputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1020 | "Reference Lstm: input and InputToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1021 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetRecurrentToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1022 | reasonIfUnsupported, |
| 1023 | "Reference Lstm: input and RecurrentToInputWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1024 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputGateBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1025 | "Reference Lstm: input and InputGateBias types are mismatched"); |
| 1026 | if (descriptor.m_PeepholeEnabled) |
| 1027 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1028 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToInputWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1029 | reasonIfUnsupported, |
| 1030 | "Reference Lstm: input and CellToInputWeights types are mismatched"); |
| 1031 | } |
| 1032 | } |
| 1033 | if (descriptor.m_PeepholeEnabled) |
| 1034 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1035 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToForgetWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1036 | "Reference Lstm: input and CellToForgetWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1037 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellToOutputWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1038 | "Reference Lstm: input and CellToOutputWeights types are mismatched"); |
| 1039 | } |
| 1040 | if (descriptor.m_ProjectionEnabled) |
| 1041 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1042 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionWeights()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1043 | "Reference Lstm: input and mProjectionWeights types are mismatched"); |
| 1044 | if (paramsInfo.m_ProjectionBias != nullptr) |
| 1045 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1046 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetProjectionBias()), reasonIfUnsupported, |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1047 | "Reference Lstm: input and ProjectionBias types are mismatched"); |
| 1048 | } |
| 1049 | } |
| 1050 | if (descriptor.m_LayerNormEnabled) |
| 1051 | { |
| 1052 | if (!descriptor.m_CifgEnabled) |
| 1053 | { |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1054 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetInputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1055 | reasonIfUnsupported, |
| 1056 | "Reference Lstm: input and InputLayerNormWeights types are mismatched"); |
| 1057 | } |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1058 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetForgetLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1059 | reasonIfUnsupported, |
| 1060 | "Reference Lstm: input and ForgetLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1061 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetCellLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1062 | reasonIfUnsupported, |
| 1063 | "Reference Lstm: input and CellLayerNormWeights types are mismatched"); |
Francis Murtagh | bb590b4 | 2019-08-14 09:51:36 +0100 | [diff] [blame] | 1064 | supported &= CheckSupportRule(TypesAreEqual(input, paramsInfo.GetOutputLayerNormWeights()), |
Jan Eilers | d01a83c | 2019-07-03 18:20:40 +0100 | [diff] [blame] | 1065 | reasonIfUnsupported, |
| 1066 | "Reference Lstm: input and OutputLayerNormWeights types are mismatched"); |
| 1067 | } |
Nattapat Chaimanowong | eb2b329 | 2019-05-07 12:02:30 +0100 | [diff] [blame] | 1068 | |
| 1069 | return supported; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1070 | } |
| 1071 | |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1072 | bool RefLayerSupport::IsMaximumSupported(const TensorInfo& input0, |
| 1073 | const TensorInfo& input1, |
| 1074 | const TensorInfo& output, |
| 1075 | Optional<std::string&> reasonIfUnsupported) const |
| 1076 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1077 | bool supported = true; |
| 1078 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1079 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1080 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1081 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1082 | DataType::QuantisedAsymm8, |
| 1083 | DataType::QuantisedSymm16 |
| 1084 | }; |
| 1085 | |
| 1086 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1087 | "Reference maximum: input 0 is not a supported type."); |
| 1088 | |
| 1089 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1090 | "Reference maximum: input 1 is not a supported type."); |
| 1091 | |
| 1092 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1093 | "Reference maximum: output is not a supported type."); |
| 1094 | |
| 1095 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1096 | "Reference maximum: input 0 and Input 1 types are mismatched"); |
| 1097 | |
| 1098 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1099 | "Reference maximum: input and output types are mismatched"); |
| 1100 | |
| 1101 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1102 | "Reference maximum: shapes are not suitable for implicit broadcast."); |
| 1103 | |
| 1104 | return supported; |
saoste01 | 2df12b3 | 2018-11-28 16:57:20 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1107 | bool RefLayerSupport::IsMeanSupported(const TensorInfo& input, |
| 1108 | const TensorInfo& output, |
| 1109 | const MeanDescriptor& descriptor, |
| 1110 | Optional<std::string&> reasonIfUnsupported) const |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1111 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1112 | bool supported = true; |
| 1113 | std::string meanLayerStr = "Mean"; |
| 1114 | std::string outputTensorStr = "output"; |
| 1115 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1116 | std::array<DataType,4> supportedTypes = |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1117 | { |
| 1118 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1119 | DataType::Float16, |
James Conroy | b80775f | 2019-06-11 11:25:30 +0100 | [diff] [blame] | 1120 | DataType::QuantisedAsymm8, |
| 1121 | DataType::QuantisedSymm16 |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1122 | }; |
| 1123 | |
| 1124 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1125 | "Reference Mean: input type not supported."); |
| 1126 | |
| 1127 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1128 | "Reference Mean: input and output types are mismatched"); |
| 1129 | |
| 1130 | if (descriptor.m_KeepDims) |
| 1131 | { |
| 1132 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, input.GetNumDimensions()), |
| 1133 | reasonIfUnsupported, |
| 1134 | CreateIncorrectDimensionsErrorMsg(input.GetNumDimensions(), |
| 1135 | output.GetNumDimensions(), |
| 1136 | meanLayerStr, outputTensorStr).data()); |
| 1137 | } |
| 1138 | else if (descriptor.m_Axis.empty()) |
| 1139 | { |
| 1140 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1141 | reasonIfUnsupported, |
| 1142 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1143 | meanLayerStr, outputTensorStr).data()); |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | auto outputDim = input.GetNumDimensions() - boost::numeric_cast<unsigned int>(descriptor.m_Axis.size()); |
| 1148 | |
| 1149 | if (outputDim > 0) |
| 1150 | { |
| 1151 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, outputDim), |
| 1152 | reasonIfUnsupported, |
| 1153 | CreateIncorrectDimensionsErrorMsg(outputDim, output.GetNumDimensions(), |
| 1154 | meanLayerStr, outputTensorStr).data()); |
| 1155 | } |
| 1156 | else |
| 1157 | { |
| 1158 | supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 1), |
| 1159 | reasonIfUnsupported, |
| 1160 | CreateIncorrectDimensionsErrorMsg(1, output.GetNumDimensions(), |
| 1161 | meanLayerStr, outputTensorStr).data()); |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | return supported; |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 1166 | } |
| 1167 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1168 | bool RefLayerSupport::IsMergerSupported(const std::vector<const TensorInfo*> inputs, |
Nikhil Raj | 8599a41 | 2018-11-19 14:51:07 +0000 | [diff] [blame] | 1169 | const TensorInfo& output, |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1170 | const MergerDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1171 | Optional<std::string&> reasonIfUnsupported) const |
| 1172 | { |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 1173 | return IsConcatSupported(inputs, output, descriptor, reasonIfUnsupported); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1174 | } |
| 1175 | |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1176 | bool RefLayerSupport::IsMemCopySupported(const TensorInfo &input, |
| 1177 | const TensorInfo &output, |
| 1178 | Optional<std::string &> reasonIfUnsupported) const |
| 1179 | { |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1180 | bool supported = true; |
| 1181 | |
| 1182 | std::array<DataType,5> supportedTypes = |
| 1183 | { |
| 1184 | DataType::Float32, |
| 1185 | DataType::Float16, |
| 1186 | DataType::QuantisedAsymm8, |
| 1187 | DataType::QuantisedSymm16, |
| 1188 | DataType::Boolean |
| 1189 | }; |
| 1190 | |
| 1191 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1192 | "Reference MemCopy: input type not supported"); |
| 1193 | |
| 1194 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1195 | "Reference MemCopy: output type not supported"); |
| 1196 | |
| 1197 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1198 | "Reference MemCopy: input and output types are mismatched"); |
| 1199 | |
| 1200 | return supported; |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1203 | bool RefLayerSupport::IsMinimumSupported(const TensorInfo& input0, |
| 1204 | const TensorInfo& input1, |
| 1205 | const TensorInfo& output, |
| 1206 | Optional<std::string&> reasonIfUnsupported) const |
| 1207 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1208 | bool supported = true; |
| 1209 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1210 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1211 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1212 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1213 | DataType::QuantisedAsymm8, |
| 1214 | DataType::QuantisedSymm16 |
| 1215 | }; |
| 1216 | |
| 1217 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1218 | "Reference minimum: input 0 is not a supported type."); |
| 1219 | |
| 1220 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1221 | "Reference minimum: input 1 is not a supported type."); |
| 1222 | |
| 1223 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1224 | "Reference minimum: output is not a supported type."); |
| 1225 | |
| 1226 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1227 | "Reference minimum: input 0 and Input 1 types are mismatched"); |
| 1228 | |
| 1229 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1230 | "Reference minimum: input and output types are mismatched"); |
| 1231 | |
| 1232 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1233 | "Reference minimum: shapes are not suitable for implicit broadcast."); |
| 1234 | |
| 1235 | return supported; |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 1236 | } |
| 1237 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1238 | bool RefLayerSupport::IsMultiplicationSupported(const TensorInfo& input0, |
| 1239 | const TensorInfo& input1, |
| 1240 | const TensorInfo& output, |
| 1241 | Optional<std::string&> reasonIfUnsupported) const |
| 1242 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1243 | bool supported = true; |
| 1244 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1245 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1246 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1247 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1248 | DataType::QuantisedAsymm8, |
| 1249 | DataType::QuantisedSymm16 |
| 1250 | }; |
| 1251 | |
| 1252 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1253 | "Reference multiplication: input 0 is not a supported type."); |
| 1254 | |
| 1255 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1256 | "Reference multiplication: input 1 is not a supported type."); |
| 1257 | |
| 1258 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1259 | "Reference multiplication: output is not a supported type."); |
| 1260 | |
| 1261 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1262 | "Reference multiplication: input 0 and Input 1 types are mismatched"); |
| 1263 | |
| 1264 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1265 | "Reference multiplication: input and output types are mismatched"); |
| 1266 | |
| 1267 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1268 | "Reference multiplication: shapes are not suitable for implicit broadcast."); |
| 1269 | |
| 1270 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | bool RefLayerSupport::IsNormalizationSupported(const TensorInfo& input, |
| 1274 | const TensorInfo& output, |
| 1275 | const NormalizationDescriptor& descriptor, |
| 1276 | Optional<std::string&> reasonIfUnsupported) const |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1277 | { |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1278 | ignore_unused(descriptor); |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1279 | |
| 1280 | // Define supported types |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1281 | std::array<DataType, 4> supportedTypes = |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1282 | { |
| 1283 | DataType::Float16, |
| 1284 | DataType::Float32, |
Matteo Martincigh | 6aeb771 | 2019-06-05 17:23:29 +0100 | [diff] [blame] | 1285 | DataType::QuantisedAsymm8, |
| 1286 | DataType::QuantisedSymm16 |
Matteo Martincigh | 2fc70c5 | 2019-06-05 14:12:48 +0100 | [diff] [blame] | 1287 | }; |
| 1288 | |
| 1289 | bool supported = true; |
| 1290 | |
| 1291 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1292 | "Reference normalization: input type not supported."); |
| 1293 | |
| 1294 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1295 | "Reference normalization: output type not supported."); |
| 1296 | |
| 1297 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1298 | "Reference normalization: input and output shapes have different " |
| 1299 | "num total elements."); |
| 1300 | |
| 1301 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | bool RefLayerSupport::IsOutputSupported(const TensorInfo& output, |
| 1305 | Optional<std::string&> reasonIfUnsupported) const |
| 1306 | { |
Narumol Prangnawarat | b6441e4 | 2019-06-04 11:22:00 +0100 | [diff] [blame] | 1307 | return true; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | bool RefLayerSupport::IsPadSupported(const TensorInfo& input, |
| 1311 | const TensorInfo& output, |
| 1312 | const PadDescriptor& descriptor, |
| 1313 | Optional<std::string&> reasonIfUnsupported) const |
| 1314 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1315 | ignore_unused(descriptor); |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1316 | bool supported = true; |
| 1317 | |
| 1318 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1319 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1320 | { |
| 1321 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1322 | DataType::Float16, |
Narumol Prangnawarat | e6eaf66 | 2019-07-08 08:57:17 +0100 | [diff] [blame] | 1323 | DataType::QuantisedAsymm8, |
| 1324 | DataType::QuantisedSymm16 |
| 1325 | }; |
| 1326 | |
| 1327 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1328 | "Reference pad: input is not a supported type."); |
| 1329 | |
| 1330 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1331 | "Reference pad: output is not a supported type."); |
| 1332 | |
| 1333 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1334 | "Reference pad: input and output types are mismatched."); |
| 1335 | |
| 1336 | return supported; |
Nina Drozd | 661dfa7 | 2018-10-02 11:14:17 +0100 | [diff] [blame] | 1337 | } |
| 1338 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1339 | bool RefLayerSupport::IsPermuteSupported(const TensorInfo& input, |
| 1340 | const TensorInfo& output, |
| 1341 | const PermuteDescriptor& descriptor, |
| 1342 | Optional<std::string&> reasonIfUnsupported) const |
| 1343 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1344 | ignore_unused(descriptor); |
Narumol Prangnawarat | 86bb4e1 | 2019-07-08 11:36:05 +0100 | [diff] [blame] | 1345 | bool supported = true; |
| 1346 | |
| 1347 | // Define supported output and inputs types. |
| 1348 | std::array<DataType,3> supportedTypes = |
| 1349 | { |
| 1350 | DataType::Float32, |
| 1351 | DataType::QuantisedAsymm8, |
| 1352 | DataType::QuantisedSymm16 |
| 1353 | }; |
| 1354 | |
| 1355 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1356 | "Reference permute: input is not a supported type."); |
| 1357 | |
| 1358 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1359 | "Reference permute: output is not a supported type."); |
| 1360 | |
| 1361 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1362 | "Reference permute: input and output types are mismatched."); |
| 1363 | |
| 1364 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1365 | } |
| 1366 | |
| 1367 | bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, |
| 1368 | const TensorInfo& output, |
| 1369 | const Pooling2dDescriptor& descriptor, |
| 1370 | Optional<std::string&> reasonIfUnsupported) const |
| 1371 | { |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1372 | ignore_unused(descriptor); |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1373 | bool supported = true; |
| 1374 | |
| 1375 | // Define supported output and inputs types. |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1376 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1377 | { |
| 1378 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1379 | DataType::Float16, |
Teresa Charlin | 0434df6 | 2019-06-06 13:40:35 +0100 | [diff] [blame] | 1380 | DataType::QuantisedAsymm8, |
| 1381 | DataType::QuantisedSymm16 |
Teresa Charlin | a3b2047 | 2019-06-06 11:12:32 +0100 | [diff] [blame] | 1382 | }; |
| 1383 | |
| 1384 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1385 | "Reference poolind2d: input is not a supported type."); |
| 1386 | |
| 1387 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1388 | "Reference poolind2d: output is not a supported type."); |
| 1389 | |
| 1390 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1391 | "Reference poolind2d: input and output types are mismatched."); |
| 1392 | |
| 1393 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1394 | } |
| 1395 | |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1396 | bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, |
| 1397 | const TensorInfo& output, |
| 1398 | Optional<std::string&> reasonIfUnsupported) const |
| 1399 | { |
| 1400 | bool supported = true; |
| 1401 | |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1402 | // Define supported input types. |
Sadik Armagan | 1a81630 | 2019-07-29 17:16:40 +0100 | [diff] [blame] | 1403 | std::array<DataType,1> supportedInputTypes = { |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1404 | DataType::Float32, |
| 1405 | }; |
| 1406 | |
| 1407 | supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, |
| 1408 | "Reference quantize: input type not supported."); |
| 1409 | |
| 1410 | // Define supported output types. |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1411 | std::array<DataType,3> supportedOutputTypes = { |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1412 | DataType::QuantisedAsymm8, |
Finn Williams | fd27106 | 2019-12-04 14:27:27 +0000 | [diff] [blame] | 1413 | DataType::QSymmS8, |
Derek Lamberti | 5f400d6 | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 1414 | DataType::QuantisedSymm16 |
| 1415 | }; |
| 1416 | supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, |
| 1417 | "Reference quantize: output type not supported."); |
| 1418 | |
| 1419 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1420 | "Reference quantize: input and output shapes have different num total elements."); |
| 1421 | |
| 1422 | return supported; |
| 1423 | } |
| 1424 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1425 | bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1426 | const ReshapeDescriptor& descriptor, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1427 | Optional<std::string&> reasonIfUnsupported) const |
| 1428 | { |
Matteo Martincigh | 992d6dc | 2019-01-10 17:34:20 +0000 | [diff] [blame] | 1429 | ignore_unused(descriptor); |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1430 | // Define supported output types. |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1431 | std::array<DataType,5> supportedOutputTypes = |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1432 | { |
| 1433 | DataType::Float32, |
| 1434 | DataType::Float16, |
Narumol Prangnawarat | 0718ee9 | 2019-09-13 16:53:38 +0100 | [diff] [blame] | 1435 | DataType::Signed32, |
Nina Drozd | 8ed4b8c | 2019-05-29 10:41:04 +0100 | [diff] [blame] | 1436 | DataType::QuantisedAsymm8, |
| 1437 | DataType::QuantisedSymm16 |
Nina Drozd | 2f2778f | 2019-05-27 10:37:05 +0100 | [diff] [blame] | 1438 | }; |
| 1439 | return CheckSupportRule(TypeAnyOf(input, supportedOutputTypes), reasonIfUnsupported, |
| 1440 | "Reference reshape: input type not supported."); |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | bool RefLayerSupport::IsResizeBilinearSupported(const TensorInfo& input, |
Sadik Armagan | c625f00 | 2018-12-17 11:32:16 +0000 | [diff] [blame] | 1444 | const TensorInfo& output, |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1445 | Optional<std::string&> reasonIfUnsupported) const |
| 1446 | { |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1447 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1448 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1449 | { |
| 1450 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1451 | DataType::Float16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1452 | DataType::QuantisedAsymm8, |
| 1453 | DataType::QuantisedSymm16 |
| 1454 | }; |
Ellen Norris-Thompson | 3cb85f3 | 2019-06-17 11:32:49 +0100 | [diff] [blame] | 1455 | |
| 1456 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1457 | "Reference ResizeBilinear: input type not supported"); |
| 1458 | |
| 1459 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1460 | "Reference ResizeBilinear: output type not supported"); |
| 1461 | |
| 1462 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1463 | "Reference ResizeBilinear: input and output types not matching"); |
| 1464 | |
| 1465 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1466 | } |
| 1467 | |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1468 | bool RefLayerSupport::IsResizeSupported(const TensorInfo& input, |
| 1469 | const TensorInfo& output, |
| 1470 | const ResizeDescriptor& descriptor, |
| 1471 | Optional<std::string&> reasonIfUnsupported) const |
| 1472 | { |
| 1473 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1474 | std::array<DataType,4> supportedTypes = |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1475 | { |
| 1476 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1477 | DataType::Float16, |
Teresa Charlin | 970f43b | 2019-07-01 13:51:07 +0100 | [diff] [blame] | 1478 | DataType::QuantisedAsymm8, |
| 1479 | DataType::QuantisedSymm16 |
| 1480 | }; |
| 1481 | |
| 1482 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1483 | "Reference Resize: input type not supported"); |
| 1484 | |
| 1485 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1486 | "Reference Resize: output type not supported"); |
| 1487 | |
| 1488 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1489 | "Reference Resize: input and output types not matching"); |
| 1490 | |
| 1491 | return supported; |
| 1492 | } |
| 1493 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1494 | bool RefLayerSupport::IsRsqrtSupported(const TensorInfo& input, |
| 1495 | const TensorInfo& output, |
| 1496 | Optional<std::string&> reasonIfUnsupported) const |
| 1497 | { |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1498 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1499 | std::array<DataType,4> supportedTypes = |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1500 | { |
| 1501 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1502 | DataType::Float16, |
nikraj01 | 24d7321 | 2019-06-14 14:20:40 +0100 | [diff] [blame] | 1503 | DataType::QuantisedAsymm8, |
| 1504 | DataType::QuantisedSymm16 |
nikraj01 | 0421e7f | 2019-06-14 09:40:34 +0100 | [diff] [blame] | 1505 | }; |
| 1506 | |
| 1507 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1508 | "Reference rsqrt: input type not supported"); |
| 1509 | |
| 1510 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1511 | "Reference rsqrt: output type not supported"); |
| 1512 | |
| 1513 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1514 | "Reference rsqrt: input and output types not matching"); |
| 1515 | |
| 1516 | supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, |
| 1517 | "Reference Rsqrt: input and output shapes have different number of total elements"); |
| 1518 | |
| 1519 | return supported; |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 1520 | } |
| 1521 | |
Aron Virginas-Tar | 92b9f87 | 2019-09-17 17:27:04 +0100 | [diff] [blame] | 1522 | bool RefLayerSupport::IsSliceSupported(const TensorInfo& input, |
| 1523 | const TensorInfo& output, |
| 1524 | const SliceDescriptor& descriptor, |
| 1525 | Optional<std::string&> reasonIfUnsupported) const |
| 1526 | { |
| 1527 | ignore_unused(descriptor); |
| 1528 | bool supported = true; |
| 1529 | |
| 1530 | std::array<DataType, 3> supportedTypes = |
| 1531 | { |
| 1532 | DataType::Float32, |
| 1533 | DataType::QuantisedAsymm8, |
| 1534 | DataType::QuantisedSymm16 |
| 1535 | }; |
| 1536 | |
| 1537 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1538 | "Reference Slice: input type not supported"); |
| 1539 | |
| 1540 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1541 | "Reference Slice: output type not supported"); |
| 1542 | |
| 1543 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1544 | "Reference Slice: input and output types are mismatched"); |
| 1545 | |
| 1546 | return supported; |
| 1547 | } |
| 1548 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1549 | bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, |
| 1550 | const TensorInfo& output, |
| 1551 | const SoftmaxDescriptor& descriptor, |
| 1552 | Optional<std::string&> reasonIfUnsupported) const |
| 1553 | { |
| 1554 | ignore_unused(output); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1555 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1556 | std::array<DataType,4> supportedTypes = |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1557 | { |
| 1558 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1559 | DataType::Float16, |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1560 | DataType::QuantisedAsymm8, |
| 1561 | DataType::QuantisedSymm16 |
| 1562 | }; |
| 1563 | |
| 1564 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1565 | "Reference Softmax: output type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1566 | |
| 1567 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
Aron Virginas-Tar | e662a94 | 2019-10-14 15:12:00 +0100 | [diff] [blame] | 1568 | "Reference Softmax: input type not supported"); |
nikraj01 | 248683f | 2019-05-29 16:46:50 +0100 | [diff] [blame] | 1569 | |
| 1570 | supported &= CheckSupportRule(TypesAreEqual(input, output), 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 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1574 | } |
| 1575 | |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1576 | bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, |
| 1577 | const TensorInfo& output, |
| 1578 | const SpaceToBatchNdDescriptor& descriptor, |
| 1579 | Optional<std::string&> reasonIfUnsupported) const |
| 1580 | { |
| 1581 | ignore_unused(output); |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1582 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1583 | std::array<DataType,4> supportedTypes = |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1584 | { |
| 1585 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1586 | DataType::Float16, |
nikraj01 | 120522a | 2019-05-31 11:33:07 +0100 | [diff] [blame] | 1587 | DataType::QuantisedAsymm8, |
| 1588 | DataType::QuantisedSymm16 |
| 1589 | }; |
| 1590 | |
| 1591 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1592 | "Reference SpaceToBatchNd: input type not supported"); |
| 1593 | |
| 1594 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1595 | "Reference SpaceToBatchNd: output type not supported"); |
| 1596 | |
| 1597 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1598 | "Reference SpaceToBatchNd: input and output types are mismatched"); |
| 1599 | |
| 1600 | return supported; |
Nattapat Chaimanowong | 3ea76d5 | 2018-11-09 14:10:38 +0000 | [diff] [blame] | 1601 | } |
| 1602 | |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1603 | bool RefLayerSupport::IsSpaceToDepthSupported(const TensorInfo& input, |
Keith Davis | 5191033 | 2019-06-26 15:28:43 +0100 | [diff] [blame] | 1604 | const TensorInfo& output, |
| 1605 | const SpaceToDepthDescriptor& descriptor, |
| 1606 | Optional<std::string&> reasonIfUnsupported) const |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1607 | { |
| 1608 | |
| 1609 | ignore_unused(descriptor); |
| 1610 | bool supported = true; |
| 1611 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1612 | std::array<DataType,4> supportedTypes = |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1613 | { |
| 1614 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1615 | DataType::Float16, |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1616 | DataType::QuantisedAsymm8, |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 1617 | DataType::QuantisedSymm16 |
Keith Davis | a57eccb | 2019-06-14 17:33:22 +0100 | [diff] [blame] | 1618 | }; |
| 1619 | |
| 1620 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1621 | "Reference SpaceToDepth: input type not supported"); |
| 1622 | |
| 1623 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1624 | "Reference SpaceToDepth: output type not supported"); |
| 1625 | |
| 1626 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1627 | "Reference SpaceToDepth: input and output types are mismatched"); |
| 1628 | |
| 1629 | return supported; |
| 1630 | } |
| 1631 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1632 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1633 | const ViewsDescriptor& descriptor, |
| 1634 | Optional<std::string&> reasonIfUnsupported) const |
| 1635 | { |
| 1636 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1637 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1638 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1639 | { |
| 1640 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1641 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1642 | DataType::QuantisedAsymm8, |
| 1643 | DataType::QuantisedSymm16 |
| 1644 | }; |
| 1645 | |
| 1646 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1647 | "Reference splitter: input type not supported"); |
| 1648 | |
| 1649 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1650 | } |
| 1651 | |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1652 | bool RefLayerSupport::IsSplitterSupported(const TensorInfo& input, |
| 1653 | const std::vector<std::reference_wrapper<TensorInfo>>& outputs, |
| 1654 | const ViewsDescriptor& descriptor, |
| 1655 | Optional<std::string&> reasonIfUnsupported) const |
| 1656 | { |
| 1657 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1658 | bool supported = true; |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1659 | std::array<DataType,4> supportedTypes = |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1660 | { |
| 1661 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1662 | DataType::Float16, |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1663 | DataType::QuantisedAsymm8, |
| 1664 | DataType::QuantisedSymm16 |
| 1665 | }; |
| 1666 | |
| 1667 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1668 | "Reference splitter: output type not supported"); |
| 1669 | for (const TensorInfo output : outputs) |
| 1670 | { |
| 1671 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1672 | "Reference splitter: input type not supported"); |
| 1673 | |
| 1674 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1675 | "Reference splitter: input and output types mismatched."); |
| 1676 | } |
| 1677 | |
| 1678 | return supported; |
Narumol Prangnawarat | 15eb583 | 2019-05-20 15:31:05 +0100 | [diff] [blame] | 1679 | } |
| 1680 | |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1681 | bool RefLayerSupport::IsStackSupported(const std::vector<const TensorInfo*>& inputs, |
| 1682 | const TensorInfo& output, |
| 1683 | const StackDescriptor& descriptor, |
| 1684 | Optional<std::string&> reasonIfUnsupported) const |
| 1685 | { |
| 1686 | ignore_unused(descriptor); |
| 1687 | |
| 1688 | bool supported = true; |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1689 | std::array<DataType,4> supportedTypes = |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1690 | { |
| 1691 | DataType::Float32, |
Matthew Jackson | e69c399 | 2019-09-09 14:31:21 +0100 | [diff] [blame] | 1692 | DataType::Float16, |
Matthew Jackson | 81e601c | 2019-07-11 12:07:09 +0100 | [diff] [blame] | 1693 | DataType::QuantisedAsymm8, |
| 1694 | DataType::QuantisedSymm16 |
| 1695 | }; |
| 1696 | |
| 1697 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1698 | "Reference stack: output type not supported"); |
| 1699 | for (const TensorInfo* input : inputs) |
| 1700 | { |
| 1701 | BOOST_ASSERT(input != nullptr); |
| 1702 | supported &= CheckSupportRule(TypeAnyOf(*input, supportedTypes), reasonIfUnsupported, |
| 1703 | "Reference stack: input type not supported"); |
| 1704 | |
| 1705 | supported &= CheckSupportRule(TypesAreEqual(*input, output), reasonIfUnsupported, |
| 1706 | "Reference stack: input and output types mismatched."); |
| 1707 | } |
| 1708 | |
| 1709 | return supported; |
| 1710 | } |
| 1711 | |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1712 | bool RefLayerSupport::IsStridedSliceSupported(const TensorInfo& input, |
| 1713 | const TensorInfo& output, |
| 1714 | const StridedSliceDescriptor& descriptor, |
| 1715 | Optional<std::string&> reasonIfUnsupported) const |
| 1716 | { |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1717 | ignore_unused(descriptor); |
Narumol Prangnawarat | f9ac3fd | 2019-07-03 14:55:57 +0100 | [diff] [blame] | 1718 | bool supported = true; |
| 1719 | |
| 1720 | std::array<DataType,3> supportedTypes = |
| 1721 | { |
| 1722 | DataType::Float32, |
| 1723 | DataType::QuantisedAsymm8, |
| 1724 | DataType::QuantisedSymm16 |
| 1725 | }; |
| 1726 | |
| 1727 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1728 | "Reference StridedSlice: input type not supported"); |
| 1729 | |
| 1730 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1731 | "Reference StridedSlice: output type not supported"); |
| 1732 | |
| 1733 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1734 | "Reference StridedSlice: input and output types are mismatched"); |
| 1735 | |
| 1736 | return supported; |
Nattapat Chaimanowong | 1216b58 | 2018-11-23 15:33:41 +0000 | [diff] [blame] | 1737 | } |
| 1738 | |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1739 | bool RefLayerSupport::IsSubtractionSupported(const TensorInfo& input0, |
| 1740 | const TensorInfo& input1, |
| 1741 | const TensorInfo& output, |
| 1742 | Optional<std::string&> reasonIfUnsupported) const |
| 1743 | { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1744 | bool supported = true; |
| 1745 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1746 | std::array<DataType,4> supportedTypes = { |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1747 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1748 | DataType::Float16, |
Sadik Armagan | 2999a02 | 2019-04-09 14:20:12 +0100 | [diff] [blame] | 1749 | DataType::QuantisedAsymm8, |
| 1750 | DataType::QuantisedSymm16 |
| 1751 | }; |
| 1752 | |
| 1753 | supported &= CheckSupportRule(TypeAnyOf(input0, supportedTypes), reasonIfUnsupported, |
| 1754 | "Reference subtraction: input 0 is not a supported type."); |
| 1755 | |
| 1756 | supported &= CheckSupportRule(TypeAnyOf(input1, supportedTypes), reasonIfUnsupported, |
| 1757 | "Reference subtraction: input 1 is not a supported type."); |
| 1758 | |
| 1759 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1760 | "Reference subtraction: output is not a supported type."); |
| 1761 | |
| 1762 | supported &= CheckSupportRule(TypesAreEqual(input0, input1), reasonIfUnsupported, |
| 1763 | "Reference subtraction: input 0 and Input 1 types are mismatched"); |
| 1764 | |
| 1765 | supported &= CheckSupportRule(TypesAreEqual(input0, output), reasonIfUnsupported, |
| 1766 | "Reference subtraction: input and output types are mismatched"); |
| 1767 | |
| 1768 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input0, input1, output), reasonIfUnsupported, |
| 1769 | "Reference subtraction: shapes are not suitable for implicit broadcast."); |
| 1770 | |
| 1771 | return supported; |
Aron Virginas-Tar | b5acbb7 | 2018-10-15 11:11:51 +0100 | [diff] [blame] | 1772 | } |
| 1773 | |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1774 | bool RefLayerSupport::IsPreluSupported(const TensorInfo& input, |
| 1775 | const TensorInfo& alpha, |
| 1776 | const TensorInfo& output, |
| 1777 | Optional<std::string&> reasonIfUnsupported) const |
| 1778 | { |
| 1779 | bool supported = true; |
| 1780 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1781 | std::array<DataType, 4> supportedTypes |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1782 | { |
| 1783 | DataType::Float32, |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 1784 | DataType::Float16, |
Matteo Martincigh | ab9e525 | 2019-06-13 17:27:46 +0100 | [diff] [blame] | 1785 | DataType::QuantisedAsymm8, |
| 1786 | DataType::QuantisedSymm16 |
| 1787 | }; |
| 1788 | |
| 1789 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1790 | "PReLU: input is not a supported type."); |
| 1791 | |
| 1792 | supported &= CheckSupportRule(TypeAnyOf(alpha, supportedTypes), reasonIfUnsupported, |
| 1793 | "PReLU: alpha is not a supported type."); |
| 1794 | |
| 1795 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1796 | "PReLU: output is not a supported type."); |
| 1797 | |
| 1798 | supported &= CheckSupportRule(TypesAreEqual(input, alpha, output), reasonIfUnsupported, |
| 1799 | "PReLU: input, alpha and output types are mismatched"); |
| 1800 | |
| 1801 | supported &= CheckSupportRule(ShapesAreBroadcastCompatible(input, alpha, output), reasonIfUnsupported, |
| 1802 | "PReLU: shapes are not suitable for implicit broadcast"); |
| 1803 | |
| 1804 | return supported; |
| 1805 | } |
| 1806 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1807 | bool RefLayerSupport::IsTransposeConvolution2dSupported(const TensorInfo& input, |
| 1808 | const TensorInfo& output, |
| 1809 | const TransposeConvolution2dDescriptor& descriptor, |
| 1810 | const TensorInfo& weights, |
| 1811 | const Optional<TensorInfo>& biases, |
| 1812 | Optional<std::string&> reasonIfUnsupported) const |
| 1813 | { |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1814 | bool supported = true; |
| 1815 | |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1816 | std::array<DataType,4> supportedTypes = |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1817 | { |
| 1818 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1819 | DataType::Float16, |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1820 | DataType::QuantisedAsymm8, |
| 1821 | DataType::QuantisedSymm16 |
| 1822 | }; |
| 1823 | |
| 1824 | supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, |
| 1825 | "Reference TransposeConvolution2d: input is not a supported type."); |
| 1826 | |
| 1827 | supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, |
| 1828 | "Reference TransposeConvolution2d: output is not a supported type."); |
| 1829 | |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1830 | supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, |
| 1831 | "Reference TransposeConvolution2d: input and output types mismatched."); |
| 1832 | |
Aron Virginas-Tar | 94d3b93 | 2019-11-11 12:54:47 +0000 | [diff] [blame] | 1833 | |
| 1834 | const DataType inputType = input.GetDataType(); |
| 1835 | if (inputType == DataType::QuantisedAsymm8) |
| 1836 | { |
| 1837 | std::array<DataType, 2> supportedWeightTypes = |
| 1838 | { |
| 1839 | DataType::QuantisedAsymm8, |
| 1840 | DataType::QuantizedSymm8PerAxis |
| 1841 | }; |
| 1842 | |
| 1843 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedWeightTypes), reasonIfUnsupported, |
| 1844 | "Reference TransposeConvolution2d: weights type not supported for " |
| 1845 | "quantized input."); |
| 1846 | } |
| 1847 | else |
| 1848 | { |
| 1849 | supported &= CheckSupportRule(TypeAnyOf(weights, supportedTypes), reasonIfUnsupported, |
| 1850 | "Reference TransposeConvolution2d: weights is not a supported type."); |
| 1851 | |
| 1852 | supported &= CheckSupportRule(TypesAreEqual(input, weights), reasonIfUnsupported, |
| 1853 | "Reference TransposeConvolution2d: input and weights types mismatched."); |
| 1854 | } |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1855 | |
| 1856 | if (biases.has_value()) |
| 1857 | { |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1858 | std::array<DataType,3> biasesSupportedTypes = |
Aron Virginas-Tar | 651aafe | 2019-08-05 11:52:05 +0100 | [diff] [blame] | 1859 | { |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1860 | DataType::Float32, |
Matthew Jackson | 252df3a | 2019-09-11 09:19:18 +0100 | [diff] [blame] | 1861 | DataType::Float16, |
Aron Virginas-Tar | 98180ef | 2019-06-26 15:02:47 +0100 | [diff] [blame] | 1862 | DataType::Signed32 |
| 1863 | }; |
| 1864 | supported &= CheckSupportRule(TypeAnyOf(biases.value(), biasesSupportedTypes), reasonIfUnsupported, |
| 1865 | "Reference TransposeConvolution2d: biases is not a supported type."); |
| 1866 | } |
| 1867 | |
| 1868 | return supported; |
| 1869 | } |
| 1870 | |
arovir01 | 1c7c81b | 2018-10-08 11:34:28 +0100 | [diff] [blame] | 1871 | } // namespace armnn |