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]: Global ordering relation of dimensions #1847

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

SF-N
Copy link
Contributor

@SF-N SF-N commented Feb 5, 2025

This PR introduces a global ordering relation of dimensions, replacing the previous mechanism in promote_dims. The ordering relation is: sorting first by Dimension.kind (HORIZONTAL < VERTICAL < LOCAL) and then lexicographically by Dimension.value.

Reason:
An as_fieldop call as emitted by the frontend has no domain, and inferring the type of the domain was not possible, since no global ordering relation of dimensions existed, e.g. for an as_fieldop operating on a Vertex and a K field it was unclear if the dimensions of the output were (Vertex, K) or (K, Vertex), which lead to many negative consequences in other places, that will be tackled in PR 1853 and following ones.

@SF-N SF-N requested a review from tehrengruber February 5, 2025 18:59
else:
assert isinstance(lhs, ts.FieldType) and isinstance(rhs, ts.FieldType)
assert lhs.dtype == rhs.dtype
return ts.FieldType(dims=common.promote_dims(*[lhs.dims, rhs.dims]), dtype=lhs.dtype)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was necessary for the new test (im.plus(im.ref("inp1", float_i_field), im.ref("inp2", float_j_field)), float_ij_field) in test_type_inference.py. I am not sure if supporting this is actually desired.

@@ -185,6 +189,8 @@ def expression_test_cases():
),
ts.DeferredType(constraint=None),
),
# (im.as_fieldop(im.lambda_("x", "y")(im.plus(im.deref("x"), im.deref("y"))))(
# im.ref("inp1", float_i_field), im.ref("inp2", float_j_field)), float_ij_field),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should something like this, i.e. not returning DeferredType but FieldType, work in the end as well ?

@SF-N SF-N changed the title refactor[next]: Decouple type inference and domain inference refactor[next]: lobal ordering relation of dimensions Feb 10, 2025
@SF-N SF-N changed the title refactor[next]: lobal ordering relation of dimensions refactor[next]: Global ordering relation of dimensions Feb 10, 2025
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.

1 participant