@@ -52,22 +52,22 @@ module {
52
52
53
53
// CHECK-LABEL: @generic
54
54
// CHECK-SAME: %[[T0:.*]]: tensor<7x5xf32>,
55
- // CHECK-SAME: %[[T1:.*]]: tensor<7x11x12xf32 >)
56
- func.func @generic (%arg0: tensor <7 x5 xf32 >, %arg1: tensor <7 x 11 x 12 x f32 >) -> tensor <7 x 11 x 12 x f32 > {
55
+ // CHECK-SAME: %[[T1:.*]]: tensor<7x11x11xf32 >)
56
+ func.func @generic (%arg0: tensor <7 x5 xf32 >, %arg1: tensor <7 x 11 x 11 x f32 >) -> tensor <7 x 11 x 11 x f32 > {
57
57
58
58
// CHECK-DAG: %[[CST:.*]] = arith.constant 0.
59
59
60
60
// CHECK: %[[PAD0:.*]] = tensor.pad %[[T0]] low[0, 0] high[2, 0]
61
61
// CHECK: : tensor<7x5xf32> to tensor<9x5xf32>
62
62
// CHECK: %[[PAD1:.*]] = tensor.pad %[[T1]] low[0, 0, 0] high[2, 4, 2] {
63
- // CHECK: : tensor<7x11x12xf32 > to tensor<9x15x14xf32 >
63
+ // CHECK: : tensor<7x11x11xf32 > to tensor<9x15x13xf32 >
64
64
// CHECK-NEXT: linalg.generic
65
- // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0] [7, 11, 12 ] [1, 1, 1] : tensor<9x15x14xf32 > to tensor<7x11x12xf32 >
66
- %0 = linalg.generic {index ing_maps = [#map , #map1 ], iterator_types = [" parallel" , " parallel" , " reduction" ]} ins (%arg0 : tensor <7 x5 xf32 >) outs (%arg1 : tensor <7 x 11 x 12 x f32 >) {
65
+ // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0] [7, 11, 11 ] [1, 1, 1] : tensor<9x15x13xf32 > to tensor<7x11x11xf32 >
66
+ %0 = linalg.generic {index ing_maps = [#map , #map1 ], iterator_types = [" parallel" , " parallel" , " reduction" ]} ins (%arg0 : tensor <7 x5 xf32 >) outs (%arg1 : tensor <7 x 11 x 11 x f32 >) {
67
67
^bb0 (%in: f32 , %out: f32 ):
68
68
linalg.yield %in : f32
69
- } -> tensor <7 x 11 x 12 x f32 >
70
- return %0 : tensor <7 x 11 x 12 x f32 >
69
+ } -> tensor <7 x 11 x 11 x f32 >
70
+ return %0 : tensor <7 x 11 x 11 x f32 >
71
71
}
72
72
module attributes {transform.with_named_sequence } {
73
73
transform.named_sequence @__transform_main (%arg0: !transform.any_op {transform.readonly }) {
@@ -83,7 +83,7 @@ module {
83
83
// -----
84
84
85
85
// CHECK-DAG: #[[$MAP0:.*]] = affine_map<()[s0, s1] -> (-s1 + (s0 ceildiv 3) * 3)>
86
- // CHECK-DAG: #[[$MAP1:.*]] = affine_map<()[s0, s1] -> (-s1 + (s0 ceildiv 3) * 3 + 5 )>
86
+ // CHECK-DAG: #[[$MAP1:.*]] = affine_map<()[s0, s1] -> (-s1 + (s0 ceildiv 3) * 3 + 4 )>
87
87
// CHECK-DAG: #[[$MAP2:.*]] = affine_map<()[s0] -> (s0 + 5)>
88
88
89
89
#map = affine_map <(d0 , d1 , d2 ) -> (d0 , d1 )>
@@ -272,3 +272,136 @@ module attributes {transform.with_named_sequence} {
272
272
}
273
273
}
274
274
275
+ // -----
276
+
277
+ // CHECK-LABEL: pad_conv
278
+ func.func @pad_conv (%arg0: tensor <1 x16 x16 x4 xf32 >, %arg1: tensor <16 x3 x3 x4 xf32 >, %arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 > {
279
+
280
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 2, 12]
281
+ // CHECK: : tensor<1x16x16x4xf32> to tensor<1x16x18x16xf32>
282
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 0, 12]
283
+ // CHECK: : tensor<16x3x3x4xf32> to tensor<16x3x3x16xf32>
284
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 2, 0]
285
+ // CHECK: : tensor<1x14x14x16xf32> to tensor<1x14x16x16xf32>
286
+ // CHECK-NEXT: linalg.conv_2d_nhwc_fhwc
287
+ // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0, 0] [1, 14, 14, 16] [1, 1, 1, 1] : tensor<1x14x16x16xf32> to tensor<1x14x14x16xf32>
288
+
289
+ %0 = linalg.conv_2d_nhwc_fhwc
290
+ {dilations = dense <1 > : tensor <2 xi64 >, strides = dense <1 > : tensor <2 xi64 > }
291
+ ins (%arg0 , %arg1: tensor <1 x16 x16 x4 xf32 >, tensor <16 x3 x3 x4 xf32 >)
292
+ outs (%arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 >
293
+ return %0 : tensor <1 x14 x14 x16 xf32 >
294
+ }
295
+
296
+ module attributes {transform.with_named_sequence } {
297
+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
298
+ %0 = transform.structured.match ops {[" linalg.conv_2d_nhwc_fhwc" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
299
+ %padded , %pad = transform.structured.pad_tiling_interface %0 to padding_sizes [0 , 0 , 16 , 0 , 0 , 0 , 16 ] pad_to_multiple_of {
300
+ padding_values = [0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 ]
301
+ } : (!transform.any_op ) -> (!transform.any_op , !transform.any_op )
302
+ transform.yield
303
+ }
304
+ }
305
+
306
+ // -----
307
+
308
+ // CHECK-DAG: #[[$MAP0:.*]] = affine_map<()[s0, s1] -> (-s1 + (s0 ceildiv 16) * 16 + 2)>
309
+ // CHECK-DAG: #[[$MAP1:.*]] = affine_map<()[s0, s1] -> (-s1 + (s0 ceildiv 16) * 16)>
310
+
311
+ // CHECK-LABEL: pad_conv_dynamic
312
+ func.func @pad_conv_dynamic (%arg0: tensor <1 x16 x?x4 xf32 >, %arg1: tensor <16 x3 x3 x4 xf32 >, %arg2: tensor <1 x14 x?x16 xf32 >) -> tensor <1 x14 x?x16 xf32 > {
313
+
314
+ // CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
315
+ // CHECK: %[[D0_0:.*]] = tensor.dim %{{.*}}, %[[C2]] : tensor<1x14x?x16xf32>
316
+ // CHECK: %[[D0_1:.*]] = tensor.dim %{{.*}}, %[[C2]] : tensor<1x16x?x4xf32>
317
+ // CHECK: %[[H0:.*]] = affine.apply #[[$MAP0]]()[%[[D0_0]], %[[D0_1]]]
318
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, %[[H0]], 12]
319
+ // CHECK: : tensor<1x16x?x4xf32> to tensor<1x16x?x16xf32>
320
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 0, 12]
321
+ // CHECK: : tensor<16x3x3x4xf32> to tensor<16x3x3x16xf32>
322
+ // CHECK: %[[D1_0:.*]] = tensor.dim %{{.*}}, %[[C2]] : tensor<1x14x?x16xf32>
323
+ // CHECK: %[[H1:.*]] = affine.apply #[[$MAP1]]()[%[[D0_0]], %[[D1_0]]]
324
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, %[[H1]], 0]
325
+ // CHECK: : tensor<1x14x?x16xf32> to tensor<1x14x?x16xf32>
326
+ // CHECK: %[[D2_0:.*]] = tensor.dim %{{.*}}, %[[C2]] : tensor<1x14x?x16xf32>
327
+ // CHECK-NEXT: linalg.conv_2d_nhwc_fhwc
328
+ // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0, 0] [1, 14, %[[D2_0]], 16] [1, 1, 1, 1] : tensor<1x14x?x16xf32> to tensor<1x14x?x16xf32>
329
+
330
+ %0 = linalg.conv_2d_nhwc_fhwc
331
+ {dilations = dense <1 > : tensor <2 xi64 >, strides = dense <1 > : tensor <2 xi64 > }
332
+ ins (%arg0 , %arg1: tensor <1 x16 x?x4 xf32 >, tensor <16 x3 x3 x4 xf32 >)
333
+ outs (%arg2: tensor <1 x14 x?x16 xf32 >) -> tensor <1 x14 x?x16 xf32 >
334
+ return %0 : tensor <1 x14 x?x16 xf32 >
335
+ }
336
+
337
+ module attributes {transform.with_named_sequence } {
338
+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
339
+ %0 = transform.structured.match ops {[" linalg.conv_2d_nhwc_fhwc" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
340
+ %padded , %pad = transform.structured.pad_tiling_interface %0 to padding_sizes [0 , 0 , 16 , 0 , 0 , 0 , 16 ] pad_to_multiple_of {
341
+ padding_values = [0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 ]
342
+ } : (!transform.any_op ) -> (!transform.any_op , !transform.any_op )
343
+ transform.yield
344
+ }
345
+ }
346
+
347
+ // -----
348
+
349
+ // CHECK-LABEL: pad_conv_strided
350
+ func.func @pad_conv_strided (%arg0: tensor <1 x42 x42 x4 xf32 >, %arg1: tensor <16 x3 x3 x4 xf32 >, %arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 > {
351
+
352
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 6, 12]
353
+ // CHECK: : tensor<1x42x42x4xf32> to tensor<1x42x48x16xf32>
354
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 0, 12]
355
+ // CHECK: : tensor<16x3x3x4xf32> to tensor<16x3x3x16xf32>
356
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 2, 0]
357
+ // CHECK: : tensor<1x14x14x16xf32> to tensor<1x14x16x16xf32>
358
+ // CHECK-NEXT: linalg.conv_2d_nhwc_fhwc
359
+ // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0, 0] [1, 14, 14, 16] [1, 1, 1, 1] : tensor<1x14x16x16xf32> to tensor<1x14x14x16xf32>
360
+
361
+ %0 = linalg.conv_2d_nhwc_fhwc
362
+ {dilations = dense <1 > : tensor <2 xi64 >, strides = dense <3 > : tensor <2 xi64 > }
363
+ ins (%arg0 , %arg1: tensor <1 x42 x42 x4 xf32 >, tensor <16 x3 x3 x4 xf32 >)
364
+ outs (%arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 >
365
+ return %0 : tensor <1 x14 x14 x16 xf32 >
366
+ }
367
+
368
+ module attributes {transform.with_named_sequence } {
369
+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
370
+ %0 = transform.structured.match ops {[" linalg.conv_2d_nhwc_fhwc" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
371
+ %padded , %pad = transform.structured.pad_tiling_interface %0 to padding_sizes [0 , 0 , 16 , 0 , 0 , 0 , 16 ] pad_to_multiple_of {
372
+ padding_values = [0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 ]
373
+ } : (!transform.any_op ) -> (!transform.any_op , !transform.any_op )
374
+ transform.yield
375
+ }
376
+ }
377
+
378
+ // -----
379
+
380
+ // CHECK-LABEL: pad_conv_dilated
381
+ func.func @pad_conv_dilated (%arg0: tensor <1 x18 x18 x4 xf32 >, %arg1: tensor <16 x3 x3 x4 xf32 >, %arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 > {
382
+
383
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 2, 12]
384
+ // CHECK: : tensor<1x18x18x4xf32> to tensor<1x18x20x16xf32>
385
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 0, 12]
386
+ // CHECK: : tensor<16x3x3x4xf32> to tensor<16x3x3x16xf32>
387
+ // CHECK: tensor.pad %{{.*}} low[0, 0, 0, 0] high[0, 0, 2, 0]
388
+ // CHECK: : tensor<1x14x14x16xf32> to tensor<1x14x16x16xf32>
389
+ // CHECK-NEXT: linalg.conv_2d_nhwc_fhwc
390
+ // CHECK: tensor.extract_slice %{{.*}}[0, 0, 0, 0] [1, 14, 14, 16] [1, 1, 1, 1] : tensor<1x14x16x16xf32> to tensor<1x14x14x16xf32>
391
+
392
+ %0 = linalg.conv_2d_nhwc_fhwc
393
+ {dilations = dense <2 > : tensor <2 xi64 >, strides = dense <1 > : tensor <2 xi64 > }
394
+ ins (%arg0 , %arg1: tensor <1 x18 x18 x4 xf32 >, tensor <16 x3 x3 x4 xf32 >)
395
+ outs (%arg2: tensor <1 x14 x14 x16 xf32 >) -> tensor <1 x14 x14 x16 xf32 >
396
+ return %0 : tensor <1 x14 x14 x16 xf32 >
397
+ }
398
+
399
+ module attributes {transform.with_named_sequence } {
400
+ transform.named_sequence @__transform_main (%arg1: !transform.any_op {transform.readonly }) {
401
+ %0 = transform.structured.match ops {[" linalg.conv_2d_nhwc_fhwc" ]} in %arg1 : (!transform.any_op ) -> !transform.any_op
402
+ %padded , %pad = transform.structured.pad_tiling_interface %0 to padding_sizes [0 , 0 , 16 , 0 , 0 , 0 , 16 ] pad_to_multiple_of {
403
+ padding_values = [0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 , 0.0 : f32 ]
404
+ } : (!transform.any_op ) -> (!transform.any_op , !transform.any_op )
405
+ transform.yield
406
+ }
407
+ }
0 commit comments