[Mlir-commits] [mlir] [MLIR] Add allow Insert/extract slice option to pack/unpack op (PR #117340)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Dec 9 01:18:27 PST 2024
================
@@ -96,6 +96,34 @@ module attributes {transform.with_named_sequence} {
// -----
+// This is same as pack_as_pad but since we explicitly added {lowerPadLikeWithInsertSlice = false}, it should not
+// be lowered to insert_slice.
+// CHECK-LABEL: func.func @pack_disallowed_as_pad(
+func.func @pack_disallowed_as_pad(%arg0: tensor<129x47x16x16xf32>, %arg1: tensor<1x1x1x1x136x64x16x16xf32>) -> tensor<1x1x1x1x136x64x16x16xf32> {
+ %cst_0 = arith.constant 0.0 : f32
+ // tensor.pack is lowered to tensor.pad + tensor.expand_shape + linalg.transpose
+ // CHECK-SAME: %[[ARG0:[^:]*]]: tensor<129x47x16x16xf32>
+ // CHECK: %[[PAD:.*]] = tensor.pad %[[ARG0]]
+ // CHECK-NOT: %[[RES:.*]] = tensor.insert_slice %[[PAD]]
+ // CHECK: %[[PAD_EXPANDED:.*]] = tensor.expand_shape %[[PAD]]
+ // CHECK: %[[RES:.*]] = linalg.transpose ins(%[[PAD_EXPANDED]]
----------------
banach-space wrote:
```suggestion
// CHECK-DAG: %[[PAD:.*]] = tensor.pad %[[ARG0]]
// CHECK-NOT: %[[RES:.*]] = tensor.insert_slice %[[PAD]]
// CHECK: %[[PAD_EXPANDED:.*]] = tensor.expand_shape %[[PAD]]
// CHECK: %[[RES:.*]] = linalg.transpose ins(%[[PAD_EXPANDED]]
// CHECK-DAG: return %[[RES]]
```
This way you make sure that there's `tensor.insert_slice` between `tensor.pad` and `return`.
https://github.com/llvm/llvm-project/pull/117340
More information about the Mlir-commits
mailing list