[mlir][vector] lowerParallel is a misleading name: it also lowers unit-size reduction dimensions
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.
@llvm/issue-subscribers-mlir
Author: Prashanth (StarOne01)
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?
Yes, thank you to keep track! 🙏