57 bool file_exists(
const std::string &filename)
59 std::ifstream file(filename);
65 static detail::BackendRegistrar<CLDeviceBackend> CLDeviceBackend_registrar(
Target::CL);
68 : _context_count(0), _tuner(), _gemm_heuristics(), _allocator(nullptr), _tuner_file()
92 _allocator = std::make_unique<CLBufferAllocator>(
nullptr );
99 if(_context_count == 0)
101 _allocator =
nullptr;
109 if(_context_count == 1)
118 if(file_exists(_tuner_file))
161 return _allocator.get();
174 return std::make_unique<CLTensorHandle>(
info);
179 if(parent ==
nullptr)
184 return std::make_unique<CLSubTensorHandle>(parent,
shape, coords, extend_parent);
212 auto lifetime_mgr = std::make_shared<BlobLifetimeManager>();
213 auto pool_mgr = std::make_shared<PoolManager>();
214 auto mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr);
221 auto weights_mgr = std::make_shared<IWeightsManager>();
void setup_backend_context(GraphContext &ctx) override
Setups the given graph context.
DataType data_type
Data type.
TensorShape shape
Tensor shape.
Affinity at buffer level.
void set_tuner_mode(CLTunerMode mode)
Set OpenCL tuner mode.
Affinity at offset level.
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
void set_kernel_tuning(bool enable_tuning)
Switchs on or off the kernel tuning.
~CLDeviceBackend()
Destructor.
CLDeviceBackend()
Default Constructor.
std::unique_ptr< ITensorHandle > create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) override
Create a backend Sub-Tensor.
static CLScheduler & get()
Access the scheduler singleton.
void set_kernel_tuning_mode(CLTunerMode tuning_mode)
Set kernel tuning mode.
Target assigned_target() const
Returns assigned target for this node.
bool insert_weights_management_ctx(WeightsManagerContext &&weights_ctx)
Inserts a weights manager context.
std::shared_ptr< arm_compute::IMemoryGroup > cross_group
Cross-function memory group.
static std::unique_ptr< arm_compute::IFunction > create(INode *node, GraphContext &ctx)
Create a backend execution function depending on the node type.
void load_from_file(const std::string &filename)
Load the tuning parameters table from file.
bool insert_memory_management_ctx(MemoryManagerContext &&memory_ctx)
Inserts a memory manager context.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
WeightsManagerContext * weights_management_ctx(Target target)
Gets a weights manager context for a given target.
void initialize_backend() override
Initializes the backend.
std::unique_ptr< arm_compute::IFunction > configure_node(INode &node, GraphContext &ctx) override
Configure a backend Node.
CLGEMMHeuristicsHandle * gemm_heuristics() const
Accessor for the associated CLGEMMHeuristicsHandle.
Copyright (c) 2017-2021 Arm Limited.
std::string mlgo_file
Filename to load MLGO heuristics from.
std::string tuner_file
File to load/store tuning values from.
bool is_backend_supported() override
Checks if an instantiated backend is actually supported.
TensorDescriptor & desc()
TensorInfo metadata accessor.
std::shared_ptr< arm_compute::IWeightsManager > create_weights_manager() override
Create a backend weights manager.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
QuantizationInfo quant_info
Quantization info.
ITensorInfo & set_data_layout(const DataLayout &data_layout) override
Set the data layout of the tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
bool save_to_file(const std::string &filename) const
Save the content of the tuning parameters table to file.
bool reload_from_file(const std::string &filename)
(Re)Load the heuristics from reading a dotmlgo file
void set_tune_new_kernels(bool tune_new_kernels)
Setter for tune_new_kernels option.
void release_backend_context(GraphContext &ctx) override
Release the backend specific resources associated to a given graph context.
NodeID id() const
Returns node's ID.
Status validate_node(INode &node) override
Validate a node.
std::shared_ptr< arm_compute::IMemoryManager > create_memory_manager(MemoryManagerAffinity affinity) override
Create a backend memory manager given its affinity.
Tensor handle interface object.
std::shared_ptr< arm_compute::IMemoryManager > intra_mm
Intra-function memory manager.
static Status validate(INode *node)
Validate a node.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_GRAPH_WARNING(x)
const GraphConfig & config() const
Graph configuration accessor.
std::shared_ptr< arm_compute::IMemoryManager > cross_mm
Cross-function memory manager.
CLTunerMode
< OpenCL tuner modes
bool use_tuner
Use a tuner in tunable backends.
Contains structs required for weights management.
#define ARM_COMPUTE_LOG_GRAPH_VERBOSE(x)
IAllocator * backend_allocator() override
Gets a backend memory allocator.
Contains structs required for memory management.
Store the tensor's metadata.
std::unique_ptr< ITensorHandle > create_tensor(const Tensor &tensor) override
Create a backend Tensor.
IAllocator * allocator
Backend allocator to use.
void default_init(ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr)
Initialises the context and command queue used by the scheduler to default values and sets a default ...
MemoryManagerContext * memory_management_ctx(Target target)
Gets a memory manager context for a given target.
DataLayout layout
Data layout.
OpenCL capable target device.
MemoryManagerAffinity
Backend Memory Manager affinity.
std::shared_ptr< arm_compute::IWeightsManager > wm
Weights manager.
bool opencl_is_available()
Check if OpenCL is available.