#[repr(C)]pub struct TfLiteRegistration {
pub init: Option<unsafe extern "C" fn(context: *mut TfLiteContext, buffer: *const c_char, length: usize) -> *mut c_void>,
pub free: Option<unsafe extern "C" fn(context: *mut TfLiteContext, buffer: *mut c_void)>,
pub prepare: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> TfLiteStatus>,
pub invoke: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> TfLiteStatus>,
pub profiling_string: Option<unsafe extern "C" fn(context: *const TfLiteContext, node: *const TfLiteNode) -> *const c_char>,
pub builtin_code: i32,
pub custom_name: *const c_char,
pub version: c_int,
pub registration_external: *mut TfLiteOperator,
pub async_kernel: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> *mut TfLiteAsyncKernel>,
pub inplace_operator: u64,
}Expand description
TfLiteRegistration defines the implementation of an operation
(a built-in op, custom op, or custom delegate kernel).
It is a struct containing “methods” (C function pointers) that will be invoked by the TF Lite runtime to evaluate instances of the operation.
See also TfLiteOperator which is a more ABI-stable equivalent.
Fields§
§init: Option<unsafe extern "C" fn(context: *mut TfLiteContext, buffer: *const c_char, length: usize) -> *mut c_void>Initializes the op from serialized data. Called only once for the lifetime of the op, so any one-time allocations should be made here (unless they depend on tensor sizes).
- If a built-in op:
*
bufferis the op’s params data (TfLiteLSTMParams*). *lengthis zero. - If custom op:
*
bufferis the op’scustom_options. *lengthis the size of the buffer.
Returns a type-punned (i.e. void*) opaque data (e.g. a primitive pointer or an instance of a struct).
The returned pointer will be stored with the node in the user_data
field, accessible within prepare and invoke functions below.
NOTE: if the data is already in the desired format, simply implement this
function to return nullptr and implement the free function to be a
no-op.
free: Option<unsafe extern "C" fn(context: *mut TfLiteContext, buffer: *mut c_void)>The pointer buffer is the data previously returned by an init
invocation.
prepare: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> TfLiteStatus>prepare is called when the inputs this node depends on have been resized.
context->ResizeTensor() can be called to request output tensors to be
resized.
Can be called multiple times for the lifetime of the op.
Returns kTfLiteOk on success.
invoke: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> TfLiteStatus>Execute the node (should read node->inputs and output to
node->outputs).
Returns kTfLiteOk on success.
profiling_string: Option<unsafe extern "C" fn(context: *const TfLiteContext, node: *const TfLiteNode) -> *const c_char>profiling_string is called during summarization of profiling information
in order to group executions together. Providing a value here will cause a
given op to appear multiple times is the profiling report. This is
particularly useful for custom ops that can perform significantly
different calculations depending on their user-data.
builtin_code: i32Builtin codes. If this kernel refers to a builtin this is the code of the builtin. This is so we can do marshaling to other frameworks like NN API.
Note: It is the responsibility of the registration binder to set this properly.
custom_name: *const c_charCustom op name. If the op is a builtin, this will be null.
Note: It is the responsibility of the registration binder to set this properly.
WARNING: This is an experimental interface that is subject to change.
version: c_intThe version of the op. Note: It is the responsibility of the registration binder to set this properly.
registration_external: *mut TfLiteOperatorThe external (i.e. ABI-stable) version of TfLiteRegistration.
Since we can’t use internal types (such as TfLiteContext) for C API to
maintain ABI stability. C API user will provide TfLiteOperator to
implement custom ops. We keep it inside of TfLiteRegistration and use
it to route callbacks properly.
async_kernel: Option<unsafe extern "C" fn(context: *mut TfLiteContext, node: *mut TfLiteNode) -> *mut TfLiteAsyncKernel>Retrieves asynchronous kernel.
If the async_kernel field is nullptr, it means the operation described
by this TfLiteRegistration object does not support asynchronous execution.
Otherwise, the function that the field points to should only be called for
delegate kernel nodes, i.e. node should be a delegate kernel node
created by applying a delegate. If the function returns nullptr, that
means that the underlying delegate does not support asynchronous execution
for this node.
inplace_operator: u64Indicates if an operator’s output may safely overwrite its inputs.
See the comments in TfLiteInPlaceOp.
Trait Implementations§
Source§impl Clone for TfLiteRegistration
impl Clone for TfLiteRegistration
Source§fn clone(&self) -> TfLiteRegistration
fn clone(&self) -> TfLiteRegistration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more