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

#include <BackendContext.h>

Collaboration diagram for onert::backend::trix::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< DevContextdev_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 32 of file BackendContext.h.

Constructor & Destructor Documentation

◆ BackendContext()

onert::backend::trix::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 35 of file BackendContext.h.

40 tensor_builder{tensor_builder}, kernel_gen{kernel_gen}, _dev_context(new DevContext)
41 {
42 }
std::shared_ptr< ITensorRegistry > tensor_registry
const ContextData & data() const
const Backend * backend() const
std::shared_ptr< TensorBuilder > tensor_builder
std::shared_ptr< KernelGenerator > kernel_gen

Member Function Documentation

◆ dev_context()

std::shared_ptr< DevContext > onert::backend::trix::BackendContext::dev_context ( )
inline

Definition at line 47 of file BackendContext.h.

47{ return _dev_context; }

◆ genKernels()

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

Implements onert::backend::BackendContext.

Definition at line 36 of file BackendContext.cc.

37{
38 FunctionMap ret;
39
40 for (auto &&op_ind : _data.op_order)
41 {
42 auto fn_seq = kernel_gen->generate(op_ind);
43 ret.emplace(op_ind, std::move(fn_seq));
44 }
45
46 basic::initConsts(*this);
47
48 // NOTE For memory optimization, we want to free some operand data
49 const_cast<ir::Graph &>(*_data.graph)
50 .operands()
51 .iterate([&](const ir::OperandIndex &, ir::Operand &obj) { obj.releaseData(); });
52
53 for (auto &&it : ret)
54 {
55 auto &fn_seq = it.second;
56 fn_seq->iterate([&](exec::IFunction &ifunc) { ifunc.prepare(); });
57 }
58
59 return ret;
60}
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
std::unique_ptr< ir::Graph > graph

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

◆ genTensors()

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

Implements onert::backend::BackendContext.

Definition at line 34 of file BackendContext.cc.

34{ 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::trix::BackendContext::kernel_gen

Definition at line 52 of file BackendContext.h.

Referenced by genKernels().

◆ tensor_builder

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

Definition at line 51 of file BackendContext.h.


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