[Mlir-commits] [mlir] [MLIR][XeGPU][XeVM] create_nd_tdesc: use correct pitch from strides. (PR #170384)

Sang Ik Lee llvmlistbot at llvm.org
Wed Dec 3 11:56:15 PST 2025


================
@@ -179,11 +178,10 @@ class CreateNdDescToXeVMPattern
     Value baseAddr;
     Value baseShapeW;
     Value baseShapeH;
-    Value offsetW;
-    Value offsetH;
 
     // Source can be a memref or a pointer (ui64, ui32, i64 or i32).
     SmallVector<OpFoldResult> mixedSizes = op.getMixedSizes();
+    SmallVector<OpFoldResult> mixedStrides = op.getMixedStrides();
----------------
silee2 wrote:

Even if ranked dynamic memref triggers ExtractStrideMetadataOp, lowering will clean up and allow direct access to relevant fields from lowered and decomposed memref.
See
```
(python-3.9) jovyan at jupyter-silee2:~/Projects/llvm-project [main|⚑ 29]$ cat strided.mlir
module {
  func.func @test(%arg0: memref<?x?xf32>) -> (index) {
    %base, %offset, %sizes:2, %strides:2 =
      memref.extract_strided_metadata %arg0 : memref<?x?xf32>
        -> memref<f32>, index, index, index, index, index
        return %strides#0 : index
  }
}
(python-3.9) jovyan at jupyter-silee2:~/Projects/llvm-project [main|⚑ 29]$ ./build/bin/mlir-opt --convert-to-llvm -canonicalize strided.mlir
module {
  llvm.func @test(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64) -> i64 {
    llvm.return %arg5 : i64
  }
}
```

You can see that stride is forwarded directly from kernel arg, which is lowered and unpacked from memref.

https://github.com/llvm/llvm-project/pull/170384


More information about the Mlir-commits mailing list