diff options
author | Mike Kelly <mike.kelly@arm.com> | 2023-06-30 15:18:26 +0100 |
---|---|---|
committer | mike.kelly <mike.kelly@arm.com> | 2023-07-03 15:32:04 +0000 |
commit | a9ac6ba643e8dc4fee88bd0e7e186f0918080c4b (patch) | |
tree | 4e05fbb098b30f3d2c7d3e5b4b83d48c9bdd59ac /src/armnn/test | |
parent | 6d2d4ead359aa02d502f15cfcb7e69c7658bd1ed (diff) | |
download | armnn-a9ac6ba643e8dc4fee88bd0e7e186f0918080c4b.tar.gz |
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 <mike.kelly@arm.com>
Change-Id: I43184cc05e4472011b9347aaa820eb8deb1cd4a0
Diffstat (limited to 'src/armnn/test')
-rw-r--r-- | src/armnn/test/LayerTests.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
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 <Network.hpp> +#include <doctest/doctest.h> +#include <armnn/utility/PolymorphicDowncast.hpp> + +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<armnn::Layer*>(add); + armnn::Layer* outlayer = armnn::PolymorphicDowncast<armnn::Layer*>(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()); +} + +} + +} |