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