-
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[cartesian]: read-only data dims direct access & Fields #1451
feat[cartesian]: read-only data dims direct access & Fields #1451
Conversation
`.at` operator to index globally utest
Better error message.
Just a quick feedback (didn't look close): couldn't that be implemented with just a a normal field with no I,J or K dimension? Since our iteration space is always 3D, writing to a pure |
Technically the |
E.g.
|
NB: One side effect of the way I coded up |
I meant read-only fields and fields with no spatial dimensions are probably both useful features, but they are orthogonal. I’ll have a closer look tomorrow. |
Yes, I did think about that. And technically the read-only Field is enforced by the fact you can only do At first I wrote it as a "DataField". Let's exchange tomorrow at community meeting |
Make utest more readable
I renamed I looked into using I didn't come up with an alternate way to write the definition that was clean enough. So out of abundance of caution around the feature, I opted again for the |
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.
Looks good. I'll discuss with @egparedes when he is back from vacation.
src/gt4py/cartesian/gtscript.py
Outdated
# GTScript builtins: variable annotations | ||
Field = _FieldDescriptorMaker() | ||
"""Field descriptor.""" | ||
|
||
OffgridField = _ReadOnlyFieldDescriptorMaker() |
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 personally like ConstantField (constant with respect to the grid), but I think not everyone likes it for confusion with non-mutable. Here it both meanings coincide.
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.
ConstantField
would be confusing for users I think. Though, indeed, the system make it constant
in stencils, the Field is still modifiable outside of gtscript
I fully agree that the two features added in this PR make sense: the shortcut to access data dimensions in the current point instead of the two pairs of brackets, and a way to pass ndarrays of data which are not linked to the grid, however I disagree with the names. Since the content of the new Regarding the new |
Two very good points. The generic As for the re-use of |
Yes, I see your point and it makes sense. What about |
|
From my side at least, you can go ahead and change the names of the two features, and I think the PR would already be ready to be merged. |
Swapped `.at` -> `.A`
Done. |
Ready to be merged. |
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.
It looks good to me.
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.
Please update the PR to the new formatting tools (it should be very easy)
cscs-ci run |
cscs-ci run |
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
Description
We introduce a
ROField
which is a data dimensions only Field. Access is provided via.at[]
which also becomes a way to access data dimensions on regular Field.Technically, we re-use the data dims concept, empty out the cartesian axes and make sure we have protection in place against write to the
ROField
. Definition follows the already established data dimensions format for now:[(type, (axes...))]
Requirements