-
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
feature[next]: Extend cartesian offset syntax #1484
Conversation
…handle several arguments
… 1 + 2 and some mypy fixes
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.
Partial review.
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.
Just as a reminder. We should wait with the merge until CAA is sorted out.
case foast.BinOp( | ||
op=dialect_ast_enums.BinaryOperator.ADD | ||
| dialect_ast_enums.BinaryOperator.SUB, | ||
left=foast.BinOp( | ||
op=dialect_ast_enums.BinaryOperator.ADD | ||
| dialect_ast_enums.BinaryOperator.SUB, | ||
left=foast.Name(id=dimension), | ||
right=foast.Constant(value=offset_index_left), | ||
), | ||
right=foast.Constant(value=offset_index), | ||
): | ||
if node.args[i].op == dialect_ast_enums.BinaryOperator.SUB: # type: ignore[attr-defined] # ensured by pattern | ||
offset_index *= -1 | ||
shift_offsets.append( | ||
im.shift(f"{dimension}off", offset_index_left + offset_index) | ||
) |
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 for the IDim+1+1
case right? Let's remove it for now since it is not generic anyway (i.e. doesn't work for IDim+1+1+1
).
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.
As discussed, I removed all sopport for (IDim +1) + 1 again and raise an error in type_deduction.py
instaed.
I tried to resolve the conflict with |
…ring, fixed lowering of `as_offset` (offset field erroneously was captured)
#1484 introduced support for writing `field(I+1)`. The implicit offset providers we generate for this accidentally also included local dimensions, which broke e.g. Icon4Py with errors like: ``` if not dim.kind == common.DimensionKind.VERTICAL: > raise ValueError( "Mapping an offset to a horizontal dimension in unstructured is not allowed." ) E ValueError: Mapping an offset to a horizontal dimension in unstructured is not allowed. ``` This PR fixes that by only including horizontal and vertical, but not local dimensions in the implicit offset providers.
Description
Add support for replacing the syntax for Cartesian offsets
field(Ioff[1])(Joff[-1])
byfield(I+1,J-1)
.Current status: finished for embedded execution
Requirements
TODOs