ArmNN
 25.11
Loading...
Searching...
No Matches
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.
void RegisterMemoryManager (std::shared_ptr< IMemoryManager > memoryManger)
 Register a memory manager with shared ownership.
ITensorHandleFactoryGetFactory (ITensorHandleFactory::FactoryId id) const
 Find a TensorHandleFactory by Id Returns nullptr if not found.
ITensorHandleFactoryGetFactory (ITensorHandleFactory::FactoryId id, MemorySource memSource) const
 Overload of above allowing specification of Memory Source.
void RegisterCopyAndImportFactoryPair (ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
 Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Import.
ITensorHandleFactory::FactoryId GetMatchingImportFactoryId (ITensorHandleFactory::FactoryId copyFactoryId)
 Get a matching TensorHandleFatory Id for Memory Import given TensorHandleFactory Id for Memory Copy.
void AquireMemory ()
 Aquire memory required for inference.
void ReleaseMemory ()
 Release memory required for inference.
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(), ConcatLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), SplitterLayer::CreateTensorHandles(), 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}
unsigned int MemorySourceFlags

◆ 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()

◆ 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 ClBackend::CreateWorkloadFactory(), ClBackend::CreateWorkloadFactory(), ClBackend::CreateWorkloadFactory(), NeonBackend::CreateWorkloadFactory(), NeonBackend::CreateWorkloadFactory(), RefBackend::CreateWorkloadFactory(), TosaRefBackend::CreateWorkloadFactory(), ClBackend::RegisterTensorHandleFactories(), ClBackend::RegisterTensorHandleFactories(), NeonBackend::RegisterTensorHandleFactories(), RefBackend::RegisterTensorHandleFactories(), and TosaRefBackend::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}

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