ArmNN
 25.11
Loading...
Searching...
No Matches
BackendRegistry Class Reference

#include <BackendRegistry.hpp>

Classes

struct  StaticRegistryInitializer

Public Types

using PointerType = IBackendInternalUniquePtr
using FactoryFunction = std::function<PointerType()>

Public Member Functions

void Register (const BackendId &id, FactoryFunction factory)
bool IsBackendRegistered (const BackendId &id) const
FactoryFunction GetFactory (const BackendId &id) const
size_t Size () const
BackendIdSet GetBackendIds () const
std::string GetBackendIdsAsString () const
void SetProfilingService (armnn::Optional< arm::pipe::IProfilingService & > profilingService)
void RegisterAllocator (const BackendId &id, std::shared_ptr< ICustomAllocator > alloc)
std::unordered_map< BackendId, std::shared_ptr< ICustomAllocator > > GetAllocators ()
void RegisterMemoryOptimizerStrategy (const BackendId &id, std::shared_ptr< IMemoryOptimizerStrategy > strategy)
MemoryOptimizerStrategiesMapRef GetMemoryOptimizerStrategies ()
void AddMappedGpuBackend (const BackendId &id)
BackendIdVector GetMappedGpuBackends ()
 BackendRegistry ()
virtual ~BackendRegistry ()
void Deregister (const BackendId &id)
void DeregisterAllocator (const BackendId &id)
void DeregisterMemoryOptimizerStrategy (const BackendId &id)

Protected Types

using FactoryStorage = std::unordered_map<BackendId, FactoryFunction>

Static Protected Member Functions

static void Swap (BackendRegistry &instance, FactoryStorage &other)
 For testing only.

Detailed Description

Definition at line 35 of file BackendRegistry.hpp.

Member Typedef Documentation

◆ FactoryFunction

using FactoryFunction = std::function<PointerType()>

Definition at line 39 of file BackendRegistry.hpp.

◆ FactoryStorage

using FactoryStorage = std::unordered_map<BackendId, FactoryFunction>
protected

Definition at line 73 of file BackendRegistry.hpp.

◆ PointerType

Definition at line 38 of file BackendRegistry.hpp.

Constructor & Destructor Documentation

◆ BackendRegistry()

◆ ~BackendRegistry()

virtual ~BackendRegistry ( )
inlinevirtual

Definition at line 56 of file BackendRegistry.hpp.

56{}

Member Function Documentation

◆ AddMappedGpuBackend()

void AddMappedGpuBackend ( const BackendId & id)

Definition at line 155 of file BackendRegistry.cpp.

156{
157 m_MappedGpuBackends.insert(m_MappedGpuBackends.begin(), id);
158}

◆ Deregister()

void Deregister ( const BackendId & id)

Definition at line 41 of file BackendRegistry.cpp.

42{
43 m_Factories.erase(id);
44 DeregisterAllocator(id);
45
46 if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
47 {
48 m_ProfilingService.value().IncrementCounterValue(arm::pipe::UNREGISTERED_BACKENDS);
49 }
50}

References DeregisterAllocator().

Referenced by DynamicBackendUtils::DeregisterDynamicBackends().

◆ DeregisterAllocator()

void DeregisterAllocator ( const BackendId & id)

Definition at line 123 of file BackendRegistry.cpp.

124{
125 m_CustomMemoryAllocatorMap.erase(id);
126}

Referenced by Deregister().

◆ DeregisterMemoryOptimizerStrategy()

void DeregisterMemoryOptimizerStrategy ( const BackendId & id)

Definition at line 145 of file BackendRegistry.cpp.

146{
147 m_MemoryOptimizerStrategyMap.erase(id);
148}

◆ GetAllocators()

std::unordered_map< BackendId, std::shared_ptr< ICustomAllocator > > GetAllocators ( )

Definition at line 128 of file BackendRegistry.cpp.

129{
130 return m_CustomMemoryAllocatorMap;
131}

◆ GetBackendIds()

BackendIdSet GetBackendIds ( ) const

Definition at line 75 of file BackendRegistry.cpp.

76{
77 BackendIdSet result;
78 for (const auto& it : m_Factories)
79 {
80 result.insert(it.first);
81 }
82 return result;
83}
std::unordered_set< BackendId > BackendIdSet

Referenced by GetBackendIdsAsString(), and IOptimizedNetwork::Optimize.

◆ GetBackendIdsAsString()

std::string GetBackendIdsAsString ( ) const

Definition at line 85 of file BackendRegistry.cpp.

86{
87 static const std::string delimitator = ", ";
88
89 std::stringstream output;
90 for (auto& backendId : GetBackendIds())
91 {
92 if (output.tellp() != std::streampos(0))
93 {
94 output << delimitator;
95 }
96 output << backendId;
97 }
98
99 return output.str();
100}

References GetBackendIds().

◆ GetFactory()

BackendRegistry::FactoryFunction GetFactory ( const BackendId & id) const

Definition at line 57 of file BackendRegistry.cpp.

58{
59 auto it = m_Factories.find(id);
60 if (it == m_Factories.end())
61 {
62 throw InvalidArgumentException(
63 std::string(id) + " has no IBackend factory registered",
65 }
66
67 return it->second;
68}
#define CHECK_LOCATION()

References CHECK_LOCATION.

Referenced by armnn::GetILayerSupportByBackendId(), and RuntimeImpl::RuntimeImpl().

◆ GetMappedGpuBackends()

BackendIdVector GetMappedGpuBackends ( )

Definition at line 160 of file BackendRegistry.cpp.

161{
162 return m_MappedGpuBackends;
163}

Referenced by IOptimizedNetwork::Optimize.

◆ GetMemoryOptimizerStrategies()

MemoryOptimizerStrategiesMapRef GetMemoryOptimizerStrategies ( )

Definition at line 150 of file BackendRegistry.cpp.

151{
152 return m_MemoryOptimizerStrategyMap;
153}

◆ IsBackendRegistered()

bool IsBackendRegistered ( const BackendId & id) const

Definition at line 52 of file BackendRegistry.cpp.

53{
54 return (m_Factories.find(id) != m_Factories.end());
55}

Referenced by armnn::GetILayerSupportByBackendId(), and DynamicBackendUtils::RegisterDynamicBackendsImpl().

◆ Register()

void Register ( const BackendId & id,
BackendRegistry::FactoryFunction factory )

Definition at line 21 of file BackendRegistry.cpp.

22{
23 if (m_Factories.find(id) != m_Factories.end())
24 {
25 throw InvalidArgumentException(
26 std::string(id) + " already registered as IBackend factory",
28 }
29 m_Factories[id] = factory;
30
31 if (m_ProfilingService.has_value())
32 {
33 if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
34 {
35 m_ProfilingService.value().IncrementCounterValue(arm::pipe::REGISTERED_BACKENDS);
36 }
37 }
38
39}

References CHECK_LOCATION.

Referenced by DynamicBackendUtils::RegisterDynamicBackendsImpl(), and BackendRegistry::StaticRegistryInitializer::StaticRegistryInitializer().

◆ RegisterAllocator()

void RegisterAllocator ( const BackendId & id,
std::shared_ptr< ICustomAllocator > alloc )

Definition at line 112 of file BackendRegistry.cpp.

113{
114 if (m_CustomMemoryAllocatorMap.find(id) != m_CustomMemoryAllocatorMap.end())
115 {
116 throw InvalidArgumentException(
117 std::string(id) + " already has an allocator associated with it",
119 }
120 m_CustomMemoryAllocatorMap[id] = alloc;
121}

References CHECK_LOCATION.

Referenced by RuntimeImpl::RuntimeImpl().

◆ RegisterMemoryOptimizerStrategy()

void RegisterMemoryOptimizerStrategy ( const BackendId & id,
std::shared_ptr< IMemoryOptimizerStrategy > strategy )

Definition at line 133 of file BackendRegistry.cpp.

135{
136 if (m_MemoryOptimizerStrategyMap.find(id) != m_MemoryOptimizerStrategyMap.end())
137 {
138 throw InvalidArgumentException(
139 std::string(id) + " already has an memory optimizer strategy associated with it",
141 }
142 m_MemoryOptimizerStrategyMap[id] = strategy;
143}

References CHECK_LOCATION.

Referenced by RuntimeImpl::RuntimeImpl().

◆ SetProfilingService()

void SetProfilingService ( armnn::Optional< arm::pipe::IProfilingService & > profilingService)

Definition at line 107 of file BackendRegistry.cpp.

108{
109 m_ProfilingService = profilingService;
110}

Referenced by RuntimeImpl::~RuntimeImpl().

◆ Size()

size_t Size ( ) const

Definition at line 70 of file BackendRegistry.cpp.

71{
72 return m_Factories.size();
73}

◆ Swap()

void Swap ( BackendRegistry & instance,
BackendRegistry::FactoryStorage & other )
staticprotected

For testing only.

Definition at line 102 of file BackendRegistry.cpp.

103{
104 std::swap(instance.m_Factories, other);
105}

References BackendRegistry().


The documentation for this class was generated from the following files: