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