SensorForge Optimizer
v0.1.0Shrink trained models to fit edge devices with the hosted SensorForge Optimizer.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_chips List chips
List the chips (edge devices) the optimizer targets, with each one's SRAM and flash budget for the model. Use a chip's name as `chip` in check_fit, lossless and optimize. Chips without budgets take yours (ram_kb, flash_kb in optimize).
check_fit Check fit on a chip
Check whether a model runs on one or more chips and how much SRAM and flash it needs there, measured. Takes seconds; no data needed. Returns a per-chip verdict with SRAM and flash against each chip's budget, and the SRAM lossless would reach. Use it first, before lossless or optimize.
| Parameter | Type | Description |
|---|---|---|
model_path * | string | The model: a .tflite or .onnx file, or a .zip of a firmware export. Relative to the working directory, or starting with ~. |
chips | Chip names from list_chips (a list, or comma separated). Each chip is one run. Default: cortex-m-cmsis, a generic Arm Cortex-M. |
check_data Check data locally
Check, locally, that a data file is what optimize needs for this model, before uploading anything. For an .npz: X present, float32, each sample in the model's input shape; y one class index per sample within the model's outputs; X_test / y_test if given. For an image zip: class folders (or train/ and test/). Explains each problem and how to fix it. Nothing is uploaded and no run is used.
| Parameter | Type | Description |
|---|---|---|
data_path * | string | The data: an .npz (X, y) or a .zip of image folders, one per class. |
model_path * | string | The model the data is for (.tflite, .onnx, or a firmware .zip). |
output | string | 'classes' when the model outputs class scores; 'values' for detectors, autoencoders and regression. |
lossless Lossless shrink
Make the model smaller in SRAM and flash with outputs bit-identical to the original: no data, no retraining. Usually under a minute. Waits for the result, downloads it, and unpacks the model for TensorFlow Lite Micro and its C sources into the project. Returns the before -> after figures and the files. If it is still running after about four minutes it returns the run id: then call wait_for_run and download.
| Parameter | Type | Description |
|---|---|---|
chip * | string | A chip name from list_chips. |
model_path * | string | The model: .tflite or .onnx, or a .zip of a firmware export. |
folder | Where to unpack the result. Default: <the model's folder>/sensorforge/<run id>/. | |
overwrite | boolean | Replace files already in the folder. |
optimize Optimize within an accuracy limit
Find the smallest model for the chip within your accuracy limit, retrained on your data. Runs on the service for 5-60 minutes, so this returns right away with the run id and its place in the queue: then call wait_for_run(run_id) (again while it says still running), and download(run_id) when it passes.
| Parameter | Type | Description |
|---|---|---|
chip * | string | A chip name from list_chips. |
data_path * | string | The data: an .npz (X, y) or a .zip of image folders, one per class. Run check_data first. |
model_path * | string | The trained model: .tflite or .onnx, or a .zip of a firmware export. |
accuracy_limit | number | How many points of accuracy the result may lose against your model, on the test part of the data. |
check_first | boolean | Run the local data check first and stop on problems. |
effort | string | 'quick' (about 15 minutes) or 'thorough' (up to an hour; not on the trial). |
flash_kb | Flash budget in KB (default: the chip's). | |
image_scaling | string | Image zips only: how the model expects pixels. 'auto' = as the model says (int8 .tflite files carry it). |
minimize | string | What to shrink: SRAM ('ram'), flash, or both. |
output | string | 'classes' for class scores; 'values' for detectors, autoencoders and regression (y not needed). |
ram_kb | SRAM budget in KB (default: the chip's). |
run_status Run status
The state of a run right now, without waiting: queued (with its place in line), running (with its latest progress), or finished with the verdict and the before -> after SRAM, flash and accuracy.
| Parameter | Type | Description |
|---|---|---|
run_id * | string | The run id from check_fit, lossless, optimize or list_runs. |
wait_for_run Wait for a run
Wait for a run to finish, checking about every 10 seconds and reporting progress. Returns the final result (verdict and before -> after figures), or 'still running, call again' when max_wait_s is up: then call wait_for_run again. Optimize runs take 5-60 minutes, so expect several calls.
| Parameter | Type | Description |
|---|---|---|
run_id * | string | The run id. |
max_wait_s | integer | How long to wait in this call, in seconds (at most 600). |
get_report Get a run's report
The run's full report as markdown: the measured figures, what was changed and why, and what to do next. Available on every plan, including the trial.
| Parameter | Type | Description |
|---|---|---|
run_id * | string | The run id. |
download Download a run's result
Download a finished run's result and unpack it into the project: the model for TensorFlow Lite Micro, its C sources (c/: the model as a C array, the operator list, integration notes) and the report. Refuses to write into a folder that is not empty unless overwrite=True. Returns each file and what it is for.
| Parameter | Type | Description |
|---|---|---|
run_id * | string | The run id of a lossless or optimize run that passed. |
folder | Where to unpack. Default: <the model's folder>/sensorforge/<run id>/ (the working directory's when the model is unknown). | |
overwrite | boolean | Replace files already in the folder. |
list_runs List runs
The account's recent runs, newest first: id, when, kind, model, status and verdict.
| Parameter | Type | Description |
|---|---|---|
limit | integer | How many runs, newest first. |
stop_run Stop a run
Stop a queued or running run, for example one sent with the wrong chip or data. A stopped run gives no result; submit it again to rerun.
| Parameter | Type | Description |
|---|---|---|
run_id * | string | The run id. |
account Account and usage
The account's plan, this month's usage, and how many runs are left today (with when the next one is free when a daily cap is reached).