@@ -1130,14 +1130,14 @@ func.func private @insert_slice_static_sizes(%source: tensor<?x3x?x1xi32>) -> te
1130
1130
// CHECK: %[[C_2:.*]] = arith.constant 2 : index
1131
1131
// CHECK: %[[INIT:.*]] = tensor.empty() : tensor<5x3xi32>
1132
1132
// CHECK: %[[SRC_SLICE:.*]] = tensor.extract_slice %[[SEC]][0, %[[C_2]], 0, 0] [1, 1, 5, 1] [1, 1, 1, 1] : tensor<?x3x?x1xi32> to tensor<5x1xi32>
1133
- // CHECK: %[[PAD:.*]] = arith.constant 0 : i32
1134
- // CHECK: %[[C0:.*]] = arith.constant 0 : index
1135
- // CHECK: %[[C_5:.*]] = arith.constant 5 : index
1136
- // CHECK: %[[C_1:.*]] = arith.constant 1 : index
1133
+ // CHECK-DAG: %[[PAD:.*]] = arith.constant 0 : i32
1134
+ // CHECK-DAG: %[[C_5:.*]] = arith.constant 5 : index
1135
+ // CHECK-DAG: %[[C_1:.*]] = arith.constant 1 : index
1137
1136
// CHECK: %[[MASK:.*]] = vector.create_mask %[[C_5]], %[[C_1]] : vector<8x1xi1>
1137
+ // CHECK: %[[C0:.*]] = arith.constant 0 : index
1138
1138
// CHECK: %[[READ:.*]] = vector.mask %[[MASK]] { vector.transfer_read %[[SRC_SLICE]][%[[C0]], %[[C0]]], %[[PAD]] : tensor<5x1xi32>, vector<8x1xi32> } : vector<8x1xi1> -> vector<8x1xi32>
1139
1139
// CHECK: %[[C_0:.*]] = arith.constant 0 : index
1140
- // CHECK: %[[RES:.*]] = vector.transfer_write %[[READ]], %[[INIT]][%[[C_0]], %[[C_2]]] : vector<8x1xi32>, tensor<5x3xi32>
1140
+ // CHECK: %[[RES:.*]] = vector.mask %[[MASK]] { vector. transfer_write %[[READ]], %[[INIT]][%[[C_0]], %[[C_2]]] : vector<8x1xi32>, tensor<5x3xi32> } : vector<8x1xi1> -> tensor<5x3xi32>
1141
1141
// CHECK: return %[[RES]] : tensor<5x3xi32>
1142
1142
1143
1143
module attributes {transform.with_named_sequence } {
@@ -1170,11 +1170,11 @@ func.func private @insert_slice_dynamic_src_dim(%source: tensor<?x3x?x1xi32>, %s
1170
1170
// CHECK: %[[SRC_SLICE:.*]] = tensor.extract_slice %[[SRC]][0, %[[C_2]], 0, 0] [1, 1, %[[SIZE]], 1] [1, 1, 1, 1] : tensor<?x3x?x1xi32> to tensor<?x1xi32>
1171
1171
// CHECK-DAG: %[[PAD:.*]] = arith.constant 0 : i32
1172
1172
// CHECK-DAG: %[[C_1:.*]] = arith.constant 1 : index
1173
- // CHECK-DAG: %[[C_0:.*]] = arith.constant 0 : index
1174
1173
// CHECK: %[[MASK:.*]] = vector.create_mask %[[SIZE]], %[[C_1]] : vector<8x1xi1>
1174
+ // CHECK: %[[C_0:.*]] = arith.constant 0 : index
1175
1175
// CHECK: %[[READ:.*]] = vector.mask %[[MASK]] { vector.transfer_read %[[SRC_SLICE]][%[[C_0]], %[[C_0]]], %[[PAD]] : tensor<?x1xi32>, vector<8x1xi32> } : vector<8x1xi1> -> vector<8x1xi32>
1176
1176
// CHECK: %[[C_0_1:.*]] = arith.constant 0 : index
1177
- // CHECK: %[[RES:.*]] = vector.transfer_write %[[READ]], %[[INIT]][%[[C_0_1]], %[[C_2]]] : vector<8x1xi32>, tensor<5x3xi32>
1177
+ // CHECK: %[[RES:.*]] = vector.mask %[[MASK]] { vector. transfer_write %[[READ]], %[[INIT]][%[[C_0_1]], %[[C_2]]] : vector<8x1xi32>, tensor<5x3xi32> } : vector<8x1xi1> -> tensor<5x3xi32>
1178
1178
// CHECK: return %[[RES]] : tensor<5x3xi32>
1179
1179
1180
1180
module attributes {transform.with_named_sequence } {
@@ -1184,3 +1184,78 @@ func.func private @insert_slice_dynamic_src_dim(%source: tensor<?x3x?x1xi32>, %s
1184
1184
transform.yield
1185
1185
}
1186
1186
}
1187
+
1188
+ // -----
1189
+
1190
+ // One of the _destination_ dimensions is dynamic (but _source_ dimensions are static).
1191
+
1192
+ func.func private @insert_slice_dynamic_dest_dim (%source: tensor <?x3 x?x1 xi32 >, %size: index ) -> tensor <?x3 xi32 > {
1193
+ %c2 = arith.constant 2 : index
1194
+ %init = tensor.empty (%size ) : tensor <?x3 xi32 >
1195
+
1196
+ %source_slice = tensor.extract_slice %source [0 , %c2 , 0 , 0 ] [1 , 1 , 5 , 1 ] [1 , 1 , 1 , 1 ] : tensor <?x3 x?x1 xi32 > to tensor <5 x1 xi32 >
1197
+ %res = tensor.insert_slice %source_slice into %init [0 , %c2 ] [5 , 1 ] [1 , 1 ] : tensor <5 x1 xi32 > into tensor <?x3 xi32 >
1198
+
1199
+ return %res : tensor <?x3 xi32 >
1200
+ }
1201
+
1202
+ // CHECK-LABEL: func.func private @insert_slice_dynamic_dest_dim(
1203
+ // CHECK-SAME: %[[SRC:.*]]: tensor<?x3x?x1xi32>,
1204
+ // CHECK-SAME: %[[size:.*]]: index) -> tensor<?x3xi32> {
1205
+ // CHECK: %[[C_2:.*]] = arith.constant 2 : index
1206
+ // CHECK: %[[INIT:.*]] = tensor.empty(%[[size]]) : tensor<?x3xi32>
1207
+ // CHECK: %[[SRC_SLICE:.*]] = tensor.extract_slice %[[SRC]][0, %[[C_2]], 0, 0] [1, 1, 5, 1] [1, 1, 1, 1] : tensor<?x3x?x1xi32> to tensor<5x1xi32>
1208
+ // CHECK: %[[PAD:.*]] = arith.constant 0 : i32
1209
+ // CHECK: %[[C_5:.*]] = arith.constant 5 : index
1210
+ // CHECK: %[[C_1:.*]] = arith.constant 1 : index
1211
+ // CHECK: %[[MASK:.*]] = vector.create_mask %[[C_5]], %[[C_1]] : vector<8x1xi1>
1212
+ // CHECK: %[[C_0:.*]] = arith.constant 0 : index
1213
+ // CHECK: %[[READ:.*]] = vector.mask %[[MASK]] { vector.transfer_read %[[SRC_SLICE]][%[[C_0]], %[[C_0]]], %[[PAD]] : tensor<5x1xi32>, vector<8x1xi32> } : vector<8x1xi1> -> vector<8x1xi32>
1214
+ // CHECK: %[[C_0_1:.*]] = arith.constant 0 : index
1215
+ // CHECK: %[[WRITE:.*]] = vector.mask %[[MASK]] { vector.transfer_write %[[READ]], %[[INIT]][%[[C_0_1]], %[[C_2]]] : vector<8x1xi32>, tensor<?x3xi32> } : vector<8x1xi1> -> tensor<?x3xi32>
1216
+ // CHECK: return %[[WRITE]] : tensor<?x3xi32>
1217
+
1218
+ module attributes {transform.with_named_sequence } {
1219
+ transform.named_sequence @__transform_main (%arg0: !transform.any_op {transform.readonly }) {
1220
+ %0 = transform.structured.match ops {[" tensor.insert_slice" ]} in %arg0 : (!transform.any_op ) -> !transform.any_op
1221
+ transform.structured.vectorize %0 vector_sizes [8 , 1 ] : !transform.any_op
1222
+ transform.yield
1223
+ }
1224
+ }
1225
+
1226
+ // -----
1227
+
1228
+ // At least one _source_ and one _destination_ dimensions are dynamic.
1229
+
1230
+ func.func private @insert_slice_dynamic_source_and_dest_dim (%source: tensor <?x3 x?x1 xi32 >, %size: index ) -> tensor <?x3 xi32 > {
1231
+ %c2 = arith.constant 2 : index
1232
+ %init = tensor.empty (%size ) : tensor <?x3 xi32 >
1233
+
1234
+ %source_slice = tensor.extract_slice %source [0 , %c2 , 0 , 0 ] [1 , 1 , %size , 1 ] [1 , 1 , 1 , 1 ] : tensor <?x3 x?x1 xi32 > to tensor <?x1 xi32 >
1235
+ %res = tensor.insert_slice %source_slice into %init [0 , %c2 ] [%size , 1 ] [1 , 1 ] : tensor <?x1 xi32 > into tensor <?x3 xi32 >
1236
+
1237
+ return %res : tensor <?x3 xi32 >
1238
+ }
1239
+
1240
+ // CHECK-LABEL: func.func private @insert_slice_dynamic_source_and_dest_dim(
1241
+ // CHECK-SAME: %[[SRC:.*]]: tensor<?x3x?x1xi32>,
1242
+ // CHECK-SAME: %[[SIZE:.*]]: index) -> tensor<?x3xi32> {
1243
+ // CHECK: %[[C_2:.*]] = arith.constant 2 : index
1244
+ // CHECK: %[[INIT:.*]] = tensor.empty(%[[SIZE]]) : tensor<?x3xi32>
1245
+ // CHECK: %[[SRC_SIZE:.*]] = tensor.extract_slice %[[SRC]][0, %[[C_2]], 0, 0] [1, 1, %[[SIZE]], 1] [1, 1, 1, 1] : tensor<?x3x?x1xi32> to tensor<?x1xi32>
1246
+ // CHECK: %[[PAD:.*]] = arith.constant 0 : i32
1247
+ // CHECK: %[[C1:.*]] = arith.constant 1 : index
1248
+ // CHECK: %[[MASK:.*]] = vector.create_mask %[[SIZE]], %[[C1]] : vector<8x1xi1>
1249
+ // CHECK: %[[C0:.*]] = arith.constant 0 : index
1250
+ // CHECK: %[[READ:.*]] = vector.mask %[[MASK]] { vector.transfer_read %[[SRC_SIZE]]{{\[}}%[[C0]], %[[C0]]], %[[PAD]] : tensor<?x1xi32>, vector<8x1xi32> } : vector<8x1xi1> -> vector<8x1xi32>
1251
+ // CHECK: %[[C_0_1:.*]] = arith.constant 0 : index
1252
+ // CHECK: %[[WRITE:.*]] = vector.mask %[[MASK]] { vector.transfer_write %[[READ]], %[[INIT]]{{\[}}%[[C_0_1]], %[[C_2]]] : vector<8x1xi32>, tensor<?x3xi32> } : vector<8x1xi1> -> tensor<?x3xi32>
1253
+ // CHECK: return %[[WRITE]] : tensor<?x3xi32>
1254
+
1255
+ module attributes {transform.with_named_sequence } {
1256
+ transform.named_sequence @__transform_main (%arg0: !transform.any_op {transform.readonly }) {
1257
+ %0 = transform.structured.match ops {[" tensor.insert_slice" ]} in %arg0 : (!transform.any_op ) -> !transform.any_op
1258
+ transform.structured.vectorize %0 vector_sizes [8 , 1 ] : !transform.any_op
1259
+ transform.yield
1260
+ }
1261
+ }
0 commit comments