-
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
bug[next]: itir.embedded: fix shift inside scan pass #1280
Conversation
@@ -1196,7 +1195,7 @@ def can_deref(self) -> bool: | |||
return self.wrapped_iter.can_deref() | |||
|
|||
def shift(self, *offsets: OffsetPart) -> ScanArgIterator: | |||
return ScanArgIterator(self.wrapped_iter, self.k_pos, offsets=[*offsets, *self.offsets]) | |||
return ScanArgIterator(self.wrapped_iter.shift(*offsets), self.k_pos) |
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 is the important part.
src/gt4py/next/iterator/embedded.py
Outdated
if isinstance(res, tuple): | ||
out.field_setitem( | ||
ordered_indices, tuple(res[i][k] for i in range(len(res))) | ||
) # TODO(tehrengruber): only works for scalars | ||
else: | ||
out.field_setitem(ordered_indices, res[k]) |
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.
is this fixed in https://github.com/GridTools/gt4py/pull/1141/files? or is it another instance of that problem?
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.
Not sure actually, might be two different things. This is not clean however as it only works for tuples not nested tuples.
@@ -46,7 +46,7 @@ def shifted(inp): | |||
|
|||
@fundef | |||
def wrapped(inp): | |||
return scan(sum, True, 0.0)(inp, lift(shifted)(inp)) | |||
return scan(sum, True, 0.0)(inp, shift(Koff, 1)(inp)) |
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 change breaks something else, if we undo we could merge.
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 addressed this issue by adding another inline_into_scan pass after temporaries are created
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.
We concluded that this is fine for now even though we are not sure whether the ordering of the passes makes sense anymore. This will be addressed as a whole in another PR.
tests/next_tests/integration_tests/feature_tests/ffront_tests/test_execution.py
Outdated
Show resolved
Hide resolved
The test failures seem to be a result of removing https://github.com/GridTools/gt4py/pull/1280/files/d4160bb32c7e091e94afe983fbe747c32c9f7514#r1250968455 again. |
Shifts were ignored in the
ScanArgIterator
, i.e. all shifts in the scan_pass were ignored. This partially fixes thetest_icon_like_scan
.Additional:
InlineIntoScan
after temporary creation to inline remaining operations that block bubbling scans to the top.