[Mlir-commits] [mlir] [MLIR][XeGPU] Minor fix for proper handling of 0D memrefs (PR #195877)
Andrey Pavlenko
llvmlistbot at llvm.org
Tue May 5 09:38:27 PDT 2026
https://github.com/AndreyPavlenko updated https://github.com/llvm/llvm-project/pull/195877
>From 4747b65bcb467a2df65a8208d0971b812d210fa9 Mon Sep 17 00:00:00 2001
From: Andrey Pavlenko <andrey.a.pavlenko at gmail.com>
Date: Tue, 5 May 2026 16:17:25 +0000
Subject: [PATCH] [MLIR][XeGPU] Minor fix for proper handling of 0D memrefs
It fixes the following case:
vector.transfer_read %arg0[], %0 : memref<f16>, vector<f16>
---
mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp | 7 ++++++-
.../VectorToXeGPU/transfer-read-to-xegpu.mlir | 13 +++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp b/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
index 36e1975017881..61585b6853b6e 100644
--- a/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
+++ b/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
@@ -85,7 +85,12 @@ static LogicalResult transferPreconditions(PatternRewriter &rewriter,
// Validate further transfer op semantics.
SmallVector<int64_t> strides;
int64_t offset;
- if (failed(srcTy.getStridesAndOffset(strides, offset)) || strides.back() != 1)
+ if (failed(srcTy.getStridesAndOffset(strides, offset)))
+ return rewriter.notifyMatchFailure(xferOp,
+ "The memref strides cannot be inferred");
+ if (strides.empty())
+ return rewriter.notifyMatchFailure(xferOp, "0D memref is not supported");
+ if (strides.back() != 1)
return rewriter.notifyMatchFailure(
xferOp, "Buffer must be contiguous in the innermost dimension");
diff --git a/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir b/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
index 7ba576313c6d4..37d1b417a3424 100644
--- a/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
+++ b/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
@@ -613,3 +613,16 @@ gpu.func @load_1D_vector_addrspace3_unsupported(%source: memref<32xf32, 3>,
// LOAD-GATHER: vector.transfer_read
}
+
+// -----
+gpu.module @xevm_module {
+gpu.func @load_0D_memref_unsupported(%source: memref<f16>) -> vector<f16> {
+ %c0 = arith.constant 0.0 : f16
+ %0 = vector.transfer_read %source[], %c0 : memref<f16>, vector<f16>
+ gpu.return %0 : vector<f16>
+}
+
+// CHECK-LABEL: @load_0D_memref_unsupported
+// CHECK: vector.transfer_read
+
+}
More information about the Mlir-commits
mailing list