ArmNN
 20.08
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 
7 
8 namespace armnn
9 {
10 
12 IBackendInternal::ISubGraphConverterPtr IBackendInternal::CreateSubGraphConverter(
13  const std::shared_ptr<SubGraph>& /*subGrapg*/) const
14 {
15  return ISubGraphConverterPtr{};
16 }
17 
19 {
20  return Optimizations{};
21 }
22 
23 IBackendInternal::SubGraphUniquePtr IBackendInternal::OptimizeSubGraph(const SubGraph& /*subGraph*/,
24  bool& optimizationAttempted) const
25 {
26  optimizationAttempted = false;
27  return nullptr;
28 }
30 
32 {
33  return IMemoryManagerUniquePtr();
34 }
35 
37  class TensorHandleFactoryRegistry& /*tensorHandleFactoryRegistry*/) const
38 {
39  return IWorkloadFactoryPtr{};
40 }
41 
43 {
44  return IBackendContextPtr{};
45 }
46 
49 {
51 }
52 
53 // Default implementation of OptimizeSubgraphView for backward compatibility with the old API.
54 // Override this method with a custom optimization implementation.
56 {
57  bool optimizationAttempted = false;
58 
60  SubGraphUniquePtr optSubgraph = OptimizeSubGraph(subgraph, optimizationAttempted);
62 
63  OptimizationViews result;
64  if (!optimizationAttempted)
65  {
66  result.AddUntouchedSubgraph(SubgraphView(subgraph));
67  }
68  else if (optSubgraph)
69  {
70  result.AddSubstitution({subgraph, SubgraphView(*optSubgraph.get())});
71  }
72  else
73  {
74  result.AddFailedSubgraph(SubgraphView(subgraph));
75  }
76 
77  return result;
78 }
79 
81 {
82  return !GetHandleFactoryPreferences().empty();
83 }
84 
86 {
87  auto favorites = GetHandleFactoryPreferences();
88  if (favorites.empty())
89  {
91  }
92 
93  return favorites[0];
94 }
95 
96 std::vector<ITensorHandleFactory::FactoryId> IBackendInternal::GetHandleFactoryPreferences() const
97 {
98  return std::vector<ITensorHandleFactory::FactoryId>();
99 }
100 
101 } // namespace armnn
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
std::vector< OptimizationPtr > Optimizations
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const
Create the runtime context of the backend.
Copyright (c) 2020 ARM Limited.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory()
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::unique_ptr< armnn::profiling::IBackendProfiling > IBackendProfilingPtr
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
bool SupportsTensorAllocatorAPI() const
virtual Optimizations GetOptimizations() const
void AddUntouchedSubgraph(SubgraphView &&subgraph)
virtual IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling)
Create context specifically used for profiling interaction from backends.
virtual OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const
virtual SubGraphUniquePtr OptimizeSubGraph(const SubGraph &subGraph, bool &optimizationAttempted) const
virtual ARMNN_NO_DEPRECATE_WARN_END IMemoryManagerUniquePtr CreateMemoryManager() const
virtual ISubGraphConverterPtr CreateSubGraphConverter(const std::shared_ptr< SubGraph > &subGraph) const
static const FactoryId LegacyFactoryId
std::shared_ptr< armnn::profiling::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we&#39;ll keep it in the backend namespace...
std::unique_ptr< IBackendContext > IBackendContextPtr