From 3e9e11541c177abd7101962ef1e703d70d718c56 Mon Sep 17 00:00:00 2001 From: David Beck Date: Wed, 17 Oct 2018 14:17:50 +0100 Subject: IVGCVSW-2037 : separate registry for layer support intrefaces * because their lifetime is different from backends Change-Id: I9ba525e7e503b148cde1294933f3954b8bad3d68 --- src/backends/test/BackendRegistryTests.cpp | 48 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src/backends/test') diff --git a/src/backends/test/BackendRegistryTests.cpp b/src/backends/test/BackendRegistryTests.cpp index e895df63a6..f6f749936f 100644 --- a/src/backends/test/BackendRegistryTests.cpp +++ b/src/backends/test/BackendRegistryTests.cpp @@ -15,16 +15,16 @@ class SwapRegistryStorage : public armnn::BackendRegistry public: SwapRegistryStorage() : armnn::BackendRegistry() { - Swap(m_TempStorage); + Swap(armnn::BackendRegistryInstance(), m_TempStorage); } ~SwapRegistryStorage() { - Swap(m_TempStorage); + Swap(armnn::BackendRegistryInstance(),m_TempStorage); } private: - BackendRegistry::FactoryStorage m_TempStorage; + FactoryStorage m_TempStorage; }; } @@ -33,30 +33,36 @@ BOOST_AUTO_TEST_SUITE(BackendRegistryTests) BOOST_AUTO_TEST_CASE(SwapRegistry) { - using armnn::BackendRegistry; - auto nFactories = BackendRegistry::Instance().Size(); + using namespace armnn; + auto nFactories = BackendRegistryInstance().Size(); { SwapRegistryStorage helper; - BOOST_TEST(BackendRegistry::Instance().Size() == 0); + BOOST_TEST(BackendRegistryInstance().Size() == 0); } - BOOST_TEST(BackendRegistry::Instance().Size() == nFactories); + BOOST_TEST(BackendRegistryInstance().Size() == nFactories); } BOOST_AUTO_TEST_CASE(TestRegistryHelper) { - using armnn::BackendRegistry; + using namespace armnn; SwapRegistryStorage helper; bool called = false; - BackendRegistry::Helper factoryHelper("HelloWorld", [&called]() { - called = true; - return armnn::IBackendUniquePtr(nullptr, nullptr); - } ); + + StaticRegistryInitializer factoryHelper( + BackendRegistryInstance(), + "HelloWorld", + [&called]() + { + called = true; + return armnn::IBackendUniquePtr(nullptr, nullptr); + } + ); // sanity check: the factory has not been called yet BOOST_TEST(called == false); - auto factoryFunction = BackendRegistry::Instance().GetFactory("HelloWorld"); + auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld"); // sanity check: the factory still not called BOOST_TEST(called == false); @@ -67,19 +73,23 @@ BOOST_AUTO_TEST_CASE(TestRegistryHelper) BOOST_AUTO_TEST_CASE(TestDirectCallToRegistry) { - using armnn::BackendRegistry; + using namespace armnn; SwapRegistryStorage helper; bool called = false; - BackendRegistry::Instance().Register("HelloWorld", [&called]() { - called = true; - return armnn::IBackendUniquePtr(nullptr, nullptr); - } ); + BackendRegistryInstance().Register( + "HelloWorld", + [&called]() + { + called = true; + return armnn::IBackendUniquePtr(nullptr, nullptr); + } + ); // sanity check: the factory has not been called yet BOOST_TEST(called == false); - auto factoryFunction = BackendRegistry::Instance().GetFactory("HelloWorld"); + auto factoryFunction = BackendRegistryInstance().GetFactory("HelloWorld"); // sanity check: the factory still not called BOOST_TEST(called == false); -- cgit v1.2.1