[Mlir-commits] [mlir] [MLIR][Vector] Implement memory effect for print (PR #80400)
lorenzo chelini
llvmlistbot at llvm.org
Fri Feb 2 00:12:17 PST 2024
https://github.com/chelini updated https://github.com/llvm/llvm-project/pull/80400
>From ac66fd7a5261d83209ec274345aa06d21e9d5c9b Mon Sep 17 00:00:00 2001
From: Lorenzo Chelini <l.chelini at icloud.com>
Date: Fri, 26 Jan 2024 21:53:41 +0100
Subject: [PATCH 1/2] [MLIR][Vector] Implement memory effects for print
Add write memory effect for the print operation. The exact memory
behavior is implemented in other print-like operations such as
`transform::PrintOp` or `gpu::printf`.
Providing memory behavior allows using the operation in passes like
buffer deallocation instead of emitting an error.
---
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 1 +
.../OwnershipBasedBufferDeallocation/dealloc-other.mlir | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index fdf51f0173511..bc08f8d07fb0d 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -2497,6 +2497,7 @@ def Vector_TransposeOp :
def Vector_PrintOp :
Vector_Op<"print", [
+ MemoryEffects<[MemWrite]>,
PredOpTrait<
"`source` or `punctuation` are not set when printing strings",
CPred<"!getStringLiteral() || (!getSource() && getPunctuation() == PrintPunctuation::NewLine)">
diff --git a/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir b/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
index 9bfa91589482b..4fae622c510a2 100644
--- a/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
+++ b/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
@@ -38,3 +38,12 @@ func.func @no_side_effects() {
"test.unregistered_op_foo"(%0) : (memref<5xf32>) -> ()
return
}
+
+// -----
+
+// Buffer deallocation should not emit any error here as the operation does not
+// operate on buffer and has known memory effect (write).
+func.func @no_buffer_semantics_with_write_effect(%v0: vector<9x6xf32>) {
+ vector.print %v0 : vector<9x6xf32>
+ return
+}
>From 726c34f4f8dd000cb4e908619f78252755619ee6 Mon Sep 17 00:00:00 2001
From: Lorenzo Chelini <l.chelini at icloud.com>
Date: Fri, 2 Feb 2024 09:12:00 +0100
Subject: [PATCH 2/2] typo
---
.../OwnershipBasedBufferDeallocation/dealloc-other.mlir | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir b/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
index 4fae622c510a2..5293977fe733f 100644
--- a/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
+++ b/mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
@@ -42,7 +42,7 @@ func.func @no_side_effects() {
// -----
// Buffer deallocation should not emit any error here as the operation does not
-// operate on buffer and has known memory effect (write).
+// operate on buffers and has known memory effect (write).
func.func @no_buffer_semantics_with_write_effect(%v0: vector<9x6xf32>) {
vector.print %v0 : vector<9x6xf32>
return
More information about the Mlir-commits
mailing list