[Mlir-commits] [mlir] [mlir][MemRef] Add position-based matching heuristics for rank-reduction with dynamic strides (PR #184334)
Abhishek Varma
llvmlistbot at llvm.org
Tue Mar 3 23:17:15 PST 2026
================
@@ -977,6 +1027,18 @@ computeMemRefRankReductionMask(MemRefType originalType, MemRefType reducedType,
reducedType.getStridesAndOffset(candidateStrides, candidateOffset)))
return failure();
+ // When strides are dynamic and multiple dimensions need to be dropped, we use
+ // position-based matching instead.
+ if (unusedDims.count() > 1 &&
+ (llvm::any_of(originalStrides, ShapedType::isDynamic) ||
+ llvm::any_of(candidateStrides, ShapedType::isDynamic))) {
----------------
Abhishek-Varma wrote:
That's a nice suggestion and makes the code verbose too by the segregation. I've updated the code to make use of a non-trivial stride guard to invoke stride-based logic else fall back to position-based logic.
https://github.com/llvm/llvm-project/pull/184334
More information about the Mlir-commits
mailing list