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

#include <KernelGenerator.h>

Collaboration diagram for onert::backend::builtin::KernelGenerator:

Public Member Functions

 KernelGenerator (const ir::Graph &graph, DynamicTensorManager *dyn_tensor_manager, const std::shared_ptr< TensorRegistry > &tensor_reg, const std::shared_ptr< ExternalContext > &external_context)
 
void setTensorRegistries (const compiler::TensorRegistries &tensor_registries)
 
void setExecutors (const std::shared_ptr< exec::IExecutors > &executors)
 
void setModelIndex (const ir::ModelIndex &index)
 
std::unique_ptr< exec::FunctionSequencegenerate (ir::OperationIndex ind) override
 
- Public Member Functions inherited from onert::backend::basic::KernelGeneratorBase
virtual ~KernelGeneratorBase ()=default
 
 KernelGeneratorBase (const ir::Graph &graph)
 
- Public Member Functions inherited from onert::ir::OperationVisitor
virtual ~OperationVisitor ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from onert::backend::basic::KernelGeneratorBase
std::unique_ptr< exec::IFunctionreleaseFunction ()
 
- Protected Attributes inherited from onert::backend::basic::KernelGeneratorBase
const ir::Graph_graph
 
std::unique_ptr< exec::IFunction_return_fn
 

Detailed Description

Definition at line 36 of file KernelGenerator.h.

Constructor & Destructor Documentation

◆ KernelGenerator()

onert::backend::builtin::KernelGenerator::KernelGenerator ( const ir::Graph graph,
DynamicTensorManager dyn_tensor_manager,
const std::shared_ptr< TensorRegistry > &  tensor_reg,
const std::shared_ptr< ExternalContext > &  external_context 
)

Definition at line 32 of file KernelGenerator.cc.

35 : basic::KernelGeneratorBase{graph}, _dyn_tensor_manager{dyn_tensor_manager},
36 _tensor_reg{tensor_reg}, _tensor_registries{}, _executors{nullptr}, _model_index{},
37 _external_context{external_context}
38{
39 // DO NOTHING
40}

Member Function Documentation

◆ generate()

std::unique_ptr< exec::FunctionSequence > onert::backend::builtin::KernelGenerator::generate ( ir::OperationIndex  ind)
overridevirtual

Implements onert::backend::basic::KernelGeneratorBase.

Definition at line 42 of file KernelGenerator.cc.

43{
44 assert(_dyn_tensor_manager);
45 assert(_tensor_reg);
46
47 auto ret = std::make_unique<exec::FunctionSequence>();
48
49 // Prepare to handle dynamic tensors later
50 auto dyn_ctx = std::make_shared<exec::FunctionSequence::DynamicTensorCtx>();
51 {
52 dyn_ctx->op = &_graph.operations().at(ind);
53 dyn_ctx->dynamic_shape_inferer = std::make_unique<exec::DynamicShapeInferer>(_tensor_reg);
54 }
55 ret->dynamic_tensor_ctx(dyn_ctx);
56
57 auto &op = _graph.operations().at(ind);
58 op.accept(*this);
59 assert(_return_fn); // _return_fn must have been generated
60 ret->append(std::move(_return_fn));
61
62 return ret;
63}
std::unique_ptr< exec::IFunction > _return_fn
const Operations & operations() const override
Definition Graph.h:114
const Object & at(const Index &index) const
Get the object that is associated with the given index.

References onert::backend::basic::KernelGeneratorBase::_graph, onert::backend::basic::KernelGeneratorBase::_return_fn, onert::util::ObjectManager< Index, Object >::at(), and onert::ir::Graph::operations().

◆ setExecutors()

void onert::backend::builtin::KernelGenerator::setExecutors ( const std::shared_ptr< exec::IExecutors > &  executors)
inline

Definition at line 47 of file KernelGenerator.h.

48 {
49 // FIXME Using shared_ptr's raw pointer!
50 _executors = executors.get();
51 }

◆ setModelIndex()

void onert::backend::builtin::KernelGenerator::setModelIndex ( const ir::ModelIndex index)
inline

Definition at line 53 of file KernelGenerator.h.

53{ _model_index = index; }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

◆ setTensorRegistries()

void onert::backend::builtin::KernelGenerator::setTensorRegistries ( const compiler::TensorRegistries tensor_registries)
inline

Definition at line 43 of file KernelGenerator.h.

44 {
45 _tensor_registries = tensor_registries;
46 }

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