ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::builtin::BackendContext Class Reference

#include <BackendContext.h>

Collaboration diagram for onert::backend::builtin::BackendContext:

Public Member Functions

 BackendContext (const Backend *backend, ContextData &&data, std::shared_ptr< ITensorRegistry > tensor_registry=nullptr, std::shared_ptr< TensorBuilder > tensor_builder=nullptr, std::shared_ptr< KernelGenerator > kernel_gen=nullptr)
 
ITensorRegistrygenTensors () override
 
FunctionMap genKernels () override
 
std::shared_ptr< ExternalContextexternal_context ()
 
- 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< TensorBuildertensor_builder
 
std::shared_ptr< KernelGeneratorkernel_gen
 
- Data Fields inherited from onert::backend::BackendContext
std::shared_ptr< ITensorRegistrytensor_registry
 

Additional Inherited Members

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

Detailed Description

Definition at line 33 of file BackendContext.h.

Constructor & Destructor Documentation

◆ BackendContext()

onert::backend::builtin::BackendContext::BackendContext ( const Backend backend,
ContextData &&  data,
std::shared_ptr< ITensorRegistry tensor_registry = nullptr,
std::shared_ptr< TensorBuilder tensor_builder = nullptr,
std::shared_ptr< KernelGenerator kernel_gen = nullptr 
)
inline

Definition at line 36 of file BackendContext.h.

42 _external_context(std::make_shared<ExternalContext>())
43 {
44 }
std::shared_ptr< ITensorRegistry > tensor_registry
const ContextData & data() const
const Backend * backend() const
std::shared_ptr< KernelGenerator > kernel_gen
std::shared_ptr< TensorBuilder > tensor_builder

Member Function Documentation

◆ external_context()

std::shared_ptr< ExternalContext > onert::backend::builtin::BackendContext::external_context ( )
inline

Definition at line 50 of file BackendContext.h.

50{ return _external_context; }

◆ genKernels()

FunctionMap onert::backend::builtin::BackendContext::genKernels ( )
overridevirtual

Implements onert::backend::BackendContext.

Definition at line 31 of file BackendContext.cc.

32{
33 FunctionMap ret;
34
35 for (auto &&op_ind : _data.op_order)
36 {
37 auto fn_seq = kernel_gen->generate(op_ind);
38 ret.emplace(op_ind, std::move(fn_seq));
39 }
40
41 basic::initConsts(*this);
42
43 // NOTE For memory optimization, we want to free some operand data
44 const_cast<ir::Graph *>(graph())->operands().iterate(
45 [&](const ir::OperandIndex &, ir::Operand &obj) { obj.releaseData(); });
46
47 for (auto &&it : ret)
48 {
49 auto &fn_seq = it.second;
50 fn_seq->iterate([&](exec::IFunction &ifunc) { ifunc.prepare(); });
51 }
52
53 return ret;
54}
const ir::Graph * graph() const
void initConsts(const ir::Operands &operands, const util::Set< ir::OperandIndex > &external_operands, ITensorRegistry *tensor_registry, const ir::OperandIndexMap< ir::OperandIndex > &shared_memory_operands_map)
std::unordered_map< ir::OperationIndex, std::unique_ptr< exec::FunctionSequence > > FunctionMap
::onert::util::Index< uint32_t, OperandIndexTag > OperandIndex
Definition Index.h:35

References onert::backend::BackendContext::_data, onert::backend::BackendContext::graph(), onert::backend::basic::initConsts(), kernel_gen, onert::backend::ContextData::op_order, and onert::exec::IFunction::prepare().

◆ genTensors()

ITensorRegistry * onert::backend::builtin::BackendContext::genTensors ( )
overridevirtual

Implements onert::backend::BackendContext.

Definition at line 29 of file BackendContext.cc.

29{ return basic::genTensors(*this); }
ITensorRegistry * genTensors(const std::shared_ptr< T_TensorBuilder > &tensor_builder, const ir::Graph &graph, const util::Set< ir::OperandIndex > &external_operands, const std::shared_ptr< ITensorRegistry > &tensor_registry, const std::vector< onert::ir::OperationIndex > &op_order, const ir::OperandIndexMap< ir::OperandIndex > &shared_memory_operand_idx)

References onert::backend::basic::genTensors().

Field Documentation

◆ kernel_gen

std::shared_ptr<KernelGenerator> onert::backend::builtin::BackendContext::kernel_gen

Definition at line 59 of file BackendContext.h.

Referenced by genKernels().

◆ tensor_builder

std::shared_ptr<TensorBuilder> onert::backend::builtin::BackendContext::tensor_builder

Definition at line 58 of file BackendContext.h.


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