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