IVGCVSW-2626 Add Quantization of ResizeBilinear Layer Change-Id: I0daffd23f32cc094d8309aed822cc46bb2aaa46f Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/src/armnn/QuantizerVisitor.cpp b/src/armnn/QuantizerVisitor.cpp index 2ca164b..8b009c6 100644 --- a/src/armnn/QuantizerVisitor.cpp +++ b/src/armnn/QuantizerVisitor.cpp
@@ -280,4 +280,13 @@ SetQuantizedInputConnections(layer, newLayer); } +void QuantizerVisitor::VisitResizeBilinearLayer(const IConnectableLayer* layer, + const ResizeBilinearDescriptor& resizeDesc, + const char* name) +{ + IConnectableLayer* newLayer = m_QuantizedNetwork->AddResizeBilinearLayer(resizeDesc, name); + RecordLayer(layer, newLayer); + SetQuantizedInputConnections(layer, newLayer); +} + } //namespace armnn
diff --git a/src/armnn/QuantizerVisitor.hpp b/src/armnn/QuantizerVisitor.hpp index 79c44f2..2ccbac2 100644 --- a/src/armnn/QuantizerVisitor.hpp +++ b/src/armnn/QuantizerVisitor.hpp
@@ -96,6 +96,10 @@ const ReshapeDescriptor& reshapeDescriptor, const char* name = nullptr) override; + void VisitResizeBilinearLayer(const IConnectableLayer* layer, + const ResizeBilinearDescriptor& resizeDesc, + const char* name = nullptr) override; + /// Extract the quantized network INetworkPtr RetrieveFinalNetwork() { return std::move(m_QuantizedNetwork); }
diff --git a/src/armnn/StaticRangeVisitor.cpp b/src/armnn/StaticRangeVisitor.cpp index ad2de63..15f4616 100644 --- a/src/armnn/StaticRangeVisitor.cpp +++ b/src/armnn/StaticRangeVisitor.cpp
@@ -212,6 +212,16 @@ const char* name) { boost::ignore_unused(splitterDescriptor); + boost::ignore_unused(name); + ForwardParentParameters(layer); +} + +void StaticRangeVisitor::VisitResizeBilinearLayer(const IConnectableLayer* layer, + const ResizeBilinearDescriptor& resizeDesc, + const char* name) +{ + boost::ignore_unused(resizeDesc); + boost::ignore_unused(name); ForwardParentParameters(layer); }
diff --git a/src/armnn/StaticRangeVisitor.hpp b/src/armnn/StaticRangeVisitor.hpp index a42ad37..6984346 100644 --- a/src/armnn/StaticRangeVisitor.hpp +++ b/src/armnn/StaticRangeVisitor.hpp
@@ -87,6 +87,10 @@ const SplitterDescriptor& splitterDescriptor, const char* name = nullptr) override; + void VisitResizeBilinearLayer(const IConnectableLayer* layer, + const ResizeBilinearDescriptor& resizeDesc, + const char* name = nullptr) override; + private: /// Set the range for an output slot on a layer void SetRange(const IConnectableLayer* layer, unsigned int outputIdx, float min, float max);
diff --git a/src/armnn/test/QuantizerTest.cpp b/src/armnn/test/QuantizerTest.cpp index 1f6537d..21ac3e6 100644 --- a/src/armnn/test/QuantizerTest.cpp +++ b/src/armnn/test/QuantizerTest.cpp
@@ -1120,5 +1120,38 @@ VisitLayersTopologically(quantizedNetwork.get(), validator); } +BOOST_AUTO_TEST_CASE(QuantizeResizeBilinear) +{ + class TestResizeBilinearQuantization : public TestLeakyReLuActivationQuantization + { + public: + void VisitResizeBilinearLayer(const IConnectableLayer* layer, + const ResizeBilinearDescriptor& resizeDescriptor, + const char* name = nullptr) override + { + CheckForwardedQuantizationSettings(layer); + } + }; + + INetworkPtr network = INetwork::Create(); + + TensorShape shape{1U}; + TensorInfo info(shape, DataType::Float32); + + IConnectableLayer* activation = CreateStartOfLeakyReluNetwork(network.get(), info); + + // Add the layer under test + ResizeBilinearDescriptor descriptor; + descriptor.m_TargetHeight = 3; + descriptor.m_TargetWidth = 3; + IConnectableLayer* spaceToBatch = network->AddResizeBilinearLayer(descriptor); + + CompleteLeakyReluNetwork(network.get(), activation, spaceToBatch, info); + + auto quantizedNetwork = INetworkQuantizer::Create(network.get())->ExportNetwork(); + TestResizeBilinearQuantization validator; + VisitLayersTopologically(quantizedNetwork.get(), validator); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace armnn