aboutsummaryrefslogtreecommitdiff
path: root/src/armnnSerializer/test
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2021-03-25 07:46:55 +0000
committerSadik Armagan <sadik.armagan@arm.com>2021-03-25 07:46:55 +0000
commitf0a6dec75832604d5ab18242dc216852821a8279 (patch)
treeff25e64c62c63975a54abd16a8bff744be70d7c0 /src/armnnSerializer/test
parent16fb1a2d9c1d3d80c0f0b6ab549919fbabd2a0b9 (diff)
downloadarmnn-f0a6dec75832604d5ab18242dc216852821a8279.tar.gz
IVGCVSW-5736 and IVGCVSW-5743 'NonConstWeights: Update front-end and TfLiteDelegate support for FullyConnected Operator'
* Added front-end support for non-const weights for FULLY_CONNECTED operator * Added FULLY_CONNECTED end-to-end test * Updated FULLY_CONNECTED operator support in TfLite Arm NN Delegate for non-const weights * Updated the version numbers Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: Iffa5b9aa9297aca4c02d923cce4636c88ac21faa
Diffstat (limited to 'src/armnnSerializer/test')
-rw-r--r--src/armnnSerializer/test/SerializerTests.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/armnnSerializer/test/SerializerTests.cpp b/src/armnnSerializer/test/SerializerTests.cpp
index f261731a75..d7c10cb599 100644
--- a/src/armnnSerializer/test/SerializerTests.cpp
+++ b/src/armnnSerializer/test/SerializerTests.cpp
@@ -748,6 +748,7 @@ BOOST_AUTO_TEST_CASE(SerializeFullyConnected)
armnn::FullyConnectedDescriptor descriptor;
descriptor.m_BiasEnabled = true;
descriptor.m_TransposeWeightMatrix = false;
+ descriptor.m_ConstantWeights = true;
armnn::INetworkPtr network = armnn::INetwork::Create();
armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
@@ -773,6 +774,53 @@ BOOST_AUTO_TEST_CASE(SerializeFullyConnected)
deserializedNetwork->ExecuteStrategy(verifier);
}
+BOOST_AUTO_TEST_CASE(SerializeFullyConnectedWeightsAsInputs)
+{
+ const std::string layerName("fullyConnected_weights_as_inputs");
+ const armnn::TensorInfo inputInfo ({ 2, 5, 1, 1 }, armnn::DataType::Float32);
+ const armnn::TensorInfo outputInfo({ 2, 3 }, armnn::DataType::Float32);
+
+ const armnn::TensorInfo weightsInfo({ 5, 3 }, armnn::DataType::Float32);
+ const armnn::TensorInfo biasesInfo ({ 3 }, armnn::DataType::Float32);
+
+ armnn::Optional<armnn::ConstTensor> weights = armnn::EmptyOptional();
+ armnn::Optional<armnn::ConstTensor> bias = armnn::EmptyOptional();
+
+ armnn::FullyConnectedDescriptor descriptor;
+ descriptor.m_BiasEnabled = true;
+ descriptor.m_TransposeWeightMatrix = false;
+ descriptor.m_ConstantWeights = false;
+
+ armnn::INetworkPtr network = armnn::INetwork::Create();
+ armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0);
+ armnn::IConnectableLayer* const weightsInputLayer = network->AddInputLayer(1);
+ armnn::IConnectableLayer* const biasInputLayer = network->AddInputLayer(2);
+ armnn::IConnectableLayer* const fullyConnectedLayer =
+ network->AddFullyConnectedLayer(descriptor,
+ weights,
+ bias,
+ layerName.c_str());
+ armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
+
+ inputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(0));
+ weightsInputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(1));
+ biasInputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(2));
+ fullyConnectedLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
+
+ inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo);
+ weightsInputLayer->GetOutputSlot(0).SetTensorInfo(weightsInfo);
+ biasInputLayer->GetOutputSlot(0).SetTensorInfo(biasesInfo);
+ fullyConnectedLayer->GetOutputSlot(0).SetTensorInfo(outputInfo);
+
+ armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network));
+ BOOST_CHECK(deserializedNetwork);
+
+ const std::vector<armnn::ConstTensor> constants {};
+ LayerVerifierBaseWithDescriptorAndConstants<armnn::FullyConnectedDescriptor> verifier(
+ layerName, {inputInfo, weightsInfo, biasesInfo}, {outputInfo}, descriptor, constants);
+ deserializedNetwork->ExecuteStrategy(verifier);
+}
+
BOOST_AUTO_TEST_CASE(SerializeGather)
{
using GatherDescriptor = armnn::GatherDescriptor;