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