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

feature[next]: Inline center deref lift vars #1455

Merged

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Feb 15, 2024

Inline all variables which are derefed in the center only (i.e. unshifted).

Consider the following example where var is never shifted:

let(var, (↑stencil)(it))(·var + ·var)

Directly inlining var would increase the size of the tree and duplicate the calculation.
Instead, this pass computes the value at the current location once and replaces all previous
references to var by an applied lift which captures this value.

let(_icdlv_1, stencil(it))(·(↑(λ() → _icdlv_1) + ·(↑(λ() → _icdlv_1))

The lift inliner can then later easily transform this into a nice expression:

let(_icdlv_1, stencil(it))(_icdlv_1 + _icdlv_1)

@tehrengruber tehrengruber requested a review from havogt February 15, 2024 14:07
@@ -125,7 +125,8 @@ def new_name(name):
class InlineLambdas(PreserveLocationVisitor, NodeTranslator):
"""Inline lambda calls by substituting every argument by its value."""

PRESERVED_ANNEX_ATTRS = ("type",)
# TODO: document that these annex attrs are preserved, but not used by the pass itself.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the TODO here?

Copy link
Contributor

Choose a reason for hiding this comment

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

... in other passes

Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

see comment about TODO

@tehrengruber tehrengruber merged commit 66f8447 into GridTools:main Mar 6, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants