[Mlir-commits] [mlir] [MLIR][NFC] Add allow Insert/extract slice option to pack/unpack op (PR #117340)
Andrzej Warzyński
llvmlistbot at llvm.org
Mon Nov 25 07:06:33 PST 2024
================
@@ -96,6 +96,34 @@ module attributes {transform.with_named_sequence} {
// -----
+// This is same as pack_as_pad but since we explicitly added {allowInsertSliceLowering = false}, it should not
+// be lowered to insert_slice.
+// CHECK-LABEL: func.func @pack_disallowed_as_pad(
+// CHECK: %[[SRC:.+]]: tensor<129x47x16x16xf32>,
+// CHECK: %[[OUT:.+]]: tensor<1x1x1x1x136x64x16x16xf32>)
+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 + tensor.insert_slice
+ // CHECK: %[[PAD:.*]] = tensor.pad %[[SRC]] low[0, 0, 0, 0] high[7, 17, 0, 0]
+ // CHECK: : tensor<129x47x16x16xf32> to tensor<136x64x16x16xf32>
----------------
banach-space wrote:
I agree that it's unnecessary to generate `CHECK` lines for behavior already covered elsewhere. However, I see this test as a variation of `@pack_as_pad`, which produces:
```mlir
%pad = tensor.pad
%slice = tensor.insert_slice %pad
return %slice
```
What's the actual sequence here? I was hoping the lowerPack docs would clarify: https://github.com/llvm/llvm-project/blob/157d847ba737b4136aeb1d92912f549ea1c96d4c/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h#L1122-L1124
However, the description is sparse and mentions reshape and transpose, which don’t seem to apply here. Is `PAD` the actual return value in this case?
https://github.com/llvm/llvm-project/pull/117340
More information about the Mlir-commits
mailing list