[Mlir-commits] [mlir] [MLIR][Vector] Implement memory effect for print (PR #80400)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Feb 2 00:11:11 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-bufferization
Author: lorenzo chelini (chelini)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/80400.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/Vector/IR/VectorOps.td (+1)
- (modified) mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir (+9)
``````````diff
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
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/80400
More information about the Mlir-commits
mailing list