ArmNN
 20.08
IBackendInternal Class Referenceabstract

#include <IBackendInternal.hpp>

Inheritance diagram for IBackendInternal:
IBackend ClBackend MockBackend MockImportBackend NeonBackend RefBackend

Public Types

using IWorkloadFactoryPtr = std::unique_ptr< IWorkloadFactory >
 
using IBackendContextPtr = std::unique_ptr< IBackendContext >
 
using IBackendProfilingContextPtr = std::shared_ptr< armnn::profiling::IBackendProfilingContext >
 This is the bridge between backend and backend profiling we'll keep it in the backend namespace. More...
 
using IBackendProfilingPtr = std::unique_ptr< armnn::profiling::IBackendProfiling >
 
using OptimizationPtr = std::unique_ptr< Optimization >
 
using Optimizations = std::vector< OptimizationPtr >
 
using ILayerSupportSharedPtr = std::shared_ptr< ILayerSupport >
 
using IMemoryManagerUniquePtr = std::unique_ptr< IMemoryManager >
 
using IMemoryManagerSharedPtr = std::shared_ptr< IMemoryManager >
 
using GraphUniquePtr = std::unique_ptr< Graph >
 
using SubgraphViewUniquePtr = std::unique_ptr< SubgraphView >
 
using supported = std::unique_ptr< ISubGraphConverter >
 
using instead = std::unique_ptr< SubGraph >
 

Public Member Functions

 ~IBackendInternal () override=default
 Allow backends created by the factory function to be destroyed through IBackendInternal. More...
 
virtual ISubGraphConverterPtr CreateSubGraphConverter (const std::shared_ptr< SubGraph > &subGraph) const
 
virtual Optimizations GetOptimizations () const
 
virtual SubGraphUniquePtr OptimizeSubGraph (const SubGraph &subGraph, bool &optimizationAttempted) const
 
virtual ARMNN_NO_DEPRECATE_WARN_END IMemoryManagerUniquePtr CreateMemoryManager () const
 
virtual IWorkloadFactoryPtr CreateWorkloadFactory (const IMemoryManagerSharedPtr &memoryManager=nullptr) const =0
 
virtual IWorkloadFactoryPtr CreateWorkloadFactory (class TensorHandleFactoryRegistry &tensorHandleFactoryRegistry) const
 
virtual IBackendContextPtr CreateBackendContext (const IRuntime::CreationOptions &) const
 Create the runtime context of the backend. More...
 
virtual IBackendProfilingContextPtr CreateBackendProfilingContext (const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling)
 Create context specifically used for profiling interaction from backends. More...
 
virtual ILayerSupportSharedPtr GetLayerSupport () const =0
 
virtual OptimizationViews OptimizeSubgraphView (const SubgraphView &subgraph) const
 
bool SupportsTensorAllocatorAPI () const
 
ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory ()
 
virtual std::vector< ITensorHandleFactory::FactoryIdGetHandleFactoryPreferences () const
 (Optional) Returns a vector of supported TensorHandleFactory ids in preference order. More...
 
virtual void RegisterTensorHandleFactories (class TensorHandleFactoryRegistry &)
 (Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFactory::CreateTensor()/IWorkloadFactory::CreateSubtensor() methods must be implemented. More...
 
- Public Member Functions inherited from IBackend
virtual const BackendIdGetId () const =0
 

Static Public Member Functions

static constexpr BackendVersion GetApiVersion ()
 Returns the version of the Backend API. More...
 

Protected Member Functions

 IBackendInternal ()=default
 Creation must be done through a specific backend interface. More...
 
- Protected Member Functions inherited from IBackend
 IBackend ()
 
virtual ~IBackend ()
 

Detailed Description

Definition at line 68 of file IBackendInternal.hpp.

Member Typedef Documentation

◆ GraphUniquePtr

using GraphUniquePtr = std::unique_ptr<Graph>

Definition at line 92 of file IBackendInternal.hpp.

◆ IBackendContextPtr

using IBackendContextPtr = std::unique_ptr<IBackendContext>

Definition at line 81 of file IBackendInternal.hpp.

◆ IBackendProfilingContextPtr

This is the bridge between backend and backend profiling we'll keep it in the backend namespace.

Definition at line 83 of file IBackendInternal.hpp.

◆ IBackendProfilingPtr

Definition at line 84 of file IBackendInternal.hpp.

◆ ILayerSupportSharedPtr

using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>

Definition at line 87 of file IBackendInternal.hpp.

◆ IMemoryManagerSharedPtr

using IMemoryManagerSharedPtr = std::shared_ptr<IMemoryManager>

Definition at line 90 of file IBackendInternal.hpp.

◆ IMemoryManagerUniquePtr

using IMemoryManagerUniquePtr = std::unique_ptr<IMemoryManager>

Definition at line 89 of file IBackendInternal.hpp.

◆ instead

using instead = std::unique_ptr<SubGraph>

Definition at line 99 of file IBackendInternal.hpp.

◆ IWorkloadFactoryPtr

using IWorkloadFactoryPtr = std::unique_ptr<IWorkloadFactory>

Definition at line 80 of file IBackendInternal.hpp.

◆ OptimizationPtr

using OptimizationPtr = std::unique_ptr<Optimization>

Definition at line 85 of file IBackendInternal.hpp.

◆ Optimizations

using Optimizations = std::vector<OptimizationPtr>

Definition at line 86 of file IBackendInternal.hpp.

◆ SubgraphViewUniquePtr

using SubgraphViewUniquePtr = std::unique_ptr<SubgraphView>

Definition at line 93 of file IBackendInternal.hpp.

◆ supported

using supported = std::unique_ptr<ISubGraphConverter>

Definition at line 97 of file IBackendInternal.hpp.

Constructor & Destructor Documentation

◆ IBackendInternal()

IBackendInternal ( )
protecteddefault

Creation must be done through a specific backend interface.

◆ ~IBackendInternal()

~IBackendInternal ( )
overridedefault

Allow backends created by the factory function to be destroyed through IBackendInternal.

Member Function Documentation

◆ CreateBackendContext()

IBackendInternal::IBackendContextPtr CreateBackendContext ( const IRuntime::CreationOptions ) const
virtual

Create the runtime context of the backend.

Implementations may return a default-constructed IBackendContextPtr if no context is needed at runtime. Implementations must throw BackendUnavailableException if the backend cannot be used (for example, necessary accelerator hardware is not present). The default implementation always returns a default-constructed pointer.

Reimplemented in MockBackend, MockImportBackend, ClBackend, NeonBackend, and RefBackend.

Definition at line 42 of file IBackendInternal.cpp.

43 {
44  return IBackendContextPtr{};
45 }
std::unique_ptr< IBackendContext > IBackendContextPtr

◆ CreateBackendProfilingContext()

IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext ( const IRuntime::CreationOptions creationOptions,
IBackendProfilingPtr backendProfiling 
)
virtual

Create context specifically used for profiling interaction from backends.

Reimplemented in MockBackend, MockImportBackend, ClBackend, RefBackend, and NeonBackend.

Definition at line 47 of file IBackendInternal.cpp.

49 {
51 }
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...

◆ CreateMemoryManager()

ARMNN_NO_DEPRECATE_WARN_END IMemoryManagerUniquePtr CreateMemoryManager ( ) const
virtual

Reimplemented in MockBackend, MockImportBackend, ClBackend, NeonBackend, and RefBackend.

Definition at line 31 of file IBackendInternal.cpp.

Referenced by LoadedNetwork::MakeLoadedNetwork().

32 {
33  return IMemoryManagerUniquePtr();
34 }
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr

◆ CreateSubGraphConverter()

ARMNN_NO_DEPRECATE_WARN_BEGIN IBackendInternal::ISubGraphConverterPtr CreateSubGraphConverter ( const std::shared_ptr< SubGraph > &  subGraph) const
virtual

Definition at line 12 of file IBackendInternal.cpp.

14 {
15  return ISubGraphConverterPtr{};
16 }

◆ CreateWorkloadFactory() [1/2]

virtual IWorkloadFactoryPtr CreateWorkloadFactory ( const IMemoryManagerSharedPtr memoryManager = nullptr) const
pure virtual

◆ CreateWorkloadFactory() [2/2]

IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory ( class TensorHandleFactoryRegistry tensorHandleFactoryRegistry) const
virtual

Reimplemented in MockImportBackend, ClBackend, NeonBackend, and RefBackend.

Definition at line 36 of file IBackendInternal.cpp.

38 {
39  return IWorkloadFactoryPtr{};
40 }
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr

◆ GetApiVersion()

static constexpr BackendVersion GetApiVersion ( )
inlinestatic

Returns the version of the Backend API.

Definition at line 149 of file IBackendInternal.hpp.

References BackendVersion::BackendVersion().

Referenced by DynamicBackend::DynamicBackend(), GetVersion(), and DynamicBackendUtils::IsBackendCompatible().

149 { return BackendVersion(1, 0); }

◆ GetBackwardCompatibleFavoriteHandleFactory()

ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory ( )

Definition at line 85 of file IBackendInternal.cpp.

References IBackendInternal::GetHandleFactoryPreferences(), and ITensorHandleFactory::LegacyFactoryId.

86 {
87  auto favorites = GetHandleFactoryPreferences();
88  if (favorites.empty())
89  {
91  }
92 
93  return favorites[0];
94 }
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
static const FactoryId LegacyFactoryId

◆ GetHandleFactoryPreferences()

std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences ( ) const
virtual

(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.

Reimplemented in MockImportBackend, RefBackend, NeonBackend, and ClBackend.

Definition at line 96 of file IBackendInternal.cpp.

Referenced by armnn::CalculateSlotOption(), IBackendInternal::GetBackwardCompatibleFavoriteHandleFactory(), and IBackendInternal::SupportsTensorAllocatorAPI().

97 {
98  return std::vector<ITensorHandleFactory::FactoryId>();
99 }

◆ GetLayerSupport()

virtual ILayerSupportSharedPtr GetLayerSupport ( ) const
pure virtual

◆ GetOptimizations()

IBackendInternal::Optimizations GetOptimizations ( ) const
virtual

Reimplemented in MockBackend, MockImportBackend, ClBackend, RefBackend, and NeonBackend.

Definition at line 18 of file IBackendInternal.cpp.

19 {
20  return Optimizations{};
21 }
std::vector< OptimizationPtr > Optimizations

◆ OptimizeSubGraph()

IBackendInternal::SubGraphUniquePtr OptimizeSubGraph ( const SubGraph &  subGraph,
bool &  optimizationAttempted 
) const
virtual

Definition at line 23 of file IBackendInternal.cpp.

References ARMNN_NO_DEPRECATE_WARN_END.

Referenced by IBackendInternal::OptimizeSubgraphView().

25 {
26  optimizationAttempted = false;
27  return nullptr;
28 }

◆ OptimizeSubgraphView()

OptimizationViews OptimizeSubgraphView ( const SubgraphView subgraph) const
virtual

Reimplemented in MockBackend, MockImportBackend, ClBackend, RefBackend, and NeonBackend.

Definition at line 55 of file IBackendInternal.cpp.

References OptimizationViews::AddUntouchedSubgraph(), ARMNN_NO_DEPRECATE_WARN_BEGIN, ARMNN_NO_DEPRECATE_WARN_END, and IBackendInternal::OptimizeSubGraph().

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 }
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
virtual SubGraphUniquePtr OptimizeSubGraph(const SubGraph &subGraph, bool &optimizationAttempted) const

◆ RegisterTensorHandleFactories()

virtual void RegisterTensorHandleFactories ( class TensorHandleFactoryRegistry )
inlinevirtual

(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFactory::CreateTensor()/IWorkloadFactory::CreateSubtensor() methods must be implemented.

Reimplemented in MockImportBackend, RefBackend, NeonBackend, and ClBackend.

Definition at line 146 of file IBackendInternal.hpp.

146 {}

◆ SupportsTensorAllocatorAPI()

bool SupportsTensorAllocatorAPI ( ) const

Definition at line 80 of file IBackendInternal.cpp.

References IBackendInternal::GetHandleFactoryPreferences().

Referenced by LoadedNetwork::MakeLoadedNetwork().

81 {
82  return !GetHandleFactoryPreferences().empty();
83 }
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.

The documentation for this class was generated from the following files: