How pulp-platform/deeploy works
Project Type and Purpose
• Deeploy is a domain‐specific compiler: it takes an ONNX neural network graph as input and emits highly optimized, low-level C code for various target SoCs (Generic CPU, Cortex-M, MemPool, Siracusa, Snitch, Neureka, PULPOpen).
• It is organized as a bottom-up, modular compilation framework where each stage of compilation and each hardware backend is factored into separate “extensions” or “targets.”
High-Level File Structure Analysis
Top-level directories:
• Container, Dockerfile, .github/workflows – CI/CD and containerized environment
• Deeploy/ – core compiler engine, IR definitions, pass managers, and plugin extensions
• Deeploy/Targets/… – one subdirectory per hardware backend (CortexM, Generic, MemPool, etc.), each containing parsers, platform modelling, deployers, code generation templates, tile constraints, type-checkers
• Deeploy/CommonExtensions, EngineExtension, MemoryLevelExtension, FutureExtension, TilingExtension – compiler passes grouped by functional phase (IR transforms, memory/scheduling passes, future‐proofing, tiling)
• TargetLibraries/… – low-level C runtime libraries per backend (e.g., CMSIS-NN for CortexM, PULP SDK for PULPOpen)
• DeeployTest/ – test harnesses and ONNX test models, with per-platform test runners
• cmake/, setup.py, pyproject.toml – build system configuration (Python packaging, CMake modules for cross-compilation)
• docs/ – Sphinx documentation and tutorials
Key Architectural Patterns and Components
• Layered, plugin-based compiler pipeline (frontend → IR → passes → backend codegen)
• Separation of concerns: “Core engine” (graph and data types, pass manager, common utilities) vs. “Extensions” (specialized passes) vs. “Targets” (hardware backends) vs. “Libraries” (runtime support) vs. “Tests & CI”
• Pipeline pattern: each pass consumes and produces an intermediate representation (IR) stored as Python data structures; final codegen backends traverse the IR to produce C templates.
• Backends follow the same structure: Parser (ONNX→IR), Platform (target capabilities), Deployer (maps IR onto platform model), Templates (C code snippets), TileConstraints & Tiler (for data partitioning).