ArmNN
 20.05
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 
41  return std::make_unique<RefWorkloadFactory>(PolymorphicPointerDowncast<RefMemoryManager>(memoryManager));
42 }
43 
45 {
46  return IBackendContextPtr{};
47 }
48 
51 {
53 }
54 
56 {
57  return std::make_unique<RefMemoryManager>();
58 }
59 
61 {
62  return Optimizations{};
63 }
64 
66 {
67  static ILayerSupportSharedPtr layerSupport{new RefLayerSupport};
68  return layerSupport;
69 }
70 
72 {
73  OptimizationViews optimizationViews;
74 
75  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
76 
77  return optimizationViews;
78 }
79 
80 std::vector<ITensorHandleFactory::FactoryId> RefBackend::GetHandleFactoryPreferences() const
81 {
82  return std::vector<ITensorHandleFactory::FactoryId> { RefTensorHandleFactory::GetIdStatic() };
83 }
84 
86 {
87  auto memoryManager = std::make_shared<RefMemoryManager>();
88 
89  registry.RegisterMemoryManager(memoryManager);
90  registry.RegisterFactory(std::make_unique<RefTensorHandleFactory>(memoryManager));
91 }
92 
93 } // 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:55
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:65
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:85
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:44
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
Definition: RefBackend.cpp:49
The SubgraphView class represents a subgraph of a Graph.
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
Definition: RefBackend.cpp:71
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:60
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: RefBackend.cpp:80
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