Model Handle Structure#
Runtime context for one TensorFlow Lite Micro model on an embedded target. Instantiate one handle per deployed model.
The handle holds the serialized model flatbuffer (flatbuffer), operator resolver (opcode_resolver), and tensor arena memory (buffers and buffer_sizes). The embedded interpreter wrapper (TfliteMicroModel, or SLTfliteMicroModel when profiling is enabled) is default-constructed at creation; call sl_ml_model_init before running inference.
Public Attributes#
Public Functions#
Return the input tensor at index.
Return the output tensor at index.
Initialize a model handle with flatbuffer, resolver, and tensor-buffer metadata.
Public Attribute Documentation#
model#
npu_toolkit::TfliteMicroModel sl_ml_model_handle_t::model
Embedded TFLM interpreter; default-constructed until sl_ml_model_init succeeds.
flatbuffer#
const uint8_t* sl_ml_model_handle_t::flatbuffer
Pointer to the serialized model flatbuffer.
opcode_resolver#
const tflite::MicroOpResolver* sl_ml_model_handle_t::opcode_resolver
Operator resolver that registers kernels required by the model.
buffers#
uint8_t** sl_ml_model_handle_t::buffers
Pointers to tensor arena buffers; parallel to buffer_sizes.
buffer_sizes#
const int32_t* sl_ml_model_handle_t::buffer_sizes
Size in bytes of each buffer in buffers.
buffer_count#
int32_t sl_ml_model_handle_t::buffer_count
Number of entries in buffers and buffer_sizes.
model_buffer_alignment#
int32_t sl_ml_model_handle_t::model_buffer_alignment
Byte alignment required for each tensor arena buffer (typically 4).
model_buffer_sections#
const char** sl_ml_model_handle_t::model_buffer_sections
Linker section name for each buffer slot; parallel to buffers. May be NULL.
Public Function Documentation#
input_tensor#
TfLiteTensor * sl_ml_model_handle_t::input_tensor (size_t index)
Return the input tensor at index.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| size_t | [in] | index | Zero-based input tensor index (0 to |
The model must be loaded successfully (sl_ml_model_init).
Returns
Pointer to the input
TfLiteTensor, or NULL if the model is not loaded,indexis invalid, or the interpreter is unavailable.
output_tensor#
TfLiteTensor * sl_ml_model_handle_t::output_tensor (size_t index)
Return the output tensor at index.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| size_t | [in] | index | Zero-based output tensor index (0 to |
The model must be loaded successfully (sl_ml_model_init).
Returns
Pointer to the output
TfLiteTensor, or NULL if the model is not loaded,indexis invalid, or the interpreter is unavailable.
sl_ml_model_handle_t#
sl_ml_model_handle_t::sl_ml_model_handle_t (const uint8_t * flatbuffer_in, int flatbuffer_length_in, const tflite::MicroOpResolver * opcode_resolver_in, uint8_t ** buffers_in, const int32_t * buffer_sizes_in, int32_t buffer_count_in, int32_t model_buffer_alignment_in, const char ** model_buffer_sections_in)
Initialize a model handle with flatbuffer, resolver, and tensor-buffer metadata.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| const uint8_t * | [in] | flatbuffer_in | Pointer to the serialized model flatbuffer; must not be NULL. |
| int | [in] | flatbuffer_length_in | Length of |
| const tflite::MicroOpResolver * | [in] | opcode_resolver_in | Operator resolver for kernels used by the model; must not be NULL. |
| uint8_t ** | [in] | buffers_in | Array of tensor arena buffers; must not be NULL. |
| const int32_t * | [in] | buffer_sizes_in | Size in bytes of each buffer in |
| int32_t | [in] | buffer_count_in | Number of elements in |
| int32_t | [in] | model_buffer_alignment_in | Required byte alignment for each tensor arena buffer (typically 4). |
| const char ** | [in] | model_buffer_sections_in | Linker section name for each buffer slot; parallel to |
Default-constructs the embedded interpreter wrapper (and profiler when enabled). Call sl_ml_model_init before sl_ml_model_run.