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