[Mlir-commits] [mlir] [mlir] Add missing pad reshape propagation patterns (PR #168888)
Ian Wood
llvmlistbot at llvm.org
Thu Nov 20 11:24:39 PST 2025
================
@@ -1921,6 +2023,52 @@ struct FoldReshapeWithGenericOpByCollapsing
ControlFusionFn controlFoldingReshapes;
};
+/// Computes the collapsed padding information for the given pad operation based
+/// on the provided collapsed shape and reassociation indices. Returns a
+/// PadDimInfo containing the low and high padding amounts and the collapsed
+/// shape for each dimension, or failure if the collapse is not possible.
+static FailureOr<PadDimInfo>
+computeCollapsedPadding(tensor::PadOp padOp,
+ ArrayRef<ReassociationIndices> reassociations,
+ PatternRewriter &rewriter) {
+ ArrayRef<int64_t> low = padOp.getStaticLow();
+ ArrayRef<int64_t> high = padOp.getStaticHigh();
+
+ // Collapsed dimensions cannot have padding because this can produce strided
+ // padding that isn't representable by a tensor.pad op. There are some special
+ // cases where it it possible (like collapsing unit dims), but supporting
----------------
IanWood1 wrote:
```suggestion
// cases where it is possible (like collapsing unit dims), but supporting
```
https://github.com/llvm/llvm-project/pull/168888
More information about the Mlir-commits
mailing list