ArmNN
 25.02
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
virtual const BackendId & GetId() const =0
virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const
Create the runtime context of the backend.
virtual IMemoryManagerUniquePtr CreateMemoryManager() const
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
virtual IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
virtual void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry &)
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
virtual OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
virtual IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling)
Create context specifically used for profiling interaction from backends.
ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory()
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
virtual ILayerSupportSharedPtr GetLayerSupport() const =0
std::unique_ptr< IBackendContext > IBackendContextPtr
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace.
bool SupportsTensorAllocatorAPI() const
virtual IWorkloadFactoryPtr CreateWorkloadFactory(const IMemoryManagerSharedPtr &memoryManager=nullptr) const =0
static const FactoryId LegacyFactoryId
void AddUntouchedSubgraph(SubgraphView &&subgraph)
The SubgraphView class represents a subgraph of a Graph.
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
unsigned int MemorySourceFlags
std::vector< BackendOptions > ModelOptions