[Mlir-commits] [mlir] 84c8d03 - [MLIR][Vector] Implement memory effect for print (#80400)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Feb 2 02:05:40 PST 2024


Author: lorenzo chelini
Date: 2024-02-02T11:05:35+01:00
New Revision: 84c8d0377de1f7f45e65e85d1f3cc69ca5e29af5

URL: https://github.com/llvm/llvm-project/commit/84c8d0377de1f7f45e65e85d1f3cc69ca5e29af5
DIFF: https://github.com/llvm/llvm-project/commit/84c8d0377de1f7f45e65e85d1f3cc69ca5e29af5.diff

LOG: [MLIR][Vector] Implement memory effect for print (#80400)

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.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
    mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir

Removed: 
    


################################################################################
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..5293977fe733f 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 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