-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support for 4d Data #71
base: develop
Are you sure you want to change the base?
Conversation
ndsl/dsl/gt4py_utils.py
Outdated
elif n_dims == 4: | ||
|
||
data = _make_storage_data_4d(data, shape, start, backend=backend) |
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.
Remove the empty line.
I may have missed it, but there is no test to ensure ndims <=4. I'm guessing the gt4py.storage.from_array function will crash at that point since data is undefined when ndims >4.
@@ -257,6 +262,25 @@ def _make_storage_data_3d( | |||
return buffer | |||
|
|||
|
|||
def _make_storage_data_4d( |
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.
Can we generalize this with something like
def _make_storage_data_Nd(
data: Field,
shape: Tuple[int, ...],
start: Tuple[int, ...],
*,
backend: str,
) -> Field:
buffer = zeros(shape, backend=backend)
idx = tuple([slice(start, start + shape_dim) for shape_dim in data.shape])
buffer[idx] = asarray(data, type(buffer))
return buffer
and we just have to pass a default start if it doesn't exist (that can be build with something like tuple([0]*data.ndim)
Description
This PR adds support for 4D data structures in NDSL, especially the translate tests, and also fixes a bug where TranslateFortranData2Py would cast everything to Float instead of respecting types.
How Has This Been Tested?
The PBL and surface layer translate tests have been run with these updates
Checklist: