jacdac.model_runner

Submodules

Package Contents

Classes

ModelRunnerClient

Runs machine learning models.

class jacdac.model_runner.ModelRunnerClient(bus: jacdac.bus.Bus, role: str)

Bases: jacdac.bus.Client

Runs machine learning models.
  • Only models with a single input tensor and a single output tensor are supported at the moment.

  • Input is provided by Sensor Aggregator service on the same device.

  • Multiple instances of this service may be present, if more than one model format is supported by a device.

Implements a client for the Model Runner service.

property auto_invoke_every: int | None

When register contains N > 0, run the model automatically every time new N samples are collected. Model may be run less often if it takes longer to run than N * sampling_interval. The outputs register will stream its value after each run. This register is not stored in flash.,

property last_run_time: int | None

The time consumed in last model execution., _: us

property allocated_arena_size: int | None

Number of RAM bytes allocated for model execution., _: B

property model_size: int | None

The size of the model in bytes., _: B

property last_error: str | None

Textual description of last error when running or loading model (if any).,

property format: jacdac.model_runner.constants.ModelRunnerModelFormat | None

The type of ML models supported by this service. TFLite is flatbuffer .tflite file. ML4F is compiled machine code model for Cortex-M4F. The format is typically present as first or second little endian word of model file.,

property format_version: int | None

A version number for the format.,

property parallel: bool | None

(Optional) If present and true this service can run models independently of other instances of this service on the device.,

set_model(model_size: int) None

Open pipe for streaming in the model. The size of the model has to be declared upfront. The model is streamed over regular pipe data packets. The format supported by this instance of the service is specified in format register. When the pipe is closed, the model is written all into flash, and the device running the service may reset.