Skip to content

Commit 4b28638

Browse files
committed
Fix multiple memory leaks in mlir-cpu-runner tests (NFC)
1 parent fe48ecb commit 4b28638

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

mlir/test/mlir-cpu-runner/copy.mlir

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ func @main() -> () {
4949
%copy_empty = memref.alloc() : memref<3x0x1xf32>
5050
// Copying an empty shape should do nothing (and should not crash).
5151
memref.copy %input_empty, %copy_empty : memref<3x0x1xf32> to memref<3x0x1xf32>
52-
52+
memref.dealloc %copy_empty : memref<3x0x1xf32>
53+
memref.dealloc %input_empty : memref<3x0x1xf32>
54+
memref.dealloc %copy_two : memref<3x2xf32>
55+
memref.dealloc %copy : memref<2x3xf32>
56+
memref.dealloc %input : memref<2x3xf32>
5357
return
5458
}

mlir/test/mlir-cpu-runner/memref_reinterpret_cast.mlir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func @main() -> () {
3131
call @cast_ranked_memref_to_dynamic_shape(%input) : (memref<2x3xf32>) -> ()
3232
call @cast_unranked_memref_to_static_shape(%input) : (memref<2x3xf32>) -> ()
3333
call @cast_unranked_memref_to_dynamic_shape(%input) : (memref<2x3xf32>) -> ()
34+
memref.dealloc %input : memref<2x3xf32>
3435
return
3536
}
3637

mlir/test/mlir-cpu-runner/memref_reshape.mlir

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func @main() -> () {
4343
: (memref<2x3xf32>, memref<2xindex>) -> ()
4444
call @reshape_unranked_memref_to_unranked(%input, %shape)
4545
: (memref<2x3xf32>, memref<2xindex>) -> ()
46+
memref.dealloc %input : memref<2x3xf32>
47+
memref.dealloc %shape : memref<2xindex>
4648
return
4749
}
4850

mlir/test/mlir-cpu-runner/unranked_memref.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func @main() -> () {
6969
%U4 = memref.cast %I8 : memref<i8> to memref<*xi8>
7070
call @print_memref_i8(%U4) : (memref<*xi8>) -> ()
7171

72+
memref.dealloc %U4 : memref<*xi8>
7273
memref.dealloc %A : memref<10x3xf32, 0>
7374

7475
call @return_var_memref_caller() : () -> ()
@@ -113,7 +114,7 @@ func private @printU64(index) -> ()
113114
func private @printNewline() -> ()
114115

115116
func @dim_op_of_unranked() {
116-
%ranked = memref.alloc() : memref<4x3xf32>
117+
%ranked = memref.alloca() : memref<4x3xf32>
117118
%unranked = memref.cast %ranked: memref<4x3xf32> to memref<*xf32>
118119

119120
%c0 = constant 0 : index

0 commit comments

Comments
 (0)