From 2e24175c683bca42496104591d6b702dad360b8e Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Tue, 1 Feb 2022 16:42:15 +0000 Subject: IVGCVSW-6724 Accessing ConstTensors from IConnectableLayer Signed-off-by: Nikhil Raj Change-Id: I01f42a520d15c6dabd2f77c7715c91b8f7026476 --- src/armnn/test/GraphTests.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/armnn/test/GraphTests.cpp') diff --git a/src/armnn/test/GraphTests.cpp b/src/armnn/test/GraphTests.cpp index 6b3e611017..d3dd499850 100644 --- a/src/armnn/test/GraphTests.cpp +++ b/src/armnn/test/GraphTests.cpp @@ -614,4 +614,29 @@ TEST_CASE("CheckGraphConstTensorSharing") CHECK(*sharedWeightPtr == 1); } +TEST_CASE("IConnectableLayerConstantTensorsByRef") +{ + using namespace armnn; + INetworkPtr net(INetwork::Create()); + + std::vector falseData = {3}; + ConstTensor falseTensor(TensorInfo({1}, DataType::Boolean, 0.0f, 0, true), falseData); + IConnectableLayer* constLayer = net->AddConstantLayer(falseTensor, "const"); + constLayer->GetOutputSlot(0).SetTensorInfo(TensorInfo({1, 1, 1, 1}, DataType::Boolean)); + + const TensorInfo& constInfo = constLayer->GetOutputSlot(0).GetTensorInfo(); + + const void* weightData = constLayer->GetConstantTensorsByRef()[0].get()->GetConstTensor(); + auto weightValue = reinterpret_cast(weightData); + CHECK(weightValue[0] == 3); + TensorInfo weightsInfo = constInfo; + ConstTensor weights(weightsInfo, weightData); + DepthwiseConvolution2dDescriptor desc; + const auto depthwiseLayer = net->AddDepthwiseConvolution2dLayer(desc, weights, EmptyOptional(), "Depthwise"); + + const void* resultData = depthwiseLayer->GetConstantTensorsByRef()[0].get()->GetConstTensor(); + auto resultValue = reinterpret_cast(resultData); + CHECK(resultValue[0] == 3); +} + } -- cgit v1.2.1