Skip to content

Commit 53c4418

Browse files
[mlir][linalg, tosa] Fix memory leaks in integration tests (#85366)
Buffers are no longer deallocation by One-Shot Bufferize. This is now done by a separate buffer deallocation pass. Also fix a bug in the `vector.mask` folding, which was triggered by `-buffer-deallocation-pipeline`, which runs the canonicalizer.
1 parent 513cdb8 commit 53c4418

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

mlir/lib/Dialect/Vector/IR/VectorOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6064,7 +6064,7 @@ LogicalResult MaskOp::fold(FoldAdaptor adaptor,
60646064
maskableOp->dropAllUses();
60656065
maskableOp->moveBefore(getOperation());
60666066

6067-
results.push_back(maskableOp->getResult(0));
6067+
llvm::append_range(results, maskableOp->getResults());
60686068
return success();
60696069
}
60706070

mlir/test/Dialect/Vector/canonicalize.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,18 @@ func.func @all_true_vector_mask(%a : vector<3x4xf32>) -> vector<3x4xf32> {
24832483

24842484
// -----
24852485

2486+
// CHECK-LABEL: func @all_true_vector_mask_no_result(
2487+
func.func @all_true_vector_mask_no_result(%a : vector<3x4xf32>, %m : memref<3x4xf32>) {
2488+
// CHECK-NOT: vector.mask
2489+
// CHECK: vector.transfer_write
2490+
%c0 = arith.constant 0 : index
2491+
%all_true = vector.constant_mask [3, 4] : vector<3x4xi1>
2492+
vector.mask %all_true { vector.transfer_write %a, %m[%c0, %c0] : vector<3x4xf32>, memref<3x4xf32> } : vector<3x4xi1>
2493+
return
2494+
}
2495+
2496+
// -----
2497+
24862498
// CHECK-LABEL: func.func @fold_shape_cast_with_mask(
24872499
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x?xf32>) -> vector<1x4xi1> {
24882500
func.func @fold_shape_cast_with_mask(%arg0: tensor<1x?xf32>) -> vector<1x4xi1> {

mlir/test/Integration/Dialect/Linalg/CPU/mmt4d.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// DEFINE: %{compile} = mlir-opt %s \
22
// DEFINE: -transform-interpreter -test-transform-dialect-erase-schedule \
3-
// DEFINE: -one-shot-bufferize -func-bufferize -cse -canonicalize -convert-vector-to-scf -test-lower-to-llvm -o %t
3+
// DEFINE: -one-shot-bufferize="bufferize-function-boundaries" -buffer-deallocation-pipeline -cse -canonicalize -convert-vector-to-scf -test-lower-to-llvm -o %t
44
// DEFINE: %{entry_point} = mmt4d
55
// DEFINE: %{run} = mlir-cpu-runner %t -e %{entry_point} -entry-point-result=void \
66
// DEFINE: -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils

mlir/test/Integration/Dialect/Linalg/CPU/test-matmul-masked-vec.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule -one-shot-bufferize -func-bufferize -lower-vector-mask --test-lower-to-llvm | \
1+
// RUN: mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule -one-shot-bufferize="bufferize-function-boundaries" -buffer-deallocation-pipeline -lower-vector-mask --test-lower-to-llvm | \
22
// RUN: mlir-cpu-runner -e main -entry-point-result=void --shared-libs=%mlir_c_runner_utils,%mlir_runner_utils | \
33
// RUN: FileCheck %s
44

mlir/test/Integration/Dialect/Tosa/CPU/test-fully-connected.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg,tosa-to-arith))" | \
2-
// RUN: mlir-opt -one-shot-bufferize -func-bufferize -test-lower-to-llvm | \
2+
// RUN: mlir-opt -one-shot-bufferize="bufferize-function-boundaries" -buffer-deallocation-pipeline -test-lower-to-llvm | \
33
// RUN: mlir-cpu-runner -O3 -e main -entry-point-result=void \
44
// RUN: -shared-libs=%mlir_runner_utils \
55
// RUN: | FileCheck %s

0 commit comments

Comments
 (0)