|
1 | 1 | // RUN: mlir-opt %s --transform-interpreter --split-input-file -canonicalize | FileCheck %s |
2 | 2 |
|
3 | 3 | // 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. |
6 | 6 |
|
7 | 7 | module { |
8 | 8 | // CHECK-label: func @fuse_pack_as_producer |
9 | 9 | // CHECK: scf.forall {{.*}} { |
10 | | - // CHECK: linalg.transpose |
11 | | - // CHECK: linalg.generic |
| 10 | + // CHECK: %[[PRODUCER:.*]] = linalg.transpose |
| 11 | + // CHECK: linalg.generic {{.*}} ins(%[[PRODUCER]] |
12 | 12 | // CHECK: scf.forall.in_parallel |
13 | 13 | // CHECK: } |
14 | 14 | func.func @fuse_pack_as_producer(%src: tensor<128x256xf32>, %other: tensor<4x4x128x256xf32>) |
@@ -60,11 +60,13 @@ module { |
60 | 60 |
|
61 | 61 | // ----- |
62 | 62 | // 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. |
63 | 64 |
|
64 | 65 | module { |
65 | 66 | // CHECK-label: func @fuse_pack_as_producer_blocked_by_insert_slice |
66 | | - // CHECK: tensor.insert_slice |
| 67 | + // CHECK: %[[PRODUCER:.*]] = tensor.insert_slice |
67 | 68 | // CHECK: scf.forall {{.*}} { |
| 69 | + // CHECK: linalg.generic {{.*}} ins(%[[PRODUCER]] |
68 | 70 | // CHECK: scf.forall.in_parallel |
69 | 71 | // CHECK: } |
70 | 72 | func.func @fuse_pack_as_producer_blocked_by_insert_slice(%src: tensor<128x256xf32>, %other: tensor<4x4x128x256xf32>) |
@@ -116,14 +118,13 @@ module { |
116 | 118 |
|
117 | 119 | // ----- |
118 | 120 | // 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. |
122 | 123 | module { |
123 | 124 | // CHECK-label: func @fuse_unpack_as_consumer |
124 | 125 | // CHECK: scf.forall {{.*}} { |
125 | | - // CHECK: linalg.generic |
126 | | - // CHECK: linalg.transpose |
| 126 | + // CHECK: %[[CONSUMER:.*]] = linalg.generic |
| 127 | + // CHECK: linalg.transpose ins(%[[CONSUMER]] |
127 | 128 | // CHECK: scf.forall.in_parallel |
128 | 129 | // CHECK: } |
129 | 130 | func.func @fuse_unpack_as_consumer(%src: tensor<4x4x128x256xf32>, %other: tensor<4x4x128x256xf32>) |
@@ -178,14 +179,15 @@ module { |
178 | 179 |
|
179 | 180 | // ----- |
180 | 181 | // 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. |
182 | 183 | module { |
183 | 184 | // 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 |
186 | 187 | // CHECK: scf.forall.in_parallel |
| 188 | + // CHECK: tensor.parallel_insert_slice %[[ADDF]] |
187 | 189 | // CHECK: } |
188 | | - // CHECK: tensor.extract_slice |
| 190 | + // CHECK: tensor.extract_slice %[[CONSUMER]] |
189 | 191 | func.func @fuse_unpack_as_consumer_blocked_by_extract_slice(%src: tensor<4x4x128x256xf32>, %other: tensor<4x4x128x256xf32>) |
190 | 192 | -> tensor<128x256xf32> { |
191 | 193 | %out = tensor.empty() : tensor<1x1x128x256xf32> |
|
0 commit comments