# tflitetensor

Tensor data, dimensions, quantization and allocation metadata for static-memory builds.

## TfLiteTensor

`struct` · `cpp`

```cpp
struct TfLiteTensor
```

A tensor in the interpreter system which is a wrapper around a buffer of data including a dimensionality (or NULL if not currently defined). NOTE: This flag is opt-in only at compile time.

Specific reduced `TfLiteTensor` struct for TF Micro runtime. This struct contains only the minimum fields required to initialize and prepare a micro inference graph. The fields in this struct have been ordered from largest-to-smallest for optimal struct sizeof.

This struct does not use:

- allocation
- buffer_handle
- data_is_stale
- delegate
- dims_signature
- name
- sparsity

Source: `tensorflow/lite/core/c/common.h:678`

### TfLiteTensor::quantization

`attribute` · `cpp`

```cpp
TfLiteQuantization quantization
```

TODO(b/155784997): Consider consolidating these quantization fields: Quantization information. Replaces params field above.

Source: `tensorflow/lite/core/c/common.h:681`

### TfLiteTensor::params

`attribute` · `cpp`

```cpp
TfLiteQuantizationParams params
```

Quantization information.

Source: `tensorflow/lite/core/c/common.h:684`

### TfLiteTensor::data

`attribute` · `cpp`

```cpp
TfLitePtrUnion data
```

A union of data pointers. The appropriate type should be used for a typed tensor based on `type`.

Source: `tensorflow/lite/core/c/common.h:688`

### TfLiteTensor::dims

`attribute` · `cpp`

```cpp
TfLiteIntArray * 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.

Source: `tensorflow/lite/core/c/common.h:693`

### TfLiteTensor::bytes

`attribute` · `cpp`

```cpp
size_t 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.

Source: `tensorflow/lite/core/c/common.h:699`

### TfLiteTensor::type

`attribute` · `cpp`

```cpp
TfLiteType type
```

The data type specification for data stored in `data`. This affects what member of `data` union should be used.

Source: `tensorflow/lite/core/c/common.h:703`

### TfLiteTensor::allocation_type

`attribute` · `cpp`

```cpp
TfLiteAllocationType allocation_type
```

How memory is mapped kTfLiteMmapRo: Memory mapped read only. i.e. weights kTfLiteArenaRw: Arena allocated read write memory (i.e. temporaries, outputs).

Source: `tensorflow/lite/core/c/common.h:710`

### TfLiteTensor::is_variable

`attribute` · `cpp`

```cpp
bool is_variable
```

True if the tensor is a variable.

Source: `tensorflow/lite/core/c/common.h:713`
