Skip to content
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

Merged
merged 10 commits into from
Feb 23, 2024

Conversation

tbennun
Copy link
Collaborator

@tbennun tbennun commented Jan 13, 2024

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.

@tbennun tbennun added the in the merge queue waiting for CI to work again label Jan 14, 2024
Copy link
Contributor

@alexnick83 alexnick83 left a 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):
Copy link
Contributor

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.

Copy link
Collaborator Author

@tbennun tbennun Jan 15, 2024

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.

JanKleine added a commit to JanKleine/dace that referenced this pull request Feb 14, 2024
alexnick83 and others added 2 commits February 20, 2024 17:35
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
@tbennun tbennun added this pull request to the merge queue Feb 21, 2024
@phschaad phschaad removed this pull request from the merge queue due to the queue being cleared Feb 22, 2024
@alexnick83 alexnick83 added this pull request to the merge queue Feb 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 23, 2024
@tbennun tbennun changed the title Generalize StructArrays to ContainerArrays Generalize StructArrays to ContainerArrays and refactor View class structure Feb 23, 2024
@tbennun tbennun added this pull request to the merge queue Feb 23, 2024
Merged via the queue into master with commit 9ee470c Feb 23, 2024
11 checks passed
@tbennun tbennun deleted the container-array branch February 23, 2024 19:54
github-merge-queue bot pushed a commit that referenced this pull request May 3, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in the merge queue waiting for CI to work again
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants