-
Notifications
You must be signed in to change notification settings - Fork 49
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
base: main
Are you sure you want to change the base?
Conversation
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) | ||
|
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.
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), |
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.
Should something like this, i.e. not returning DeferredType but FieldType, work in the end as well ?
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 byDimension.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 aK
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.