ArmNN
 20.11
RefBackend.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RefBackend.hpp"
7 #include "RefBackendId.hpp"
8 #include "RefWorkloadFactory.hpp"
9 #include "RefLayerSupport.hpp"
11 
16 
17 #include <Optimizer.hpp>
18 
19 namespace armnn
20 {
21 
23 {
24  static const BackendId s_Id{RefBackendId()};
25  return s_Id;
26 }
27 
29  const IBackendInternal::IMemoryManagerSharedPtr& memoryManager) const
30 {
31  return std::make_unique<RefWorkloadFactory>(PolymorphicPointerDowncast<RefMemoryManager>(memoryManager));
32 }
33 
35  class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry) const
36 {
37  auto memoryManager = std::make_shared<RefMemoryManager>();
38 
39  tensorHandleFactoryRegistry.RegisterMemoryManager(memoryManager);
40  tensorHandleFactoryRegistry.RegisterFactory(std::make_unique<RefTensorHandleFactory>(memoryManager));
41 
42  return std::make_unique<RefWorkloadFactory>(PolymorphicPointerDowncast<RefMemoryManager>(memoryManager));
43 }
44 
46 {
47  return IBackendContextPtr{};
48 }
49 
52 {
54 }
55 
57 {
58  return std::make_unique<RefMemoryManager>();
59 }
60 
62 {
63  return Optimizations{};
64 }
65 
67 {
68  static ILayerSupportSharedPtr layerSupport{new RefLayerSupport};
69  return layerSupport;
70 }
71 
73 {
74  OptimizationViews optimizationViews;
75 
76  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
77 
78  return optimizationViews;
79 }
80 
81 std::vector<ITensorHandleFactory::FactoryId> RefBackend::GetHandleFactoryPreferences() const
82 {
83  return std::vector<ITensorHandleFactory::FactoryId> { RefTensorHandleFactory::GetIdStatic() };
84 }
85 
87 {
88  auto memoryManager = std::make_shared<RefMemoryManager>();
89 
90  registry.RegisterMemoryManager(memoryManager);
91  registry.RegisterFactory(std::make_unique<RefTensorHandleFactory>(memoryManager));
92 }
93 
94 } // namespace armnn
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
static const FactoryId & GetIdStatic()
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
std::vector< OptimizationPtr > Optimizations
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
Definition: RefBackend.cpp:56
constexpr const char * RefBackendId()
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
Definition: RefBackend.cpp:66
static const BackendId & GetIdStatic()
Definition: RefBackend.cpp:22
void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry &registry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
Definition: RefBackend.cpp:86
Copyright (c) 2020 ARM Limited.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
Definition: RefBackend.cpp:45
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
Definition: RefBackend.cpp:50
The SubgraphView class represents a subgraph of a Graph.
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
Definition: RefBackend.cpp:72
std::unique_ptr< armnn::profiling::IBackendProfiling > IBackendProfilingPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
Definition: RefBackend.cpp:28
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
IBackendInternal::Optimizations GetOptimizations() const override
Definition: RefBackend.cpp:61
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: RefBackend.cpp:81
std::shared_ptr< armnn::profiling::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we&#39;ll keep it in the backend namespace...
std::unique_ptr< IBackendContext > IBackendContextPtr