-
Notifications
You must be signed in to change notification settings - Fork 80
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
core: Make PatternRewriter a Builder #3540
Conversation
This allows us to now use the ImplicitBuilder on PatternRewriter, or to use `insert` using an InsertPoint. stack-info: PR: #3540, branch: math-fehr/stack/4
56bc13b
to
a8b1c12
Compare
902ccce
to
7ce487c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## math-fehr/stack/3 #3540 +/- ##
==================================================
Coverage 90.36% 90.36%
==================================================
Files 466 466
Lines 58517 58544 +27
Branches 5584 5588 +4
==================================================
+ Hits 52878 52905 +27
Misses 4210 4210
Partials 1429 1429 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastico
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments but they may be more due to my ignorance than actual problems with the change.
@@ -726,7 +731,11 @@ def _handle_operation_removal(self, op: Operation) -> None: | |||
"""Handle removal of an operation.""" | |||
if self.apply_recursively: | |||
self._add_operands_to_worklist(op.operands) | |||
self._worklist.remove(op) | |||
if op.regions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a separate change to making PatternRewriter
a Builder
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rebase this branch on a new one, this was indeed a bug before that can be refactored.
if (block := op.parent) is not None: | ||
block.erase_op(op, safe_erase=safe_erase) | ||
else: | ||
op.erase(safe_erase=safe_erase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it now ok to erase a operation with no parents?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move this to a separate PR as well, the idea is that sometimes we detach an operation and then destroy it.
if (block := op.parent) is not None: | ||
block.erase_op(op, safe_erase=safe_erase) | ||
else: | ||
op.erase(safe_erase=safe_erase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH this feels like it could be its own PR, with an accompanying test
…project#3537) Stacked PRs: * xdslproject#3540 * xdslproject#3539 * xdslproject#3538 * __->__#3537 --- --- --- ### transforms: use Rewriter instead of PatternRewriter in mlir-opt `PatternRewriter` should only be used for rewrite patterns.
…il (xdslproject#3538) Stacked PRs: * xdslproject#3540 * xdslproject#3539 * __->__#3538 * xdslproject#3537 --- --- --- ### transforms: use rewriter and listener in convert-stencil-to-csl-stencil The pass was not propagating the listener from the PatternRewriter, and thus some operations were modified without notifying the rewrite worklist.
a3414af
to
85635f2
Compare
85635f2
to
18b6baa
Compare
Since some time passed, and to simplify splitting this PR, I created a new stack of PRs starting at math-fehr/stack/5 |
Stacked PRs:
core: Make PatternRewriter a Builder
This allows us to now use the ImplicitBuilder on PatternRewriter,
or to use
insert
using an InsertPoint.