aboutsummaryrefslogtreecommitdiff
path: root/src/armnnSerializer/test/SerializerTests.cpp
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2019-10-14 13:00:47 +0100
committerSadik Armagan <sadik.armagan@arm.com>2019-10-14 13:00:47 +0100
commit262578500338274b5fa0bcfeb2d72c13e717f4ff (patch)
treea7ec5fee3c7c8354540b61a37408865abfde0b5f /src/armnnSerializer/test/SerializerTests.cpp
parentc626345daafe9c0f49c88eb336d30bac5a58bf71 (diff)
downloadarmnn-262578500338274b5fa0bcfeb2d72c13e717f4ff.tar.gz
IVGCVSW-3974 Add serialization support for LOG_SOFTMAX
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I0777abc672dd7d5c9fadaed27b0e776ac591d2c7
Diffstat (limited to 'src/armnnSerializer/test/SerializerTests.cpp')
-rw-r--r--src/armnnSerializer/test/SerializerTests.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/armnnSerializer/test/SerializerTests.cpp b/src/armnnSerializer/test/SerializerTests.cpp
index 98893a59cf..a70c891849 100644
--- a/src/armnnSerializer/test/SerializerTests.cpp
+++ b/src/armnnSerializer/test/SerializerTests.cpp
@@ -1437,6 +1437,61 @@ BOOST_AUTO_TEST_CASE(EnsureL2NormalizationBackwardCompatibility)
deserializedNetwork->Accept(verifier);
}
+BOOST_AUTO_TEST_CASE(SerializeLogSoftmax)
+{
+ class LogSoftmaxLayerVerifier : public LayerVerifierBase
+ {
+ public:
+ LogSoftmaxLayerVerifier(const std::string& layerName,
+ const std::vector<armnn::TensorInfo>& inputInfos,
+ const std::vector<armnn::TensorInfo>& outputInfos,
+ const armnn::LogSoftmaxDescriptor& descriptor)
+ : LayerVerifierBase(layerName, inputInfos, outputInfos)
+ , m_Descriptor(descriptor) {}
+
+ void VisitLogSoftmaxLayer(const armnn::IConnectableLayer* layer,
+ const armnn::LogSoftmaxDescriptor& descriptor,
+ const char* name) override
+ {
+ VerifyNameAndConnections(layer, name);
+ VerifyDescriptor(descriptor);
+ }
+
+ private:
+ void VerifyDescriptor(const armnn::LogSoftmaxDescriptor& descriptor)
+ {
+ BOOST_TEST(descriptor.m_Beta == m_Descriptor.m_Beta);
+ BOOST_TEST(descriptor.m_Axis == m_Descriptor.m_Axis);
+ }
+
+ armnn::LogSoftmaxDescriptor m_Descriptor;
+ };
+
+ const std::string layerName("log_softmax");
+ const armnn::TensorInfo info({1, 10}, armnn::DataType::Float32);
+
+ armnn::LogSoftmaxDescriptor descriptor;
+ descriptor.m_Beta = 1.0f;
+ descriptor.m_Axis = -1;
+
+ armnn::INetworkPtr network = armnn::INetwork::Create();
+ armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
+ armnn::IConnectableLayer* const logSoftmaxLayer = network->AddLogSoftmaxLayer(descriptor, layerName.c_str());
+ armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
+
+ inputLayer->GetOutputSlot(0).Connect(logSoftmaxLayer->GetInputSlot(0));
+ logSoftmaxLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
+
+ inputLayer->GetOutputSlot(0).SetTensorInfo(info);
+ logSoftmaxLayer->GetOutputSlot(0).SetTensorInfo(info);
+
+ armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
+ BOOST_CHECK(deserializedNetwork);
+
+ LogSoftmaxLayerVerifier verifier(layerName, {info}, {info}, descriptor);
+ deserializedNetwork->Accept(verifier);
+}
+
BOOST_AUTO_TEST_CASE(SerializeMaximum)
{
class MaximumLayerVerifier : public LayerVerifierBase