[Mlir-commits] [mlir] [mlir][bufferization] Support custom types (1/N) (PR #142986)
Matthias Springer
llvmlistbot at llvm.org
Wed Jun 18 00:26:38 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("
+ "$_op, $" # tensor # ", $" # buffer #")"
+ >
+>;
+
def Bufferization_ToTensorOp : Bufferization_Op<"to_tensor", [
BufferizableOpInterface,
SameOperandsAndResultShape,
SameOperandsAndResultElementType,
- AllElementTypesMatch<["memref", "result"]>
+ Bufferization_TensorAndBufferMatch<"result", "buffer">
]> {
- let summary = "create a tensor from a `memref`";
+ let summary = "create a buffer-like type from a tensor-like type";
let description = [{
- An operation that creates a tensor from a `memref`. The result value is a
- tensor whose shape and element type match the memref operand.
+ An operation that creates a tensor from a buffer. The result value is a
+ tensor-like type whose shape and element type match the buffer-like operand.
----------------
matthias-springer wrote:
Mention in the documentation that operand and result types must be compatible as per `TensorLikeTypeInterface::verifyCompatibleBufferType`.
https://github.com/llvm/llvm-project/pull/142986
More information about the Mlir-commits
mailing list