This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Avoid infinite loop in InnerOuterDimReductionConversion.
ClosedPublic

Authored by mravishankar on Dec 8 2021, 10:53 PM.

Details

Summary

This patterns tries to convert an inner (outer) dim reduction to an
outer (inner) dim reduction. Doing this on a 1D or 0D vector results
in an infinite loop since the converted op is same as the original
operation. Just returning failure when source rank <= 1 fixes the
issue.

Diff Detail

Event Timeline

mravishankar created this revision.Dec 8 2021, 10:53 PM
mravishankar requested review of this revision.Dec 8 2021, 10:53 PM
ThomasRaoux accepted this revision.Dec 9 2021, 8:39 AM
ThomasRaoux added inline comments.
mlir/test/Dialect/Vector/vector-multi-reduction-outer-lowering.mlir
165

nit: You could make it a negative test and check that op is unchanged:
// CHECK: vector.multi_reduction #vector.kind<maxf>, %{{.*}} [0] : vector<2xf32> to f32

This revision is now accepted and ready to land.Dec 9 2021, 8:39 AM
mravishankar added inline comments.Dec 9 2021, 9:13 AM
mlir/test/Dialect/Vector/vector-multi-reduction-outer-lowering.mlir
165

That was the hope, but the pass adds many different patterns and the op is changed (in ways that are not great). So this at least tests there is no infinite loop.