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

transforms: use rewriter and listener in convert-stencil-to-csl-stencil #3538

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

math-fehr
Copy link
Collaborator

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

Stacked PRs:


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.

`PatternRewriter` should only be used for rewrite patterns.

stack-info: PR: #3537, branch: math-fehr/stack/1
The pass was not propagating the listener from the PatternRewriter, and
thus some operations were modified without notifying the rewrite
worklist.

stack-info: PR: #3538, branch: math-fehr/stack/2
@math-fehr
Copy link
Collaborator Author

@n-io, can you confirm that the coeffs attribute in csl_stencil.apply do not have an order?
This PR changed the order in which the coefficients are stored, but my understanding is that this is irrelevant?

@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.40%. Comparing base (4ebfbe8) to head (7467961).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3538      +/-   ##
==========================================
- Coverage   90.40%   90.40%   -0.01%     
==========================================
  Files         467      467              
  Lines       58861    58862       +1     
  Branches     5605     5605              
==========================================
  Hits        53213    53213              
- Misses       4206     4207       +1     
  Partials     1442     1442              

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

@n-io
Copy link
Collaborator

n-io commented Nov 29, 2024

Yes, the order is irrelevant since the stencil index is stored with the coefficient value.

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.

Only added one comment. Do you also know what caused the test diff?

@@ -505,12 +506,13 @@ def match_and_rewrite(self, op: stencil.ApplyOp, rewriter: PatternRewriter, /):
# add operations from list to receive_chunk, use translation table to rebuild operands
for o in chunk_region_ops:
if isinstance(o, stencil.ReturnOp | csl_stencil.YieldOp):
rewriter.erase_op(o)
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 this new erase_op necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

good question, if I had to guess, I'd say it seems like defensive programming to me as the yield is added anyhow below. Unless there's something else @math-fehr ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The operation was just unused anywhere, and not deleted.
In particular, that means it was still in the greedy pattern rewriter worklist, and was being matched on.
The last PR in the list expose that error, as now it tries to still match it, but fails because it shouldn't match any operation that has no parents.

@@ -505,12 +506,13 @@ def match_and_rewrite(self, op: stencil.ApplyOp, rewriter: PatternRewriter, /):
# add operations from list to receive_chunk, use translation table to rebuild operands
for o in chunk_region_ops:
if isinstance(o, stencil.ReturnOp | csl_stencil.YieldOp):
rewriter.erase_op(o)
Copy link
Collaborator

Choose a reason for hiding this comment

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

good question, if I had to guess, I'd say it seems like defensive programming to me as the yield is added anyhow below. Unless there's something else @math-fehr ?

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.
Base automatically changed from math-fehr/stack/1 to main December 5, 2024 15:13
@math-fehr math-fehr merged commit ce85340 into main Dec 5, 2024
15 checks passed
@math-fehr math-fehr deleted the math-fehr/stack/2 branch December 5, 2024 15:29
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.
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