MLIR AIE Explained: Compiling for AMD's AI Engine Dataflow Array

MLIR AIE explained: how AMD's MLIR-based toolchain and IRON Python API turn explicit tile placement and data movement into an xclbin for the AI Engine…

MLIR AIE Explained: Compiling for AMD's AI Engine Dataflow Array
Written by TechnoLynx Published on 11 Jul 2026

MLIR-AIE is AMD’s open-source, MLIR-based compiler toolchain for the AI Engine tile array. It targets the AI Engine arrays in Ryzen AI NPUs and in Versal devices. At its core is an MLIR dialect, aie, that models tiles, buffers, locks and stream switches. The core of the IRON Python API is generated from that dialect. The aiecc driver then works with the LLVM-based Peano compiler, which handles per-core code, to turn a design into two outputs: an xclbin and an instruction stream that XRT loads onto the array. In short, MLIR AIE explained in one sentence: you control where computation runs on the tiles and how data moves between them, and the toolchain turns that design into a configuration for the array.

MLIR AIE Explained as a Stack, from Python to Xclbin

We read mlir-aie as a set of layers, each with a narrow job. The IRON paper calls the mlir-aie dialect “the heart of IRON”. The dialect has two aims: to represent the hardware’s capabilities clearly and completely, and to make data movement, synchronisation and design structure simpler to express. Higher-level compilers are also meant to emit it, so it works as a target IR as well as a programming surface.

AMD’s fork of MLIR includes several dialects, as described by the authors of a 2025 paper on offloading Fortran intrinsics. aie covers streaming connections between compute tiles and direct memory access. aievec covers vector arithmetic. adf expresses AMD’s Adaptive Data Flow graph, which connects tiles. The project glossary describes aie as the core dialect for tiles, buffers, locks and stream switches, written in lowercase now that the uppercase AIE. form is deprecated.

How a Design Becomes a Running NPU Program

  1. Write the design. Use Python with the IRON API or write mlir-aie directly. A Python script emits MLIR assembly.
  2. Write the per-core code. Each core block says what one processor core runs. It can compute directly, call an externally compiled kernel, or both.
  3. Compile external kernels. Peano compiles C++ core code written against the AIE API header library.
  4. Run aiecc. aiecc takes the MLIR plus any kernel object files. It produces a binary containing the per-core programs and an instruction sequence that reconfigures the NPU from the host at runtime.
  5. Load and run. XRT loads the xclbin to configure the NPU partition and streams the per-core ELFs to the tiles.

The @iron.jit decorator wraps the whole design. The first call to a decorated function compiles the design to an xclbin plus instruction stream and runs it on the attached NPU.

Which AMD Devices Does MLIR-AIE Compile For?

MLIR-AIE compiles for the AI Engine part of two device families: Ryzen AI NPUs and Versal devices. The project’s device-support page says each device is supported “at some level of completeness”, so check your specific part before planning around it.

Device target Where it ships Array shape
npu1 Ryzen Phoenix (e.g. 7940HS) and Hawk Point (e.g. 8040HS) SoCs 5 columns, 6 rows
npu1_1col to npu1_4col Physical partitions of an npu1 device, each with a DMA shim tile N columns, 6 rows
xcvc1902 (AIE version 1) VCK190 and VCK5000 boards 50 columns, 9 rows
xcve2302 (AIE version 2) No board named on the device-support page 17 columns, 4 rows
xcve2802 (AIE version 2) V70 board 38 columns, 11 rows

The Peano LLVM backend has a narrower focus. Its repository currently focuses on the AIE2 architecture in the XDNA accelerators of Phoenix and Hawk Point devices. The project positions IRON for researchers and performance engineers. It complements the AMD Ryzen AI Software Platform for mainstream inference rather than replacing it. AMD’s MLIR-AIE slides name the audience as researchers and tool developers, with architectural details exposed and accessible.

How mlir-aie Relates to Upstream MLIR and LLVM

MLIR-AIE provides MLIR representations at several levels of abstraction. AMD’s own tutorial describes MLIR as an LLVM core project with frontends ranging from Fortran to PyTorch and backends that include LLVM, GPUs and the AI Engine. Three connections matter in practice.

Below it, Peano extends LLVM. Peano adds the AI Engine processor as an LLVM target architecture, which lets frontends such as clang compile core code. The LLVM backend supports a single processor, while support for the device as a whole lives in the MLIR-based mlir-aie tools.

Upstream dialects can lower into it. The Fortran paper lowers MLIR’s linalg dialect to AMD’s AIE dialects. It intercepts the IR after Flang’s HLFIR and FIR have been lowered to standard dialects, and targets the NPU in the Ryzen AI 7000 CPU. The generated IR then goes through AMD’s AIE MLIR tooling to produce the xclbin and instruction files.

Above it, MLIR-AIR targets it. MLIR-AIR’s final IR is consumed by MLIR-AIE for NPUs, or by LLVM-based pipelines for CPUs and GPUs. During lowering, air.herd operations become per-core compute kernels, air.channel becomes DMA engines, buffer descriptors and stream connections, and air.token synchronisation becomes tile-local locks. Through Torch-MLIR and Triton-Shared, AIR lets PyTorch models and Triton programs reach AMD NPUs. The route from a full model down to the array has its own explainer, on compiling models to AMD/Xilinx AI Engine targets.

The AIR authors measured the gap against hand-written MLIR-AIE code. Their compiler-generated matrix multiplication reached 78.7%, 48.6% and 59.1% of theoretical peak for i16, bf16 and i8. Each result was within 5 percentage points of the hand-optimised MLIR-AIE designs. MLIR-AIE’s hand-optimised matrix multiplication is the baseline many recent research works have adopted for spatial execution on AMD NPUs.

Why Compiling for the Dataflow Array Is a Different Problem from Compiling a GPU Kernel

On a GPU, you write one kernel, launch a grid of threads and let hardware-managed caches and schedulers deal with much of the locality. On the AI Engine array, compute and memory are spatially distributed, data movement is explicitly scheduled and decoupled from compute, and each core runs its own independent task with data flowing between tasks. The MLIR-AIR paper puts it plainly: traditional thread-centric models obscure coordination of computation, data movement and synchronisation, or defer it to hardware, while spatial architectures need it stated explicitly.

Concern GPU kernel compilation MLIR-AIE on the AI Engine array
Unit of work Many threads running one kernel One program per compute tile (a Worker)
Where code runs Hardware schedules blocks onto SMs The design places code on specific tiles
Data movement Loads and stores through a cache hierarchy ObjectFifos, DMAs and stream switches, described explicitly
Path to main memory Any thread can address global memory Always shim to (mem) to compute, scheduled by per-tile DMA
Synchronisation Barriers and atomics inside the kernel Locks, plus acquire/release on FIFO elements
Core pipeline Hardware handles hazards In-order, exposed-pipeline VLIW with no stall logic, so the compiler schedules hazards
Local memory Shared memory per SM, sized by the vendor 64 KB per compute tile on the Ryzen AI 7000 NPU

This is why a working CUDA kernel and its thread-hierarchy mental model do not carry over as a port. The question changes from “how many threads, how is memory coalesced” to “which tiles, which FIFOs, which DMA patterns”. A paper on Versal AIE-ML describes the programming model as a rigid dataflow paradigm that “fundamentally” diverges from the control-flow models of GPUs and CPUs. In that model, kernels execute inside predefined graphs for a fixed number of iterations. That paper composed its kernels in AMD’s ADF graph flow.

That paper maps a complete DNN onto the AIE-ML array for low-latency inference. The same paper keeps all weights and intermediate activations on-chip, so DRAM is touched only for inputs and outputs. It also notes that its batch-size-1 workload keeps a GPU from reaching peak performance.

What the IRON Python API Lets You Control on a Ryzen AI NPU

The IRON Python API gives you control over tile placement, data movement and vectorised compute, “with nothing hidden behind a framework”. In practice, a design is built from a few named objects. A Worker is the code for one compute tile. An ObjectFifo is a synchronised streaming channel between host and tile, or between two tiles, whose elements producers and consumers acquire and release. A Runtime sequence describes which host tensors fill the array and which get drained back.

The design controls several things directly:

  • Placement. The lower-level API declares tiles by coordinates, such as tile(1, 3) inside an @device(AIEDevice.npu) block. The newer API has an extensible placement interface. Its example SequentialPlacer, 64 lines of source, assigns cores in a grid and then picks memory and shim tiles so that ObjectFifo endpoints stay in the same column.
  • Buffering. ObjectFifo depth defaults to 2, reflecting how common ping-pong buffers are. Names are auto-generated and endpoints are inferred.
  • Data layout in transit. Runtime DMA calls such as npu_dma_memcpy_nd take sizes and strides that describe a layout transformation for the DMA to perform. The taplib library wraps this in TensorAccessPattern and TensorAccessSequence objects, because raw sizes and strides are hard to reason about.
  • Per-core compute. Core code can be inline MLIR or a call to an external C++ kernel compiled separately.
  • Metaprogramming. Ordinary Python can be mixed with generation of MLIR operations.

The newer top-level API defers creating MLIR operations until a resolve step. Across 27 example designs, its authors report an average of about 26% fewer source lines than the earlier IRON interface, with functionality preserved.

Placement and Routing Break First in Large Designs

Automatic placement broke down in one published design that crowded the array. In that Versal AIE-ML study, the default compiler placement failed to find a valid routing after 62 minutes for a design using 223 active AIE engines. Raising the optimisation level to its maximum still failed, this time after 48 minutes. A custom placer that put dataflow-adjacent kernels on neighbouring engines compiled the design in 8 minutes. That result comes from an ADF graph flow on the Versal VE2802, not from IRON on a Ryzen NPU.

The IRON authors chose manual placement and data-transformation specification as their extension points because those tasks are tedious and error-prone. On a small Phoenix partition, a sequential placer may be all you need. As a design approaches full array use, we would expect to plan placement the way the dataflow is drawn, with communicating kernels kept close together, and to budget compile time for iteration.

Deciding Which Layer to Work At

Teams deploying a model on a Ryzen AI laptop have mainstream inference tooling in the Ryzen AI Software Platform, which IRON complements rather than replaces. For matrix multiplication, MLIR-AIR’s compiler-generated code came within 5 percentage points of hand-written MLIR-AIE, which argues for starting there and dropping lower only where the profile demands it. mlir-aie itself earns its place when you need to decide exactly how a layer streams through memory tiles, how buffers are double-buffered and which column owns which shim. Those are the decisions no higher layer can make for you on hardware where data movement is the program. One part of the picture is still open: how far automatic placement scales on the larger Ryzen parts. The placement failures cited here come from a Versal design.