[Mlir-commits] [mlir] [mlir][bufferization] Refine tensor-buffer compatibility checks (PR #167705)
Andrei Golubev
llvmlistbot at llvm.org
Tue Nov 18 00:34:23 PST 2025
================
@@ -569,11 +569,17 @@ TestTensorType::getBufferType(
::mlir::LogicalResult TestTensorType::verifyCompatibleBufferType(
::mlir::bufferization::BufferLikeType bufferType,
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
- auto testMemref = dyn_cast<TestMemrefType>(bufferType);
- if (!testMemref)
- return emitError() << "expected TestMemrefType";
+ if (auto testMemref = dyn_cast<TestMemrefType>(bufferType)) {
+ const bool valid = getShape() == testMemref.getShape() &&
+ getElementType() == testMemref.getElementType();
+ return mlir::success(valid);
+ }
+
+ if (auto builtinMemref = dyn_cast<MemRefType>(bufferType)) {
+ const bool valid = getShape() == builtinMemref.getShape() &&
+ getElementType() == builtinMemref.getElementType();
+ return mlir::success(valid);
+ }
- const bool valid = getShape() == testMemref.getShape() &&
- getElementType() == testMemref.getElementType();
- return mlir::success(valid);
+ return emitError() << "expected MemRefType or TestMemrefType";
----------------
andrey-golubev wrote:
this specifically - not really.
the bulk of the change is for checking for builtin memref and for test memref now (this is what the test above exercises). the emit-error message is changed just to better align with the new logic (so that the message is non-ambiguous in case someone will start writing new tests on top, etc. etc.).
https://github.com/llvm/llvm-project/pull/167705
More information about the Mlir-commits
mailing list