diff options
Diffstat (limited to 'src/backends/reference/RefLayerSupport.cpp')
-rw-r--r-- | src/backends/reference/RefLayerSupport.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/backends/reference/RefLayerSupport.cpp b/src/backends/reference/RefLayerSupport.cpp index 532c8eaf98..4d164d58a2 100644 --- a/src/backends/reference/RefLayerSupport.cpp +++ b/src/backends/reference/RefLayerSupport.cpp @@ -122,6 +122,14 @@ struct ShapesAreSameRank : public Rule } }; +struct ShapesAreSameTotalSize : public Rule +{ + ShapesAreSameTotalSize(const TensorInfo& info0, const TensorInfo& info1) + { + m_Res = info0.GetNumElements() == info1.GetNumElements(); + } +}; + struct ShapesAreBroadcastCompatible : public Rule { unsigned int CalcInputSize(const TensorShape& in, const TensorShape& out, unsigned int idx) @@ -719,6 +727,34 @@ bool RefLayerSupport::IsPooling2dSupported(const TensorInfo& input, &TrueFunc<>); } +bool RefLayerSupport::IsQuantizeSupported(const TensorInfo& input, + const TensorInfo& output, + Optional<std::string&> reasonIfUnsupported) const +{ + bool supported = true; + + // Define supported output types. + std::array<DataType,2> supportedInputTypes = { + DataType::Float32, + }; + + supported &= CheckSupportRule(TypeAnyOf(input, supportedInputTypes), reasonIfUnsupported, + "Reference quantize: input type not supported."); + + // Define supported output types. + std::array<DataType,2> supportedOutputTypes = { + DataType::QuantisedAsymm8, + DataType::QuantisedSymm16 + }; + supported &= CheckSupportRule(TypeAnyOf(output, supportedOutputTypes), reasonIfUnsupported, + "Reference quantize: output type not supported."); + + supported &= CheckSupportRule(ShapesAreSameTotalSize(input, output), reasonIfUnsupported, + "Reference quantize: input and output shapes have different num total elements."); + + return supported; +} + bool RefLayerSupport::IsReshapeSupported(const TensorInfo& input, const ReshapeDescriptor& descriptor, Optional<std::string&> reasonIfUnsupported) const |