ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::api::CustomKernel Class Reference

#include <CustomKernel.h>

Collaboration diagram for onert::api::CustomKernel:

Public Member Functions

 CustomKernel (nnfw_custom_eval evalFunction)
 
virtual void configure (backend::custom::CustomKernelConfigParams &&inParams)
 
void run () override
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 
virtual void prepare ()
 

Data Fields

backend::custom::CustomKernelConfigParams _in_params
 
char * _userdata
 
size_t _userdata_size
 
nnfw_custom_eval _evalFunction
 

Detailed Description

Definition at line 32 of file CustomKernel.h.

Constructor & Destructor Documentation

◆ CustomKernel()

onert::api::CustomKernel::CustomKernel ( nnfw_custom_eval  evalFunction)
explicit

Definition at line 65 of file CustomKernel.cc.

66 : _in_params(), _userdata(nullptr), _userdata_size(0), _evalFunction(evalFunction)
67{
68}
nnfw_custom_eval _evalFunction
backend::custom::CustomKernelConfigParams _in_params

Member Function Documentation

◆ configure()

void onert::api::CustomKernel::configure ( backend::custom::CustomKernelConfigParams &&  inParams)
virtual

Fills _params field used later by user specified eval function

Parameters
inParamscustom kernel parameters

Definition at line 70 of file CustomKernel.cc.

71{
72 _userdata = inParams.userdata;
73 _userdata_size = inParams.userdata_size;
74
75 _in_params = std::move(inParams);
76}

References _in_params, _userdata, and _userdata_size.

◆ run()

void onert::api::CustomKernel::run ( )
overridevirtual

Implements onert::exec::IFunction.

Definition at line 78 of file CustomKernel.cc.

79{
81
82 // set input tensor buffer and types
83 params.ninputs = _in_params.input_tensors.size();
84 params.inputs = new nnfw_operand[params.ninputs];
85
86 for (size_t i = 0; i < params.ninputs; ++i)
87 {
88 auto *buf = _in_params.input_tensors[i]->buffer();
89 assert(buf);
91 }
92
93 // set output tensor buffer and types
94 params.noutputs = _in_params.output_tensors.size();
95 params.outputs = new nnfw_operand[params.noutputs];
96
97 for (size_t i = 0; i < params.noutputs; ++i)
98 {
99 auto *buf = _in_params.output_tensors[i]->buffer();
100 assert(buf);
102 }
103
105
106 delete[] params.inputs;
107 delete[] params.outputs;
108}
static nnfw_operand convertOperand(void *alloc, const TypeInfo &type)
std::vector< backend::IPortableTensor * > input_tensors
std::vector< backend::IPortableTensor * > output_tensors

References _evalFunction, _in_params, _userdata, _userdata_size, onert::api::APIConverter::convertOperand(), onert::backend::custom::CustomKernelConfigParams::input_tensors, onert::backend::custom::CustomKernelConfigParams::input_types, nnfw_custom_kernel_params::inputs, nnfw_custom_kernel_params::ninputs, nnfw_custom_kernel_params::noutputs, onert::backend::custom::CustomKernelConfigParams::output_tensors, onert::backend::custom::CustomKernelConfigParams::output_types, and nnfw_custom_kernel_params::outputs.

Referenced by package.infer.session::inference().

Field Documentation

◆ _evalFunction

nnfw_custom_eval onert::api::CustomKernel::_evalFunction

Definition at line 42 of file CustomKernel.h.

Referenced by run().

◆ _in_params

backend::custom::CustomKernelConfigParams onert::api::CustomKernel::_in_params

Definition at line 37 of file CustomKernel.h.

Referenced by configure(), and run().

◆ _userdata

char* onert::api::CustomKernel::_userdata

Definition at line 39 of file CustomKernel.h.

Referenced by configure(), and run().

◆ _userdata_size

size_t onert::api::CustomKernel::_userdata_size

Definition at line 40 of file CustomKernel.h.

Referenced by configure(), and run().


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