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/armnn/LayerSupport.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'src/armnn') diff --git a/src/armnn/LayerSupport.cpp b/src/armnn/LayerSupport.cpp index 2494c74373..846da6086e 100644 --- a/src/armnn/LayerSupport.cpp +++ b/src/armnn/LayerSupport.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include @@ -30,34 +30,17 @@ void CopyErrorMessage(char* truncatedString, const char* fullString, size_t maxL } } -IBackend& GetBackend(const BackendId& id) -{ - static std::unordered_map cachedBackends; - auto it = cachedBackends.find(id); - if (it == cachedBackends.end()) - { - auto factoryFunc = BackendRegistry::Instance().GetFactory(id); - auto emplaceResult = - cachedBackends.emplace( - std::make_pair(id, factoryFunc()) - ); - BOOST_ASSERT(emplaceResult.second); - it = emplaceResult.first; - } - - return *(it->second.get()); -} - } // Helper macro to avoid code duplication. // Forwards function func to funcRef, funcNeon or funcCl, depending on the value of compute. -#define FORWARD_LAYER_SUPPORT_FUNC(backend, func, ...) \ +#define FORWARD_LAYER_SUPPORT_FUNC(backendId, func, ...) \ std::string reasonIfUnsupportedFull; \ bool isSupported; \ try { \ - auto const& layerSupportObject = GetBackend(backend).GetLayerSupport(); \ - isSupported = layerSupportObject.func(__VA_ARGS__, Optional(reasonIfUnsupportedFull)); \ + auto factoryFunc = LayerSupportRegistryInstance().GetFactory(backendId); \ + auto layerSupportObject = factoryFunc(); \ + isSupported = layerSupportObject->func(__VA_ARGS__, Optional(reasonIfUnsupportedFull)); \ CopyErrorMessage(reasonIfUnsupported, reasonIfUnsupportedFull.c_str(), reasonIfUnsupportedMaxLength); \ } catch (InvalidArgumentException e) { \ /* re-throwing with more context information */ \ -- cgit v1.2.1