From 9e1cb4a8f8638ed961568d7374f9eac67b7ac986 Mon Sep 17 00:00:00 2001 From: alexnick83 <31545860+alexnick83@users.noreply.github.com> Date: Fri, 3 May 2024 01:57:41 +0200 Subject: [PATCH] Adds support for ArrayView to the Python Frontend (#1565) 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. --- dace/frontend/python/newast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index 3d2ec5c09d..fda2bd2e23 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -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) @@ -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: