aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/GraphTests.cpp
diff options
context:
space:
mode:
authorNikhil Raj <nikhil.raj@arm.com>2022-02-01 16:42:15 +0000
committerNikhil Raj Arm <nikhil.raj@arm.com>2022-02-03 14:36:14 +0000
commit2e24175c683bca42496104591d6b702dad360b8e (patch)
tree1802062ab9132e3196e76b083b1a7b2b6c6efd11 /src/armnn/test/GraphTests.cpp
parentab8a4465ba32cb00ad05d63abfd2e60c307edc51 (diff)
downloadarmnn-2e24175c683bca42496104591d6b702dad360b8e.tar.gz
IVGCVSW-6724 Accessing ConstTensors from IConnectableLayer
Signed-off-by: Nikhil Raj <nikhil.raj@arm.com> Change-Id: I01f42a520d15c6dabd2f77c7715c91b8f7026476
Diffstat (limited to 'src/armnn/test/GraphTests.cpp')
-rw-r--r--src/armnn/test/GraphTests.cpp25
1 files changed, 25 insertions, 0 deletions
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<uint8_t> 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<void>();
+ auto weightValue = reinterpret_cast<const uint8_t*>(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<void>();
+ auto resultValue = reinterpret_cast<const uint8_t*>(resultData);
+ CHECK(resultValue[0] == 3);
+}
+
}