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

#include <KernelGenerator.h>

Collaboration diagram for onert::backend::xnnpack::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 37 of file KernelGenerator.h.

Constructor & Destructor Documentation

◆ KernelGenerator()

onert::backend::xnnpack::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::xnnpack::KernelGenerator::generate ( ir::OperationIndex  ind)
overridevirtual

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

Definition at line 51 of file KernelGenerator.cc.

52{
53 auto ret = std::make_unique<exec::FunctionSequence>();
54
55 assert(_tensor_builder->dynamicTensorManager());
56 assert(_tensor_reg);
57
58 // Prepare to handle dynamic tensors later
59 auto dyn_ctx = std::make_shared<exec::FunctionSequence::DynamicTensorCtx>();
60 {
61 dyn_ctx->op = &_operations_ctx.at(ind);
62 dyn_ctx->dynamic_shape_inferer = std::make_shared<exec::DynamicShapeInferer>(_tensor_reg);
63 }
64 ret->dynamic_tensor_ctx(dyn_ctx);
65
66 auto &op = _graph.operations().at(ind);
67 op.accept(*this);
68 assert(_return_fn); // _return_fn must have been generated
69 ret->append(std::move(_return_fn));
70
71 for (auto &&ind : (op.getInputs() | ir::Remove::UNDEFINED) + op.getOutputs())
72 {
73 auto tensor = _tensor_reg->getNativeTensor(ind);
74 if (tensor)
75 {
76 tensor->increase_ref();
77 }
78 }
79 return ret;
80}
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.

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