ArmNN
 25.11
Loading...
Searching...
No Matches
TensorHandleFactoryRegistry.hpp
Go to the documentation of this file.
1//
2// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <armnn/Types.hpp>
10#include <map>
11#include <memory>
12#include <vector>
13
14namespace armnn
15{
16
17//Forward
18class IMemoryManager;
19
20using CopyAndImportFactoryPairs = std::map<ITensorHandleFactory::FactoryId, ITensorHandleFactory::FactoryId>;
21
22///
24{
25public:
27
30
31 /// Register a TensorHandleFactory and transfer ownership
32 void RegisterFactory(std::unique_ptr<ITensorHandleFactory> allocator);
33
34 /// Register a memory manager with shared ownership
35 void RegisterMemoryManager(std::shared_ptr<IMemoryManager> memoryManger);
36
37 /// Find a TensorHandleFactory by Id
38 /// Returns nullptr if not found
40
41 /// Overload of above allowing specification of Memory Source
43 MemorySource memSource) const;
44
45 /// Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Import
47 ITensorHandleFactory::FactoryId importFactoryId);
48
49 /// Get a matching TensorHandleFatory Id for Memory Import given TensorHandleFactory Id for Memory Copy
51
52 /// Aquire memory required for inference
53 void AquireMemory();
54
55 /// Release memory required for inference
56 void ReleaseMemory();
57
58 std::vector<std::shared_ptr<IMemoryManager>>& GetMemoryManagers()
59 {
60 return m_MemoryManagers;
61 }
62
63private:
64 std::vector<std::unique_ptr<ITensorHandleFactory>> m_Factories;
65 std::vector<std::shared_ptr<IMemoryManager>> m_MemoryManagers;
66 CopyAndImportFactoryPairs m_FactoryMappings;
67};
68
69} // namespace armnn
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
TensorHandleFactoryRegistry(TensorHandleFactoryRegistry &&other)=delete
void AquireMemory()
Aquire memory required for inference.
TensorHandleFactoryRegistry(const TensorHandleFactoryRegistry &other)=delete
void ReleaseMemory()
Release memory required for inference.
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
std::vector< std::shared_ptr< IMemoryManager > > & GetMemoryManagers()
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
ITensorHandleFactory::FactoryId GetMatchingImportFactoryId(ITensorHandleFactory::FactoryId copyFactoryId)
Get a matching TensorHandleFatory Id for Memory Import given TensorHandleFactory Id for Memory Copy.
void RegisterCopyAndImportFactoryPair(ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Impor...
Copyright (c) 2021 ARM Limited and Contributors.
MemorySource
Define the Memory Source to reduce copies.
Definition Types.hpp:246
std::map< ITensorHandleFactory::FactoryId, ITensorHandleFactory::FactoryId > CopyAndImportFactoryPairs