TfLiteOpaqueDelegateBuilder

#include <common.h>

TfLiteOpaqueDelegateBuilder is used for constructing TfLiteOpaqueDelegate, see TfLiteOpaqueDelegateCreate below.

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.

WARNING: This is an experimental interface that is subject to change.

Public attributes

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.
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.
FreeBufferHandle)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data, TfLiteBufferHandle *handle)
void(*
Frees the Delegate Buffer Handle.
Prepare)(TfLiteOpaqueContext *context, TfLiteOpaqueDelegate *delegate, void *data)
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.