Skip to main content

TfLiteDelegate

Struct TfLiteDelegate 

Source
#[repr(C)]
pub struct TfLiteDelegate { pub data_: *mut c_void, pub Prepare: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate) -> TfLiteStatus>, pub CopyFromBufferHandle: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, buffer_handle: TfLiteBufferHandle, tensor: *mut TfLiteTensor) -> TfLiteStatus>, pub CopyToBufferHandle: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, buffer_handle: TfLiteBufferHandle, tensor: *mut TfLiteTensor) -> TfLiteStatus>, pub FreeBufferHandle: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, handle: *mut TfLiteBufferHandle)>, pub flags: i64, pub opaque_delegate_builder: *mut TfLiteOpaqueDelegateBuilder, }
Expand description

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

Fields§

§data_: *mut c_void

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.

§Prepare: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate) -> TfLiteStatus>

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.

§CopyFromBufferHandle: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, buffer_handle: TfLiteBufferHandle, tensor: *mut TfLiteTensor) -> TfLiteStatus>

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: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, buffer_handle: TfLiteBufferHandle, tensor: *mut TfLiteTensor) -> TfLiteStatus>

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: Option<unsafe extern "C" fn(context: *mut TfLiteContext, delegate: *mut TfLiteDelegate, handle: *mut TfLiteBufferHandle)>

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.

§flags: i64

Bitmask flags. See the comments in TfLiteDelegateFlags.

§opaque_delegate_builder: *mut TfLiteOpaqueDelegateBuilder

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.

Trait Implementations§

Source§

impl Clone for TfLiteDelegate

Source§

fn clone(&self) -> TfLiteDelegate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TfLiteDelegate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for TfLiteDelegate

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.