[Mlir-commits] [mlir] [mlir][memref]: Fix Bug in GlobalOp Verifier (PR #144900)

Jack Frankland llvmlistbot at llvm.org
Tue Jun 24 07:10:49 PDT 2025


================
@@ -59,7 +59,8 @@ LogicalResult mlir::memref::foldMemRefCast(Operation *op, Value inner) {
 /// type.
 Type mlir::memref::getTensorTypeFromMemRefType(Type type) {
   if (auto memref = llvm::dyn_cast<MemRefType>(type))
-    return RankedTensorType::get(memref.getShape(), memref.getElementType());
+    return RankedTensorType::get(memref.getShape(), memref.getElementType(),
+                                 memref.getMemorySpace());
----------------
FranklandJack wrote:

Yes agreed this feels a bit odd so input on the best way forward very much appreciated here :D

Ultimately there is a question here about whether the encoding/address space of a tensor/memref needs to match its initializer. In the case of TOSA the answer is no (at least that isn’t something the `tosa.const` verifier checks), in the case of `arith.const` the answer seems to be yes, the operation inherits from an interface that requires they be the same.

For bufferization it seems like we should allow differences between the address space of the memref and the encoding of the tensor that initializes a global memref op since you may want to convert the memref’s address space like we do for spirv and we shouldn’t need to go back and update the initializer so that when the verifier does the type check they match.


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


More information about the Mlir-commits mailing list