Skip to content

Commit f6c54e8

Browse files
committed
Add additional LIT variable
This help to clearly demonstrate the produer fusion in pack case and consumer fusion in unpack case.
1 parent 68b5328 commit f6c54e8

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

mlir/test/Dialect/Linalg/transform-tile-and-fuse-pack-unpack.mlir

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// RUN: mlir-opt %s --transform-interpreter --split-input-file -canonicalize | FileCheck %s
22

33
// For pack op, we use lowerPadLikeWithInsertSlice = false to ensure no insert_slice is generated.
4-
// This allows linalg.transpose to be fused as a producer operation. Alternatively, without this attribute
5-
// insert_slice will be generated and fusion blocked.
4+
// This allows linalg.transpose to be fused as a producer operation. In below testcase, linalg.transpose
5+
// as a producer operation is fused into the scf.forall loop.
66

77
module {
88
// CHECK-label: func @fuse_pack_as_producer
99
// CHECK: scf.forall {{.*}} {
10-
// CHECK: linalg.transpose
11-
// CHECK: linalg.generic
10+
// CHECK: %[[PRODUCER:.*]] = linalg.transpose
11+
// CHECK: linalg.generic {{.*}} ins(%[[PRODUCER]]
1212
// CHECK: scf.forall.in_parallel
1313
// CHECK: }
1414
func.func @fuse_pack_as_producer(%src: tensor<128x256xf32>, %other: tensor<4x4x128x256xf32>)
@@ -60,11 +60,13 @@ module {
6060

6161
// -----
6262
// For pack op, by default lowerPadLikeWithInsertSlice = true, which generates insert_slice and blocks fusion.
63+
// In below testcase, tensor.insert_slice as a producer operation cannot be fused into the scf.forall loop.
6364

6465
module {
6566
// CHECK-label: func @fuse_pack_as_producer_blocked_by_insert_slice
66-
// CHECK: tensor.insert_slice
67+
// CHECK: %[[PRODUCER:.*]] = tensor.insert_slice
6768
// CHECK: scf.forall {{.*}} {
69+
// CHECK: linalg.generic {{.*}} ins(%[[PRODUCER]]
6870
// CHECK: scf.forall.in_parallel
6971
// CHECK: }
7072
func.func @fuse_pack_as_producer_blocked_by_insert_slice(%src: tensor<128x256xf32>, %other: tensor<4x4x128x256xf32>)
@@ -116,14 +118,13 @@ module {
116118

117119
// -----
118120
// For unpack op, we use lowerUnpadLikeWithExtractSlice = false to ensure no extract_slice is generated.
119-
// This allows linalg.transpose to be fused as a consumer operation. Alternatively, without this attribute
120-
// extract_slice will be generated and fusion blocked.
121-
121+
// This allows linalg.transpose to be fused as a consumer operation. In below testcase, linalg.transpose
122+
// as a consumer operation is fused into the scf.forall loop.
122123
module {
123124
// CHECK-label: func @fuse_unpack_as_consumer
124125
// CHECK: scf.forall {{.*}} {
125-
// CHECK: linalg.generic
126-
// CHECK: linalg.transpose
126+
// CHECK: %[[CONSUMER:.*]] = linalg.generic
127+
// CHECK: linalg.transpose ins(%[[CONSUMER]]
127128
// CHECK: scf.forall.in_parallel
128129
// CHECK: }
129130
func.func @fuse_unpack_as_consumer(%src: tensor<4x4x128x256xf32>, %other: tensor<4x4x128x256xf32>)
@@ -178,14 +179,15 @@ module {
178179

179180
// -----
180181
// For unpack op, by default lowerUnpadLikeWithExtractSlice = true, which generates extract_slice and blocks fusion.
181-
182+
// In below testcase, tensor.extract_slice as a consumer operation cannot be fused into the scf.forall loop.
182183
module {
183184
// CHECK-label: func @fuse_unpack_as_consumer_blocked_by_extract_slice
184-
// CHECK: scf.forall {{.*}} {
185-
// CHECK: linalg.generic
185+
// CHECK: %[[CONSUMER:.*]] = scf.forall {{.*}} {
186+
// CHECK: %[[ADDF:.*]] = linalg.generic
186187
// CHECK: scf.forall.in_parallel
188+
// CHECK: tensor.parallel_insert_slice %[[ADDF]]
187189
// CHECK: }
188-
// CHECK: tensor.extract_slice
190+
// CHECK: tensor.extract_slice %[[CONSUMER]]
189191
func.func @fuse_unpack_as_consumer_blocked_by_extract_slice(%src: tensor<4x4x128x256xf32>, %other: tensor<4x4x128x256xf32>)
190192
-> tensor<128x256xf32> {
191193
%out = tensor.empty() : tensor<1x1x128x256xf32>

0 commit comments

Comments
 (0)