llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[mlir][vector] lowerParallel is a misleading name: it also lowers unit-size reduction dimensions

Open StarOne01 opened this issue 1 month ago • 3 comments

While working on #228971 (fixed in #229824), the name lowerParallel in ContractionOpLowering turned out to be misleading. This issue is to keep track of that as suggested by @FedericoBruzzone .

What the code does today

In matchAndRewriteMaskableOp, dimensions are split into contracting ones (reductions present in both the LHS and RHS maps, from getContractingDimMap) and everything else. Every dimension that is not contracting is sent to lowerParallel. That includes unit-size reduction dimensions that appear on only one operand. In #228971, after CombineContractBroadcastMask, two unit reduction dimensions appear only in the RHS map, so a contraction whose iterators are all reduction ends up in lowerParallel.

Why this is confusing

lowerParallel sounds like it only handles parallel iterators, and lowerReduction sounds like it handles every reduction, but the split is by whether a dimension is contracting, and lowerReduction only accepts non-vector results.

StarOne01 avatar Oct 08 '26 15:10 StarOne01

@llvm/issue-subscribers-mlir

Author: Prashanth (StarOne01)

While working on #228971 (fixed in #229824), the name `lowerParallel `in `ContractionOpLowering` turned out to be misleading. This issue is to keep track of that as suggested by @FedericoBruzzone .

What the code does today

In matchAndRewriteMaskableOp, dimensions are split into contracting ones (reductions present in both the LHS and RHS maps, from getContractingDimMap) and everything else. Every dimension that is not contracting is sent to lowerParallel. That includes unit-size reduction dimensions that appear on only one operand. In #228971, after CombineContractBroadcastMask, two unit reduction dimensions appear only in the RHS map, so a contraction whose iterators are all reduction ends up in lowerParallel.

Why this is confusing

lowerParallel sounds like it only handles parallel iterators, and lowerReduction sounds like it handles every reduction, but the split is by whether a dimension is contracting, and lowerReduction only accepts non-vector results.

can we close this @FedericoBruzzone?

StarOne01 avatar Nov 27 '26 13:11 StarOne01

Yes, thank you to keep track! 🙏

FedericoBruzzone avatar Nov 27 '26 16:11 FedericoBruzzone