-
Notifications
You must be signed in to change notification settings - Fork 54
fix[next]: apply cse in fuse_as_fieldop #2257
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3c353ff
fix[next]: apply cse in fuse_as_fieldop
havogt 5cf6e49
fix name collision in cse
havogt 6ffd03c
pass offset_provider_type
havogt 5c90bcf
dont cse collect neighbors
havogt 7cd660c
Merge branch 'main' into cse_in_fieldop_fusion
edopao 8e8814a
Merge branch 'main' into cse_in_fieldop_fusion
edopao 96bce96
Merge branch 'main' into cse_in_fieldop_fusion
edopao 9e75186
Merge branch 'main' into cse_in_fieldop_fusion
edopao 80eeab4
Merge remote-tracking branch 'upstream/main' into cse_in_fieldop_fusion
havogt 13a8597
fix cse type reinfer
havogt 0f6737c
fix test references
havogt 0ae4a27
Merge branch 'main' into cse_in_fieldop_fusion
havogt d82fd06
make the unique ids uniquer
havogt ab4b7b1
Merge remote-tracking branch 'upstream/main' into cse_in_fieldop_fusion
havogt 4079135
add comment
havogt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
|
|
||
| import gt4py.next.iterator.ir_utils.common_pattern_matcher as cpm | ||
| from gt4py import eve | ||
| from gt4py.next import utils | ||
| from gt4py.next import common, utils | ||
| from gt4py.next.iterator import ir as itir | ||
| from gt4py.next.iterator.transforms import fuse_as_fieldop, inline_lambdas, trace_shifts | ||
| from gt4py.next.iterator.transforms.symbol_ref_utils import collect_symbol_refs | ||
|
|
@@ -33,11 +33,17 @@ def _dynamic_shift_args(node: itir.Expr) -> None | list[bool]: | |
|
|
||
| @dataclasses.dataclass | ||
| class InlineDynamicShifts(eve.NodeTranslator, eve.VisitorWithSymbolTableTrait): | ||
| offset_provider_type: common.OffsetProviderType | ||
| uids: utils.IDGeneratorPool | ||
|
|
||
| @classmethod | ||
| def apply(cls, node: itir.Program, uids: utils.IDGeneratorPool): | ||
| return cls(uids=uids).visit(node) | ||
| def apply( | ||
| cls, | ||
| node: itir.Program, | ||
| offset_provider_type: common.OffsetProviderType, | ||
| uids: utils.IDGeneratorPool, | ||
| ): | ||
| return cls(offset_provider_type=offset_provider_type, uids=uids).visit(node) | ||
|
|
||
| def visit_FunCall(self, node: itir.FunCall, **kwargs): | ||
| node = self.generic_visit(node, **kwargs) | ||
|
|
@@ -65,6 +71,12 @@ def visit_FunCall(self, node: itir.FunCall, **kwargs): | |
| for inp, dynamic_shift_arg in zip(node.args, dynamic_shift_args, strict=True) | ||
| ] | ||
| if any(fuse_args): | ||
| return fuse_as_fieldop.fuse_as_fieldop(node, fuse_args, uids=self.uids) | ||
| return fuse_as_fieldop.fuse_as_fieldop( | ||
| node, | ||
| fuse_args, | ||
| uids=self.uids, | ||
| offset_provider_type=self.offset_provider_type, | ||
| enable_cse=True, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this option mainly for testing, but now we could disable it here and we wouldn't have to pass the offset_provider_type. Not sure what to do... |
||
| ) | ||
|
|
||
| return node | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you extend the comment above to document why
neighborsshould not be collected.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.
Wondering if this can be undone, after unroll_reduce #2267 ?