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

refactor[next]: new ITIR type inference #1531

Merged
merged 58 commits into from
Jun 27, 2024

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Apr 17, 2024

New type inference algorithm on ITIR unifying the type system with the one used in the frontend. Types are stored directly in the ITIR nodes. This replaces the constraint based type inference giving significant performance and usability improvements. Types of builtins are expressing using simple to write TypeSynthesizer of the form:

@_register_builtin_type_synthesizer
def power(base: ts.ScalarType, exponent: ts.ScalarType) -> ts.ScalarType:
    return base

tehrengruber added a commit that referenced this pull request Apr 18, 2024
…ir.Ref. (#1532)

In the new ITIR type inference #1531 IR nodes store their type in the node itself. While we initially exclude the attribute from equality comparison we should nonetheless avoid comparison of nodes that only differ in type. This PR removes many of this occurrences.
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.

First round of review. I focused mainly in general python aspects and skipped the tests and an in-depth review of the type inference algorithm itself, which I'll do in a following review.

src/gt4py/next/ffront/type_info.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/ir.py Show resolved Hide resolved
src/gt4py/next/iterator/ir_utils/ir_makers.py Show resolved Hide resolved
src/gt4py/next/iterator/ir_utils/ir_makers.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/transforms/symbol_ref_utils.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/inference.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/inference.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/inference.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/inference.py Outdated Show resolved Hide resolved
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.

Just minor comments. I'm still thinking about the idea of transforming the inference algorithm to use a graph instead of callbacks, but it might be out of scope for this PR.

src/gt4py/next/iterator/type_system/type_specifications.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/type_synthesizer.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/type_synthesizer.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/type_specifications.py Outdated Show resolved Hide resolved
src/gt4py/next/iterator/type_system/inference.py Outdated Show resolved Hide resolved
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. I think it's better to merge the PR now and keep thinking about ways to simplify or improve the inference algorithm in other PRs.

@egparedes
Copy link
Contributor

Don't forget to add a proper PR description before merging.

@tehrengruber tehrengruber merged commit 3dfbf3f into GridTools:main Jun 27, 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