Back to Tensorflow

TfLiteTensor

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

2.21.05.4 KB
Original Source

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 | TfLitePtrUnion

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 | TfLiteIntArray *

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 | TfLiteQuantizationParams

Quantization information. | | quantization | TfLiteQuantization

Quantization information. Replaces params field above. | | sparsity | TfLiteSparsity *

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](/lite/api_docs/c/group/common.html#group__common_1gae48332e93fec6c3fe7c4ee4897770d4b)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](/lite/api_docs/c/group/common.html#group__common_1ga837e524d72cc15f4790178c2e7bf57e1)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](/lite/api_docs/c/union/tf-lite-ptr-union.html#union_tf_lite_ptr_union)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](/lite/api_docs/c/struct/tf-lite-delegate.html#struct_tf_lite_delegate)* TfLiteTensor::delegate

The delegate which knows how to handle buffer_handle.

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

dims

[TfLiteIntArray](/lite/api_docs/c/struct/tf-lite-int-array.html#struct_tf_lite_int_array)* 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](/lite/api_docs/c/struct/tf-lite-int-array.html#struct_tf_lite_int_array)* 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](/lite/api_docs/c/struct/tf-lite-quantization-params.html#struct_tf_lite_quantization_params)TfLiteTensor::params

Quantization information.

quantization

[TfLiteQuantization](/lite/api_docs/c/struct/tf-lite-quantization.html#struct_tf_lite_quantization)TfLiteTensor::quantization

Quantization information. Replaces params field above.

sparsity

[TfLiteSparsity](/lite/api_docs/c/struct/tf-lite-sparsity.html#struct_tf_lite_sparsity)* 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](/lite/api_docs/c/group/c-api-types.html#group __c__ api__types_1ga8a47ba81bdef28b5c479ee7928a7d123)TfLiteTensor::type

The data type specification for data stored in data.

This affects what member of data union should be used.