| commit | b98c1b92cb630bd696992f47df591bb2f247a8d7 | [log] [tgz] |
|---|---|---|
| author | Eric Feng <55723758+efric@users.noreply.github.com> | Fri Nov 21 15:44:03 2025 -0800 |
| committer | GitHub <noreply@github.com> | Fri Nov 21 15:44:03 2025 -0800 |
| tree | 93920d7b3916230fda643d245f1f380ce8c4ca92 | |
| parent | df3d0762b6120e3740f82bbfe28e0130cf668c9b [diff] |
[LLVMGPU][Codegen] Emit packed chain FMA from select multi_reductions and contracts (#21855)
This patch teaches the vector lowering pipeline to:
1. Rewrite `vector.multi_reduction<add>` whose input is `arith.mulf`
into a `vector.contract` via
`vector::populateVectorReductionToContractPatterns`
2. Lower a restricted set of `vector.contract` into packed FMA chains.
Previously lowering `vector.multi_reduction` of the same form produced
elementwise pack-muls per K-slice and then reduced them with a
left-associated, serial chain of `v_add_f{16, 32}`
`(mul(a0 ,b0) + (mul(a1, b1) + … + acc`
The new lowering emits a single nested FMA chain and folds the
accumulation into the `math.fma` c-operand
`fma(a0 ,b0, fma(a1, b1, fma(a2, b2, fma(a3, b3, acc))))`
To do this, we first permute the reduction and parallel dimensions of
the `LHS` and `RHS` to the order of `[reduction, ..., parallel, ...]`.
The `LHS` and `RHS` are then collapsed to a 2D shape of `{Π reduction
dimensions, Π parallel dimensions}`. Then we form the FMA chain by
iterating backwards, seeded by the accumulator.
Not all forms of `vector.contract` are suitable in the current approach.
For example, when an operand drops a parallel iterator as in matmul-like
contracts. We require both sides to share the same 2D tuple. Unsupported
cases fall back to the existing lowering.
Fixes: #21483 (variant of original issue; for [issue
#21513](https://github.com/iree-org/iree/issues/21513)).
---------
Signed-off-by: Eric Feng <Eric.Feng@amd.com>IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.
See our website for project details, user guides, and instructions on building from source.
Releases notes are published on GitHub releases.
| Package | Release status |
|---|---|
| GitHub release (stable) | |
| GitHub release (nightly) | |
iree-base-compiler | |
iree-base-runtime |
For more details on the release process, see https://iree.dev/developers/general/release-management/.
| Operating system | Build status |
|---|---|
| Linux | |
| macOS | |
| macOS |
For the full list of workflows see https://iree.dev/developers/general/github-actions/.
See our website for more information.
Community meeting recordings: IREE YouTube channel
| Date | Title | Recording | Slides |
|---|---|---|---|
| 2025-06-10 | Data-Tiling in IREE: Achieving High Performance Through Compiler Design (AsiaLLVM) | recording | slides |
| 2025-05-17 | Introduction to GPU architecture and IREE's GPU CodeGen Pipeline | recording | slides |
| 2025-02-12 | The Long Tail of AI: SPIR-V in IREE and MLIR (Vulkanised) | recording | slides |
| 2024-10-01 | Unveiling the Inner Workings of IREE: An MLIR-Based Compiler for Diverse Hardware | recording | |
| 2021-06-09 | IREE Runtime Design Tech Talk | recording | slides |
| 2020-08-20 | IREE CodeGen (MLIR Open Design Meeting) | recording | slides |
| 2020-03-18 | Interactive HAL IR Walkthrough | recording | |
| 2020-01-31 | End-to-end MLIR Workflow in IREE (MLIR Open Design Meeting) | recording | slides |
IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.