TL;DR
This paper introduces an automated, high-level framework that simplifies integrating custom GEMM-based deep learning accelerators into the TVM compiler. By abstracting compiler complexities and extending the CoSA scheduling tool, the approach reduces manual integration effort by 80% while matching the performance of specialized, hand-optimized hardware toolchains.
What Problem Does This Paper Address?
Custom hardware accelerators (like systolic arrays) are highly efficient for edge deep learning, but they suffer from a massive "compiler tax." Integrating a new accelerator into modern machine learning compilers like TVM typically requires deep, specialized knowledge of compiler internals. Developers must manually write complex lowering passes, handle fine-grained hardware instructions (intrinsics), and figure out optimal tensor scheduling (tiling and data movement).
Existing integration frameworks fall short: some require users to manually rewrite computational graphs, while others lack support for essential real-world features like quantization, tiling, and double buffering. As a result, hardware developers often resort to writing proprietary, hand-optimized C-function toolchains, missing out on the broader ecosystem of automated ML compilers.
Methods
The authors propose an automated compiler integration framework built on top of TVM and the Universal Modular Accelerator (UMA) interface. The system requires only two high-level inputs from the user: a functional description (defining operators using Python's Tensor Expression DSL) and an architectural description (specifying hardware constraints in YAML).
The framework divides the heavy lifting into automated frontend and backend configurators:
- Frontend Configurator: Automatically groups multi-op sequences common in quantized models (e.g., Conv + Bias Add + Requantize + Clip) into generalized single operators, simplifying graph partitioning.
- Extended CoSA Scheduler: The authors extended CoSA (Constrained Optimization for Spatial Accelerators), a Mixed-Integer Programming (MIP) formulation tool. The extended version accounts for strict hardware constraints like fixed processing element (PE) array dimensions, uneven mapping strategies, and double buffering.
- Hardware Intrinsic Generator: Automatically generates the necessary TVM tensor intrinsics directly from the user's high-level functional description, eliminating tedious boilerplate code.
- Mapping Generator: Translates CoSA’s optimized schedule outputs into Tensor IR (TIR) loop transformations and inserts the generated hardware intrinsics.
Datasets
The framework was evaluated using:
- Single Dense Layers: Varied systematically in size ($N, K, C$ dimensions ranging from $64 \times 64 \times 64$ to $512 \times 512 \times 512$).
- The ToyCar Network: A full deep learning model taken from the MLPerf Tiny benchmark, representing a realistic edge computing workload.
Evaluation was performed on a cycle-accurate simulator of the Gemmini hardware accelerator via Verilator.
Key Insights and Ideas
- TIR-Level Scheduling over TE-Level: Traditional TVM lowering relies on explicit Tensor Expression (TE) schedules. By bypassing TE scheduling and handling optimization entirely at the Tensor IR (TIR) level via the Mapping Generator, the framework gains significant flexibility and makes compiler debugging much easier.
- The Constant Folding Trap: A naive integration into TVM often disables constant folding for matched operators after graph partitioning. This causes massive performance degradation because preprocessing steps (like matrix transposition and quantization parameter adjustments) are executed dynamically at runtime. Properly extending the compiler to propagate and fold these constants is vital for matching native hardware performance.
Key Results
- 80% Reduction in Code Complexity: To enable lowering and scheduling for 2D convolution and dense operators on the Gemmini backend, traditional manual integration requires over 1,050 lines of code (LoC) across C++ and Python. The proposed approach requires only ~208 LoC of high-level functional descriptions.
- Performance Parity: When tested on the Gemmini accelerator, the automated framework achieved execution latencies virtually identical to Gemmini’s native, hand-optimized C-function toolchain. For the MLPerf ToyCar network, the proposed framework completed the workload in 50,064 cycles compared to the native toolchain's 51,034 cycles. Meanwhile, a standard, unoptimized UMA/BYOC baseline lagged far behind at over 10 million cycles due to inefficient preprocessing and lack of scheduling.
Limitations and Future Work
The current implementation focuses specifically on GEMM-based spatial architectures (such as systolic arrays like Gemmini). While GEMM operations dominate deep learning workloads, the framework's abstraction model may need further adaptation to support non-GEMM accelerators or highly heterogeneous dataflow architectures. The authors note that future work will focus on expanding the framework to support a broader variety of accelerator types and enhancing the automated scheduling exploration space.
Summary updated