1
- // RUN: mlir-opt %s -transform-interpreter -cse --split-input-file | FileCheck %s
1
+ // RUN: mlir-opt %s -transform-interpreter -cse -verify-diagnostics -split-input-file | FileCheck %s
2
2
3
3
// CHECK-LABEL: func.func @pack(
4
4
func.func @pack (%arg0: tensor <129 x47 x16 x16 xf32 >, %arg1: tensor <17 x2 x16 x16 x32 x8 xf32 >) -> tensor <17 x2 x16 x16 x32 x8 xf32 > {
@@ -143,9 +143,9 @@ func.func @unpack(%arg0: tensor<17x2x16x16x32x8xf32>, %arg1: tensor<129x47x16x16
143
143
// CHECK-SAME: : tensor<136x64x16x16xf32> to tensor<129x47x16x16xf32>
144
144
// CHECK: linalg.copy ins(%[[SLICE]] : tensor<129x47x16x16xf32>)
145
145
// CHECK-SAME: outs(%[[ARG1]] : tensor<129x47x16x16xf32>)
146
- %pack = tensor.unpack %arg0 inner_dims_pos = [1 , 0 ] inner_tiles = [32 , 8 ] into %arg1
146
+ %unpack = tensor.unpack %arg0 inner_dims_pos = [1 , 0 ] inner_tiles = [32 , 8 ] into %arg1
147
147
: tensor <17 x2 x16 x16 x32 x8 xf32 > -> tensor <129 x47 x16 x16 xf32 >
148
- return %pack : tensor <129 x47 x16 x16 xf32 >
148
+ return %unpack : tensor <129 x47 x16 x16 xf32 >
149
149
}
150
150
151
151
module attributes {transform.with_named_sequence } {
@@ -162,6 +162,7 @@ module attributes {transform.with_named_sequence} {
162
162
}
163
163
164
164
// -----
165
+
165
166
// When an unpack is a plain 'unpad', lower it to a simple extract_slice.
166
167
// CHECK-LABEL: func.func @unpack_as_pad(
167
168
func.func @unpack_as_pad (%arg0: tensor <1 x1 x1 x1 x136 x64 x16 x16 xf32 >, %arg1: tensor <129 x47 x16 x16 xf32 >) -> tensor <129 x47 x16 x16 xf32 > {
@@ -460,3 +461,27 @@ module attributes {transform.with_named_sequence} {
460
461
transform.yield
461
462
}
462
463
}
464
+
465
+ // -----
466
+
467
+ // At the moment, we cannot lower tensor.unpack with outer_dims_perm.
468
+ func.func @diagnostic_unpack (%arg0: tensor <32 x64 xf32 >, %arg1: tensor <2 x4 x32 x8 xf32 >) -> tensor <32 x64 xf32 > {
469
+ // expected-note @below {{target payload op}}
470
+ %unpack = tensor.unpack %arg1 outer_dims_perm = [1 , 0 ]
471
+ inner_dims_pos = [1 , 0 ] inner_tiles = [32 , 8 ] into %arg0 : tensor <2 x4 x32 x8 xf32 > -> tensor <32 x64 xf32 >
472
+ return %unpack : tensor <32 x64 xf32 >
473
+ }
474
+
475
+ module attributes {transform.with_named_sequence } {
476
+ transform.named_sequence @__transform_main (%module_op: !transform.any_op {transform.readonly }) {
477
+ %unpack = transform.structured.match ops {[" tensor.unpack" ]} in %module_op
478
+ : (!transform.any_op ) -> !transform.op <" tensor.unpack" >
479
+ // expected-error @below {{cannot lower to transpose + collapse + extract}}
480
+ transform.structured.lower_unpack %unpack : (!transform.op <" tensor.unpack" >)
481
+ -> (!transform.op <" tensor.empty" >,
482
+ !transform.op <" linalg.transpose" >,
483
+ !transform.op <" tensor.collapse_shape" >,
484
+ !transform.op <" tensor.extract_slice" >)
485
+ transform.yield
486
+ }
487
+ }
0 commit comments