-
Notifications
You must be signed in to change notification settings - Fork 133
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
Generalize StructArrays to ContainerArrays and refactor View class structure #1504
Conversation
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 fine
@@ -516,13 +510,15 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]: | |||
if atype.optional is False: # If array cannot be None | |||
raise TypeError(f'Passing a None value to a non-optional array in argument "{a}"') | |||
# Otherwise, None values are passed as null pointers below | |||
elif isinstance(arg, ctypes._Pointer): |
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.
Could we leave a note here about the use of an underscored type? I am mostly concerned about the developers changing or removing it in a future version.
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.
Interestingly, it is part of the Python stable API: https://docs.python.org/3/library/ctypes.html#ctypes._Pointer
It is also the only one we can check against that covers all ctypes.POINTER types.
This PR refactors the notion of views to a `View` interface, and provides views to arrays, structures, and container arrays. It also adds a syntactic-sugar/helper API to define a view of an existing data descriptor. Depends on merging #1504
The refactoring of Views in PR #1504 led to the creation of the ArrayView type. This PR addresses an issue in the Python ProgramVisitor, where ArrayViews are not recognized properly as Views (of Arrays), leading to a NotImplementedError. The fix is simple: when checking if a container is an Array or a View (of an Array), instead of making a direct equality comparison to Array or View, a subclass comparison against Array is performed. The latter returns true if the container is an Array or any Array subclass, including ArrayViews.
This PR enables the use of an array data descriptor that contains a nested data descriptor (e.g., ContainerArray of Arrays). Its contents can then be viewed normally with View or StructureView.
With this, concepts such as jagged arrays are natively supported in DaCe (see test for example).
Also adds support for using ctypes pointers and arrays as arguments to SDFGs.
This PR also refactors the notion of views to a View interface, and provides views to arrays, structures, and container arrays. It also adds a syntactic-sugar/helper API to define a view of an existing data descriptor.