Skip to content

Commit e40d0ef

Browse files
committed
[mlir][bufferization]-add lit test to show where insertion point still fail
1 parent 8087fc0 commit e40d0ef

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,27 @@ func.func @fail_to_eliminate_any_empty_tensors() -> tensor<5x6x128xf32> {
392392

393393
// -----
394394

395+
// CHECK-LABEL: func.func @empty_tensor_destination_with_dynamic_index
396+
func.func @empty_tensor_destination_with_dynamic_index(%arg0: tensor<?xf32>) -> tensor<?x6x128xf32> {
397+
%cst_0 = arith.constant 0 : index
398+
%cst_1 = arith.constant 1.0 : f32
399+
%cst_2 = arith.constant 2.0 : f32
400+
%empty_1 = tensor.empty() : tensor<5x6x64xf32>
401+
%res_1 = linalg.fill ins(%cst_1 : f32) outs(%empty_1 : tensor<5x6x64xf32>) -> tensor<5x6x64xf32>
402+
%empty_2 = tensor.empty() : tensor<5x6x64xf32>
403+
%res_2 = linalg.fill ins(%cst_2 : f32) outs(%empty_2 : tensor<5x6x64xf32>) -> tensor<5x6x64xf32>
404+
%dim = tensor.dim %arg0, %cst_0 : tensor<?xf32>
405+
%cancatenated_empty = tensor.empty(%dim) : tensor<?x6x128xf32>
406+
// CHECK: memref.copy
407+
%inserted_slice_1 = tensor.insert_slice %res_1 into %cancatenated_empty[0, 0, 0][5, 6, 64][1, 1, 1]
408+
: tensor<5x6x64xf32> into tensor<?x6x128xf32>
409+
%inserted_slice_2 = tensor.insert_slice %res_2 into %inserted_slice_1[0, 0, 64][5, 6, 64][1, 1, 1]
410+
: tensor<5x6x64xf32> into tensor<?x6x128xf32>
411+
return %inserted_slice_2 : tensor<?x6x128xf32>
412+
}
413+
414+
// -----
415+
395416
// CHECK-LABEL: func.func @succeed_to_eliminate_one_empty_tensor
396417
func.func @succeed_to_eliminate_one_empty_tensor() -> tensor<5x6x128xf32> {
397418
%cst_1 = arith.constant 1.0 : f32

0 commit comments

Comments
 (0)