-
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
feat[next]: Slicing field to 0d to return field not scalar #1427
Conversation
Co-authored-by: Hannes Vogt <[email protected]>
…s/test_horizontal_indirection.py Co-authored-by: Hannes Vogt <[email protected]>
…s/test_horizontal_indirection.py Co-authored-by: Hannes Vogt <[email protected]>
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.
I have to look at the details again tomorrow. We can talk in the morning...
def _scalar_to_field(self, value: core_defs.Scalar) -> np.ndarray: | ||
if self.array_ns == cp: | ||
return cp.asarray(value) | ||
else: | ||
return np.asarray(value) | ||
|
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.
Shouldn't this be removed already?
tests/next_tests/unit_tests/embedded_tests/test_nd_array_field.py
Outdated
Show resolved
Hide resolved
tests/next_tests/unit_tests/embedded_tests/test_nd_array_field.py
Outdated
Show resolved
Hide resolved
src/gt4py/next/embedded/operators.py
Outdated
res = field[pos] if common.is_field(field) else field | ||
res = res.item() if hasattr(res, "item") else res # extract scalar value from array | ||
res = ( | ||
res.ndarray.item() if hasattr(res, "ndarray") else res # type: ignore[union-attr] | ||
) # extract scalar value from array |
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.
yes
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.
ILGTM
Extracting a single value from a field should return an empty field, not a scalar
Given the following example:
The
program
return type should be:Additionally, a small fix was made in
past_passes.type_deduction
such thatarg_types
is used instead ofnodes.args.type