Skip to content

Commit

Permalink
Adds support for ArrayView to the Python Frontend (#1565)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexnick83 authored May 2, 2024
1 parent a0422c9 commit 9e1cb4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def _add_access(
arr_type = type(parent_array)
if arr_type == data.Scalar:
self.sdfg.add_scalar(var_name, dtype)
elif arr_type in (data.Array, data.View):
elif issubclass(arr_type, data.Array):
self.sdfg.add_array(var_name, shape, dtype, strides=strides)
elif arr_type == data.Stream:
self.sdfg.add_stream(var_name, dtype)
Expand Down Expand Up @@ -3116,7 +3116,7 @@ def _add_access(
arr_type = data.Scalar
if arr_type == data.Scalar:
self.sdfg.add_scalar(var_name, dtype)
elif arr_type in (data.Array, data.View):
elif issubclass(arr_type, data.Array):
if non_squeezed:
strides = [parent_array.strides[d] for d in non_squeezed]
else:
Expand Down

0 comments on commit 9e1cb4a

Please sign in to comment.