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

#include <KernelGenerator.h>

Collaboration diagram for onert::backend::cpu::KernelGenerator:

Public Member Functions

 KernelGenerator (const ir::Graph &graph, const std::shared_ptr< TensorBuilder > &tensor_builder, const std::shared_ptr< basic::TensorRegistry > &tensor_reg, const std::shared_ptr< ExternalContext > &external_context)
 
std::unique_ptr< exec::FunctionSequencegenerate (ir::OperationIndex op_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 32 of file KernelGenerator.h.

Constructor & Destructor Documentation

◆ KernelGenerator()

onert::backend::cpu::KernelGenerator::KernelGenerator ( const ir::Graph graph,
const std::shared_ptr< TensorBuilder > &  tensor_builder,
const std::shared_ptr< basic::TensorRegistry > &  tensor_reg,
const std::shared_ptr< ExternalContext > &  external_context 
)

Definition at line 27 of file KernelGenerator.cc.

31 : basic::KernelGeneratorBase{graph}, _ctx(graph.operands()), _operations_ctx{graph.operations()},
32 _tensor_builder(tensor_builder), _tensor_reg{tensor_reg}, _external_context(external_context)
33{
34 // DO NOTHING
35}

Member Function Documentation

◆ generate()

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

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

Definition at line 37 of file KernelGenerator.cc.

38{
39 auto ret = std::make_unique<exec::FunctionSequence>();
40
41 assert(_tensor_builder->dynamicTensorManager());
42 assert(_tensor_reg);
43
44 // Prepare to handle dynamic tensors later
45 auto dyn_ctx = std::make_shared<exec::FunctionSequence::DynamicTensorCtx>();
46 {
47 dyn_ctx->op = &_operations_ctx.at(ind);
48 dyn_ctx->dynamic_shape_inferer = std::make_shared<exec::DynamicShapeInferer>(_tensor_reg);
49 }
50 ret->dynamic_tensor_ctx(dyn_ctx);
51
52 auto &op = _graph.operations().at(ind);
53 op.accept(*this);
54 assert(_return_fn); // _return_fn must have been generated
55 ret->append(std::move(_return_fn));
56
57 for (auto &&ind : (op.getInputs() | ir::Remove::UNDEFINED) + op.getOutputs())
58 {
59 auto tensor = _tensor_reg->getNativeTensor(ind);
60 if (tensor)
61 {
62 tensor->increase_ref();
63 }
64 }
65 return ret;
66}
std::unique_ptr< exec::IFunction > _return_fn
const Operations & operations() const override
Definition Graph.h:105
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(), onert::ir::Graph::operations(), and onert::ir::UNDEFINED.


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