10 #include <client/include/IProfilingService.hpp>
23 if (m_Factories.find(
id) != m_Factories.end())
26 std::string(
id) +
" already registered as IBackend factory",
29 m_Factories[id] = factory;
33 if (m_ProfilingService.
has_value() && m_ProfilingService.
value().IsProfilingEnabled())
35 m_ProfilingService.
value().IncrementCounterValue(arm::pipe::REGISTERED_BACKENDS);
43 m_Factories.erase(
id);
46 if (m_ProfilingService.
has_value() && m_ProfilingService.
value().IsProfilingEnabled())
48 m_ProfilingService.
value().IncrementCounterValue(arm::pipe::UNREGISTERED_BACKENDS);
54 return (m_Factories.find(
id) != m_Factories.end());
59 auto it = m_Factories.find(
id);
60 if (it == m_Factories.end())
63 std::string(
id) +
" has no IBackend factory registered",
72 return m_Factories.size();
78 for (
const auto& it : m_Factories)
80 result.insert(it.first);
87 static const std::string delimitator =
", ";
89 std::stringstream output;
92 if (output.tellp() != std::streampos(0))
94 output << delimitator;
109 m_ProfilingService = profilingService;
114 if (m_CustomMemoryAllocatorMap.find(
id) != m_CustomMemoryAllocatorMap.end())
117 std::string(
id) +
" already has an allocator associated with it",
120 m_CustomMemoryAllocatorMap[id] = alloc;
125 m_CustomMemoryAllocatorMap.erase(
id);
130 return m_CustomMemoryAllocatorMap;
134 std::shared_ptr<IMemoryOptimizerStrategy> strategy)
136 if (m_MemoryOptimizerStrategyMap.find(
id) != m_MemoryOptimizerStrategyMap.end())
139 std::string(
id) +
" already has an memory optimizer strategy associated with it",
142 m_MemoryOptimizerStrategyMap[id] = strategy;
147 m_MemoryOptimizerStrategyMap.erase(
id);
152 return m_MemoryOptimizerStrategyMap;
157 m_MappedGpuBackends.insert(m_MappedGpuBackends.begin(),
id);
162 return m_MappedGpuBackends;
void Register(const BackendId &id, FactoryFunction factory)
void DeregisterMemoryOptimizerStrategy(const BackendId &id)
std::unordered_map< BackendId, FactoryFunction > FactoryStorage
void AddMappedGpuBackend(const BackendId &id)
bool IsBackendRegistered(const BackendId &id) const
void Deregister(const BackendId &id)
static void Swap(BackendRegistry &instance, FactoryStorage &other)
For testing only.
void SetProfilingService(armnn::Optional< arm::pipe::IProfilingService & > profilingService)
BackendIdSet GetBackendIds() const
std::unordered_map< BackendId, std::shared_ptr< ICustomAllocator > > GetAllocators()
void RegisterAllocator(const BackendId &id, std::shared_ptr< ICustomAllocator > alloc)
MemoryOptimizerStrategiesMapRef GetMemoryOptimizerStrategies()
std::function< PointerType()> FactoryFunction
void RegisterMemoryOptimizerStrategy(const BackendId &id, std::shared_ptr< IMemoryOptimizerStrategy > strategy)
std::string GetBackendIdsAsString() const
BackendIdVector GetMappedGpuBackends()
void DeregisterAllocator(const BackendId &id)
FactoryFunction GetFactory(const BackendId &id) const
bool has_value() const noexcept
Copyright (c) 2021 ARM Limited and Contributors.
void swap(OriginsDescriptor &first, OriginsDescriptor &second)
std::unordered_set< BackendId > BackendIdSet
std::unordered_map< BackendId, std::shared_ptr< IMemoryOptimizerStrategy > > MemoryOptimizerStrategiesMapRef
BackendRegistry & BackendRegistryInstance()
std::vector< BackendId > BackendIdVector