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