ArmNN
 22.08
EthosnRefBackend Class Reference

#include <EthosnRefBackend.hpp>

Inheritance diagram for EthosnRefBackend:
IBackendInternal IBackend

Public Member Functions

 EthosnRefBackend ()=default
 
 ~EthosnRefBackend ()=default
 
const BackendIdGetId () const override
 
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager () const override
 
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory (const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
 
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory (class TensorHandleFactoryRegistry &tensorHandleFactoryRegistry) const override
 
IBackendInternal::IBackendContextPtr CreateBackendContext (const IRuntime::CreationOptions &) const override
 Create the runtime context of the backend. More...
 
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext (const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling) override
 Create context specifically used for profiling interaction from backends. More...
 
IBackendInternal::Optimizations GetOptimizations () const override
 
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport () const override
 
OptimizationViews OptimizeSubgraphView (const SubgraphView &subgraph) const override
 
std::vector< ITensorHandleFactory::FactoryIdGetHandleFactoryPreferences () const override
 (Optional) Returns a vector of supported TensorHandleFactory ids in preference order. More...
 
void RegisterTensorHandleFactories (class TensorHandleFactoryRegistry &registry) override
 (Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFactory::CreateTensor()/IWorkloadFactory::CreateSubtensor() methods must be implemented. More...
 
- Public Member Functions inherited from IBackendInternal
 ~IBackendInternal () override=default
 Allow backends created by the factory function to be destroyed through IBackendInternal. More...
 
virtual IWorkloadFactoryPtr CreateWorkloadFactory (const IMemoryManagerSharedPtr &memoryManager, const ModelOptions &modelOptions) const
 
virtual IWorkloadFactoryPtr CreateWorkloadFactory (class TensorHandleFactoryRegistry &tensorHandleFactoryRegistry, const ModelOptions &modelOptions) const
 
virtual IWorkloadFactoryPtr CreateWorkloadFactory (class TensorHandleFactoryRegistry &tensorHandleFactoryRegistry, const ModelOptions &modelOptions, MemorySourceFlags inputFlags, MemorySourceFlags outputFlags) const
 
virtual IBackendSpecificModelContextPtr CreateBackendSpecificModelContext (const ModelOptions &modelOptions) const
 
virtual ILayerSupportSharedPtr GetLayerSupport (const ModelOptions &modelOptions) const
 
virtual OptimizationViews OptimizeSubgraphView (const SubgraphView &subgraph, const ModelOptions &modelOptions) const
 
bool SupportsTensorAllocatorAPI () const
 
ITensorHandleFactory::FactoryId GetBackwardCompatibleFavoriteHandleFactory ()
 
virtual void RegisterTensorHandleFactories (class TensorHandleFactoryRegistry &registry, MemorySourceFlags inputFlags, MemorySourceFlags outputFlags)
 (Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFactory::CreateTensor()/IWorkloadFactory::CreateSubtensor() methods must be implemented. More...
 
virtual BackendCapabilities GetCapabilities () const
 Returns a BackendCapability if the backend lists the capability The BackendCapability must then be inspected to check whether or not that BackendCapability is supported Otherwise returns an EmptyOptional if the BackendCapability is unlisted. More...
 
virtual bool UseCustomMemoryAllocator (std::shared_ptr< ICustomAllocator > allocator, armnn::Optional< std::string &> errMsg)
 Signals the backend to use a custom memory allocator provided by the user. More...
 
virtual std::unique_ptr< ICustomAllocatorGetDefaultAllocator () const
 Returns the default memory allocator for the backend. More...
 
virtual unsigned int GetNumberOfCacheFiles () const
 Returns the number of files cached if backend supports caching. More...
 
virtual ExecutionData CreateExecutionData (WorkingMemDescriptor &workingMemDescriptor) const
 Returns ExecutionData for the backend. More...
 
virtual void UpdateExecutionData (ExecutionData &executionData, WorkingMemDescriptor &workingMemDescriptor) const
 Update the ExecutionData for a layer. More...
 

Static Public Member Functions

static const BackendIdGetIdStatic ()
 
- Static Public Member Functions inherited from IBackendInternal
static constexpr BackendVersion GetApiVersion ()
 Returns the version of the Backend API. More...
 

Additional Inherited Members

- Public Types inherited from IBackendInternal
using IWorkloadFactoryPtr = std::unique_ptr< IWorkloadFactory >
 
using IBackendContextPtr = std::unique_ptr< IBackendContext >
 
using IBackendProfilingContextPtr = std::shared_ptr< arm::pipe::IBackendProfilingContext >
 This is the bridge between backend and backend profiling we'll keep it in the backend namespace. More...
 
using IBackendProfilingPtr = std::unique_ptr< arm::pipe::IBackendProfiling >
 
using ILayerSupportSharedPtr = std::shared_ptr< ILayerSupport >
 
using IBackendSpecificModelContextPtr = std::shared_ptr< IBackendModelContext >
 
using IMemoryManagerUniquePtr = std::unique_ptr< IMemoryManager >
 
using IMemoryManagerSharedPtr = std::shared_ptr< IMemoryManager >
 
- Protected Member Functions inherited from IBackendInternal
 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 12 of file EthosnRefBackend.hpp.

Constructor & Destructor Documentation

◆ EthosnRefBackend()

EthosnRefBackend ( )
default

◆ ~EthosnRefBackend()

~EthosnRefBackend ( )
default

Member Function Documentation

◆ CreateBackendContext()

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

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 from IBackendInternal.

Definition at line 50 of file EthosnRefBackend.cpp.

References BackendOptions::Var::AsBool(), BackendOptions::Var::AsString(), EthosnRefBackend::GetId(), BackendOptions::BackendOption::GetName(), BackendOptions::BackendOption::GetValue(), BackendOptions::Var::IsBool(), BackendOptions::Var::IsString(), and IRuntime::CreationOptions::m_BackendOptions.

Referenced by EthosnRefBackend::GetId().

51 {
52  VarGlobal_EnableWinograd = false;
53  VarGlobal_BlockConfigs = "";
54 
55  for (auto optionsGroup : creationOptions.m_BackendOptions)
56  {
57  if (optionsGroup.GetBackendId() == EthosnRefBackend::GetId())
58  {
59  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
60  {
61  const BackendOptions::BackendOption option = optionsGroup.GetOption(i);
62 
63  if(option.GetName() == "EnableWinograd" && option.GetValue().IsBool() == true) {
64  VarGlobal_EnableWinograd = option.GetValue().AsBool();
65  }
66  if(option.GetName() == "BlockConfigs" && option.GetValue().IsString() == true) {
67  VarGlobal_BlockConfigs = option.GetValue().AsString();
68  }
69  }
70  }
71  }
72  return IBackendContextPtr{};
73 }
const BackendId & GetId() const override
std::unique_ptr< IBackendContext > IBackendContextPtr

◆ CreateBackendProfilingContext()

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

Create context specifically used for profiling interaction from backends.

Reimplemented from IBackendInternal.

Definition at line 75 of file EthosnRefBackend.cpp.

Referenced by EthosnRefBackend::GetId().

77 {
79 }
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...

◆ CreateMemoryManager()

IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager ( ) const
overridevirtual

Reimplemented from IBackendInternal.

Definition at line 81 of file EthosnRefBackend.cpp.

Referenced by EthosnRefBackend::GetId().

82 {
83  return std::make_unique<EthosnRefMemoryManager>();
84 }

◆ CreateWorkloadFactory() [1/2]

IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory ( const IBackendInternal::IMemoryManagerSharedPtr memoryManager = nullptr) const
overridevirtual

Implements IBackendInternal.

Definition at line 33 of file EthosnRefBackend.cpp.

Referenced by EthosnRefBackend::GetId().

35 {
36  return std::make_unique<EthosnRefWorkloadFactory>(PolymorphicPointerDowncast<EthosnRefMemoryManager>(memoryManager), VarGlobal_EnableWinograd, VarGlobal_BlockConfigs);
37 }

◆ CreateWorkloadFactory() [2/2]

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

Reimplemented from IBackendInternal.

Definition at line 39 of file EthosnRefBackend.cpp.

References TensorHandleFactoryRegistry::RegisterFactory(), and TensorHandleFactoryRegistry::RegisterMemoryManager().

41 {
42  auto memoryManager = std::make_shared<EthosnRefMemoryManager>();
43 
44  tensorHandleFactoryRegistry.RegisterMemoryManager(memoryManager);
45  tensorHandleFactoryRegistry.RegisterFactory(std::make_unique<EthosnRefTensorHandleFactory>(memoryManager));
46 
47  return std::make_unique<EthosnRefWorkloadFactory>(PolymorphicPointerDowncast<EthosnRefMemoryManager>(memoryManager), VarGlobal_EnableWinograd, VarGlobal_BlockConfigs);
48 }

◆ GetHandleFactoryPreferences()

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

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

Reimplemented from IBackendInternal.

Definition at line 106 of file EthosnRefBackend.cpp.

References EthosnRefTensorHandleFactory::GetIdStatic().

Referenced by EthosnRefBackend::GetId().

107 {
108  return std::vector<ITensorHandleFactory::FactoryId> { EthosnRefTensorHandleFactory::GetIdStatic() };
109 }

◆ GetId()

◆ GetIdStatic()

const BackendId & GetIdStatic ( )
static

Definition at line 27 of file EthosnRefBackend.cpp.

References armnn::EthosnRefBackendId().

Referenced by EthosnRefBackend::GetId().

28 {
29  static const BackendId s_Id{EthosnRefBackendId()};
30  return s_Id;
31 }
constexpr const char * EthosnRefBackendId()

◆ GetLayerSupport()

IBackendInternal::ILayerSupportSharedPtr GetLayerSupport ( ) const
overridevirtual

Implements IBackendInternal.

Definition at line 91 of file EthosnRefBackend.cpp.

Referenced by EthosnRefBackend::GetId().

92 {
93  static ILayerSupportSharedPtr layerSupport{new EthosnRefLayerSupport};
94  return layerSupport;
95 }
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr

◆ GetOptimizations()

IBackendInternal::Optimizations GetOptimizations ( ) const
override

Definition at line 86 of file EthosnRefBackend.cpp.

Referenced by EthosnRefBackend::GetId().

87 {
88  return Optimizations{};
89 }

◆ OptimizeSubgraphView()

OptimizationViews OptimizeSubgraphView ( const SubgraphView subgraph) const
overridevirtual

Reimplemented from IBackendInternal.

Definition at line 97 of file EthosnRefBackend.cpp.

References OptimizationViews::AddUntouchedSubgraph().

Referenced by EthosnRefBackend::GetId().

98 {
99  OptimizationViews optimizationViews;
100 
101  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
102 
103  return optimizationViews;
104 }

◆ RegisterTensorHandleFactories()

void RegisterTensorHandleFactories ( class TensorHandleFactoryRegistry )
overridevirtual

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

Reimplemented from IBackendInternal.

Definition at line 111 of file EthosnRefBackend.cpp.

References TensorHandleFactoryRegistry::RegisterFactory(), and TensorHandleFactoryRegistry::RegisterMemoryManager().

Referenced by EthosnRefBackend::GetId().

112 {
113  auto memoryManager = std::make_shared<EthosnRefMemoryManager>();
114 
115  registry.RegisterMemoryManager(memoryManager);
116  registry.RegisterFactory(std::make_unique<EthosnRefTensorHandleFactory>(memoryManager));
117 }

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