From a9ac6ba643e8dc4fee88bd0e7e186f0918080c4b Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Fri, 30 Jun 2023 15:18:26 +0100 Subject: IVGCVSW-7828 Add an Optional TensorInfo to InputSlot * Updated calls to use the new function From: GetInputSlot(n).GetConnection()->GetTensorInfo(); To: GetInputSlot(n).GetTensorInfo(); * Added UnitTests Signed-off-by: Mike Kelly Change-Id: I43184cc05e4472011b9347aaa820eb8deb1cd4a0 --- src/armnn/test/LayerTests.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/armnn/test/LayerTests.cpp (limited to 'src/armnn/test') diff --git a/src/armnn/test/LayerTests.cpp b/src/armnn/test/LayerTests.cpp new file mode 100644 index 0000000000..3e9184e3be --- /dev/null +++ b/src/armnn/test/LayerTests.cpp @@ -0,0 +1,50 @@ +// +// Copyright © 2023 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include +#include +#include + +namespace +{ + +TEST_SUITE("Layer") +{ + +TEST_CASE("InputSlotGetTensorInfo") +{ + armnn::NetworkImpl net; + armnn::IConnectableLayer* add = net.AddElementwiseBinaryLayer(armnn::BinaryOperation::Add); + armnn::IConnectableLayer* out = net.AddOutputLayer(0); + + armnn::Layer* addlayer = armnn::PolymorphicDowncast(add); + armnn::Layer* outlayer = armnn::PolymorphicDowncast(out); + + auto outTensorInfo = armnn::TensorInfo({1,2,2,1}, armnn::DataType::Float32); + addlayer->GetOutputSlot(0).Connect(outlayer->GetInputSlot(0)); + CHECK_FALSE(outlayer->GetInputSlot(0).IsTensorInfoSet()); + + addlayer->GetOutputSlot(0).SetTensorInfo(outTensorInfo); + auto testTensorInfo = outlayer->GetInputSlot(0).GetTensorInfo(); + + CHECK_EQ(outTensorInfo, testTensorInfo); + CHECK(outlayer->GetInputSlot(0).IsTensorInfoSet()); + CHECK_FALSE(outlayer->GetInputSlot(0).IsTensorInfoOverridden()); + + auto overRiddenTensorInfo = armnn::TensorInfo({2,2}, armnn::DataType::Float32); + outlayer->GetInputSlot(0).SetTensorInfo(overRiddenTensorInfo); + testTensorInfo = outlayer->GetInputSlot(0).GetTensorInfo(); + + // Confirm that inputslot TensorInfo is changed + CHECK_EQ(overRiddenTensorInfo, testTensorInfo); + // Confirm that outputslot TensorInfo is unchanged + CHECK_EQ(outTensorInfo, outlayer->GetInputSlot(0).GetConnection()->GetTensorInfo()); + + CHECK(outlayer->GetInputSlot(0).IsTensorInfoOverridden()); +} + +} + +} -- cgit v1.2.1