Core Concepts
Tenspiler is a verified lifting-based compiler that uses program synthesis to translate sequential programs written in general-purpose programming languages into tensor operations, enabling developers to leverage powerful tensor processing infrastructures while preserving their current programming paradigm.
Abstract
Tenspiler is a verified lifting-based compiler that translates sequential programs written in general-purpose programming languages (e.g., C++ or Python) into tensor operations. It uses program synthesis to lift the input code into an intermediate representation called Tensir, which expresses tensor operations in a simple yet expressive way. Tensir enables efficient lifting, verification, and code generation.
The key aspects of Tenspiler's approach are:
Synthesis Phase: Tenspiler formulates the translation process as a syntax-guided synthesis problem, where it searches for a program expressed using Tensir operators that is semantically equivalent to the input code.
Verification Phase: Tenspiler uses a theorem prover to verify the functional equivalence of the synthesized Tensir program and the input code for all possible program states.
Code Generation: Tenspiler then translates the verified Tensir program into the concrete syntax of the target tensor processing DSL (e.g., NumPy, TensorFlow, PyTorch, MLX) using simple pattern-matching rules.
Tenspiler has been designed to be flexible and extensible. The Tensir IR is carefully crafted to capture the common tensor operations across various software frameworks and hardware accelerators, enabling Tenspiler to support a broad spectrum of tensor processing environments. Tenspiler also employs several optimization techniques, such as restricting the search space and leveraging expression trees, to make the synthesis process scalable.
Tenspiler has been evaluated on 10 real-world benchmark suites, including image processing kernels, deep learning models, and signal processing functions. The experimental results show that by translating the code to be executed on 6 different software frameworks and hardware devices, Tenspiler offers on average 105× kernel and 9.65× end-to-end execution time improvement over the fully-optimized sequential implementation of the same benchmarks.
Stats
The original sequential C++ programs compiled with gcc -O3 are on average 105x slower in kernel execution time and 9.65x slower in end-to-end execution time compared to the versions translated by Tenspiler and executed on various tensor processing software frameworks and hardware accelerators.
Quotes
"Tenspiler uses verified lifting [12] (VL), a technique using inductive program synthesis to infer provably equivalent program summaries expressed using a user-defined intermediate representation (IR), and generate executable code from the synthesized summary to the target DSL."
"Tensir is a small language based on tensor algebra that includes commonly used vector and matrix operations."
"Tenspiler formulates code translation as a search for a program expressed in Tensir that is provably semantic-equivalent to the input."