A comprehensive toolkit for CMSIS-NN testing, model generation, and FVP simulation.
- Complete Test Pipeline: End-to-end workflow from model generation to FVP execution
- TFLite Model Generation: Generate TensorFlow Lite models using pytest
- AOT Conversion: Convert TFLite models to C modules using helia-aot
- Test Runner Generation: Automatically generate Unity test runners
- FVP Building: Build test executables for FVP Corstone-300 simulator
- FVP Execution: Run tests on FVP simulator with comprehensive reporting
uv is required for Python dependency management. Install it first:
curl -LsSf https://astral.sh/uv/install.sh | shgit is required for cloning submodules (uv cannot handle git submodules).
You can either manually set up dependencies or use the automated setup:
Option 1: Automated setup
# From the repository root - uses uv sync
uv sync
# Or run the setup script
python3 setup.pyOption 2: Using CLI setup
# From the repository root - uses uv (required)
python3 cmsis_nn_tools/cli.py --setupOption 3: Manual setup
-
Initialize submodules (uv cannot do this, git is required):
git submodule update --init --recursive --depth 1
-
Install Python dependencies with uv sync:
# uv sync automatically creates .venv and installs dependencies uv sync # Or manually with uv pip install uv venv .venv uv pip install --python .venv/bin/python -e .
Run the tool:
# Using uv run
uv run python cmsis_nn_tools/cli.py --help
# Or activate the virtual environment first
source .venv/bin/activate # or .venv\Scripts\activate on Windows
python cmsis_nn_tools/cli.py --helpFor CI environments, use the setup_ci.sh script which:
- Automatically installs
uvif not present - Initializes git submodules recursively
- Sets up Python virtual environment using
uv - Downloads and configures build dependencies (ARM GCC, CMSIS-5, Corstone300 FVP, etc.)
- Configures environment variables
# In CI scripts or GitHub Actions
python3 setup.py
# Or using the shell script
./scripts/setup_ci.sh
# With custom downloads directory
./scripts/setup_ci.sh --downloads-dir /custom/path
# Skip certain steps if needed
./scripts/setup_ci.sh --skip-submodules --skip-build-depsThe script is idempotent and safe to run multiple times. It will skip steps that are already completed.
This project uses uv for Python dependency management:
- Faster: uv is 10-100x faster than pip for dependency resolution
- Better reproducibility: Lock file (
uv.lock) ensures exact dependency versions - Simplified setup:
uv synchandles everything - Standard workflow: Use
uv runto execute commands in the project environment
Setup workflow:
# 1. Install uv (one-time)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. Initialize submodules (uv cannot do this, git is required) - shallow clone
git submodule update --init --recursive --depth 1
# 3. Sync dependencies (creates .venv and installs everything)
uv sync
# 4. Run commands using uv run
uv run python cmsis_nn_tools/cli.py --helpNote: uv cannot clone git submodules (that's a git feature), so we use git submodule commands for that. All Python dependencies are managed entirely by uv.
# Run complete pipeline (default: cortex-m55)
python3 cmsis_nn_tools/cli.py
# Setup dependencies and run pipeline
python3 cmsis_nn_tools/cli.py --setup
# Specify CPU
python3 cmsis_nn_tools/cli.py --cpu cortex-m4# Run with specific filters
python3 cmsis_nn_tools/cli.py --op conv2D --dtype S8 --limit 5
# Skip certain steps
python3 cmsis_nn_tools/cli.py --skip-generation --skip-conversion
# Dry run to see what would be done
python3 cmsis_nn_tools/cli.py --dry-run
# Verbose output with custom CPU
python3 cmsis_nn_tools/cli.py --cpu cortex-m3 --verbose
# Custom optimization level and jobs
python3 cmsis_nn_tools/cli.py --opt "-O2" --jobs 8--skip-generation: Skip TFLite model generation--skip-conversion: Skip TFLite to C conversion--skip-runners: Skip test runner generation--skip-build: Skip FVP build--skip-run: Skip FVP test execution
--op OPERATOR: Generate only specific operator (e.g., 'Conv2D')--dtype DTYPE: Generate only specific dtype (e.g., 'S8', 'S16')--limit N: Limit number of models to generate
--cpu CPU: Target CPU (default: cortex-m55)--opt LEVEL: Optimization level (default: -Ofast)--jobs N: Parallel build jobs (default: auto)
--timeout SECONDS: Per-test timeout in seconds (0 = none)--no-fail-fast: Don't stop on first test failure
--setup: Initialize git submodules and install Python dependencies (requires uv)--verbose, -v: Show detailed output--dry-run: Show what would be done without actually doing it--quiet, -q: Reduce output verbosity--log-file PATH: Log file path
All Python lives under cmsis_nn_tools/:
cmsis_nn_tools.core.pipeline: Main pipeline orchestrationcmsis_nn_tools.core.config: Configuration managementcmsis_nn_tools.core.logger: Logging configuration
cmsis_nn_tools/cli.py: Command-line interface entry pointcmsis_nn_tools/build_and_run_fvp.py: FVP build and test execution
cmsis_nn_tools/scripts/generate_test_runners.py: Unity test runner generationcmsis_nn_tools/scripts/setup_dependencies.py: Dependency download and setupcmsis_nn_tools/scripts/collect_coverage.py: Coverage data collection
cmsis_nn_tools/tflite_generator/contains:test_ops.py,conftest.py: TFLite model generation via pytesttester/ops/: Operator implementationstester/io/: I/O utilitiestester/descriptors/: Test descriptor schemas and examples
cmsis_nn_tools/utils/command_runner.py: Command execution utilities
cmsis_nn_tools/reporting/: Test result parsing, storage, and report generation
cd cmsis_nn_tools/tflite_generator
pytest test_ops.py::test_generation -v --op mean_int16# Format
black cmsis_nn_tools/
# Lint
flake8 cmsis_nn_tools/
# Type check
mypy cmsis_nn_tools/- uv: Fast Python package installer (required)
- Install:
curl -LsSf https://astral.sh/uv/install.sh | sh - All setup scripts require uv
- Install:
- Python 3.8+
- pytest
- TensorFlow Lite
- helia-aot
- CMake
- ARM GCC toolchain
- FVP Corstone-300 simulator
This repository includes GitHub Actions workflows (.github/workflows/ci.yml) that:
- Checkout code with submodules
- Run the CI setup script
- Verify dependencies and build tools
- Test the CLI
The setup is designed to work seamlessly in CI environments. The setup_ci.sh script handles all dependency installation automatically.
For other CI systems, simply run:
./scripts/setup_ci.shThe script will handle all setup steps including:
- Installing uv (if not present)
- Initializing git submodules
- Setting up Python environment
- Downloading build dependencies (ARM GCC, CMSIS-5, Corstone300 FVP, etc.)