A comprehensive framework for ONNX model generation, optimization, and deployment for Deeploy.
Onnx4Deeploy provides a unified interface for exporting PyTorch models to ONNX format with specialized optimizations for training and inference on Deeploy hardware accelerators.
- Unified Model Export: Single API for both inference and training mode ONNX export
- 27 Operator Tests: Comprehensive test coverage for all supported ONNX operators
- 3 Pre-built Models: CCT, EpiDeNet, and MI-BMInet ready to use
- Training Graph Optimization: Specialized optimizations for on-device training
- Type-safe API: Full type annotations and documentation
- GEMM conversion and fusion
- Gradient node optimization
- Graph cleaning and simplification
- Shape operation optimization
- Node naming and annotation utilities
- Pytest-based test suite
- ONNX Runtime validation
- Baseline comparison testing
- Python 3.8 or higher
- PyTorch 2.0+
- ONNX 1.14+
- ONNX Runtime 1.19+
git clone https://github.com/pulp-platform/Onnx4Deeploy.git
cd Onnx4Deeploy
pip install -e .python -c "import onnx4deeploy; print(onnx4deeploy.__version__)"Onnx4Deeploy provides two main features: Operator-level generation and Model-level export.
Use the unified CLI tool Onnx4Deeploy.py:
# Generate operator tests
python Onnx4Deeploy.py -operator Relu -o ./onnx
# Generate model inference graph
python Onnx4Deeploy.py -model CCT -mode infer -o ./onnx
# Generate model training graph
python Onnx4Deeploy.py -model CCT -mode train -o ./onnx
# List available options
python Onnx4Deeploy.py --list-models
python Onnx4Deeploy.py --list-operators
python Onnx4Deeploy.py --examplesAvailable Arguments:
-operator NAME: Generate operator test (e.g., Relu, Add, Gemm)-model NAME: Generate model ONNX (e.g., CCT, EpiDeNet, MIBMInet)-mode {infer,train}: Model export mode (default: infer)-o PATH: Output directory path--list-models: List all available models--list-operators: List all available operators--examples: Show usage examples
We welcome contributions! Please see our Contributing Guide for details.
# Install with development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests
pytest tests/
# Format code
black .
isort .All licenses used in this repository are listed under the LICENSES folder. Unless specified otherwise in the respective file headers, all code checked into this repository is made available under a permissive license.
- Most software sources and tool scripts are licensed under the MIT license.
- Markdown, JSON, text files, pictures, PDFs, are licensed under the Creative Commons Attribution 4.0 International license (CC BY 4.0).
To extract license information for all files, you can use the reuse tool and by running reuse spdx in the root directory of this repository.
- Built with ONNX
- Tested with ONNX Runtime
- Optimized for Deeploy hardware
- Issues: GitHub Issues
- Documentation: docs/
- Progress: REFACTORING_STATUS.md