Skip to content

Commit 7b21f34

Browse files
committed
[mlir][linalg] Move vectorization tests for pad + insert_slice Ops (nfc)
This patch moves vectorization tests for `tensor.pad` and `tensor.insert_slice` into dedicated files under a new subdirectory for the vectorizer. The goal is to better organize the growing set of tests, which are currently difficult to navigate. This change is also a preparatory step for upcoming work: I’ll soon be updating the vectorization logic for `tensor.pad` + `tensor.insert_slice`. With the new structure in place, two things will be clear in follow-up changes: * Only tests related to `tensor.pad` and `tensor.insert_slice` are being updated. * Only the relevant tests will be touched (e.g., when changing mask generation, only tests involving masking will be affected).
1 parent a21986b commit 7b21f34

File tree

6 files changed

+1046
-592
lines changed

6 files changed

+1046
-592
lines changed

mlir/test/Dialect/Linalg/vectorization-with-patterns.mlir

Lines changed: 0 additions & 315 deletions
Original file line numberDiff line numberDiff line change
@@ -889,207 +889,6 @@ module attributes {transform.with_named_sequence} {
889889

890890
// -----
891891

892-
// CHECK-LABEL: func @pad_static(
893-
// CHECK-SAME: %[[ARG0:.*]]: tensor<2x?x2xf32>, %[[PAD:.*]]: f32
894-
// CHECK-NOT: tensor.pad
895-
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
896-
// CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
897-
// CHECK-DAG: %[[INIT:.*]] = tensor.empty() : tensor<2x3x4xf32>
898-
// CHECK-DAG: %[[VEC:.*]] = vector.broadcast %[[PAD]] : f32 to vector<2x3x4xf32>
899-
// CHECK: %[[FILL:.*]] = vector.transfer_write %[[VEC]], %[[INIT]]{{.*}} : vector<2x3x4xf32>, tensor<2x3x4xf32>
900-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]][%[[C0]], %[[C0]], %[[C0]]], %[[PAD]] {in_bounds = [true, false, true]} : tensor<2x?x2xf32>, vector<2x3x2xf32>
901-
// CHECK: %[[RESULT:.*]] = vector.transfer_write %[[READ]], %[[FILL]][%[[C0]], %[[C0]], %[[C2]]] {in_bounds = [true, true, true]} : vector<2x3x2xf32>, tensor<2x3x4xf32>
902-
// CHECK: return %[[RESULT]]
903-
func.func @pad_static(%arg0: tensor<2x?x2xf32>, %pad_value: f32) -> tensor<2x3x4xf32> {
904-
%0 = tensor.pad %arg0 low[0, 0, 2] high[0, 1, 0] {
905-
^bb0(%arg1: index, %arg2: index, %arg3: index):
906-
tensor.yield %pad_value : f32
907-
} : tensor<2x?x2xf32> to tensor<2x3x4xf32>
908-
return %0 : tensor<2x3x4xf32>
909-
}
910-
911-
912-
module attributes {transform.with_named_sequence} {
913-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
914-
%0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
915-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
916-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
917-
transform.yield
918-
}
919-
}
920-
921-
// -----
922-
923-
// CHECK-LABEL: func @pad_static_source(
924-
// CHECK-SAME: %[[ARG0:.*]]: tensor<2x5x2xf32>, %[[PAD:.*]]: f32
925-
// CHECK-NOT: tensor.pad
926-
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
927-
// CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
928-
// CHECK: %[[INIT:.*]] = tensor.empty() : tensor<2x6x4xf32>
929-
// CHECK: %[[VEC:.*]] = vector.broadcast %[[PAD]] : f32 to vector<2x6x4xf32>
930-
// CHECK: %[[FILL:.*]] = vector.transfer_write %[[VEC]], %[[INIT]][%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<2x6x4xf32>, tensor<2x6x4xf32>
931-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]][%[[C0]], %[[C0]], %[[C0]]], %{{.*}} {in_bounds = [true, true, true]} : tensor<2x5x2xf32>, vector<2x5x2xf32>
932-
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[READ]], %[[FILL]][%[[C0]], %[[C0]], %[[C2]]] {in_bounds = [true, true, true]} : vector<2x5x2xf32>, tensor<2x6x4xf32>
933-
// CHECK: return %[[WRITE]]
934-
func.func @pad_static_source(%arg0: tensor<2x5x2xf32>, %pad_value: f32) -> tensor<2x6x4xf32> {
935-
%0 = tensor.pad %arg0 low[0, 0, 2] high[0, 1, 0] {
936-
^bb0(%arg1: index, %arg2: index, %arg3: index):
937-
tensor.yield %pad_value : f32
938-
} : tensor<2x5x2xf32> to tensor<2x6x4xf32>
939-
return %0 : tensor<2x6x4xf32>
940-
}
941-
942-
943-
module attributes {transform.with_named_sequence} {
944-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
945-
%0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
946-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
947-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
948-
transform.yield
949-
}
950-
}
951-
952-
953-
// -----
954-
955-
// CHECK-LABEL: func @pad_static_dynamic(
956-
// CHECK-SAME: %[[SRC:.*]]: tensor<1x2x2x?xf32>, %[[LOW:.*]]: index, %[[HIGH:.*]]: index
957-
// CHECK-NOT: tensor.pad
958-
// CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
959-
// CHECK-DAG: %[[C3:.*]] = arith.constant 3 : index
960-
// CHECK-DAG: %[[C5:.*]] = arith.constant 5 : index
961-
// CHECK: %[[V0:.*]] = arith.addi %[[LOW]], %[[C2]] : index
962-
// CHECK: %[[V1:.*]] = arith.addi %[[V0]], %[[C3]] : index
963-
// CHECK: %[[V2:.*]] = arith.addi %[[HIGH]], %[[C5]] : index
964-
// CHECK: %[[DIM3:.*]] = tensor.dim %[[SRC]], %[[C3]] : tensor<1x2x2x?xf32>
965-
// CHECK: %[[V4:.*]] = arith.addi %[[DIM3]], %[[C3]] : index
966-
// CHECK: %[[V5:.*]] = arith.addi %[[V4]], %[[C2]] : index
967-
// CHECK: %[[INIT:.*]] = tensor.empty(%[[V1]], %[[V2]], %[[V5]]) : tensor<6x?x?x?xf32>
968-
// CHECK: %[[FILL:.*]] = linalg.fill ins(%{{.*}} : f32) outs(%[[INIT]] : tensor<6x?x?x?xf32>) -> tensor<6x?x?x?xf32>
969-
// CHECK: %[[SRCDIM:.*]] = tensor.dim %[[SRC]], %[[C3]] : tensor<1x2x2x?xf32>
970-
// CHECK: %[[RESULT:.*]] = tensor.insert_slice %[[SRC]] into %[[FILL]][2, %[[LOW]], 3, 3] [1, 2, 2, %[[SRCDIM]]] [1, 1, 1, 1] : tensor<1x2x2x?xf32> into tensor<6x?x?x?xf32>
971-
// CHECK: return %[[RESULT]]
972-
func.func @pad_static_dynamic(%arg0: tensor<1x2x2x?xf32>, %low: index, %high: index,
973-
%pad_value: f32) -> tensor<6x?x?x?xf32> {
974-
%0 = tensor.pad %arg0 low[2, %low, 3, 3] high[3, 3, %high, 2] {
975-
^bb0(%arg1: index, %arg2: index, %arg3: index, %arg4: index):
976-
tensor.yield %pad_value : f32
977-
} : tensor<1x2x2x?xf32> to tensor<6x?x?x?xf32>
978-
return %0 : tensor<6x?x?x?xf32>
979-
}
980-
981-
982-
module attributes {transform.with_named_sequence} {
983-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
984-
%0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
985-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
986-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
987-
transform.yield
988-
}
989-
}
990-
991-
// -----
992-
993-
// CHECK-LABEL: func @pad_static_complex(
994-
// CHECK-NOT: vector<
995-
func.func @pad_static_complex(%arg0: tensor<2x5x2xcomplex<f32>>, %pad_value: complex<f32>) -> tensor<2x6x4xcomplex<f32>> {
996-
%0 = tensor.pad %arg0 low[0, 0, 2] high[0, 1, 0] {
997-
^bb0(%arg1: index, %arg2: index, %arg3: index):
998-
tensor.yield %pad_value : complex<f32>
999-
} : tensor<2x5x2xcomplex<f32>> to tensor<2x6x4xcomplex<f32>>
1000-
return %0 : tensor<2x6x4xcomplex<f32>>
1001-
}
1002-
1003-
1004-
module attributes {transform.with_named_sequence} {
1005-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
1006-
%0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
1007-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
1008-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
1009-
transform.yield
1010-
}
1011-
}
1012-
1013-
// -----
1014-
1015-
func.func private @make_vector() -> tensor<12x13xf32>
1016-
1017-
// CHECK-LABEL: func.func @pad_and_insert_slice_dest(
1018-
// CHECK-SAME: %[[ARG_0:.*]]: tensor<1x5x6xf32>) -> tensor<1x12x13xf32> {
1019-
// CHECK: %[[C0:.*]] = arith.constant 0.000000e+00 : f32
1020-
// CHECK: %[[CST:.*]] = arith.constant dense<5.000000e+00> : vector<1x12x13xf32>
1021-
// CHECK: %[[C0_IDX:.*]] = arith.constant 0 : index
1022-
// CHECK: %[[PAD_VAL:.*]] = arith.constant 5.000000e+00 : f32
1023-
// CHECK: %[[EMPTY:.*]] = tensor.empty() : tensor<1x12x13xf32>
1024-
// CHECK: %[[WRITE_1:.*]] = vector.transfer_write %[[CST]], %[[EMPTY]]{{\[}}%[[C0_IDX]], %[[C0_IDX]], %[[C0_IDX]]] {in_bounds = [true, true, true]} : vector<1x12x13xf32>, tensor<1x12x13xf32>
1025-
// CHECK: %[[READ_1:.*]] = vector.transfer_read %[[ARG_0]]{{\[}}%[[C0_IDX]], %[[C0_IDX]], %[[C0_IDX]]], %[[PAD_VAL]] {in_bounds = [true, true, true]} : tensor<1x5x6xf32>, vector<1x5x6xf32>
1026-
// CHECK: %[[WRITE_2:.*]] = vector.transfer_write %[[READ_1]], %[[WRITE_1]]{{\[}}%[[C0_IDX]], %[[C0_IDX]], %[[C0_IDX]]] {in_bounds = [true, true, true]} : vector<1x5x6xf32>, tensor<1x12x13xf32>
1027-
// CHECK: %[[MAKE_VEC:.*]] = call @make_vector() : () -> tensor<12x13xf32>
1028-
// CHECK: %[[READ_2:.*]] = vector.transfer_read %[[MAKE_VEC]]{{\[}}%[[C0_IDX]], %[[C0_IDX]]], %[[C0]] {in_bounds = [true, true]} : tensor<12x13xf32>, vector<12x13xf32>
1029-
// CHECK: %[[RES:.*]] = vector.transfer_write %[[READ_2]], %[[WRITE_2]]{{\[}}%[[C0_IDX]], %[[C0_IDX]], %[[C0_IDX]]] {in_bounds = [true, true]} : vector<12x13xf32>, tensor<1x12x13xf32>
1030-
// CHECK: return %[[RES]] : tensor<1x12x13xf32>
1031-
func.func @pad_and_insert_slice_dest(
1032-
%arg0: tensor<1x5x6xf32>) -> tensor<1x12x13xf32> {
1033-
%c5 = arith.constant 5.0 : f32
1034-
%0 = tensor.pad %arg0 low[0, 0, 0] high[0, 7, 7] {
1035-
^bb0(%arg2: index, %arg3: index, %arg4: index):
1036-
tensor.yield %c5 : f32
1037-
} : tensor<1x5x6xf32> to tensor<1x12x13xf32>
1038-
%1 = call @make_vector() : () -> tensor<12x13xf32>
1039-
%r = tensor.insert_slice %1 into %0[0, 0, 0][1, 12, 13][1, 1, 1] : tensor<12x13xf32> into tensor<1x12x13xf32>
1040-
return %r : tensor<1x12x13xf32>
1041-
}
1042-
1043-
module attributes {transform.with_named_sequence} {
1044-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
1045-
%3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
1046-
%4 = transform.get_parent_op %3 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
1047-
%5 = transform.structured.vectorize_children_and_apply_patterns %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
1048-
transform.yield
1049-
}
1050-
}
1051-
1052-
// -----
1053-
1054-
// CHECK-LABEL: func @pad_tensor_non_const_pad_value
1055-
// CHECK-SAME: %[[ARG0:.*]]: tensor<5x6xf32>
1056-
// CHECK-NOT: tensor.pad
1057-
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
1058-
// CHECK-DAG: %[[C3:.*]] = arith.constant 3 : index
1059-
// CHECK-DAG: %[[C4:.*]] = arith.constant 4 : index
1060-
// CHECK: %[[FILL:.*]] = tensor.generate
1061-
// CHECK: %[[RES:.*]] = arith.mulf
1062-
// CHECK: tensor.yield %[[RES]] : f32
1063-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]][%[[C0]], %[[C0]]], %{{.*}} {in_bounds = [true, true]} : tensor<5x6xf32>, vector<5x6xf32>
1064-
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[READ]], %[[FILL]][%[[C3]], %[[C4]]] {in_bounds = [true, true]} : vector<5x6xf32>, tensor<12x13xf32>
1065-
// CHECK: return %[[WRITE]]
1066-
func.func @pad_tensor_non_const_pad_value(%arg0: tensor<5x6xf32>) -> tensor<12x13xf32> {
1067-
%c0 = arith.constant 0 : index
1068-
%c5 = arith.constant 5.0 : f32
1069-
%0 = tensor.pad %arg0 low[3, 4] high[4, 3] {
1070-
^bb0(%arg1: index, %arg2: index):
1071-
%i1 = arith.index_cast %arg1 : index to i32
1072-
%i2 = arith.index_cast %arg2 : index to i32
1073-
%f1 = arith.sitofp %i1 : i32 to f32
1074-
%f2 = arith.sitofp %i2 : i32 to f32
1075-
%m = arith.mulf %f1, %f2 : f32
1076-
tensor.yield %m : f32
1077-
} : tensor<5x6xf32> to tensor<12x13xf32>
1078-
return %0 : tensor<12x13xf32>
1079-
}
1080-
1081-
1082-
module attributes {transform.with_named_sequence} {
1083-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
1084-
%3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
1085-
%4 = transform.get_parent_op %3 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
1086-
%5 = transform.structured.vectorize_children_and_apply_patterns %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
1087-
transform.yield
1088-
}
1089-
}
1090-
1091-
// -----
1092-
1093892
// CHECK-LABEL: func @sum_exp
1094893
func.func @sum_exp(%input: tensor<4x16x8xf32>, %output: tensor<4x16xf32>)
1095894
-> tensor<4x16xf32>
@@ -1805,29 +1604,6 @@ module attributes {transform.with_named_sequence} {
18051604

18061605
// -----
18071606

1808-
// CHECK-LABEL: func @test_masked_pad_static_dynamic
1809-
func.func @test_masked_pad_static_dynamic(%arg0: tensor<1x2x2x?xf32>, %low: index, %high: index,
1810-
%pad_value: f32) -> tensor<6x?x?x?xf32> {
1811-
// CHECK: tensor.pad
1812-
%0 = tensor.pad %arg0 low[2, %low, 3, 3] high[3, 3, %high, 2] {
1813-
^bb0(%arg1: index, %arg2: index, %arg3: index, %arg4: index):
1814-
tensor.yield %pad_value : f32
1815-
} : tensor<1x2x2x?xf32> to tensor<6x?x?x?xf32>
1816-
return %0 : tensor<6x?x?x?xf32>
1817-
}
1818-
1819-
1820-
module attributes {transform.with_named_sequence} {
1821-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
1822-
%0 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
1823-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
1824-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
1825-
transform.yield
1826-
}
1827-
}
1828-
1829-
// -----
1830-
18311607
func.func @zero_dim_tensor(%input: tensor<f32>, %output: tensor<f32>) -> tensor<f32>
18321608
{
18331609
%0 = linalg.generic { indexing_maps = [ affine_map<() -> ()>, affine_map<() -> ()> ],
@@ -2001,94 +1777,3 @@ module attributes {transform.with_named_sequence} {
20011777
transform.yield
20021778
}
20031779
}
2004-
2005-
// -----
2006-
2007-
///----------------------------------------------------------------------------------------
2008-
/// tensor.insert_slice
2009-
///----------------------------------------------------------------------------------------
2010-
2011-
// The pad value for xfer-read is neither needed nor available - use the default (0.0).
2012-
2013-
// CHECK-LABEL: func @insert_static_slice_default_pad
2014-
// CHECK-SAME: %[[ARG_0:.*]]: tensor<1x2x3xf32>,
2015-
// CHECK-SAME: %[[ARG_1:.*]]: tensor<9x8x7x1x2x3xf32>) -> tensor<9x8x7x1x2x3xf32> {
2016-
// CHECK: %[[PAD:.*]] = arith.constant 0.000000e+00 : f32
2017-
// CHECK: %[[C0:.*]] = arith.constant 0 : index
2018-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG_0]]{{\[}}%[[C0]], %[[C0]], %[[C0]]], %[[PAD]] {in_bounds = [true, true, true]} : tensor<1x2x3xf32>, vector<1x2x3xf32>
2019-
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[READ]], %[[ARG_1]]{{\[}}%[[C0]], %[[C0]], %[[C0]], %[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
2020-
// CHECK: return %[[WRITE]] : tensor<9x8x7x1x2x3xf32>
2021-
func.func @insert_static_slice_default_pad(%arg0: tensor<1x2x3xf32>, %arg1: tensor<9x8x7x1x2x3xf32>) -> tensor<9x8x7x1x2x3xf32> {
2022-
%res = tensor.insert_slice %arg0 into %arg1[0, 0, 0, 0, 0, 0] [1, 1, 1, 1, 2, 3][1, 1, 1, 1, 1, 1] : tensor<1x2x3xf32> into tensor<9x8x7x1x2x3xf32>
2023-
return %res : tensor<9x8x7x1x2x3xf32>
2024-
}
2025-
2026-
module attributes {transform.with_named_sequence} {
2027-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
2028-
%0 = transform.structured.match ops{["tensor.insert_slice"]} in %arg1 : (!transform.any_op) -> !transform.any_op
2029-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
2030-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
2031-
transform.yield
2032-
}
2033-
}
2034-
2035-
// -----
2036-
2037-
// Same as above, but there's a pad value available that should be used instead of the default value.
2038-
2039-
// CHECK-LABEL: func.func @insert_static_slice_non_zero_pad
2040-
// CHECK-SAME: %[[ARG_0:.*]]: tensor<1x2x3xf32>,
2041-
// CHECK-SAME: %[[PAD:.*]]: f32) -> tensor<9x8x7x1x2x3xf32> {
2042-
// CHECK: %[[EMPTY:.*]] = tensor.empty() : tensor<9x8x7x1x2x3xf32>
2043-
// CHECK: %[[BC:.*]] = vector.broadcast %[[PAD]] : f32 to vector<9x8x7x1x2x3xf32>
2044-
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[BC]], %[[EMPTY]]{{.*}} {in_bounds = [true, true, true, true, true, true]} : vector<9x8x7x1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
2045-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG_0]]{{.*}}, %[[PAD]] {in_bounds = [true, true, true]} : tensor<1x2x3xf32>, vector<1x2x3xf32>
2046-
// CHECK: %[[RES:.*]] = vector.transfer_write %[[READ]], %[[WRITE]]{{.*}} {in_bounds = [true, true, true]} : vector<1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
2047-
// CHECK: return %[[RES]] : tensor<9x8x7x1x2x3xf32>
2048-
func.func @insert_static_slice_non_zero_pad(%arg0: tensor<1x2x3xf32>, %pad : f32) -> tensor<9x8x7x1x2x3xf32> {
2049-
%init = tensor.empty() : tensor<9x8x7x1x2x3xf32>
2050-
%fill = linalg.fill ins(%pad : f32) outs(%init : tensor<9x8x7x1x2x3xf32>) -> tensor<9x8x7x1x2x3xf32>
2051-
%res = tensor.insert_slice %arg0 into %fill[0, 0, 0, 0, 0, 0] [1, 1, 1, 1, 2, 3][1, 1, 1, 1, 1, 1] : tensor<1x2x3xf32> into tensor<9x8x7x1x2x3xf32>
2052-
return %res : tensor<9x8x7x1x2x3xf32>
2053-
}
2054-
2055-
module attributes {transform.with_named_sequence} {
2056-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
2057-
%0 = transform.structured.match ops{["tensor.insert_slice"]} in %arg1 : (!transform.any_op) -> !transform.any_op
2058-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
2059-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 : (!transform.any_op) -> !transform.any_op
2060-
transform.yield
2061-
}
2062-
}
2063-
2064-
// -----
2065-
2066-
// Same as above, but the source type has is dynamically shaped. This means
2067-
// that the pad value is now required and the vector dim corresponding to the
2068-
// dynamic shape has to be inferred from the shape of the destination tensor.
2069-
2070-
// CHECK-LABEL: func.func @insert_dynamic_slice_non_zero_pad(
2071-
// CHECK-SAME: %[[ARG_0:.*]]: tensor<1x?x3xf32>,
2072-
// CHECK-SAME: %[[PAD:.*]]: f32,
2073-
// CHECK-SAME: %[[SIZE:.*]]: index) -> tensor<9x8x7x1x2x3xf32> {
2074-
// CHECK: %[[EMPTY:.*]] = tensor.empty() : tensor<9x8x7x1x2x3xf32>
2075-
// CHECK: %[[BC:.*]] = vector.broadcast %[[PAD]] : f32 to vector<9x8x7x1x2x3xf32>
2076-
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[BC]], %[[EMPTY]]{{.*}} {in_bounds = [true, true, true, true, true, true]} : vector<9x8x7x1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
2077-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG_0]]{{.*}}, %[[PAD]] {in_bounds = [true, false, true]} : tensor<1x?x3xf32>, vector<1x2x3xf32>
2078-
// CHECK: %[[RES:.*]] = vector.transfer_write %[[READ]], %[[WRITE]]{{.*}} {in_bounds = [true, true, true]} : vector<1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
2079-
// CHECK: return %[[RES]] : tensor<9x8x7x1x2x3xf32>
2080-
func.func @insert_dynamic_slice_non_zero_pad(%arg0: tensor<1x?x3xf32>, %pad : f32, %size: index) -> tensor<9x8x7x1x2x3xf32> {
2081-
%init = tensor.empty() : tensor<9x8x7x1x2x3xf32>
2082-
%fill = linalg.fill ins(%pad : f32) outs(%init : tensor<9x8x7x1x2x3xf32>) -> tensor<9x8x7x1x2x3xf32>
2083-
%res = tensor.insert_slice %arg0 into %fill[0, 0, 0, 0, 0, 0] [1, 1, 1, 1, %size, 3][1, 1, 1, 1, 1, 1] : tensor<1x?x3xf32> into tensor<9x8x7x1x2x3xf32>
2084-
return %res : tensor<9x8x7x1x2x3xf32>
2085-
}
2086-
2087-
module attributes {transform.with_named_sequence} {
2088-
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
2089-
%0 = transform.structured.match ops{["tensor.insert_slice"]} in %arg1 : (!transform.any_op) -> !transform.any_op
2090-
%1 = transform.get_parent_op %0 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
2091-
%2 = transform.structured.vectorize_children_and_apply_patterns %1 : (!transform.any_op) -> !transform.any_op
2092-
transform.yield
2093-
}
2094-
}

0 commit comments

Comments
 (0)