Skip to content

A comprehensive framework for ONNX model generation, optimization, and deployment for Deeploy.

Notifications You must be signed in to change notification settings

pulp-platform/Onnx4Deeploy

Onnx4Deeploy

CI Tests Python License: MIT Code style: black PRs Welcome

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.


✨ Features

🎯 Core Capabilities

  • 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

🔧 Optimization Suite

  • GEMM conversion and fusion
  • Gradient node optimization
  • Graph cleaning and simplification
  • Shape operation optimization
  • Node naming and annotation utilities

🧪 Testing Framework

  • Pytest-based test suite
  • ONNX Runtime validation
  • Baseline comparison testing

📦 Installation

Prerequisites

  • Python 3.8 or higher
  • PyTorch 2.0+
  • ONNX 1.14+
  • ONNX Runtime 1.19+

Install from source

git clone https://github.com/pulp-platform/Onnx4Deeploy.git
cd Onnx4Deeploy
pip install -e .

Verify installation

python -c "import onnx4deeploy; print(onnx4deeploy.__version__)"

🚀 Quick Start

Onnx4Deeploy provides two main features: Operator-level generation and Model-level export.

🎯 Command Line Tool (Recommended)

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 --examples

Available 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

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Development Setup

# Install with development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest tests/

# Format code
black .
isort .

📄 License

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.

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.


🙏 Acknowledgments


📞 Contact

About

A comprehensive framework for ONNX model generation, optimization, and deployment for Deeploy.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages