[Mlir-commits] [mlir] [[mlir][linalg] Infer reduction-neutral padding values in rewriteAsPaddedOp (PR #216517)
Jianhui Li
llvmlistbot at llvm.org
Fri Sep 11 08:55:25 PDT 2026
================
@@ -263,6 +266,142 @@ static Value padOperand(OpBuilder &builder, TilingInterface opToPad,
paddingValue, /*nofold=*/false, dynDims);
}
+/// Returns true if `operand` is indexed along at least one reduction dimension
+/// of `linalgOp`
+static bool isReducedOperand(linalg::LinalgOp linalgOp, OpOperand *operand,
+ ArrayRef<utils::IteratorType> iterTypes) {
+ AffineMap map = linalgOp.getMatchingIndexingMap(operand);
+ return llvm::any_of(llvm::enumerate(iterTypes), [&](auto it) {
+ return it.value() == utils::IteratorType::reduction &&
+ map.isFunctionOfDim(it.index());
+ });
+}
+
+/// Set `paddingValues` with the padding value of every input of `contractOp`
+/// that is indexed along a reduction dimension. Fails if the pair admits no
+/// padding value.
+static LogicalResult
+setContractionPaddingValues(OpBuilder &builder, linalg::LinalgOp contractOp,
+ Operation *mul, Operation *add,
+ ArrayRef<utils::IteratorType> iterTypes,
+ MutableArrayRef<Attribute> paddingValues) {
----------------
Jianhui-Li wrote:
indeed, let me move them inside and reads better.
https://github.com/llvm/llvm-project/pull/216517
More information about the Mlir-commits
mailing list