This is an archive of the discontinued LLVM Phabricator instance.

[mlir][transforms][NFC] Expand CanonicalizerPass documentation
ClosedPublic

Authored by springerm on Dec 28 2022, 8:39 AM.

Details

Summary

Mention that canonicalization is best-effort and that pass pipelines should not rely on it for correctness.

RFC: https://discourse.llvm.org/t/rfc-canonicalizerpass-convergence-error-handling/67333

Diff Detail

Event Timeline

springerm created this revision.Dec 28 2022, 8:39 AM
springerm requested review of this revision.Dec 28 2022, 8:39 AM
mehdi_amini added inline comments.Dec 28 2022, 9:12 AM
mlir/docs/Canonicalization.md
28
38–39

What is sentence bringing to this documentation? I'm wondering "what's the alternative anyway?"

39–40

I'm not sure about this advice right now, it seems to say too much or not enough to be more helpful than confusing.

40–44
41–44

I don't get why "fewer patterns may be applied"? And why is this the right parenthesis to go with "can cause inefficiencies"?

Thanks for improving the doc!

springerm updated this revision to Diff 485927.Jan 3 2023, 12:12 AM
springerm marked 4 inline comments as done.

address comments

mlir/docs/Canonicalization.md
41–44

I meant "less effective" instead of "inefficient".

We say above: It applies patterns until either fixpoint is reached or the maximum number of iterations/rewrites is exhausted. This could give the wrong impression that as long as these limits are in place, there is no problem with unstable/cyclic rewrites.

What I wanted to say with this sentence:

Situation 1: No unstable/cyclic rewrites => many different patterns are applied, maybe even fixpoint is reached

Situation 2: There are unstable/cyclic rewrites => we may spend lots of time rewriting the same piece of IR over and over without making progress => IR that was canonicalized in Situation 1 is no longer canonicalized (some patterns may not be applied) because the max_iterations/max_num_rewrites limit is reached.

Situation 2 is more desirable.

mehdi_amini accepted this revision.Jan 3 2023, 3:27 AM
This revision is now accepted and ready to land.Jan 3 2023, 3:27 AM