How cornell-zhang/allo works
Project Type and Purpose
• Allo is a Python-embedded Accelerator Design Language (ADL) and compiler built on MLIR.
• It provides a DSL (in Python) for specifying hardware kernels, a progressive transformation framework (passes), and multiple backends (AIE, HLS, LLVM, Simulator, TAPA, Vitis) that emit FPGA/ASIC-targeted code or perform simulation.
File-Structure Analysis
• Top-level “allo/” directory: core Python DSL, IR builder, transformations, autoscheduler, passes, frontends (PyTorch), backends, dataflow abstraction, memory model, verification, utilities.
• “mlir/”: C++ MLIR dialect definitions, conversion passes, translation to HLS, C API bindings.
• “allo/backend/…”: backend-specific codegen and runtime config for AIE, HLS, LLVM IR, Vitis, simulator, TAPA.
• “allo/autoscheduler/…”: DFG construction, loop outlining, schedule primitives.
• “allo/ir/…”: MLIR IR builder, type system, transforms, template engine, symbol resolution, visitor framework.
• “aio/harness/…”: generated build scripts and runtime stubs for different target flows (Vivado, Vitis, AIE, TAPA).
• “examples/” and “tests/”: usage scenarios and validation.
• Configuration files: setup.py, .github/workflows, scripts/lint, docker/ for containerized builds.
Key README Insights
• Emphasis on “progressive hardware customizations” via MLIR passes.
• “Composable schedules” that .compose() transformations.
• Multiple backends and formal verification.
a. Main Components
1) Python Frontend & DSL
2) IR Builder (MLIR Python binding)
3) MLIR Dialect & Compiler Pipeline
• Parsing/Tracing
• IR canonicalization
• Dataflow Graph (DFG) construction
• Autoscheduler passes
• Loop & memory transformation passes
• Type lowering & verification
• Backend-agnostic optimizations
4) Backend Codegens
• LLVM IR
• HLS (Vivado/TAPA/Vitis)
• AIE (AI Engine)
• Simulator
5) Harness Generator & Build System
6) External Services & Tools
• MLIR Core
• LLVM Project
• Dockerized environments
• CI workflows
7) User-Facing Artifacts
• Generated HLS C++
• Hardware bitstreams (Vivado, Vitis)
• Simulation outputs
b. Relationships & Data Flow
• User writes Python DSL → Tracer/frontends produce an MLIR module → IR Builder emits Allo dialect → Sequence of compiler passes (canonicalization, DFG, autoscheduler, transform passes) → Lowering passes generate either LLVM IR or target-specific HLS C++ → Harness Generator produces build scripts & stubs → External toolchains (Vivado/Vitis/aienginesimulator) consume artifacts → Hardware/SW binary.
• Verification pass hooks inserted post-transforms.
• Tests and examples invoke Python API, triggering end-to-end pipeline.
c. Architectural Patterns & Principles
• Progressive, composable pass pipeline.
• Separation of concerns: DSL vs. IR vs. backends.
• Plugin-style backends for extensibility.
• Parameterized kernel templates for reuse.
• Formal verification integrated as a pass.
d. Technologies & Frameworks
• Python 3 DSL
• MLIR (C++ dialects & Python bindings)
• LLVM (codegen)
• Vivado HLS, Vitis HLS, TAPA
• Docker for reproducible builds
• GitHub Actions for CI