This diff makes us not assert/crash on the testcase being added here.
This is the assert that this testcase is hitting.
This assertion is triggering because this function, lowerParallel, was expecting to be called on a parallel dimension, but its caller, ContractionOpLowering::matchAndRewrite, is actually calling it on dimensions that are not necessarily parallel.
Inspection of ContractionOpLowering::matchAndRewrite shows that it is calling lowerParallel on all dimensions except reductions dimensions that occur on both the LHS and the RHS. At first sight, that sounds equivalent to saying all dimensions except reduction dimensions, which in turns boils down to all parallel dimensions.
But the testcase has a unit-size reduction dimension occurring only on the LHS and not on the RHS. Even though it is a reduction dimension, because it does not occur on RHS, it is not seen by getContractingDimMap here and the logic below ends up calling lowerParallel on it here.
This testcase is "legitimate" in the sense that it is actually produced by the existing CastAwayContractionLeadingOneDim pattern applied on a more clearly legitimate testcase as explained in this gist:
https://gist.github.com/bjacob/d8be8ec7e70ed0be4b3a5794ced2a7e8