Table of Contents
Fetching ...

MLIR: A Compiler Infrastructure for the End of Moore's Law

Chris Lattner, Mehdi Amini, Uday Bondhugula, Albert Cohen, Andy Davis, Jacques Pienaar, River Riddle, Tatiana Shpeisman, Nicolas Vasilache, Oleksandr Zinenko

TL;DR

MLIR presents a flexible, extensible compiler infrastructure designed to reduce engineering costs and enable heterogeneous, domain-specific lowering through a unified SSA-based IR and dialect system. It introduces core design principles such as minimal built-in concepts, progressive lowering, and declarative rewrites, complemented by robust infrastructure for dialects, verification, and parallel passes. The paper demonstrates MLIR across diverse applications, including TensorFlow graphs, polyhedral codegen, Fortran IR, and domain-specific compilers, highlighting reusable passes and cross-dialect interoperability as key advantages. The work argues that this approach facilitates rapid development of specialized compilers while preserving performance and analyzability, with implications for education and future research in IR design and language engineering.

Abstract

This work presents MLIR, a novel approach to building reusable and extensible compiler infrastructure. MLIR aims to address software fragmentation, improve compilation for heterogeneous hardware, significantly reduce the cost of building domain specific compilers, and aid in connecting existing compilers together. MLIR facilitates the design and implementation of code generators, translators and optimizers at different levels of abstraction and also across application domains, hardware targets and execution environments. The contribution of this work includes (1) discussion of MLIR as a research artifact, built for extension and evolution, and identifying the challenges and opportunities posed by this novel design point in design, semantics, optimization specification, system, and engineering. (2) evaluation of MLIR as a generalized infrastructure that reduces the cost of building compilers-describing diverse use-cases to show research and educational opportunities for future programming languages, compilers, execution environments, and computer architecture. The paper also presents the rationale for MLIR, its original design principles, structures and semantics.

MLIR: A Compiler Infrastructure for the End of Moore's Law

TL;DR

MLIR presents a flexible, extensible compiler infrastructure designed to reduce engineering costs and enable heterogeneous, domain-specific lowering through a unified SSA-based IR and dialect system. It introduces core design principles such as minimal built-in concepts, progressive lowering, and declarative rewrites, complemented by robust infrastructure for dialects, verification, and parallel passes. The paper demonstrates MLIR across diverse applications, including TensorFlow graphs, polyhedral codegen, Fortran IR, and domain-specific compilers, highlighting reusable passes and cross-dialect interoperability as key advantages. The work argues that this approach facilitates rapid development of specialized compilers while preserving performance and analyzability, with implications for education and future research in IR design and language engineering.

Abstract

This work presents MLIR, a novel approach to building reusable and extensible compiler infrastructure. MLIR aims to address software fragmentation, improve compilation for heterogeneous hardware, significantly reduce the cost of building domain specific compilers, and aid in connecting existing compilers together. MLIR facilitates the design and implementation of code generators, translators and optimizers at different levels of abstraction and also across application domains, hardware targets and execution environments. The contribution of this work includes (1) discussion of MLIR as a research artifact, built for extension and evolution, and identifying the challenges and opportunities posed by this novel design point in design, semantics, optimization specification, system, and engineering. (2) evaluation of MLIR as a generalized infrastructure that reduces the cost of building compilers-describing diverse use-cases to show research and educational opportunities for future programming languages, compilers, execution environments, and computer architecture. The paper also presents the rationale for MLIR, its original design principles, structures and semantics.

Paper Structure

This paper contains 52 sections, 10 figures.

Figures (10)

  • Figure 1: TensorFlow model execution spanning different frameworks.
  • Figure 2: Compilation pipeline of different languages with multiple mid-level IRs for language-specific optimization with common backend for multiple hardware targets.
  • Figure 3: Operation (Op) is a main entity in MLIR; operations contain a list of regions, regions contain a list of blocks, blocks contains a list of Ops, enabling recursive structures
  • Figure 4: MLIR generic representation for polynomial multiplication using affine and std dialects. The same IR is displayed with the custom syntax Figure \ref{['fig:affine']}.
  • Figure 5: Operation Definition Syntax (ODS) provides a concise way of defining new Ops in MLIR. Here, one defines the Op taking a tensor and a floating-point value, and returning a tensor of the same type as the input one.
  • ...and 5 more figures