I’m sorry for posting here, I still am quite bad with the bug tracking tool.
Consider the following function:
#args2 = { indexing_maps = [#map0,#map0],
iterator_types = ["parallel"] }
func @condBranc(%arg0: i1, %arg1: tensor<?xf32>)-> (tensor<?xf32>) {
cond_br %arg0, ^bb1, ^bb2
^bb1:
br ^bb3(%arg1 : tensor<?xf32>)
^bb2:
%arg2 = linalg.generic #args2 ins(%arg1:tensor<?xf32>) {
^bb0(%gen1_arg0: f32):
%tmp1 = exp %gen1_arg0 : f32
linalg.yield %tmp1 : f32
} -> tensor<?xf32>
br ^bb3(%arg2 : tensor<?xf32>)
^bb3(%1: tensor<?xf32>):
return %1:tensor<?xf32>
}
The output of mlir-opt --linalg-bufferize --buffer-deallocation --func-bufferize
is:
func @condBranc(%arg0: i1, %arg1: memref<?xf32>) -> memref<?xf32> {
cond_br %arg0, ^bb1, ^bb2
^bb1: // pred: ^bb0
br ^bb3(%arg1 : memref<?xf32>)
^bb2: // pred: ^bb0
%c0 = constant 0 : index
%0 = dim %arg1, %c0 : memref<?xf32>
%c0_0 = constant 0 : index
%c1 = constant 1 : index
%1 = alloc(%0) : memref<?xf32>
linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel"]} ins(%arg1 : memref<?xf32>) outs(%1 : memref<?xf32>) {
^bb0(%arg2: f32, %arg3: f32): // no predecessors
%3 = exp %arg2 : f32
linalg.yield %3 : f32
}
dealloc %arg1 : memref<?xf32>
dealloc %1 : memref<?xf32>
br ^bb3(%1 : memref<?xf32>)
^bb3(%2: memref<?xf32>): // 2 preds: ^bb1, ^bb2
return %2 : memref<?xf32>
}
This code is certainly not good because it deallocates the function argument %arg1.
The bad effect seems to disappear if the last two options to mlir-opt are reversed.
Dumitru