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