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/armnn | |
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/armnn')
-rw-r--r-- | src/armnn/LayerSupport.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
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 <armnn/LayerSupport.hpp> #include <armnn/Optional.hpp> -#include <backends/BackendRegistry.hpp> +#include <backends/LayerSupportRegistry.hpp> #include <boost/assert.hpp> @@ -30,34 +30,17 @@ void CopyErrorMessage(char* truncatedString, const char* fullString, size_t maxL } } -IBackend& GetBackend(const BackendId& id) -{ - static std::unordered_map<BackendId, IBackendUniquePtr> 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<std::string&>(reasonIfUnsupportedFull)); \ + auto factoryFunc = LayerSupportRegistryInstance().GetFactory(backendId); \ + auto layerSupportObject = factoryFunc(); \ + isSupported = layerSupportObject->func(__VA_ARGS__, Optional<std::string&>(reasonIfUnsupportedFull)); \ CopyErrorMessage(reasonIfUnsupported, reasonIfUnsupportedFull.c_str(), reasonIfUnsupportedMaxLength); \ } catch (InvalidArgumentException e) { \ /* re-throwing with more context information */ \ |