[Mlir-commits] [mlir] [mlir][bufferization] Support custom types (1/N) (PR #142986)

Andrei Golubev llvmlistbot at llvm.org
Mon Jun 16 05:43:16 PDT 2025


================
@@ -387,20 +388,28 @@ def Bufferization_DeallocTensorOp : Bufferization_Op<"dealloc_tensor",
 // ToTensorOp
 //===----------------------------------------------------------------------===//
 
+class Bufferization_TensorAndBufferMatch<string tensor, string buffer> : PredOpTrait<
+  "specified tensor and buffer types match",
+  CPred<
+    "::mlir::bufferization::detail::typesMatchAfterBufferization("
----------------
andrey-golubev wrote:

@matthias-springer this would be the other problematic place. With the current approach, we want to validate that bufferization is "valid" on a tensor <-> buffer level.

The current logic checks `tensor.getShape() == buffer.getShape()` and `tensor.getElementType() == buffer.getElementType()` this practically means that TensorLike and BufferLike are ShapedType (fine by me), but even that is not enough. We've recently started to experiment with shape bounds and dynamic shapes -> getShape checking might not be sufficient.

Instead, I think we should either restore the old comparison logic (which was changed in https://github.com/llvm/llvm-project/commit/ced2fc7819d5ddea616ec330f18e08ff284c1868) or - more likely - have this put into an interface so that it's a customization point.

But then, which interface? TensorLike? BufferLike? Since it's a type matching function, it's kind of valid to be in both.

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


More information about the Mlir-commits mailing list