@@ -164,3 +164,41 @@ func.func @double_use_of_tensor_empty(%arg0: index, %arg1: index)
164
164
// CHECK: tensor.empty{{.*}} : tensor<?x10x40xf32>
165
165
// CHECK: tensor.extract_slice
166
166
// CHECK: tensor.extract_slice
167
+
168
+ // -----
169
+
170
+ module attributes {transform.with_named_sequence } {
171
+ transform.named_sequence @__transform_main (%root : !transform.any_op {transform.readonly }) {
172
+ %func_op = transform.structured.match ops {[" func.func" ]} in %root : (!transform.any_op ) -> !transform.op <" func.func" >
173
+ transform.apply_patterns to %func_op {
174
+ transform.apply_patterns.tensor.fold_tensor_empty
175
+ } : !transform.op <" func.func" >
176
+ transform.yield
177
+ }
178
+ }
179
+
180
+ func.func @concats_of_empty (
181
+ %arg0 : index , %arg1 : index , %arg2 : index , %arg3 : index )
182
+ -> tensor <5 x?x?xf32 >
183
+ {
184
+ %0 = tensor.empty (%arg0 , %arg1 ) : tensor <5 x?x?xf32 >
185
+ %1 = tensor.empty (%arg2 , %arg3 ) : tensor <5 x?x?xf32 >
186
+ %2 = tensor.concat dim (1 ) %0 , %1 : (tensor <5 x?x?xf32 >, tensor <5 x?x?xf32 >) -> tensor <5 x?x?xf32 >
187
+ return %2 : tensor <5 x?x?xf32 >
188
+ }
189
+ // CHECK: #[[MAP:.+]] = affine_map<()[s0, s1] -> (s0 + s1)>
190
+ // CHECK: func @concats_of_empty(
191
+ // CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index,
192
+ // CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index,
193
+ // CHECK-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index,
194
+ // CHECK-SAME: %[[ARG3:[a-zA-Z0-9]+]]: index)
195
+ // CHECK-DAG: %[[C1:.+]] = arith.constant 1 : index
196
+ // CHECK-DAG: %[[C2:.+]] = arith.constant 2 : index
197
+ // CHECK-DAG: %[[EMPTY0:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])
198
+ // CHECK-DAG: %[[EMPTY1:.+]] = tensor.empty(%[[ARG2]], %[[ARG3]])
199
+ // CHECK: %[[D2:.+]] = tensor.dim %[[EMPTY0]], %[[C2]]
200
+ // CHECK-DAG: %[[D0_1:.+]] = tensor.dim %[[EMPTY0]], %[[C1]]
201
+ // CHECK-DAG: %[[D1_1:.+]] = tensor.dim %[[EMPTY1]], %[[C1]]
202
+ // CHECK-DAG: %[[SUM:.+]] = affine.apply #[[MAP]]()[%[[D0_1]], %[[D1_1]]]
203
+ // CHECK: %[[NEW_EMPTY:.+]] = tensor.empty(%[[SUM]], %[[D2]])
204
+ // CHECK: return %[[NEW_EMPTY]]
0 commit comments