<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/lib/Conversion/VectorToXeGPU, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[mlir][XeGPU] Add optional layout attribute to LoadGather StoreScatter ops (#163414)</title>
<updated>2025-11-04T16:19:47+00:00</updated>
<author>
<name>Dmitry Chigarev</name>
<email>dmitry.chigarev@intel.com</email>
</author>
<published>2025-11-04T16:19:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6c563dc6a2127e3f7dd8e957093e57bd3ba35f5b'/>
<id>6c563dc6a2127e3f7dd8e957093e57bd3ba35f5b</id>
<content type='text'>
As [suggested
here](https://github.com/llvm/llvm-project/pull/163071#discussion_r2427229637)
the PR adds an optional layout attribute for `LoadGather` and
`StoreScatter` ops.

For the load-op the attribute describes the layout of the result (ex
`layout_result_0`), and for store-op it describes the layout for the
vector-to-store operand (ex `layout_operand_0`).

The PR also reworks `propagate-layout` pass to consider perm layout
attributes and back-propagate them accordingly.

The helper utility function `getDistributeLayoutAttr` is reworked to
return either `layout_operand/result_0` or `layout` for load/store ops
(denepding on which one is set). After an offline discussion decided
that the overall utilities layouts API is confusing since it tries to
mix permament and temporary layouts. Would need to change it in the
future.

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As [suggested
here](https://github.com/llvm/llvm-project/pull/163071#discussion_r2427229637)
the PR adds an optional layout attribute for `LoadGather` and
`StoreScatter` ops.

For the load-op the attribute describes the layout of the result (ex
`layout_result_0`), and for store-op it describes the layout for the
vector-to-store operand (ex `layout_operand_0`).

The PR also reworks `propagate-layout` pass to consider perm layout
attributes and back-propagate them accordingly.

The helper utility function `getDistributeLayoutAttr` is reworked to
return either `layout_operand/result_0` or `layout` for load/store ops
(denepding on which one is set). After an offline discussion decided
that the overall utilities layouts API is confusing since it tries to
mix permament and temporary layouts. Would need to change it in the
future.

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][XeGPU][VectorToXeGPU] Lower vector.load/store/transfer_read/transfer_write to new offsets syntax (#162095)</title>
<updated>2025-11-04T12:52:23+00:00</updated>
<author>
<name>Dmitry Chigarev</name>
<email>dmitry.chigarev@intel.com</email>
</author>
<published>2025-11-04T12:52:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=747050bcceca18d32dc1140461984ec2c30ae96a'/>
<id>747050bcceca18d32dc1140461984ec2c30ae96a</id>
<content type='text'>
Changes the `VectorToXeGPU` pass to generate `xegpu.load_nd/store_nd`
ops using new syntax with where offsets are specified at the load/store
ops level.
```mlir
// from this
%desc = xegpu.create_nd_tdesc %src[%off1, %off2]: memref&lt;8x16xf16&gt; -&gt; !xegpu.tensor_desc&lt;8x16xf16&gt;
%res = xegpu.load_nd %desc : !xegpu.tensor_desc&lt;8x16xf16&gt; -&gt; vector&lt;8x16xf16&gt;

// to this
%desc = xegpu.create_nd_tdesc %src: memref&lt;8x16xf16&gt; -&gt; !xegpu.tensor_desc&lt;8x16xf16&gt;
%res = xegpu.load_nd %desc[%off1, %off2] : !xegpu.tensor_desc&lt;8x16xf16&gt; -&gt; vector&lt;8x16xf16&gt;
```

In order to support cases with dimension reduction at the
`create_nd_tdesc` level (e.g. `memref&lt;8x8x16xf16&gt; -&gt;
tensor_desc&lt;8x16xf16&gt;` it was decided to insert a memref.subview that
collapses the source shape to 2d, for example:

```mlir
// input:
%0 = vector.load %source[%off0, %off1, %off2] : memref&lt;8x16x32xf32&gt;, vector&lt;8x16xf32&gt;

// --vector-to-xegpu (old)
%tdesc = xegpu.create_nd_tdesc %source[%off0, %off1, %off2] : memref&lt;8x16x32xf32&gt; -&gt; tdesc&lt;8x32xf32&gt;
%vec = xegpu.load_nd %tdesc

// --vector-to-xegpu (new)
%collapsed = memref.subview %source[%off0, 0, 0] [1, 16, 32] [1, 1, 1] :
    memref&lt;8x16x32xf32&gt; -&gt; memref&lt;16x32xf32, strided&lt;[32, 1], offset: ?&gt;&gt;
%tdesc = xegpu.create_nd_tdesc %collapsed : memref&lt;16x32xf32, ...&gt; -&gt; tdesc&lt;8x32xf32&gt;
%vec = xegpu.load_nd %tdesc[%off1, %off2]
```

&lt;details&gt;&lt;summary&gt;Why we need to change that?&lt;/summary&gt;

```mlir
// reduce dim and apply all 3 offsets at load_nd
%desc = xegpu.create_nd_tdesc %source : memref&lt;8x16x32xf32&gt; -&gt; !xegpu.tensor_desc&lt;16x32xf32&gt;
// error: xegpu.load_nd len(offsets) != desc.rank
%res = xegpu.load_nd %desc[%off, %off, %off] : !xegpu.tensor_desc&lt;16x32xf32&gt; -&gt; vector&lt;8x16xf32&gt;
```

&lt;/details&gt;

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Changes the `VectorToXeGPU` pass to generate `xegpu.load_nd/store_nd`
ops using new syntax with where offsets are specified at the load/store
ops level.
```mlir
// from this
%desc = xegpu.create_nd_tdesc %src[%off1, %off2]: memref&lt;8x16xf16&gt; -&gt; !xegpu.tensor_desc&lt;8x16xf16&gt;
%res = xegpu.load_nd %desc : !xegpu.tensor_desc&lt;8x16xf16&gt; -&gt; vector&lt;8x16xf16&gt;

// to this
%desc = xegpu.create_nd_tdesc %src: memref&lt;8x16xf16&gt; -&gt; !xegpu.tensor_desc&lt;8x16xf16&gt;
%res = xegpu.load_nd %desc[%off1, %off2] : !xegpu.tensor_desc&lt;8x16xf16&gt; -&gt; vector&lt;8x16xf16&gt;
```

In order to support cases with dimension reduction at the
`create_nd_tdesc` level (e.g. `memref&lt;8x8x16xf16&gt; -&gt;
tensor_desc&lt;8x16xf16&gt;` it was decided to insert a memref.subview that
collapses the source shape to 2d, for example:

```mlir
// input:
%0 = vector.load %source[%off0, %off1, %off2] : memref&lt;8x16x32xf32&gt;, vector&lt;8x16xf32&gt;

// --vector-to-xegpu (old)
%tdesc = xegpu.create_nd_tdesc %source[%off0, %off1, %off2] : memref&lt;8x16x32xf32&gt; -&gt; tdesc&lt;8x32xf32&gt;
%vec = xegpu.load_nd %tdesc

// --vector-to-xegpu (new)
%collapsed = memref.subview %source[%off0, 0, 0] [1, 16, 32] [1, 1, 1] :
    memref&lt;8x16x32xf32&gt; -&gt; memref&lt;16x32xf32, strided&lt;[32, 1], offset: ?&gt;&gt;
%tdesc = xegpu.create_nd_tdesc %collapsed : memref&lt;16x32xf32, ...&gt; -&gt; tdesc&lt;8x32xf32&gt;
%vec = xegpu.load_nd %tdesc[%off1, %off2]
```

&lt;details&gt;&lt;summary&gt;Why we need to change that?&lt;/summary&gt;

```mlir
// reduce dim and apply all 3 offsets at load_nd
%desc = xegpu.create_nd_tdesc %source : memref&lt;8x16x32xf32&gt; -&gt; !xegpu.tensor_desc&lt;16x32xf32&gt;
// error: xegpu.load_nd len(offsets) != desc.rank
%res = xegpu.load_nd %desc[%off, %off, %off] : !xegpu.tensor_desc&lt;16x32xf32&gt; -&gt; vector&lt;8x16xf32&gt;
```

&lt;/details&gt;

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Simplify Default cases in type switches. NFC. (#165767)</title>
<updated>2025-10-30T19:10:59+00:00</updated>
<author>
<name>Jakub Kuderski</name>
<email>jakub@nod-labs.com</email>
</author>
<published>2025-10-30T19:10:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ba0be89cd2c08dfff483cbcbdb770dce44031b6c'/>
<id>ba0be89cd2c08dfff483cbcbdb770dce44031b6c</id>
<content type='text'>
Use default values instead of lambdas when possible. `std::nullopt` and
`nullptr` can be used now because of
https://github.com/llvm/llvm-project/pull/165724.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use default values instead of lambdas when possible. `std::nullopt` and
`nullptr` can be used now because of
https://github.com/llvm/llvm-project/pull/165724.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][vector] Simplify rewrite pattern inheriting constructors. NFC. (#161966)</title>
<updated>2025-10-04T19:49:25+00:00</updated>
<author>
<name>Jakub Kuderski</name>
<email>jakub@nod-labs.com</email>
</author>
<published>2025-10-04T19:49:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6ee362e1b5eb52421e0e700074c40ff9e7e0205e'/>
<id>6ee362e1b5eb52421e0e700074c40ff9e7e0205e</id>
<content type='text'>
Use the `Base` type alias from
https://github.com/llvm/llvm-project/pull/158433.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the `Base` type alias from
https://github.com/llvm/llvm-project/pull/158433.</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][XeGPU][VectorToXeGPU] Add lowering from vector.gather/scatter to xegpu.load/store (#158024)</title>
<updated>2025-09-19T09:12:14+00:00</updated>
<author>
<name>Dmitry Chigarev</name>
<email>dmitry.chigarev@intel.com</email>
</author>
<published>2025-09-19T09:12:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c4617bcae1308cf256bbd3738065eba2a4be8eb2'/>
<id>c4617bcae1308cf256bbd3738065eba2a4be8eb2</id>
<content type='text'>
Lowering for `vector.gather`/`vector.scatter` into `xegpu.load`/`xegpu.store`.

High level steps to lower vector.gather/scatter:
```
%0 = vector.gather %source[%off1, %off2, %off3][%indices], %mask,
       %pass_thru : memref&lt;8x16x32xf32&gt;, vector&lt;8xindex&gt;, vector&lt;8xi1&gt;, vector&lt;8xf32&gt; into vector&lt;8xf32&gt;
```

1. Compute strides and a memref offset for the `%source` memref using
`computeMemrefMeta` func from the transfer_read/write lowering
2. Compute a linear offset like `%lin_off = %base_offset + %off1 *
strides#0 + %off2 * strides#1 + %off3 * strides#2`
3. Combine the linear offset with `%indices`: `%off = (broadcast
%lin_off : index to vector&lt;8xindex&gt;) + %indices * strides#2`
4. Convert memref to an i64: `%flat_memref =
memref.extract_aligned_pointer_as_index %source + arith.index_cast`
5. Perform load/store: `%vec = xegpu.load %flat_memref[%off], %mask`
6. Apply selection to propagate values from the pass_thru vector: `%res
= arith.select %mask, %vec, %pass_thru`</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lowering for `vector.gather`/`vector.scatter` into `xegpu.load`/`xegpu.store`.

High level steps to lower vector.gather/scatter:
```
%0 = vector.gather %source[%off1, %off2, %off3][%indices], %mask,
       %pass_thru : memref&lt;8x16x32xf32&gt;, vector&lt;8xindex&gt;, vector&lt;8xi1&gt;, vector&lt;8xf32&gt; into vector&lt;8xf32&gt;
```

1. Compute strides and a memref offset for the `%source` memref using
`computeMemrefMeta` func from the transfer_read/write lowering
2. Compute a linear offset like `%lin_off = %base_offset + %off1 *
strides#0 + %off2 * strides#1 + %off3 * strides#2`
3. Combine the linear offset with `%indices`: `%off = (broadcast
%lin_off : index to vector&lt;8xindex&gt;) + %indices * strides#2`
4. Convert memref to an i64: `%flat_memref =
memref.extract_aligned_pointer_as_index %source + arith.index_cast`
5. Perform load/store: `%vec = xegpu.load %flat_memref[%off], %mask`
6. Apply selection to propagate values from the pass_thru vector: `%res
= arith.select %mask, %vec, %pass_thru`</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][XeGPU][VectorToXeGPU] Fix transfer_read/write cases with non-contiguous memrefs (#158126)</title>
<updated>2025-09-12T01:25:51+00:00</updated>
<author>
<name>Dmitry Chigarev</name>
<email>dmitry.chigarev@intel.com</email>
</author>
<published>2025-09-12T01:25:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=40e85fcaaa04515e511c2a2a8899e46bd6c300ba'/>
<id>40e85fcaaa04515e511c2a2a8899e46bd6c300ba</id>
<content type='text'>
This PR fixes a case where a source memref in
`vector.transfer_read/write` is not contiguous, which violates the
`memref.collapse_shape` semantic that is used in the lowering.

&lt;details&gt;&lt;summary&gt;An example of a failing test&lt;/summary&gt;

```mlir
gpu.module @xevm_module {
gpu.func @load_from_subview(%source: memref&lt;4096x4096xf16&gt;, %off1: index, %off2: index) -&gt; vector&lt;8xf16&gt; {
  %c0 = arith.constant 0.0 : f16
  %subview = memref.subview %source[%off1, %off2] [256, 256] [1, 1] : memref&lt;4096x4096xf16&gt; to memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;
  %0 = vector.transfer_read %subview[%off2, %off2], %c0
    {in_bounds = [true]} : memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;, vector&lt;8xf16&gt;
  gpu.return %0 : vector&lt;8xf16&gt;
}
}
```

Fails with:
```
/home/user/llvm/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir:404:8: error: 'memref.collapse_shape' op invalid source layout map or collapsing non-contiguous dims
  %0 = vector.transfer_read %subview[%off2, %off2], %c0
       ^
/home/user/llvm/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir:404:8: note: see current operation: %8 = "memref.collapse_shape"(%2) &lt;{reassociation = [[0, 1]]}&gt; : (memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;) -&gt; memref&lt;65536xf16&gt;
```

&lt;/details&gt;

A suggestion was to replace `memref.collapse_shape` with
`memref.extract_aligned_pointer_as_index` which is done in this PR.
Since `extract_aligned_pointer` applied to a subview returns an original
pointer without subview offsets, this PR also adds a logic to use an
offset obtained from `memref.extract_strided_metadata` in `baseOffset`
calculation in `computeOffsets`.

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR fixes a case where a source memref in
`vector.transfer_read/write` is not contiguous, which violates the
`memref.collapse_shape` semantic that is used in the lowering.

&lt;details&gt;&lt;summary&gt;An example of a failing test&lt;/summary&gt;

```mlir
gpu.module @xevm_module {
gpu.func @load_from_subview(%source: memref&lt;4096x4096xf16&gt;, %off1: index, %off2: index) -&gt; vector&lt;8xf16&gt; {
  %c0 = arith.constant 0.0 : f16
  %subview = memref.subview %source[%off1, %off2] [256, 256] [1, 1] : memref&lt;4096x4096xf16&gt; to memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;
  %0 = vector.transfer_read %subview[%off2, %off2], %c0
    {in_bounds = [true]} : memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;, vector&lt;8xf16&gt;
  gpu.return %0 : vector&lt;8xf16&gt;
}
}
```

Fails with:
```
/home/user/llvm/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir:404:8: error: 'memref.collapse_shape' op invalid source layout map or collapsing non-contiguous dims
  %0 = vector.transfer_read %subview[%off2, %off2], %c0
       ^
/home/user/llvm/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir:404:8: note: see current operation: %8 = "memref.collapse_shape"(%2) &lt;{reassociation = [[0, 1]]}&gt; : (memref&lt;256x256xf16, strided&lt;[4096, 1], offset: ?&gt;&gt;) -&gt; memref&lt;65536xf16&gt;
```

&lt;/details&gt;

A suggestion was to replace `memref.collapse_shape` with
`memref.extract_aligned_pointer_as_index` which is done in this PR.
Since `extract_aligned_pointer` applied to a subview returns an original
pointer without subview offsets, this PR also adds a logic to use an
offset obtained from `memref.extract_strided_metadata` in `baseOffset`
calculation in `computeOffsets`.

---------

Signed-off-by: dchigarev &lt;dmitry.chigarev@intel.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR][XeGPU] Add lowering from transfer_read/transfer_write to load_gather/store_scatter  (#152429)</title>
<updated>2025-08-14T18:27:07+00:00</updated>
<author>
<name>Jianhui Li</name>
<email>jian.hui.li@intel.com</email>
</author>
<published>2025-08-14T18:27:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=98728d9dc8f38703bc3ebbbf32d45567acaa75cc'/>
<id>98728d9dc8f38703bc3ebbbf32d45567acaa75cc</id>
<content type='text'>
Lowering transfer_read/transfer_write to load_gather/store_scatter in
case the target uArch doesn't support load_nd/store_nd. The high level
steps:
  1. compute Strides;
  2. compute Offsets;
  3. collapseMemrefTo1D;
  4. create Load gather or store_scatter op</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lowering transfer_read/transfer_write to load_gather/store_scatter in
case the target uArch doesn't support load_nd/store_nd. The high level
steps:
  1. compute Strides;
  2. compute Offsets;
  3. collapseMemrefTo1D;
  4. create Load gather or store_scatter op</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][NFC] update `Conversion` create APIs (7/n) (#149889)</title>
<updated>2025-07-22T14:41:06+00:00</updated>
<author>
<name>Maksim Levental</name>
<email>maksim.levental@gmail.com</email>
</author>
<published>2025-07-22T14:41:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=38976a03cd367b27437e0d1e81c0ccaee2777b47'/>
<id>38976a03cd367b27437e0d1e81c0ccaee2777b47</id>
<content type='text'>
See https://github.com/llvm/llvm-project/pull/147168 for more info.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://github.com/llvm/llvm-project/pull/147168 for more info.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][xegpu] Remove vector contract to dpas size restriction (#147470)</title>
<updated>2025-07-09T20:37:06+00:00</updated>
<author>
<name>Adam Siemieniuk</name>
<email>adam.siemieniuk@intel.com</email>
</author>
<published>2025-07-09T20:37:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=06ae0c2a10864e8029ea52b83c46c1839ddb0c1b'/>
<id>06ae0c2a10864e8029ea52b83c46c1839ddb0c1b</id>
<content type='text'>
Removes contraction shape check to allow representing large
workgroup-level workloads in preparation for distribution.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Removes contraction shape check to allow representing large
workgroup-level workloads in preparation for distribution.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir] Remove unused includes (NFC) (#147101)</title>
<updated>2025-07-04T20:30:21+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-07-04T20:30:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fa9adbfda9679250ab753edd9aa908d9ea53be0a'/>
<id>fa9adbfda9679250ab753edd9aa908d9ea53be0a</id>
<content type='text'>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</pre>
</div>
</content>
</entry>
</feed>
