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