ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::backend::ruy::KernelGenerator Class Reference

#include <KernelGenerator.h>

Collaboration diagram for onert::backend::ruy::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< custom::IKernelBuilder > &kernel_builder, 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 33 of file KernelGenerator.h.

Constructor & Destructor Documentation

◆ KernelGenerator()

onert::backend::ruy::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< custom::IKernelBuilder > &  kernel_builder,
const std::shared_ptr< ExternalContext > &  external_context 
)

Member Function Documentation

◆ generate()

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

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

Definition at line 34 of file KernelGenerator.cc.

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