Compute Library
 21.11
BackendRegistry Class Referencefinal

Registry holding all the supported backends. More...

#include <BackendRegistry.h>

Public Member Functions

IDeviceBackendfind_backend (Target target)
 Finds a backend in the registry. More...
 
IDeviceBackendget_backend (Target target)
 Get a backend from the registry. More...
 
bool contains (Target target) const
 Checks if a backend for a given target exists. More...
 
const std::map< Target, std::unique_ptr< IDeviceBackend > > & backends () const
 Backends accessor. More...
 
template<typename T >
void add_backend (Target target)
 Registers a backend to the registry. More...
 

Static Public Member Functions

static BackendRegistryget ()
 Gets backend registry instance. More...
 

Detailed Description

Registry holding all the supported backends.

Definition at line 40 of file BackendRegistry.h.

Member Function Documentation

◆ add_backend()

void add_backend ( Target  target)
inline

Registers a backend to the registry.

Parameters
[in]targetExecution target to register for

Definition at line 93 of file BackendRegistry.h.

Referenced by BackendRegistrar< T >::BackendRegistrar().

94 {
95  _registered_backends[target] = std::make_unique<T>();
96 }

◆ backends()

const std::map< Target, std::unique_ptr< IDeviceBackend > > & backends ( ) const

Backends accessor.

Returns
Map containing the registered backends

Definition at line 65 of file BackendRegistry.cpp.

66 {
67  return _registered_backends;
68 }

◆ contains()

bool contains ( Target  target) const

Checks if a backend for a given target exists.

Parameters
[in]targetExecution target
Returns
True if exists else false

Definition at line 59 of file BackendRegistry.cpp.

Referenced by arm_compute::graph::is_target_supported().

60 {
61  auto it = _registered_backends.find(target);
62  return (it != _registered_backends.end());
63 }

◆ find_backend()

IDeviceBackend * find_backend ( Target  target)

Finds a backend in the registry.

Parameters
[in]targetBackend target
Returns
Pointer to the backend interface if found, else nullptr

Definition at line 45 of file BackendRegistry.cpp.

References ARM_COMPUTE_ERROR_ON.

Referenced by arm_compute::graph::is_target_supported(), and arm_compute::graph::setup_requested_backend_context().

46 {
48  return _registered_backends[target].get();
49 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
bool contains(Target target) const
Checks if a backend for a given target exists.

◆ get()

◆ get_backend()

IDeviceBackend & get_backend ( Target  target)

Get a backend from the registry.

The backend must be present and supported.

Parameters
[in]targetBackend target
Returns
Reference to the backend interface

Definition at line 51 of file BackendRegistry.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, and IDeviceBackend::is_backend_supported().

Referenced by arm_compute::graph::detail::configure_all_nodes(), arm_compute::graph::detail::configure_all_tensors(), arm_compute::graph::configure_tensor(), DepthConcatSubTensorMutator::mutate(), SplitLayerSubTensorMutator::mutate(), GroupedConvolutionMutator::mutate(), and arm_compute::graph::detail::validate_all_nodes().

52 {
53  IDeviceBackend *backend = find_backend(target);
54  ARM_COMPUTE_ERROR_ON_MSG(!backend, "Requested backend doesn't exist!");
55  ARM_COMPUTE_ERROR_ON_MSG(!backend->is_backend_supported(), "Requested backend isn't supported");
56  return *backend;
57 }
virtual bool is_backend_supported()=0
Checks if an instantiated backend is actually supported.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
IDeviceBackend * find_backend(Target target)
Finds a backend in the registry.

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