TfLiteTensor

#include <common.h>

A tensor in the interpreter system which is a wrapper around a buffer of data including a dimensionality (or NULL if not currently defined).

Summary

Public attributes

allocation
const void *
An opaque pointer to a tflite::MMapAllocation.
allocation_type
TfLiteAllocationType
How memory is mapped kTfLiteMmapRo: Memory mapped read only.
buffer_handle
TfLiteBufferHandle
An integer buffer handle that can be handled by delegate.
bytes
size_t
The number of bytes required to store the data of this Tensor.
data
A union of data pointers.
data_is_stale
bool
If the delegate uses its own buffer (e.g.
delegate
struct TfLiteDelegate *
The delegate which knows how to handle buffer_handle.
dims
A pointer to a structure representing the dimensionality interpretation that the buffer should have.
dims_signature
const TfLiteIntArray *
Optional.
is_variable
bool
True if the tensor is a variable.
name
const char *
Null-terminated name of this tensor.
params
Quantization information.
quantization
Quantization information. Replaces params field above.
sparsity
Parameters used to encode a sparse tensor.
type
TfLiteType
The data type specification for data stored in data.

Public attributes

allocation

const void * TfLiteTensor::allocation

An opaque pointer to a tflite::MMapAllocation.

allocation_type

TfLiteAllocationType TfLiteTensor::allocation_type

How memory is mapped kTfLiteMmapRo: Memory mapped read only.

i.e. weights kTfLiteArenaRw: Arena allocated read write memory (i.e. temporaries, outputs).

buffer_handle

TfLiteBufferHandle TfLiteTensor::buffer_handle

An integer buffer handle that can be handled by delegate.

The value is valid only when delegate is not null.

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

bytes

size_t TfLiteTensor::bytes

The number of bytes required to store the data of this Tensor.

I.e. (bytes of each element) * dims[0] * ... * dims[n-1]. For example, if type is kTfLiteFloat32 and dims = {3, 2} then bytes = sizeof(float) * 3 * 2 = 4 * 3 * 2 = 24.

data

TfLitePtrUnion TfLiteTensor::data

A union of data pointers.

The appropriate type should be used for a typed tensor based on type.

data_is_stale

bool TfLiteTensor::data_is_stale

If the delegate uses its own buffer (e.g.

GPU memory), the delegate is responsible to set data_is_stale to true. delegate->CopyFromBufferHandle can be called to copy the data from delegate buffer.

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

delegate

struct TfLiteDelegate * TfLiteTensor::delegate

The delegate which knows how to handle buffer_handle.

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

dims

TfLiteIntArray * TfLiteTensor::dims

A pointer to a structure representing the dimensionality interpretation that the buffer should have.

NOTE: the product of elements of dims and the element datatype size should be equal to bytes below.

dims_signature

const TfLiteIntArray * TfLiteTensor::dims_signature

Optional.

Encodes shapes with unknown dimensions with -1. This field is only populated when unknown dimensions exist in a read-write tensor (i.e. an input or output tensor). (e.g. dims contains [1, 1, 1, 3] and dims_signature contains [1, -1, -1, 3]). If no unknown dimensions exist then dims_signature is either null, or set to an empty array. Note that this field only exists when TF_LITE_STATIC_MEMORY is not defined.

is_variable

bool TfLiteTensor::is_variable

True if the tensor is a variable.

name

const char * TfLiteTensor::name

Null-terminated name of this tensor.

params

TfLiteQuantizationParams TfLiteTensor::params

Quantization information.

quantization

TfLiteQuantization TfLiteTensor::quantization

Quantization information. Replaces params field above.

sparsity

TfLiteSparsity * TfLiteTensor::sparsity

Parameters used to encode a sparse tensor.

This is optional. The field is NULL if a tensor is dense.

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

type

TfLiteType TfLiteTensor::type

The data type specification for data stored in data.

This affects what member of data union should be used.