ArmNN  NotReleased
NeonBackend.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 "NeonBackend.hpp"
7 #include "NeonBackendId.hpp"
9 #include "NeonLayerSupport.hpp"
11 
13 
15 
18 
19 #include <Optimizer.hpp>
20 
21 #include <arm_compute/runtime/Allocator.h>
22 
23 #include <boost/cast.hpp>
24 #include <boost/polymorphic_pointer_cast.hpp>
25 
26 namespace armnn
27 {
28 
30 {
31  static const BackendId s_Id{NeonBackendId()};
32  return s_Id;
33 }
34 
36 {
37  return std::make_unique<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
39 }
40 
42  const IBackendInternal::IMemoryManagerSharedPtr& memoryManager) const
43 {
44  return std::make_unique<NeonWorkloadFactory>(
45  boost::polymorphic_pointer_downcast<NeonMemoryManager>(memoryManager));
46 }
47 
49  class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry) const
50 {
51  auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
53 
54  tensorHandleFactoryRegistry.RegisterMemoryManager(memoryManager);
55  return std::make_unique<NeonWorkloadFactory>(
56  boost::polymorphic_pointer_downcast<NeonMemoryManager>(memoryManager));
57 }
58 
60 {
61  return IBackendContextPtr{};
62 }
63 
66 {
68 }
69 
71 {
72  return Optimizations{};
73 }
74 
76 {
77  static ILayerSupportSharedPtr layerSupport{new NeonLayerSupport};
78  return layerSupport;
79 }
80 
82 {
83  OptimizationViews optimizationViews;
84 
85  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
86 
87  return optimizationViews;
88 }
89 
90 std::vector<ITensorHandleFactory::FactoryId> NeonBackend::GetHandleFactoryPreferences() const
91 {
92  return std::vector<ITensorHandleFactory::FactoryId>() = {"Arm/Neon/TensorHandleFactory",
93  "Arm/Cl/TensorHandleFactory"};
94 }
95 
97 {
98  auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
100 
101  registry.RegisterMemoryManager(memoryManager);
102  registry.RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
103 }
104 
105 } // namespace armnn
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
Definition: NeonBackend.cpp:81
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
std::vector< OptimizationPtr > Optimizations
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Definition: NeonBackend.cpp:59
void AddUntouchedSubgraph(SubgraphView &&subgraph)
IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
Definition: NeonBackend.cpp:41
std::unique_ptr< IBackendContext > IBackendContextPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
static const BackendId & GetIdStatic()
Definition: NeonBackend.cpp:29
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
Definition: NeonBackend.cpp:64
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: NeonBackend.cpp:90
IBackendInternal::Optimizations GetOptimizations() const override
Definition: NeonBackend.cpp:70
void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry &registry) override
Definition: NeonBackend.cpp:96
constexpr const char * NeonBackendId()
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
Definition: NeonBackend.cpp:35
std::shared_ptr< armnn::profiling::IBackendProfilingContext > IBackendProfilingContextPtr
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
Definition: NeonBackend.cpp:75
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
std::unique_ptr< armnn::profiling::IBackendProfiling > IBackendProfilingPtr