mltk.core.tflite_micro.TfliteMicroModel¶
- class TfliteMicroModel[source]¶
This class wrappers the TF-Lite Micro interpreter loaded with a .tflite model
Properties
Reference to hardware accelerator used by model
Return details about loaded model
Number of input tensors
Return if the profiler is enabled
Return if the model recorder is enabled
Return if the tensor recorder is enabled
List of error messages triggered by kernels while loading the model.
Number of output tensors
Methods
Return the TfliteMicroLayerError at the given layer index if found else return None
Return the profiling results of each model layer
Return the recorded contents of the model
Return a reference to a model input tensor's data If the value argument is provided then copy the value to the input tensor's buffer
Invoke the model to execute one inference
Return a reference to a model output tensor's data
set_layer_callback
- __init__(tflm_wrapper, tflm_accelerator, flatbuffer_data, enable_profiler=False, enable_recorder=False, enable_tensor_recorder=False, force_buffer_overlap=False, runtime_buffer_sizes=None)[source]¶
- Parameters:
tflm_accelerator (TfliteMicroAccelerator) –
flatbuffer_data (bytes) –
enable_profiler (bool) –
enable_recorder (bool) –
enable_tensor_recorder (bool) –
force_buffer_overlap (bool) –
runtime_buffer_sizes (List[int]) –
- property accelerator: TfliteMicroAccelerator¶
Reference to hardware accelerator used by model
- Return type:
- property layer_errors: List[TfliteMicroLayerError]¶
List of error messages triggered by kernels while loading the model. Typically, these errors indicate that a given model layer is not supported by a hardware accelerator and had to fallback to a default kernel implementation.
- Return type:
List
[TfliteMicroLayerError
]
- property details: TfliteMicroModelDetails¶
Return details about loaded model
- Return type:
- property input_size: int¶
Number of input tensors
- Return type:
int
- input(index=0, value=None)[source]¶
Return a reference to a model input tensor’s data If the value argument is provided then copy the value to the input tensor’s buffer
- Return type:
ndarray
- Parameters:
value (ndarray) –
- property output_size: int¶
Number of output tensors
- Return type:
int
- property is_profiler_enabled: bool¶
Return if the profiler is enabled
- Return type:
bool
- get_profiling_results()[source]¶
Return the profiling results of each model layer
- Return type:
- Returns:
A list where each entry contains the profiling results of the associated model layer
- property is_recorder_enabled: bool¶
Return if the model recorder is enabled
- Return type:
bool
- property is_tensor_recorder_enabled: bool¶
Return if the tensor recorder is enabled
- Return type:
bool
- get_recorded_data()[source]¶
Return the recorded contents of the model
- Return type:
Dict
- Returns:
A list where each entry contains the input/output tensors of the associated model layer