ArmNN
 24.02
IBackendInternal.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
9 
10 namespace armnn
11 {
12 
14 {
15  return IMemoryManagerUniquePtr();
16 }
17 
19  class TensorHandleFactoryRegistry& /*tensorHandleFactoryRegistry*/) const
20 {
21  return IWorkloadFactoryPtr{};
22 }
23 
25  const IMemoryManagerSharedPtr& memoryManager,
26  const ModelOptions& modelOptions) const
27 {
28  if (!modelOptions.empty())
29  {
30  for (auto optionsGroup : modelOptions)
31  {
32  if (optionsGroup.GetBackendId() == GetId())
33  {
34  return IWorkloadFactoryPtr{};
35  }
36  }
37  }
38 
39  return CreateWorkloadFactory(memoryManager);
40 }
41 
43  class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry,
44  const ModelOptions& modelOptions) const
45 {
46  if (!modelOptions.empty())
47  {
48  for (auto optionsGroup : modelOptions)
49  {
50  if (optionsGroup.GetBackendId() == GetId())
51  {
52  return IWorkloadFactoryPtr{};
53  }
54  }
55  }
56 
57  return CreateWorkloadFactory(tensorHandleFactoryRegistry);
58 }
59 
61  class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry,
62  const ModelOptions& modelOptions,
63  MemorySourceFlags inputFlags,
64  MemorySourceFlags outputFlags) const
65 {
66  IgnoreUnused(inputFlags);
67  IgnoreUnused(outputFlags);
68  return CreateWorkloadFactory(tensorHandleFactoryRegistry, modelOptions);
69 }
70 
72 {
73  return IBackendContextPtr{};
74 }
75 
77  const ModelOptions&) const
78 {
80 }
81 
84 {
86 }
87 
89 {
90  if (!modelOptions.empty())
91  {
92  for (auto optionsGroup : modelOptions)
93  {
94  if (optionsGroup.GetBackendId() == GetId())
95  {
96  return ILayerSupportSharedPtr{};
97  }
98  }
99  }
100 
101  return GetLayerSupport();
102 }
103 
104 // Default implementation of OptimizeSubgraphView. Returns an untouched subgraph.
105 // Override this method with a custom optimization implementation.
107 {
108  OptimizationViews result;
109  result.AddUntouchedSubgraph(SubgraphView(subgraph));
110 
111  return result;
112 }
113 
115  const ModelOptions& /*modelOptions*/) const
116 {
117  return OptimizeSubgraphView(subgraph);
118 }
119 
121 {
122  return !GetHandleFactoryPreferences().empty();
123 }
124 
126  MemorySourceFlags /*inputFlags*/,
127  MemorySourceFlags /*outputFlags*/)
128 {
129  return RegisterTensorHandleFactories(registry);
130 }
131 
133 {
134  auto favorites = GetHandleFactoryPreferences();
135  if (favorites.empty())
136  {
138  }
139 
140  return favorites[0];
141 }
142 
143 std::vector<ITensorHandleFactory::FactoryId> IBackendInternal::GetHandleFactoryPreferences() const
144 {
145  return std::vector<ITensorHandleFactory::FactoryId>();
146 }
147 
148 } // namespace armnn
armnn::IBackendInternal::GetBackwardCompatibleFavoriteHandleFactory
ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory()
Definition: IBackendInternal.cpp:132
armnn::OptimizationViews::AddUntouchedSubgraph
void AddUntouchedSubgraph(SubgraphView &&subgraph)
Definition: OptimizationViews.hpp:48
armnn::IBackendInternal::IMemoryManagerSharedPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
Definition: IBackendInternal.hpp:99
armnn::TensorHandleFactoryRegistry
Definition: TensorHandleFactoryRegistry.hpp:23
armnn::IBackendInternal::GetLayerSupport
virtual ILayerSupportSharedPtr GetLayerSupport() const =0
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::IBackendInternal::CreateWorkloadFactory
virtual IWorkloadFactoryPtr CreateWorkloadFactory(const IMemoryManagerSharedPtr &memoryManager=nullptr) const =0
armnn::IBackendInternal::IBackendContextPtr
std::unique_ptr< IBackendContext > IBackendContextPtr
Definition: IBackendInternal.hpp:90
WorkloadFactory.hpp
armnn::ITensorHandleFactory::LegacyFactoryId
static const FactoryId LegacyFactoryId
Definition: ITensorHandleFactory.hpp:50
armnn::IBackendInternal::OptimizeSubgraphView
virtual OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const
Definition: IBackendInternal.cpp:106
armnn::IBackend::GetId
virtual const BackendId & GetId() const =0
armnn::IBackendInternal::CreateBackendContext
virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const
Create the runtime context of the backend.
Definition: IBackendInternal.cpp:71
IBackendInternal.hpp
armnn::SubgraphView
The SubgraphView class represents a subgraph of a Graph.
Definition: SubgraphView.hpp:31
armnn::OptimizationViews
Definition: OptimizationViews.hpp:17
armnn::IBackendInternal::CreateMemoryManager
virtual IMemoryManagerUniquePtr CreateMemoryManager() const
Definition: IBackendInternal.cpp:13
armnn::IBackendInternal::IBackendProfilingContextPtr
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace.
Definition: IBackendInternal.hpp:92
armnn::IBackendInternal::CreateBackendProfilingContext
virtual IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling)
Create context specifically used for profiling interaction from backends.
Definition: IBackendInternal.cpp:82
armnn::IBackendInternal::RegisterTensorHandleFactories
virtual void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry &)
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
Definition: IBackendInternal.hpp:157
armnn::IBackendInternal::CreateBackendSpecificModelContext
virtual IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const
Definition: IBackendInternal.cpp:76
armnn::IBackendInternal::IBackendProfilingPtr
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
Definition: IBackendInternal.hpp:93
armnn::IRuntime::CreationOptions
Definition: IRuntime.hpp:78
armnn::IBackendInternal::SupportsTensorAllocatorAPI
bool SupportsTensorAllocatorAPI() const
Definition: IBackendInternal.cpp:120
armnn::IBackendInternal::IMemoryManagerUniquePtr
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
Definition: IBackendInternal.hpp:98
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
BackendOptions.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49
armnn::IBackendInternal::ILayerSupportSharedPtr
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
Definition: IBackendInternal.hpp:94
armnn::IBackendInternal::GetHandleFactoryPreferences
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: IBackendInternal.cpp:143
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::IBackendInternal::IWorkloadFactoryPtr
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
Definition: IBackendInternal.hpp:89
armnn::IBackendInternal::IBackendSpecificModelContextPtr
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
Definition: IBackendInternal.hpp:96