ArmNN
 24.08
TensorHandleFactoryRegistry Class Reference

#include <TensorHandleFactoryRegistry.hpp>

Public Member Functions

 TensorHandleFactoryRegistry ()=default
 
 TensorHandleFactoryRegistry (const TensorHandleFactoryRegistry &other)=delete
 
 TensorHandleFactoryRegistry (TensorHandleFactoryRegistry &&other)=delete
 
void RegisterFactory (std::unique_ptr< ITensorHandleFactory > allocator)
 Register a TensorHandleFactory and transfer ownership. More...
 
void RegisterMemoryManager (std::shared_ptr< IMemoryManager > memoryManger)
 Register a memory manager with shared ownership. More...
 
ITensorHandleFactoryGetFactory (ITensorHandleFactory::FactoryId id) const
 Find a TensorHandleFactory by Id Returns nullptr if not found. More...
 
ITensorHandleFactoryGetFactory (ITensorHandleFactory::FactoryId id, MemorySource memSource) const
 Overload of above allowing specification of Memory Source. More...
 
void RegisterCopyAndImportFactoryPair (ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
 Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Import. More...
 
ITensorHandleFactory::FactoryId GetMatchingImportFactoryId (ITensorHandleFactory::FactoryId copyFactoryId)
 Get a matching TensorHandleFatory Id for Memory Import given TensorHandleFactory Id for Memory Copy. More...
 
void AquireMemory ()
 Aquire memory required for inference. More...
 
void ReleaseMemory ()
 Release memory required for inference. More...
 
std::vector< std::shared_ptr< IMemoryManager > > & GetMemoryManagers ()
 

Detailed Description

Definition at line 23 of file TensorHandleFactoryRegistry.hpp.

Constructor & Destructor Documentation

◆ TensorHandleFactoryRegistry() [1/3]

◆ TensorHandleFactoryRegistry() [2/3]

◆ TensorHandleFactoryRegistry() [3/3]

Member Function Documentation

◆ AquireMemory()

void AquireMemory ( )

Aquire memory required for inference.

Definition at line 78 of file TensorHandleFactoryRegistry.cpp.

79 {
80  for (auto& mgr : m_MemoryManagers)
81  {
82  mgr->Acquire();
83  }
84 }

◆ GetFactory() [1/2]

Find a TensorHandleFactory by Id Returns nullptr if not found.

Definition at line 39 of file TensorHandleFactoryRegistry.cpp.

40 {
41  for (auto& factory : m_Factories)
42  {
43  if (factory->GetId() == id)
44  {
45  return factory.get();
46  }
47  }
48 
49  return nullptr;
50 }

Referenced by Graph::AddCompatibilityLayers(), armnn::CalculateEdgeStrategy(), armnn::CalculateSlotOption(), armnn::CalculateSlotOptionForInput(), SplitterLayer::CreateTensorHandles(), ConcatLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), LoadedNetwork::CreateWorkingMemHandle(), LoadedNetwork::ImportInputs(), LoadedNetwork::ImportOutputs(), and armnn::RequiresCopy().

◆ GetFactory() [2/2]

ITensorHandleFactory * GetFactory ( ITensorHandleFactory::FactoryId  id,
MemorySource  memSource 
) const

Overload of above allowing specification of Memory Source.

Definition at line 52 of file TensorHandleFactoryRegistry.cpp.

54 {
55  for (auto& factory : m_Factories)
56  {
57  if (factory->GetId() == id && factory->GetImportFlags() == static_cast<MemorySourceFlags>(memSource))
58  {
59  return factory.get();
60  }
61  }
62 
63  return nullptr;
64 }

◆ GetMatchingImportFactoryId()

ITensorHandleFactory::FactoryId GetMatchingImportFactoryId ( ITensorHandleFactory::FactoryId  copyFactoryId)

Get a matching TensorHandleFatory Id for Memory Import given TensorHandleFactory Id for Memory Copy.

Definition at line 72 of file TensorHandleFactoryRegistry.cpp.

74 {
75  return m_FactoryMappings[copyFactoryId];
76 }

◆ GetMemoryManagers()

std::vector<std::shared_ptr<IMemoryManager> >& GetMemoryManagers ( )
inline

Definition at line 58 of file TensorHandleFactoryRegistry.hpp.

59  {
60  return m_MemoryManagers;
61  }

◆ RegisterCopyAndImportFactoryPair()

void RegisterCopyAndImportFactoryPair ( ITensorHandleFactory::FactoryId  copyFactoryId,
ITensorHandleFactory::FactoryId  importFactoryId 
)

Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Import.

Definition at line 66 of file TensorHandleFactoryRegistry.cpp.

68 {
69  m_FactoryMappings[copyFactoryId] = importFactoryId;
70 }

Referenced by TosaRefBackend::CreateWorkloadFactory(), ClBackend::CreateWorkloadFactory(), NeonBackend::CreateWorkloadFactory(), RefBackend::CreateWorkloadFactory(), TosaRefBackend::RegisterTensorHandleFactories(), ClBackend::RegisterTensorHandleFactories(), RefBackend::RegisterTensorHandleFactories(), and NeonBackend::RegisterTensorHandleFactories().

◆ RegisterFactory()

void RegisterFactory ( std::unique_ptr< ITensorHandleFactory allocator)

Register a TensorHandleFactory and transfer ownership.

Definition at line 12 of file TensorHandleFactoryRegistry.cpp.

13 {
14  if (!newFactory)
15  {
16  return;
17  }
18 
19  ITensorHandleFactory::FactoryId id = newFactory->GetId();
20 
21  // Don't register duplicates
22  for (auto& registeredFactory : m_Factories)
23  {
24  if (id == registeredFactory->GetId())
25  {
26  return;
27  }
28  }
29 
30  // Take ownership of the new allocator
31  m_Factories.push_back(std::move(newFactory));
32 }

Referenced by TosaRefBackend::CreateWorkloadFactory(), ClBackend::CreateWorkloadFactory(), NeonBackend::CreateWorkloadFactory(), RefBackend::CreateWorkloadFactory(), GpuFsaBackend::CreateWorkloadFactory(), TosaRefBackend::RegisterTensorHandleFactories(), RefBackend::RegisterTensorHandleFactories(), ClBackend::RegisterTensorHandleFactories(), NeonBackend::RegisterTensorHandleFactories(), and GpuFsaBackend::RegisterTensorHandleFactories().

◆ RegisterMemoryManager()

◆ ReleaseMemory()

void ReleaseMemory ( )

Release memory required for inference.

Definition at line 86 of file TensorHandleFactoryRegistry.cpp.

87 {
88  for (auto& mgr : m_MemoryManagers)
89  {
90  mgr->Release();
91  }
92 }

Referenced by LoadedNetwork::FreeWorkingMemory().


The documentation for this class was generated from the following files:
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49