TfLiteOpaqueDelegateBuilder

#include <common.h>

TfLiteOpaqueDelegateBuilder is used for constructing TfLiteOpaqueDelegate, see TfLiteOpaqueDelegateCreate in c_api_opaque.h.

Summary

NOTE: This struct is not ABI stable.

For forward source compatibility TfLiteOpaqueDelegateBuilder objects should be brace-initialized, so that all fields (including any that might be added in the future) get zero-initialized. The purpose of each field is exactly the same as with TfLiteDelegate.

NOTE: This type is part of the TensorFlow Lite Extension APIs. We reserve the right to make changes to this API in future releases, potentially including non-backwards-compatible changes, on a different schedule than for the other TensorFlow Lite APIs. See https://www.tensorflow.org/guide/versions#separate_version_number_for_tensorflow_lite_extension_apis.

Public attributes

CopyFromBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor *tensor)
TfLiteStatus(*
Copies the data from delegate buffer handle into raw memory of the given tensor.
CopyToBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor *tensor)
TfLiteStatus(*
Copies the data from raw memory of the given tensor to delegate buffer handle.
FreeBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle *handle)
void(*
Frees the Delegate Buffer Handle.
Prepare)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data)
TfLiteStatus(*
Invoked by ModifyGraphWithDelegate.
data
void *
Data that delegate needs to identify itself.
flags
int64_t
Bitmask flags. See the comments in TfLiteDelegateFlags.

Public attributes

CopyFromBufferHandle

TfLiteStatus(* TfLiteOpaqueDelegateBuilder::CopyFromBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor *tensor)

Copies the data from delegate buffer handle into raw memory of the given tensor.

Note that the delegate is allowed to allocate the raw bytes as long as it follows the rules for kTfLiteDynamic tensors, in which case this cannot be null.

CopyToBufferHandle

TfLiteStatus(* TfLiteOpaqueDelegateBuilder::CopyToBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor *tensor)

Copies the data from raw memory of the given tensor to delegate buffer handle.

This can be null if the delegate doesn't use its own buffer.

FreeBufferHandle

void(* TfLiteOpaqueDelegateBuilder::FreeBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle *handle)

Frees the Delegate Buffer Handle.

Note: This only frees the handle, but this doesn't release the underlying resource (e.g. textures). The resources are either owned by application layer or the delegate. This can be null if the delegate doesn't use its own buffer.

Prepare

TfLiteStatus(* TfLiteOpaqueDelegateBuilder::Prepare)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data)

Invoked by ModifyGraphWithDelegate.

This prepare is called, giving the delegate a view of the current graph through TfLiteContext*. It typically will look at the nodes and call ReplaceNodeSubsetsWithDelegateKernels() to ask the TensorFlow lite runtime to create macro-nodes to represent delegated subgraphs of the original graph.

data

void * TfLiteOpaqueDelegateBuilder::data

Data that delegate needs to identify itself.

This data is owned by the delegate. The delegate is owned in the user code, so the delegate is responsible for deallocating this when it is destroyed.

flags

int64_t TfLiteOpaqueDelegateBuilder::flags

Bitmask flags. See the comments in TfLiteDelegateFlags.