Introduction
Tensor algebra—the mathematical backbone of deep learning and data analytics—requires massive computational throughput. Spatial accelerators, consisting of an array of Processing Elements (PEs), are the gold standard for this work due to their high parallelism and low power consumption. However, designing these accelerators presents a significant challenge. Manual RTL coding is too slow for exploring the vast design space, while High-Level Synthesis (HLS) tools often produce "black box" code that is difficult to optimize. Furthermore, existing automated frameworks often restrict themselves to "systolic" dataflows, missing out on more efficient patterns like broadcasting or stationary data.
The TensorLib Framework
TensorLib is an automated framework designed to bridge the gap between software loops and hardware gates using a formal mathematical approach called Space-Time Transformation (STT).
Space-Time Mapping
STT uses a transformation matrix to map every iteration of a nested loop to a specific coordinate in the PE array (Space) and a specific clock cycle (Time). This provides a rigorous blueprint for hardware execution by defining exactly where and when every computation occurs.
Automated Reuse Analysis
By analyzing the STT matrix, TensorLib automatically identifies the data reuse pattern for every tensor in the operation. It categorizes these into five types: Unicast, Stationary, Systolic, Multicast, and 2D-reuse. This categorization allows the framework to select the most efficient hardware structures for data movement, ensuring that the generated architecture is tailored to the specific tensor operation.
Chisel-Based Templates and Hierarchical Generation
Instead of generating HLS code, TensorLib utilizes Chisel, a hardware construction language. The framework employs a library of highly parameterized hardware modules. Once the dataflow is determined via STT, the framework "plugs in" the corresponding modules to build the PE structure, interconnects, and memory controllers. The hardware is generated in a bottom-up fashion, from individual PE internals to the array interconnection, and finally to the global controller and on-chip buffers.
Key Results and Insights
The framework was evaluated using essential tensor algebra benchmarks, including GEMM, Conv2D, and complex operations like MTTKRP.
- Performance Gains: TensorLib achieved a 21% performance improvement in throughput (Gop/s) compared to state-of-the-art generators like Susy and PolySA.
- Frequency and Efficiency: Generated designs reached a 15% higher clock frequency (up to 263 MHz on a Xilinx VU9P FPGA). ASIC simulations showed that selecting the optimal dataflow could reduce energy consumption by up to 1.8x.
- Dataflow Versatility: The primary differentiator is TensorLib's ability to automatically switch between systolic, multicast, and stationary patterns. This flexibility allows it to find optimal configurations for algorithms like Depthwise-Conv2D that other tools struggle to optimize.
Conclusion and Future Work
TensorLib demonstrates that combining formal mathematical transformations with high-level hardware construction languages can significantly improve both productivity and performance in accelerator design. While the framework automates much of the process, future work could address manual IP dependencies for computation cells and automate "physical awareness" for better floorplanning. Expanding the optimization of multi-level memory hierarchies for extremely large tensors also remains a promising direction.
Summary updated