[Mlir-commits] [mlir] [mlir][tensor] Generalize/restrict `GeneralizeOuterUnitDimsPackOpPattern` (PR #114315)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 5 06:56:34 PST 2024
================
@@ -1515,9 +1515,43 @@ struct GeneralizePadOpPattern : public OpRewritePattern<tensor::PadOp> {
const SmallVector<Value> &dynSizes) const;
};
-/// Rewrites a tensor::PackOp into a sequence of tensor.pad + linalg.transpose +
-/// tensor.insert_slice ops, where the tensor::PackOp has outer dims being all
-/// 1s.
+/// Rewrites a tensor::PackOp into a sequence of:
+/// * tensor::PadOp + linalg::TransposeOp + tensor::ExtractSliceOp +
+/// tensor::EmptyOp + tensor::InsertSliceOp ops.
+///
+/// Required that all the outer dims of the input tensor::PackOp are 1.
+///
+/// Before:
+/// ```
+/// %packed = tensor.pack %input
+/// padding_value(%pad : f32)
+/// inner_dims_pos = [1, 0]
+/// inner_tiles = [2, %high]
+/// into %output : tensor<5x1xf32> -> tensor<1x1x2x?xf32>
+/// ```
+///
+/// After:
+/// ```
+/// // PadOp
+/// %padded = tensor.pad %arg0 low[0, 0] high[%0, 1] {
+/// ^bb0(...):
+/// tensor.yield %arg2 : f32
+/// } : tensor<5x1xf32> to tensor<?x2xf32>
+/// // ExtractSliceOp
+/// %extracted_slice = tensor.extract_slice %padded[0, 0] [%tile_dim_1, 2] [1,
+/// 1]
----------------
Max191 wrote:
This may not be in the scope of this PR to change this, but what exactly is this extract_slice for? It seems to me like it is just taking a full slice. Is the slice ever not full?
https://github.com/llvm/llvm-project/pull/114315
More information about the Mlir-commits
mailing list