lite/acceleration/configuration/c/delegate_plugin.h

C API types for TF Lite delegate plugins.

Summary

Typedefs

TfLiteDelegatePlugin typedef
Struct to hold all the methods for a delegate plugin.
TfLiteDelegatePluginCreateFunc(const void *tflite_settings) typedef
Type of delegate creation function used to allocate and construct a delegate.
TfLiteDelegatePluginDestroyFunc(TfLiteDelegate *) typedef
void
Type of function to destroy and deallocate a delegate.
TfLiteDelegatePluginGetDelegateErrnoFunc(TfLiteDelegate *) typedef
int
Type of function to return an error code for the last delegate operation.
TfLiteOpaqueDelegatePlugin typedef
TfLiteOpaqueDelegatePluginCreateFunc typedef
TfLiteOpaqueDelegatePluginDestroyFunc typedef
TfLiteOpaqueDelegatePluginGetDelegateErrnoFunc typedef

Structs

TfLiteDelegatePlugin

Struct to hold all the methods for a delegate plugin.

Typedefs

TfLiteDelegatePlugin

struct TfLiteDelegatePlugin TfLiteDelegatePlugin

Struct to hold all the methods for a delegate plugin.

TfLiteDelegatePluginCreateFunc

TfLiteDelegate * TfLiteDelegatePluginCreateFunc(const void *tflite_settings)

Type of delegate creation function used to allocate and construct a delegate.

The tflite_settings parameter passed to the delegate creation function should be a pointer to a FlatBuffer table object of type tflite::TFLiteSettings. We use const void * here rather than const tflite::TFLiteSettings* since this is a C API so we don't want to directly reference C++ types such as tflite::TFLiteSettings. But note that this address should point to the 'parsed' FlatBuffer object, not the raw byte buffer. (Note that 'parsing' FlatBuffers is very cheap, it's just an offset load.)

If you are using the FlatBuffers C API, then you can alternatively pass in a value of type tflite_TFLiteSettings_table_t, which is a typedef for const struct tflite_TFLiteSettings_table* that is the corresponding type for the 'parsed' FlatBuffer object in the FlatBuffers C API.

Ownership of the tflite_settings flatbuffer remains with the caller. The caller of a delegate creation function may end the lifetime of the tflite_settings FlatBuffer immediately after the call to the function. So the delegate creation function should ensure that any settings that the delegate may need to reference later, after the delegate has been constructed, are copied from the FlatBuffer into storage owned by the delegate.

TfLiteDelegatePluginDestroyFunc

void TfLiteDelegatePluginDestroyFunc(TfLiteDelegate *)

Type of function to destroy and deallocate a delegate.

The delegate argument must have been created with the corresponding create function from the same delegate plugin.

TfLiteDelegatePluginGetDelegateErrnoFunc

int TfLiteDelegatePluginGetDelegateErrnoFunc(TfLiteDelegate *)

Type of function to return an error code for the last delegate operation.

The delegate argument must have been created with the corresponding create function from the same delegate plugin.

TfLiteOpaqueDelegatePlugin

TfLiteDelegatePlugin TfLiteOpaqueDelegatePlugin

TfLiteOpaqueDelegatePluginCreateFunc

TfLiteDelegatePluginCreateFunc TfLiteOpaqueDelegatePluginCreateFunc

TfLiteOpaqueDelegatePluginDestroyFunc

TfLiteDelegatePluginDestroyFunc TfLiteOpaqueDelegatePluginDestroyFunc

TfLiteOpaqueDelegatePluginGetDelegateErrnoFunc

TfLiteDelegatePluginGetDelegateErrnoFunc TfLiteOpaqueDelegatePluginGetDelegateErrnoFunc