From 1855c6b2d21c04d054f6ebd1160c70c669e92a07 Mon Sep 17 00:00:00 2001 From: Matthew Bentham Date: Fri, 11 Feb 2022 08:29:42 +0000 Subject: Fix unit test where NeonMemoryManager was used instead of RefMemoryManager Although the Neon and Ref backends can use each other's TensorHandles, their TensorHandleFactories can't use each other's MemoryManagers. Incorrectly passing the NeonMemoryManager to the RefTensorHandleFactory in unit test utility code resulted in an incorrect static_pointer_cast and a warning from the Undefined Behaviour Sanitizer. This change fixes the test code, and replaces use of static_pointer_cast with armnn::PolymorphicPointerDowncast which will check that the cast is legal in debug builds. Also, remove MockWorkloadFactoryHelper.hpp as it is unused. Signed-off-by: Matthew Bentham Change-Id: I2b425e86fccacd7cc5ff186521fc6e53e7e50c77 --- src/armnnTestUtils/UnitTests.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/armnnTestUtils/UnitTests.hpp') diff --git a/src/armnnTestUtils/UnitTests.hpp b/src/armnnTestUtils/UnitTests.hpp index f560720c9b..71324dbf81 100644 --- a/src/armnnTestUtils/UnitTests.hpp +++ b/src/armnnTestUtils/UnitTests.hpp @@ -155,11 +155,11 @@ void CompareRefTestFunctionUsingTensorHandleFactory(const char* testName, TFuncP { auto memoryManager = WorkloadFactoryHelper::GetMemoryManager(); FactoryType workloadFactory = WorkloadFactoryHelper::GetFactory(memoryManager); + auto tensorHandleFactory = WorkloadFactoryHelper::GetTensorHandleFactory(memoryManager); armnn::RefWorkloadFactory refWorkloadFactory; - auto tensorHandleFactory = WorkloadFactoryHelper::GetTensorHandleFactory(memoryManager); - auto refTensorHandleFactory = - RefWorkloadFactoryHelper::GetTensorHandleFactory(memoryManager); + auto refMemoryManager = WorkloadFactoryHelper::GetMemoryManager(); + auto refTensorHandleFactory = RefWorkloadFactoryHelper::GetTensorHandleFactory(refMemoryManager); auto testResult = (*testFunction)( workloadFactory, memoryManager, refWorkloadFactory, tensorHandleFactory, refTensorHandleFactory, args...); -- cgit v1.2.1