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