aboutsummaryrefslogtreecommitdiff
path: root/mlir/test/Examples
diff options
context:
space:
mode:
authorOleksandr "Alex" Zinenko <zinenko@google.com>2023-10-02 16:08:11 +0200
committerGitHub <noreply@github.com>2023-10-02 16:08:11 +0200
commitaab795a8dccbaf2ee199f2de174263ea4bd44e67 (patch)
tree884f0f10f7d4c7697ec347086e0a4810253d2c81 /mlir/test/Examples
parentc95fcd343d405e659190b746052a9fcac573f8ac (diff)
downloadllvm-aab795a8dccbaf2ee199f2de174263ea4bd44e67.zip
llvm-aab795a8dccbaf2ee199f2de174263ea4bd44e67.tar.gz
llvm-aab795a8dccbaf2ee199f2de174263ea4bd44e67.tar.bz2
[mlir] run buffer deallocation in transform tutorial (#67978)
Buffer deallocation pipeline previously was incorrect when applied to functions. It has since been fixed. Make sure it is exercised in the tutorial to avoid leaking allocations.
Diffstat (limited to 'mlir/test/Examples')
-rw-r--r--mlir/test/Examples/transform/ChH/full.mlir13
1 files changed, 13 insertions, 0 deletions
diff --git a/mlir/test/Examples/transform/ChH/full.mlir b/mlir/test/Examples/transform/ChH/full.mlir
index ed0509f..d90d740 100644
--- a/mlir/test/Examples/transform/ChH/full.mlir
+++ b/mlir/test/Examples/transform/ChH/full.mlir
@@ -1,6 +1,7 @@
// RUN: mlir-opt %s --test-transform-dialect-interpreter \
// RUN: --test-transform-dialect-erase-schedule \
// RUN: --math-uplift-to-fma \
+// RUN: --convert-bufferization-to-memref \
// RUN: --test-lower-to-llvm |\
// RUN: FileCheck %s
@@ -307,10 +308,22 @@ module attributes { transform.with_named_sequence } {
// transformation process, so invalidation is not an issue. However, if
// other transformations, such as loop unrolling, are required after
// bufferization, new handles should be produced using the match operations.
+ //
+ // One-shot bufferization itself does not produce buffer deallocations,
+ // which may lead to leaks. So we have to run the buffer deallocation pass
+ // pipeline to avoid them. Note that the transform dialect seamlessly runs
+ // named passes and pass pipelines: if desired, one could replace complex
+ // --pass-pipeline expressions with operations. Note that we apply the
+ // pipeline to functions rather than entire module to avoid running it
+ // on the transform IR that is contained in the module.
%arg1 = transform.bufferization.one_shot_bufferize %arg0 {
bufferize_function_boundaries = true,
function_boundary_type_conversion = 1 : i32 }
: (!transform.any_op) -> !transform.any_op
+ %f = transform.structured.match ops{["func.func"]} in %arg1
+ : (!transform.any_op) -> !transform.any_op
+ transform.apply_registered_pass "buffer-deallocation-pipeline" to %f
+ : (!transform.any_op) -> !transform.any_op
// Apply general canonicalization and CSE to each function after
// bufferization as new simplification opportunities may have appeared.