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

Propagate foast & past typing information to ITIR #1199

Merged

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Mar 6, 2023

Adds support for constraining the type of symbols in ITIR (only dtype and kind right now) and propagates the information from FOAST and PAST to ITIR.

@tehrengruber tehrengruber changed the title POC: Propagate foast typing information to ITIR Propagate foast & past typing information to ITIR Mar 17, 2023
Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

The PR looks good. Just a couple some questions, no need to change anything.

src/gt4py/next/iterator/ir.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/ir.py Outdated Show resolved Hide resolved
)
inferred = ti.infer(testee)
assert inferred == expected
assert ti.pformat(inferred) == "(It[T₁, T₂, float⁰]) → It[T₁, T₂, float⁰]"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is being tested here that hasn't been in the first assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the idea of @fthaler was to test the type pretty printer like this. Additionally this gives a more readable representation of the inferred type.

Comment on lines +421 to +422
if node.kind:
kind = {"Iterator": Iterator(), "Value": Value()}[node.kind]
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not very important, but I think it would better to use explicit pattern matching:

Suggested change
if node.kind:
kind = {"Iterator": Iterator(), "Value": Value()}[node.kind]
match node.kind:
case "Iterator":
kind = Iterator()
case "Value":
kind = Value()
case _:
raise AssertionError(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see the point, but I like the less verbose version more.

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, for just two cases, I don't think the dict version brings any value. Even a simple if-else would be better.

@egparedes
Copy link
Contributor

@tehrengruber What is the current state of this PR? Is it blocked by something else?

@gronerl
Copy link
Contributor

gronerl commented Apr 11, 2023

@egparedes you never clicked approve on this ;) we're waiting for your review.

Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

It looks good to me.

@tehrengruber tehrengruber merged commit 759727f into GridTools:main Apr 12, 2023
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.

3 participants