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: Walk regions for rewritings instead of ops #3506

Merged
merged 5 commits into from
Nov 25, 2024
Merged

Conversation

math-fehr
Copy link
Collaborator

Currently, the pattern rewriter walker walks an operation, and tries to apply patterns on all contained operations, including itself. This is not what we would want, as rewriting a toplevel operation is dangerous, if that operation does not have a parent.

This commit changes the walker to walk regions instead of operations, so it is clear that the toplevel operation will not be modified. This is similar to what MLIR currently does in applyPatternsAndFoldGreedily.

Currently, the pattern rewriter walker walks an operation, and tries to
apply patterns on all contained operations, including itself.
This is not what we would want, as rewriting a toplevel operation is
dangerous, if that operation does not have a parent.

This commit changes the walker to walk regions instead of operations, so
it is clear that the toplevel operation will not be modified. This is
similar to what MLIR currently does in applyPatternsAndFoldGreedily.
@math-fehr math-fehr added the core xDSL core (ir, textual format, ...) label Nov 22, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.33%. Comparing base (7ebcb70) to head (e593460).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3506      +/-   ##
==========================================
- Coverage   90.33%   90.33%   -0.01%     
==========================================
  Files         464      464              
  Lines       58157    58152       -5     
  Branches     5557     5558       +1     
==========================================
- Hits        52536    52530       -6     
  Misses       4190     4190              
- Partials     1431     1432       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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.

Left a few small comments but looks good to me.

PS. why don't we have the batched suggestion thing enabled

tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
tests/pattern_rewriter/test_pattern_rewriter.py Outdated Show resolved Hide resolved
xdsl/pattern_rewriter.py Show resolved Hide resolved
xdsl/transforms/dead_code_elimination.py Outdated Show resolved Hide resolved
@math-fehr math-fehr merged commit 9b5d0a4 into main Nov 25, 2024
15 checks passed
@math-fehr math-fehr deleted the fehr/rewrite_region branch November 25, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants