25309 Commits

Author SHA1 Message Date
hellozmz
ecf979cdb6
[mlir] [docs] fix toy readme (#172262)
mlir toy docs use the deprecated api, so I fix it.
2025-12-19 09:41:44 +01:00
Abhishek Varma
b290a3e12b
[Linalg] Add *Pooling* matchers (#172351)
-- This commit is the eighth in the series of adding matchers
for linalg.*conv*/*pool*. Refer:
https://github.com/llvm/llvm-project/pull/163724
-- In this commit all variants of Pooling ops have been added.

Signed-off-by: Abhishek Varma <abhvarma@amd.com>
2025-12-19 13:01:02 +05:30
Henrich Lauko
32243a54f8
[MLIR] Add DefaultValuedEnumAttr decorator (#172916)
Introduce DefaultValuedEnumAttr, which similarly to DefaultValuedAttr
decorates an enum attribute to have a default value from a specific enum
case when not present. The default is constructed as the fully-qualified
enum case symbol.

In comparison to DefaultValuedAttr, this allows using a TableGen
EnumCase
variable instead of a raw string.
2025-12-19 08:29:53 +01:00
Eric Feng
24c7b4ea48
[mlir][amdgpu] implement amdgpu.sparse_mfma wrapper for smfmac instructions (#171968)
Signed-off-by: Eric Feng <Eric.Feng@amd.com>
2025-12-18 20:16:14 -06:00
Alex MacLean
a40f444265
[NVPTX] Add support for barrier.cta.red.* instructions (#172541)
This change adds full support for the ptx `barrier.cta.red` instruction,
following the same conventions as are already used for
`barrier.cta.sync` and `barrier.cta.arrive`.

In addition this MR removes the following intrinsics which are no longer
needed:
* llvm.nvvm.barrier0.popc -->
  llvm.nvvm.barrier.cta.red.popc.aligned.all(0, c)
* llvm.nvvm.barrier0.and -->
  llvm.nvvm.barrier.cta.red.and.aligned.all(0, z)
* llvm.nvvm.barrier0.or -->
  llvm.nvvm.barrier.cta.red.or.aligned.all(0, z)
2025-12-18 18:06:27 -08:00
Giacomo Castiglioni
6e7a44986d
[MLIR] Enable dylib init/deinit in execution engine on AArch64 platform (#172833)
This PR enables JIT initialize for AArch64. Up to now it was disabled
because of #71963 which was recently fixed by #71968.
2025-12-19 01:55:21 +01:00
Ivan Butygin
58c3b223ee
[mlir][rocdl] Add s_nop intrinsic (#172918)
Also, cleaned some whitespace in affected files.
2025-12-19 03:00:12 +03:00
Krzysztof Drewniak
32040d1e1d
[mlir][NFC] Document rationale, style for AMD dialects (#172703)
This commit adds documentation to the AMDGPU and ROCDL dialects
describing their purpose and codifying design guidelines that these
dialects follow.
2025-12-18 12:10:20 -08:00
Sang Ik Lee
8b0a24a50d
[MLIR] Vector to XeGPU conversion: Use proper source variant for create_nd_tdesc op creation. (#171216)
If source strided memref is not fully static - at least one of shape,
strides, offset is kDynamic - use i64 source variant.
With this change, xegpu.create_nd_tdesc created by lowering from vector
dialect, can rely on getMixedOffsets, getMixedSize and getMixedStrides
to get relevant values.
2025-12-18 11:03:51 -08:00
lonely eagle
4a9342392d
[mlir] Use SymbolOpInterface to implement operateOnSymbol in test-symbol-uses pass (#172675)
Fix https://github.com/llvm/llvm-project/issues/172603 by using
SymbolOpInterface to implement operateOnSymbol.

---------

Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2025-12-18 20:58:30 +08:00
Lukas Sommer
5623d1f4e6
[mlir][Linalg] Allow more control in drop unit dims (#171796)
Extend the `ControlDropUnitDims` struct to allow users of the
`linalg::dropUnitDims` function more control over the behavior of the
function.

The extended struct allows users to specify functions to control how the
operands are collapsed and how the result is expanded to the original
shape.

One example (and the motivation for this change) where this additional
control is useful is to allow collapsing of tensors with an encoding, as
demonstrated by the new test.

This is a breaking change. The new default behavior changes to abort the
transformation if one of the operands cannot be collapsed or if the
result cannot be expanded. This is the case for `memref` with
non-identity layout and `tensor`s with an encoding.

---------

Signed-off-by: Lukas Sommer <lukas.sommer@amd.com>
2025-12-18 07:15:30 +01:00
Yi Zhang
188bf2769a
Fix variable only used by assert in #172716. (#172788) 2025-12-17 23:47:05 -05:00
Maksim Levental
54eee1e947
Reapply "[mlir][math] Add FP software implementation lowering pass: math-to-apfloat" (#172714) (#172716)
Reapply https://github.com/llvm/llvm-project/pull/171221 - Fix builder
by linking `MLIRTransformUtils`. Also move headers to
`mlir/Conversion/ArithAndMathToAPFloat`.
2025-12-17 17:26:37 -08:00
Billy Zhu
76a17d99a7
[MLIR] Fix AsmPrinter alias uniqueness check (#172734)
A sneaky operator precedence bug caused this resize operation to always
truncate to size 0 or 1:
```
probeAlias.resize(alias.size() + isdigit(alias.back()) ? 1 : 0);
```
Because `+` is associated more strongly than the ternary operator. This
eventually led to the asm printer repeating an alias name, generating
illegal IR.

It wasn't a problem in most cases because it required two things to
trigger:
- Two naturally generated aliases, one "xxx" the other "xxx1" (note the
trailing "1").
- A unique processing order such that we process "xxx", then "xxx1",
then "xxx" again. This can only happen if they happen to be at different
"alias depths", since otherwise the pre-sorting will make sure this
ordering never happens. See the added test case for how this works in
practice (I will also attach what the current code generates).

This PR fixes the operator precedence, but also moves the calculation
outside the loop since it never changes.
2025-12-17 15:42:01 -08:00
Rolf Morel
79ed37ca92
[MLIR][Transform] Fix transform.smt.constrain_params's verifier (#172753)
Verifier was insisting on `!transform.param<...>` too early and hence
crashed on `!transform.any_param`.
2025-12-17 23:32:32 +00:00
Jianhui Li
e7ef7229d3
[MLIR][XeGPU] Fix the test issue brought by PR172125 (#172742)
Fix merge test issue brought by
https://github.com/llvm/llvm-project/pull/172125
2025-12-17 22:06:48 +00:00
Jianhui Li
2b9e47749c
[MLIR][XeGPU] Refactor Layout access interface (#172125)
This PR builds on the anchor layout mechanism introduced in
https://github.com/llvm/llvm-project/pull/169267 and performs the
following refactoring:

1. Introduce getAnchorLayout() and setAnchorLayout() interface for
anchor ops to get and set layout attributes.

2. Add getLocalLayout() and setLocalLayout() utility functions, and
refactor workgroup/subgroup distribution patterns to use these APIs.
These utilities access the layout information directly and locally,
without relying on global propagation.

3. Introduce localPropagateLayoutsFromAnchor(), a utility used by
subgroup distribution to unify non-anchor layout setup.
This function is intended to be invoked upfront by all layout-based
passes (including workgroup/subgroup distribution and unrolling) to
propagate layouts from anchor ops to non-anchor ops.
After this step, patterns within the pass should exclusively use
getLocalLayout() / setLocalLayout().

4. Refactor getDistributeLayoutAttr() and setDistributeLayoutAttr() to
remove special-case handling. These APIs now operate in a uniform order:
anchor ops first, then non-anchor ops, and finally block arguments.
These APIs will be deprecated on long run. 

5. Refactor patterns in wg/sg distribution, load optimization passes to
use get/setAnchorLayout() and get/setLocalLayout().

6. Update test cases to enforce that anchor ops must use—and only
use—anchor layouts.
2025-12-17 12:04:58 -08:00
Mehdi Amini
51ef9302a6 [MLIR] Apply clang-tidy fixes for llvm-qualified-auto in TransformInterfaces.cpp (NFC) 2025-12-17 11:54:01 -08:00
Mehdi Amini
7794502b33 [MLIR] Add non-regression bytecode test for #170993
This is a bytecode round-trip test with a deeply nested attribute.
2025-12-17 11:49:19 -08:00
Mehdi Amini
a4baf2c7ff Revert "[mlir][bytecode] Add support for deferred attribute/type parsing. (#170993)"
This reverts commit 93d2ef105703254769a8f182300b329dad5ed976.

A regression was found.

See: https://github.com/llvm/llvm-project/pull/170993#issuecomment-3666792469
2025-12-17 11:29:13 -08:00
Mehdi Amini
7ead626bf1 [MLIR] Apply clang-tidy fixes for modernize-use-equals-default in TestXeGPUTransforms.cpp (NFC) 2025-12-17 11:16:52 -08:00
Mehdi Amini
bf161806dc [MLIR] Apply clang-tidy fixes for readability-identifier-naming in MemRefOps.cpp (NFC) 2025-12-17 11:16:52 -08:00
Maksim Levental
621fe03eaa
Revert "[mlir][math] Add FP software implementation lowering pass: math-to-apfloat" (#172714)
Reverts llvm/llvm-project#171221

Broken builder https://lab.llvm.org/buildbot/#/builders/138/builds/23270
2025-12-17 10:52:43 -08:00
Maksim Levental
7f1a30ebd2
[mlir][math] Add FP software implementation lowering pass: math-to-apfloat (#171221)
Add APFloat software implementation for `math.fma`, `math.abs`,
`math.isnan`, `math.isfinite`, `math.isinf`, `math.isnormal` for reduced
precision (`fp4*`, `fp6*`, `fp8*`).
2025-12-17 18:37:13 +00:00
Erick Ochoa Lopez
5f15fee8ac
[mlir][amdgpu] Add tensor load store operations (#172686)
Reland https://github.com/llvm/llvm-project/pull/170918

This PR differs from the original one by making the target
materialization more restrictive.
2025-12-17 12:37:27 -05:00
Tomek Kuczyński
77455615a4
[MLIR][GPUToLLVMSPV] Use global & local memory scope for GPUBarrierConversion (#169026)
The MLIR [GPU dialect
docs](https://mlir.llvm.org/docs/Dialects/GPU/#gpubarrier-gpubarrierop)
specify that gpu::BarrierOp should make *all memory accesses* visible to
all work items in the workgroup.
Current implementation uses only CLK_LOCAL_MEM_FENCE, which per the
[OpenCL
specification](https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/barrier.html)
guarantees visibility of
only *local memory accesses*.

This PR changes the barrier conversion to use CLK_LOCAL_MEM_FENCE |
CLK_GLOBAL_MEM_FENCE,
ensuring both local and global memory operations are properly
synchronized per the MLIR spec.

This issue was discovered while investigating numerical instabilities on
Intel Battlemage,
where race conditions occurred due to incomplete memory synchronization.
2025-12-17 10:28:57 -05:00
Erick Ochoa Lopez
b9d6ad9ce9
Revert "[mlir][amdgpu] Add tensor load store operations (#170918)" (#172671)
This reverts commit ecbb44464a3a5fad090be8c19632b9046f8eb109. Broke ROCM
integration tests. Will reland in future commit.
2025-12-17 15:06:22 +00:00
Vadim Curcă
47fc3992ba
[MLIR] Extend the extractvalue fold method (#172297)
Extend the `extractvalue` fold method to support extracting from
constant containers, such as `llvm.mlir.zero`, `llvm.mlir.undef`,
`llvm.mlir.poison`, and `llvm.mlir.constant` holding `ElementsAttr` or
`ArrayAttr`.
2025-12-17 15:04:00 +01:00
Ivan Butygin
c7af990cb7
Reland [mlir][gpu] Use SmallString, FailureOr and StringRef in module-to-binary infra (NFC) (#172390)
Reland https://github.com/llvm/llvm-project/pull/172284

`MCAsmParser` expects buffer to be null terminated, had to use
`getMemBufferCopy` which is unfortunate.
2025-12-17 16:42:54 +03:00
Arun Thangamani
8390909842
[mlir][x86vector] Lower BF16 vector.contract to FMA using AVX2 BF16 packed ops. (#170267)
A `transform` pass to lower `BF16` type `vector.contract` to
`vector.fma` using `AVX2` BF16 packed operations:

- `vbcstnebf162ps` - Broadcasts BF16 into packed F32.
- `vcvtneebf162ps` - Convert packed BF16 even-indexed elements into
packed F32.
- `vcvtneobf162ps` - Convert packed BF16 odd-indexed elements into
packed F32 Data.
2025-12-17 14:41:58 +01:00
Mehdi Amini
f719e11cc1 [MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in SparseTensorDialect.cpp (NFC) 2025-12-17 05:30:01 -08:00
Mehdi Amini
9cae8ec551 [MLIR] Apply clang-tidy fixes for bugprone-argument-comment in SparseTensorDescriptor.cpp (NFC) 2025-12-17 05:30:01 -08:00
Mehdi Amini
8cc9c690eb [MLIR] Fix clang-tidy fixes for llvm-prefer-isa-or-dyn-cast-in-conditionals in AMDGPUToROCDL.cpp (NFC)
The cast can't fail, the `if` checks are spurious.
2025-12-17 05:30:01 -08:00
Ivan Butygin
ce553ab69f
Revert "[mlir][amdgpu] Expose waitcnt bitpacking infra (#172313)" (#172636)
This reverts commit 93013817afabe23a07073528481856b3507b6faf.

Revert https://github.com/llvm/llvm-project/pull/172313

Missing libraries, again
2025-12-17 12:13:44 +00:00
Ivan Butygin
93013817af
[mlir][amdgpu] Expose waitcnt bitpacking infra (#172313)
So we can get rid of our copy in `AMDGPUToROCDL`.
2025-12-17 14:32:30 +03:00
Petr Kurapov
dfe84fbe93
[MLIR][NFC] Fix the pass description to describe what it actually does. (#172306) 2025-12-17 12:27:08 +01:00
Artem Kroviakov
a6f837e9f8
[MLIR][XeGPU] Add sg layout propagation (#170879) 2025-12-17 11:03:21 +01:00
Durgadoss R
9d76b2cfce
[MLIR][NVVM] Fix the lowering of legacy mbar.arrive (#172476)
We have the most basic mbarrier.arrive supported on sm_80.
It supports: Space=cta, scope=cta, No relaxed, No explicit count.

This patch updates the lowering to the legacy intrinsic when all
these conditions are met, addressing a lowering issue for sm_80.

Signed-off-by: Durgadoss R <durgadossr@nvidia.com>
2025-12-17 10:05:29 +05:30
Jianhui Li
492340aeb1
[MLIR][XeGPU] Add handling for unit-dim expansion in ShapeCast workgroup-to-subgroup distribution (#171758)
Add special-case handling for ShapeCast when it expands unit dimensions
for a succeeding broadcast op. In this scenario, distribution requires
the source layout to be a slice layout, and the result layout is first
normalized by setting the expanded unit dimensions to 1 before computing
the distributed result shape. In all other cases, ShapeCast is
distributed as usual.

This PR also updates the propagation rule for vectors with expanded unit
dimensions, allowing them to share the same layout as the result of a
broadcast op. This enables correct layout propagation back to the source
of the ShapeCast op, as that layout must ultimately be restored as the
parent layout of the slice layout.
2025-12-16 13:13:11 -08:00
Ravil Dorozhinskii
0729a74e66
[ROCDL] Added s_wakeup_barrier (GFX1250) (#172320)
This PR adds `s_wakeup_barrier` op for GFX1250. Additionally,
refactoring of the split/named barriers regarding the types in asm was
performed.
2025-12-16 19:02:03 +01:00
Artem Kroviakov
aba8ebbda0
[MLIR][Vector] Add distribution pattern for vector::ConstantMaskOp (#172268) 2025-12-16 17:24:13 +01:00
Matthias Springer
78711b66bd
[mlir][Transforms] Legalize nested operations (#172158)
This commit align the implementation of
`ConversionPatternRewriter::legalize` with its documentation:

```
  /// Attempt to legalize the given region. This can be used within
  ...
  LogicalResult legalize(Region *r);
```

This function now legalizes the entire region, including nested ops. The
implementation follows the same logic as the "main" traversal:
pre-order, forward-dominance.
2025-12-16 16:47:47 +01:00
Erick Ochoa Lopez
ecbb44464a
[mlir][amdgpu] Add tensor load store operations (#170918)
* removes unused code.
* lowers tensor load and store operations.
2025-12-16 09:09:28 -05:00
Tim Gymnich
16f41cb1b8
[mlir][amdgpu] Add Python bindings for TDM types (#172309)
Add bindings for:
- `TDMBaseType`
- `TDMDescriptorType`
- `TDMGatherBaseType`
2025-12-16 10:43:08 +00:00
Maya Amrami
44735e1082
[mlir] Clean up leftovers from moving linalg::Expand/CollapseShapeOp to memref dialect (#172448) 2025-12-16 12:14:45 +02:00
Vitalii Shutov
a08a55cab9
[mlir][tosa] Extend narrowing pass (#170712)
- unify the i64->i32 and f64->f32 narrowing logic inside the shared
implementation
- register tosa::ConstOp in the non-aggressive rewrite set so standalone
constants are narrowed

---------

Signed-off-by: Vitalii Shutov <vitalii.shutov@arm.com>
Co-authored-by: Luke Hutton <Luke.Hutton@arm.com>
2025-12-16 10:11:13 +00:00
Ivan Butygin
4c7d765d05
Revert "[mlir][gpu] Use SmallString, FailureOr and StringRef in module-to-binary infra (NFC) (#172284)" (#172386)
This reverts commit c8b8b2f1f9ced8db1458dfdf1ea6a15152c695f0.

broke the bot
2025-12-16 00:06:33 +00:00
Justin Rosner
3a88bb90bb
[mlir][AMDGPU] Add scaled wmma ops for gfx1250 (#169854)
This PR adds scaled WMMA ops (available on gfx1250) and the lowering to the AMDGPU dialect, wrapping the underlying intrinsics.
2025-12-15 15:44:36 -08:00
Ivan Butygin
c8b8b2f1f9
[mlir][gpu] Use SmallString, FailureOr and StringRef in module-to-binary infra (NFC) (#172284)
Instead of `std::string`, `std::optional` and `const std::string&`.
2025-12-16 02:43:08 +03:00
Luke Hutton
3c31c84bca
[mlir][tosa] Allow dynamic dims in --tosa-validate pass (#171463)
This commit allows tensor dimensions to be dynamic when the specified
target TOSA specification version is `1.1.draft` or higher. This is
because this version of the specification supports representation
operations that are dynamic until backend compile time.
2025-12-15 20:15:08 +00:00