[Paper Review] Relay: A High-Level IR for Deep Learning.
Relay is a high-level, functional, statically-typed intermediate representation (IR) for deep learning that unifies and generalizes existing DL IRs, enabling expressive, composable, and portable model compilation. It supports state-of-the-art models and delivers competitive performance across CPUs, GPUs, and FPGAs through optimized, extensible compilation with automatic differentiation and type safety.
Frameworks for writing, compiling, and optimizing deep learning (DL) models have recently enabled progress in areas like computer vision and natural language processing. Extending these frameworks to accommodate the rapidly diversifying landscape of DL models and hardware platforms presents challenging tradeoffs between expressiveness, composability, and portability. We present Relay, a new intermediate representation (IR) and compiler framework for DL models. The functional, statically-typed Relay IR unifies and generalizes existing DL IRs and can express state-of-the-art models. Relay's expressive IR required careful design of the type system, automatic differentiation, and optimizations. Relay's extensible compiler can eliminate abstraction overhead and target new hardware platforms. The design insights from Relay can be applied to existing frameworks to develop IRs that support extension without compromising on expressivity, composibility, and portability. Our evaluation demonstrates that the Relay prototype can already provide competitive performance for a broad class of models running on CPUs, GPUs, and FPGAs.
Motivation & Objective
- To address the growing complexity and diversity of deep learning models and hardware platforms by designing a unified, extensible intermediate representation (IR).
- To balance expressiveness, composability, and portability in DL IRs without sacrificing performance or maintainability.
- To enable efficient compilation of state-of-the-art models across CPUs, GPUs, and FPGAs through a principled IR design.
Proposed method
- Designing a functional, statically-typed IR that generalizes existing DL IRs and supports complex model structures.
- Integrating automatic differentiation into the IR to natively support backpropagation and model training.
- Developing a type system that ensures correctness and enables safe optimization across heterogeneous model components.
- Building an extensible compiler pipeline that eliminates abstraction overhead and targets new hardware platforms efficiently.
- Applying optimization techniques such as common subexpression elimination and constant folding within the typed functional IR.
- Enabling seamless compilation and deployment of models across CPUs, GPUs, and FPGAs through platform-specific code generation.
Experimental results
Research questions
- RQ1How can a deep learning IR be designed to unify and generalize existing representations while preserving expressiveness and portability?
- RQ2What type system and language features are necessary to support both high-level model composition and efficient low-level code generation?
- RQ3Can a functional, statically-typed IR enable competitive performance across diverse hardware platforms like CPUs, GPUs, and FPGAs?
- RQ4How can automatic differentiation be natively integrated into a high-level IR without sacrificing optimization opportunities?
- RQ5To what extent can abstraction in the IR be eliminated at compile time to achieve performance comparable to hand-optimized code?
Key findings
- The Relay IR successfully expresses state-of-the-art deep learning models, including complex architectures that are difficult to represent in prior IRs.
- The functional and statically-typed nature of Relay enables strong correctness guarantees and safe, composable optimizations.
- The prototype compiler achieves competitive performance on CPUs, GPUs, and FPGAs, demonstrating portability across diverse hardware platforms.
- The design enables efficient compilation with minimal abstraction overhead, approaching the performance of hand-optimized implementations.
- The extensible compiler architecture allows for easy integration of new hardware backends and optimization passes.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.