21 if (m_Factories.find(
id) != m_Factories.end())
24 std::string(
id) +
" already registered as IBackend factory",
27 m_Factories[id] = factory;
29 if (m_ProfilingService.has_value())
31 if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
33 m_ProfilingService.value().IncrementCounterValue(armnn::profiling::REGISTERED_BACKENDS);
41 m_Factories.erase(
id);
44 if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
46 m_ProfilingService.value().IncrementCounterValue(armnn::profiling::UNREGISTERED_BACKENDS);
52 return (m_Factories.find(
id) != m_Factories.end());
57 auto it = m_Factories.find(
id);
58 if (it == m_Factories.end())
61 std::string(
id) +
" has no IBackend factory registered",
70 return m_Factories.size();
76 for (
const auto& it : m_Factories)
78 result.insert(it.first);
85 static const std::string delimitator =
", ";
87 std::stringstream output;
90 if (output.tellp() != std::streampos(0))
92 output << delimitator;
107 m_ProfilingService = profilingService;
112 if (m_CustomMemoryAllocatorMap.find(
id) != m_CustomMemoryAllocatorMap.end())
115 std::string(
id) +
" already has an allocator associated with it",
118 m_CustomMemoryAllocatorMap[id] = alloc;
123 m_CustomMemoryAllocatorMap.erase(
id);
128 return m_CustomMemoryAllocatorMap;
FactoryFunction GetFactory(const BackendId &id) const
void DeregisterAllocator(const BackendId &id)
BackendIdSet GetBackendIds() const
bool IsBackendRegistered(const BackendId &id) const
std::function< PointerType()> FactoryFunction
void Register(const BackendId &id, FactoryFunction factory)
void swap(OriginsDescriptor &first, OriginsDescriptor &second)
std::unordered_set< BackendId > BackendIdSet
static void Swap(BackendRegistry &instance, FactoryStorage &other)
For testing only.
std::unordered_map< BackendId, FactoryFunction > FactoryStorage
void RegisterAllocator(const BackendId &id, std::shared_ptr< ICustomAllocator > alloc)
BackendRegistry & BackendRegistryInstance()
Copyright (c) 2021 ARM Limited and Contributors.
std::string GetBackendIdsAsString() const
void SetProfilingService(armnn::Optional< profiling::ProfilingService &> profilingService)
std::unordered_map< BackendId, std::shared_ptr< ICustomAllocator > > GetAllocators()
void Deregister(const BackendId &id)