ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer > Class Template Reference

#include <AclBackendContext.h>

Collaboration diagram for onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >:

Public Member Functions

 AclBackendContext (const Backend *backend, ContextData &&data, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr, std::shared_ptr< T_TensorBuilder > tensor_builder=nullptr, std::shared_ptr< T_ConstantInitializer > constant_initializer=nullptr, std::shared_ptr< T_KernelGenerator > kernel_gen=nullptr)
 
ITensorRegistrygenTensors () override
 
- Public Member Functions inherited from onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >
 BackendContext (const Backend *backend, ContextData &&data, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr, std::shared_ptr< T_TensorBuilder > tensor_builder=nullptr, std::shared_ptr< T_ConstantInitializer > constant_initializer=nullptr, std::shared_ptr< T_KernelGenerator > kernel_gen=nullptr)
 
FunctionMap genKernels () override
 
- Public Member Functions inherited from onert::backend::BackendContext
 BackendContext (const Backend *backend, ContextData &&data, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr)
 
virtual ~BackendContext ()=default
 
const Backendbackend () const
 
const ir::Graphgraph () const
 
const util::Set< ir::OperandIndex > & external_operands () const
 
const ContextDatadata () const
 

Data Fields

std::shared_ptr< T_Optimizer > optimizer
 
- Data Fields inherited from onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >
std::shared_ptr< T_TensorBuilder > tensor_builder
 
std::shared_ptr< T_ConstantInitializer > constant_initializer
 
std::shared_ptr< T_KernelGenerator > kernel_gen
 
- Data Fields inherited from onert::backend::BackendContext
std::shared_ptr< ITensorRegistrytensor_registry
 

Protected Member Functions

void registerTensorInfo (const ir::OperandIndex &ind, const ir::OperandInfo &info) override
 
- Protected Member Functions inherited from onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >
void initConsts ()
 
void planTensors ()
 

Additional Inherited Members

- Protected Attributes inherited from onert::backend::BackendContext
const Backend_backend {nullptr}
 
ContextData _data
 

Detailed Description

template<typename T_TensorBuilder, typename T_ConstantInitializer, typename T_KernelGenerator, typename T_Optimizer>
class onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >

Definition at line 38 of file AclBackendContext.h.

Constructor & Destructor Documentation

◆ AclBackendContext()

template<typename T_TensorBuilder , typename T_ConstantInitializer , typename T_KernelGenerator , typename T_Optimizer >
onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::AclBackendContext ( const Backend backend,
ContextData &&  data,
std::shared_ptr< ITensorRegistry tensor_registry = nullptr,
std::shared_ptr< T_TensorBuilder >  tensor_builder = nullptr,
std::shared_ptr< T_ConstantInitializer >  constant_initializer = nullptr,
std::shared_ptr< T_KernelGenerator >  kernel_gen = nullptr 
)
inline

Definition at line 43 of file AclBackendContext.h.

48 : onert::backend::cl_common::BackendContext<T_TensorBuilder, T_ConstantInitializer,
49 T_KernelGenerator>(
51 {
52 // DO NOTHING
53 }
std::shared_ptr< ITensorRegistry > tensor_registry
const ContextData & data() const
const Backend * backend() const
std::shared_ptr< T_TensorBuilder > tensor_builder
std::shared_ptr< T_ConstantInitializer > constant_initializer
std::shared_ptr< T_KernelGenerator > kernel_gen

Member Function Documentation

◆ genTensors()

template<typename T_TensorBuilder , typename T_ConstantInitializer , typename T_KernelGenerator , typename T_Optimizer >
ITensorRegistry * onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::genTensors ( )
inlineoverridevirtual

Implements onert::backend::BackendContext.

Definition at line 55 of file AclBackendContext.h.

56 {
57 optimizer->optimize();
58
59 this->graph()->operands().iterate([&](const ir::OperandIndex &ind, const ir::Operand &obj) {
60 if (this->external_operands().contains(ind))
61 return;
62
63 ir::OperandInfo backend_info{obj.shape(), obj.typeInfo(), obj.info().memAllocType(),
64 obj.isConstant()};
65 this->tensor_builder->registerTensorInfo(ind, backend_info);
66 });
67
68 // TODO Get compiler options from compiler, and use it rather than getting it from Env
69 if (util::getConfigString(util::config::EXECUTOR) == "Linear")
70 {
71 this->planTensors();
72 }
73 else
74 {
75 // For the executors that does not have fixed linear execution order:
76 // To make tensors never be deallocated, this is a workaround to use static memory planner
77 this->graph()->operands().iterate([&](const ir::OperandIndex &ind, const ir::Operand &) {
78 if (this->tensor_builder->isRegistered(ind))
79 this->tensor_builder->notifyFirstUse(ind);
80 });
81 }
82
83 this->tensor_builder->prepare();
84
85 return this->tensor_registry.get();
86 }
const ir::Graph * graph() const
const util::Set< ir::OperandIndex > & external_operands() const
const Operands & operands() const override
Definition Graph.h:112
void iterate(const std::function< void(const Index &, const Object &)> &fn) const
Iterate over the container with given function.
::onert::util::Index< uint32_t, OperandIndexTag > OperandIndex
Definition Index.h:35
std::string getConfigString(const std::string &key)

References onert::backend::BackendContext::external_operands(), onert::util::getConfigString(), onert::backend::BackendContext::graph(), onert::util::ObjectManager< Index, Object >::iterate(), onert::ir::Graph::operands(), onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::optimizer, onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >::planTensors(), onert::backend::cl_common::BackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator >::tensor_builder, and onert::backend::BackendContext::tensor_registry.

◆ registerTensorInfo()

template<typename T_TensorBuilder , typename T_ConstantInitializer , typename T_KernelGenerator , typename T_Optimizer >
void onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::registerTensorInfo ( const ir::OperandIndex ind,
const ir::OperandInfo info 
)
inlineoverrideprotectedvirtual

Field Documentation

◆ optimizer

template<typename T_TensorBuilder , typename T_ConstantInitializer , typename T_KernelGenerator , typename T_Optimizer >
std::shared_ptr<T_Optimizer> onert::backend::acl_common::AclBackendContext< T_TensorBuilder, T_ConstantInitializer, T_KernelGenerator, T_Optimizer >::optimizer

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