-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][docs] Add docs on canonicalizers being folders or patterns #129517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,3 +275,24 @@ Operation *MyDialect::materializeConstant(OpBuilder &builder, Attribute value, | |
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ### Choosing between implementing a Folder or a `RewritePattern` | ||
|
|
||
| When implementing a new canonicalization, an important thing to think about is | ||
| if the canonicalization should be a folder or a `RewritePattern`. The generally | ||
| accepted policy is: | ||
|
|
||
| * If a transformation should be a canonicalizer is a different question from | ||
| if a transformation should be a folder or a `RewritePattern`. A | ||
| transformation is promoted to a canonicalization as defined by the General | ||
| Design of canonicalizations. | ||
|
||
|
|
||
| * If a transformation is a canonicalization, there are two ways to implement | ||
| it: As a Folder or as a `RewritePattern`, both of which are implementation | ||
|
||
| details of how a canonicalization exists, with the difference being folders | ||
| have restrictions on what they can do. A `RewritePattern` can implement any | ||
| transformation a folder can. | ||
|
|
||
| * A canonicalization should always be implemented as a Folder if it fits | ||
| the "local" definition of a folder, otherwise it should be implemented | ||
| as a `RewritePattern`. | ||
Groverkss marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.