diff options
author | David Beck <david.beck@arm.com> | 2018-10-17 14:17:50 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-22 16:57:54 +0100 |
commit | 3e9e11541c177abd7101962ef1e703d70d718c56 (patch) | |
tree | f2076ddb343d51450e41465826db2a4096d1f8b3 /src/backends/test/BackendRegistryTests.cpp | |
parent | 8e6f92d2d6b2bb94e6ba9b794c08e465039ea98b (diff) | |
download | armnn-3e9e11541c177abd7101962ef1e703d70d718c56.tar.gz |
IVGCVSW-2037 : separate registry for layer support intrefaces
* because their lifetime is different from backends
Change-Id: I9ba525e7e503b148cde1294933f3954b8bad3d68
Diffstat (limited to 'src/backends/test/BackendRegistryTests.cpp')
-rw-r--r-- | src/backends/test/BackendRegistryTests.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
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<BackendRegistry> 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); |