Back to Tensorflow

TfLiteDelegate

tensorflow/lite/g3doc/api_docs/c/struct/tf-lite-delegate.html

2.21.04.1 KB
Original Source

TfLiteDelegate

#include <common.h>

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

Summary

|

Public attributes

| | --- | | CopyFromBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle buffer_handle, TfLiteTensor *tensor) | TfLiteStatus(*

Copy the data from delegate buffer handle into raw memory of the given tensor. | | CopyToBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle buffer_handle, TfLiteTensor *tensor) | TfLiteStatus(*

Copy the data from raw memory of the given tensor to delegate buffer handle. | | FreeBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle *handle) | void(*

Free the Delegate Buffer Handle. | | Prepare)(TfLiteContext *context, struct TfLiteDelegate *delegate) | TfLiteStatus(*

Invoked by ModifyGraphWithDelegate. | | data_ | void *

Data that delegate needs to identify itself. | | flags | int64_t

Bitmask flags. See the comments in TfLiteDelegateFlags. | | opaque_delegate_builder | struct TfLiteOpaqueDelegateBuilder *

The opaque delegate builder associated with this object. |

Public attributes

CopyFromBufferHandle

[TfLiteStatus](/lite/api_docs/c/group/c-api-types.html#group __c__ api__types_1gacf79d2fb5fa520303014d1303f1f6361)(* TfLiteDelegate::CopyFromBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle buffer_handle, TfLiteTensor *tensor)

Copy 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](/lite/api_docs/c/group/c-api-types.html#group __c__ api__types_1gacf79d2fb5fa520303014d1303f1f6361)(* TfLiteDelegate::CopyToBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle buffer_handle, TfLiteTensor *tensor)

Copy 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(* TfLiteDelegate::FreeBufferHandle)(TfLiteContext *context, struct TfLiteDelegate *delegate, TfLiteBufferHandle *handle)

Free 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](/lite/api_docs/c/group/c-api-types.html#group __c__ api__types_1gacf79d2fb5fa520303014d1303f1f6361)(* TfLiteDelegate::Prepare)(TfLiteContext *context, struct TfLiteDelegate *delegate)

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 * TfLiteDelegate::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 TfLiteDelegate::flags

Bitmask flags. See the comments in TfLiteDelegateFlags.

opaque_delegate_builder

struct[TfLiteOpaqueDelegateBuilder](/lite/api_docs/c/struct/tf-lite-opaque-delegate-builder.html#struct_tf_lite_opaque_delegate_builder)* TfLiteDelegate::opaque_delegate_builder

The opaque delegate builder associated with this object.

If set then the TF Lite runtime will give precedence to this field. E.g. instead of invoking Prepare via the function pointer inside the TfLiteDelegate object, the runtime will first check if the corresponding function pointer inside opaque_delegate_builder is set and if so invoke that.

If this field is non-null, then the Prepare field (of the TfLiteDelegate) should be null.