From 79bb6531358d5a780e8e86bce99fd39ae847c2f4 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 --- .../armnnTestUtils/MockWorkloadFactoryHelper.hpp | 41 ---------------------- 1 file changed, 41 deletions(-) delete mode 100644 include/armnnTestUtils/MockWorkloadFactoryHelper.hpp (limited to 'include') diff --git a/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp b/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp deleted file mode 100644 index e9f2b2f6cf..0000000000 --- a/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include "MockBackend.hpp" -#include "MockTensorHandleFactory.hpp" -#include - -namespace -{ - -template <> -struct WorkloadFactoryHelper -{ - static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() - { - armnn::MockBackend backend; - return backend.CreateMemoryManager(); - } - - static armnn::MockWorkloadFactory - GetFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) - { - IgnoreUnused(memoryManager); - return armnn::MockWorkloadFactory(); - } - - static armnn::MockTensorHandleFactory - GetTensorHandleFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) - { - - return armnn::MockTensorHandleFactory(std::static_pointer_cast(memoryManager)); - } -}; - -using MockWorkloadFactoryHelper = WorkloadFactoryHelper; - -} // anonymous namespace -- cgit v1.2.1