Legacy page
This page describes legacy neuralSPOT. For current tools and documentation, see heliaPROFILER, heliaPROFILER profile command, heliaPROFILER power measurement, heliaPROFILER PMU counters, heliaPROFILER supported boards, heliaPROFILER analyze, heliaAOT, heliaEstimator.
ns_autodeploy Multi-Model Runner
This Python script automates the deployment of multiple TFLite models using the ns_autodeploy tool. The models and their configurations are defined in a YAML file. The script passes global parameters (e.g. target platform, toolchain, result log file, and profile results path) as well as per-model settings to ns_autodeploy.
Features
- Multiple Models: Read and deploy a series of models specified in a YAML file.
- Platform Filtering: Each model may define an
unsupported_platformslist. Models will be skipped if the target platform is found in that list. - Custom Arguments: Supports per-model
arena_size_scratch_buffer_paddingto customize the--arena-size-scratch-buffer-paddingargument. - Timeout & Retry: Each
ns_autodeployinvocation is given a 15-minute timeout. If the timeout is exceeded, the process is killed and retried once before moving on. - Additional Parameters: Global options such as
--platform,--toolchain,--resultlog-file,--profile-results-path, and the option to enable--joulescopeare supported.
Requirements
- Python 3
pyyamlmodule (install viapip install pyyamlif needed)ns_autodeploymust be available in your system's PATH
YAML File Format
The YAML file should have a top-level key models that contains a list of model definitions. Each model can include the following keys:
tflite_filename(required): Path or name of the TFLite model file.model_name(optional): Name to be used for the model.unsupported_platforms(optional): A list of platform strings on which the model should not be deployed.arena_size_scratch_buffer_padding(optional): A numeric value to pass to the--arena-size-scratch-buffer-paddingparameter.runs_power(optional): Number of power measurement runs to perform.arena_location(optional): Memory location for the arena (e.g.,NS_AD_TCM,NS_AD_SRAM,NS_AD_PSRAM,NS_AD_MRAM).model_location(optional): Memory location for the model (e.g.,NS_AD_TCM,NS_AD_SRAM,NS_AD_PSRAM,NS_AD_MRAM).id(optional): Run log ID for tracking purposes.
Example models.yaml
models:
- tflite_filename: "model1.tflite"
model_name: "model1"
unsupported_platforms:
- apollo4p_evb
arena_size_scratch_buffer_padding: 5
runs_power: 10
arena_location: "NS_AD_PSRAM"
model_location: "NS_AD_SRAM"
id: 1
- tflite_filename: "model2.tflite"
unsupported_platforms:
- apollo510_evb
arena_location: "NS_AD_TCM"
model_location: "NS_AD_PSRAM"
id: 2
Usage
Run the script by providing the YAML file and the required command-line arguments:
python3 ns_ad_batch.py models.yaml \
--platform apollo510_evb \
--toolchain gcc \
--resultlog-file /path/to/result.log \
--profile-results-path /path/to/profiles \
--joulescope
Command-Line Arguments
- Positional:
-
yaml_file: Path to the YAML file containing the models configuration. -
Global Options:
--platform: Target platform (e.g.apollo4p_evb,apollo510_evb, etc.).--toolchain: Target toolchain (e.g.gcc,arm).--tflm-version: Target neuralSPOT TFLM version (default: "auto").--resultlog-file: Path and filename where the deployment log will be stored.--profile-results-path: Directory where per-model profile results will be stored.--aot: Run AOT (Ahead-of-Time compilation) instead of TFLM.--joulescope: Enable power consumption measurement using Joulescope.--model-directory: Directory where the models are located (default: "../model_perf_tests/models/").
Behavior
-
Model Filtering:
If a model's YAML configuration includes anunsupported_platformslist and the target platform (passed via--platform) is found in that list, the model is skipped. -
Command Construction:
The script builds thens_autodeploycommand by combining global parameters with per-model parameters: - Adds
--arena-size-scratch-buffer-paddingif specified. - Adds
--runs-powerif specified. - Adds
--arena-locationif specified. - Adds
--model-locationif specified. - Adds
--run-log-idif specified. - If the platform string contains "apollo5", the script automatically adds the
--full-pmu-captureflag. -
If
--aotis specified, adds--create-aot-profile. -
Timeout and Retry:
Each model deployment is given 15 minutes (900 seconds) to complete. Ifns_autodeploydoes not complete in this time, it is terminated and retried once. If the second attempt also times out, the script moves on to the next model.