[Mlir-commits] [mlir] [[mlir][linalg] Infer reduction-neutral padding values in rewriteAsPaddedOp (PR #216517)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Fri Sep 11 00:27:09 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) {
----------------
banach-space wrote:
With interface like this, what's the intended relation between `contractOp` and `mul` + `add`? IMHO, those ops should be extracted in this method to avoid confusion.
https://github.com/llvm/llvm-project/pull/216517
More information about the Mlir-commits
mailing list