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

#include <KernelGenerator.h>

Collaboration diagram for onert::backend::ggml::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 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::ggml::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 62 of file KernelGenerator.cc.

66 : basic::KernelGeneratorBase{graph}, _ctx(graph.operands()), _operations_ctx{graph.operations()},
67 _tensor_builder(tensor_builder), _tensor_reg{tensor_reg}, _external_context(external_context)
68{
69 // DO NOTHING
70}

Member Function Documentation

◆ generate()

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

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

Definition at line 31 of file KernelGenerator.cc.

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