Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

math-fehr
Copy link
Collaborator

@math-fehr math-fehr commented Nov 29, 2024

math-fehr added a commit that referenced this pull request Nov 29, 2024
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
@math-fehr math-fehr self-assigned this Nov 29, 2024
@math-fehr math-fehr added the transformations Changes or adds a transformatio label Nov 29, 2024
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.36%. Comparing base (7ce487c) to head (a8b1c12).

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastico

Copy link
Collaborator

@alexarice alexarice left a 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.

xdsl/pattern_rewriter.py Show resolved Hide resolved
xdsl/pattern_rewriter.py Show resolved Hide resolved
@@ -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:
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

xdsl/pattern_rewriter.py Show resolved Hide resolved
if (block := op.parent) is not None:
block.erase_op(op, safe_erase=safe_erase)
else:
op.erase(safe_erase=safe_erase)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

xdsl/transforms/convert_scf_to_openmp.py Show resolved Hide resolved
Comment on lines +72 to +75
if (block := op.parent) is not None:
block.erase_op(op, safe_erase=safe_erase)
else:
op.erase(safe_erase=safe_erase)
Copy link
Member

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

math-fehr added a commit that referenced this pull request Dec 5, 2024
Stacked PRs:
 * #3540
 * #3539
 * #3538
 * __->__#3537


--- --- ---

### transforms: use Rewriter instead of PatternRewriter in mlir-opt


`PatternRewriter` should only be used for rewrite patterns.
math-fehr added a commit that referenced this pull request Dec 5, 2024
…il (#3538)

Stacked PRs:
 * #3540
 * #3539
 * __->__#3538
 * #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.
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…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.
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…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.
math-fehr added a commit that referenced this pull request Dec 18, 2024
Stacked PRs:
 * #3540
 * __->__#3539
 * #3538
 * #3537


--- --- ---

### transforms: Allow to pass a pattern rewriter in CSE


Without passing the pattern rewriter, CSE couldn't be called inside
a pattern rewriter walker, as it would not notify the operations that
were deleted or replaced.
Base automatically changed from math-fehr/stack/3 to main December 18, 2024 14:44
@math-fehr math-fehr force-pushed the math-fehr/stack/4 branch 2 times, most recently from a3414af to 85635f2 Compare December 30, 2024 13:49
stack-info: PR: #3681, branch: math-fehr/stack/5
stack-info: PR: #3682, branch: math-fehr/stack/6
stack-info: PR: #3683, branch: math-fehr/stack/7
@math-fehr
Copy link
Collaborator Author

Since some time passed, and to simplify splitting this PR, I created a new stack of PRs starting at math-fehr/stack/5
It contains the same things but splitted on 3 different PRs, with more tests.

@math-fehr math-fehr closed this Dec 30, 2024
@math-fehr math-fehr deleted the math-fehr/stack/4 branch January 20, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants