mltk.core.TfliteTensor

class TfliteTensor[source]

Wrapper for TFLite flatbuffer tensor

Properties

data

Tensor data

dtype

Tensor data type

dtype_str

Tensor data type as a string

index

Index of tensor in .tflite subgraph.tensors list

is_variable

True if this tensor is populated at runtime and its state persists between inferences

model

Reference to associated TfliteModel

quantization

Data quantization information

shape

The tensor shape

size_bytes

The number of bytes required to hold the data for this tensor

Methods

InitFromBuf

InitFromObj

Pack

__init__

shape_dtype_str

Return the shape and data-type of this tensor as a string: <dim0>x<dim1>x.

__init__(index=-1, model=None, fb_tensor=None)[source]
Parameters:
  • index (int) –

  • model (TfliteModel) –

  • fb_tensor (TensorT) –

property index: int

Index of tensor in .tflite subgraph.tensors list

Return type:

int

property dtype: dtype

Tensor data type

Return type:

dtype

property dtype_str: str

Tensor data type as a string

Return type:

str

property shape: TfliteShape

The tensor shape

Return type:

TfliteShape

property quantization: TfliteQuantization

Data quantization information

Return type:

TfliteQuantization

property is_variable: bool

True if this tensor is populated at runtime and its state persists between inferences

Return type:

bool

property size_bytes: int

The number of bytes required to hold the data for this tensor

Return type:

int

property data: ndarray

Tensor data

Return type:

ndarray

property model: TfliteModel

Reference to associated TfliteModel

Return type:

TypeVar(TfliteModel)

shape_dtype_str(include_batch=False)[source]

Return the shape and data-type of this tensor as a string: <dim0>x<dim1>x… (<dtype>)

Return type:

str