ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 63 of file CustomKernel.cc.

64 : _in_params(), _userdata(nullptr), _userdata_size(0), _evalFunction(evalFunction)
65{
66}
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 68 of file CustomKernel.cc.

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

References _in_params, _userdata, and _userdata_size.

◆ run()

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

Implements onert::exec::IFunction.

Definition at line 76 of file CustomKernel.cc.

77{
79
80 // set input tensor buffer and types
81 params.ninputs = _in_params.input_tensors.size();
82 params.inputs = new nnfw_operand[params.ninputs];
83
84 for (size_t i = 0; i < params.ninputs; ++i)
85 {
86 auto *buf = _in_params.input_tensors[i]->buffer();
87 assert(buf);
89 }
90
91 // set output tensor buffer and types
92 params.noutputs = _in_params.output_tensors.size();
93 params.outputs = new nnfw_operand[params.noutputs];
94
95 for (size_t i = 0; i < params.noutputs; ++i)
96 {
97 auto *buf = _in_params.output_tensors[i]->buffer();
98 assert(buf);
100 }
101
103
104 delete[] params.inputs;
105 delete[] params.outputs;
106}
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.

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: