aboutsummaryrefslogtreecommitdiff
path: root/src/armnnSerializer/test
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-03-07 17:31:34 +0000
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-03-08 09:53:20 +0000
commit495701f016117b405d90a69de0814bf60751d78b (patch)
tree282f36b385e76ab8bc6add250250d10089e4c450 /src/armnnSerializer/test
parentac25a1beda8da71a82c0cf2795e2a6eaaeaa26b1 (diff)
downloadarmnn-495701f016117b405d90a69de0814bf60751d78b.tar.gz
IVGCVSW-2693 Serialize/de-serialize L2Normalization
Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: I6a53ac576260383f32fb0d878b42d1251ffde94a
Diffstat (limited to 'src/armnnSerializer/test')
-rw-r--r--src/armnnSerializer/test/SerializerTests.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/armnnSerializer/test/SerializerTests.cpp b/src/armnnSerializer/test/SerializerTests.cpp
index 5a054c210c..069b9d699c 100644
--- a/src/armnnSerializer/test/SerializerTests.cpp
+++ b/src/armnnSerializer/test/SerializerTests.cpp
@@ -422,6 +422,63 @@ BOOST_AUTO_TEST_CASE(SerializeDeserializeMaximum)
{0, 1});
}
+BOOST_AUTO_TEST_CASE(SerializeDeserializeL2Normalization)
+{
+ class VerifyL2NormalizationName : public armnn::LayerVisitorBase<armnn::VisitorNoThrowPolicy>
+ {
+ public:
+ explicit VerifyL2NormalizationName(const std::string& expectedL2NormalizationLayerName)
+ : m_ExpectedL2NormalizationLayerName(expectedL2NormalizationLayerName) {}
+
+ void VisitL2NormalizationLayer(const armnn::IConnectableLayer*,
+ const armnn::L2NormalizationDescriptor&,
+ const char* name) override
+ {
+ BOOST_TEST(name == m_ExpectedL2NormalizationLayerName.c_str());
+ }
+ private:
+ std::string m_ExpectedL2NormalizationLayerName;
+ };
+
+ const armnn::TensorInfo info({ 1, 2, 1, 5 }, armnn::DataType::Float32);
+
+ armnn::L2NormalizationDescriptor desc;
+ desc.m_DataLayout = armnn::DataLayout::NCHW;
+
+ armnn::INetworkPtr network = armnn::INetwork::Create();
+ armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0);
+
+ const char* l2NormLayerName = "l2Normalization";
+
+ armnn::IConnectableLayer* const l2NormLayer = network->AddL2NormalizationLayer(desc, l2NormLayerName);
+ inputLayer0->GetOutputSlot(0).Connect(l2NormLayer->GetInputSlot(0));
+
+ armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
+ l2NormLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
+
+ inputLayer0->GetOutputSlot(0).SetTensorInfo(info);
+ l2NormLayer->GetOutputSlot(0).SetTensorInfo(info);
+
+ armnnSerializer::Serializer serializer;
+ serializer.Serialize(*network);
+
+ std::stringstream stream;
+ serializer.SaveSerializedToStream(stream);
+ BOOST_TEST(stream.str().length() > 0);
+ BOOST_TEST(stream.str().find(l2NormLayerName) != stream.str().npos);
+
+ armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(stream.str());
+ BOOST_CHECK(deserializedNetwork);
+
+ VerifyL2NormalizationName nameChecker(l2NormLayerName);
+ deserializedNetwork->Accept(nameChecker);
+
+ CheckDeserializedNetworkAgainstOriginal<float>(*network,
+ *deserializedNetwork,
+ { info.GetShape() },
+ { info.GetShape() });
+}
+
BOOST_AUTO_TEST_CASE(SerializeDeserializeMultiplication)
{
class VerifyMultiplicationName : public armnn::LayerVisitorBase<armnn::VisitorNoThrowPolicy>