Transform Dialect Tutorial
Oleksandr Zinenko
TL;DR
The paper presents the MLIR Transform Dialect, a framework for orchestrating fine-grained transformations by applying transform IR to payload IR without replacing existing pass infrastructures. It clarifies architecture, including how structured Linalg operations, tiling, fusion, and rematerialization enable advanced code generation, and explains extension mechanisms for adding new transform operations and types. It also describes a Transform Dialect interpreter and patterns for matching payloads, plus top-level sequence operations to compose transforms. Together, these contributions enable precise, reusable transformation scripts with diagnostics, and demonstrate practical workflows from matmul tiling to fused elementwise operations.
Abstract
Transform Dialect in MLIR provides operations that can be used to control transformation of the Intermediate Representation (IR) using a different portion of the IR. It refers to the IR being transformed as payload IR, and to the IR guiding the transformation as transform IR. The main use case for this dialect is orchestrating fine-grain transformations on individual IR objects (operations or values) or sets thereof. For example, it may involve finding loop-like operations with specific properties (e.g., large size) in the payload IR, applying loop tiling to those and only those operations, and then applying loop unrolling to the inner loops produced by the previous transformations. As such, it is not intended as a replacement for the pass infrastructure, nor for the pattern rewriting infrastructure. In the most common case, the transform IR will be processed and applied to the payload IR by a pass. Transformations expressed by the Transform dialect may be implemented using the pattern infrastructure or any other relevant MLIR component. The rest of this document explains the main concepts and usage scenario of the MLIR Transform Dialect combined with structured operations.
