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