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

Support my_array[::-1] to reverse an array #903

Open
suranap opened this issue Dec 4, 2023 · 0 comments
Open

Support my_array[::-1] to reverse an array #903

suranap opened this issue Dec 4, 2023 · 0 comments

Comments

@suranap
Copy link

suranap commented Dec 4, 2023

Example of failure:

>>> import cunumeric as np
>>> a = np.arange(10000)
>>> a[::-1]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "mambaforge/envs/legate/lib/python3.1/site-packages/legate/core/runtime.py", line 2149, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/coverage.py", line 120, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/array.py", line 148, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/array.py", line 1053, in __getitem__
    return ndarray(shape=None, thunk=self._thunk.get_item(key))
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/deferred.py", line 995, in get_item
    result = self._get_view(key)
             ^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/deferred.py", line 900, in _get_view
    k, store = self._slice_store(k, store, dim + shift)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "projects/legate/cunumeric/cunumeric/deferred.py", line 550, in _slice_store
    store = store.slice(dim, k)
            ^^^^^^^^^^^^^^^^^^^
  File "mambaforge/envs/legate/lib/python3.1/site-packages/legate/core/store.py", line 1353, in slice
    raise NotImplementedError(f"Unsupported slicing: {sl}")
NotImplementedError: Unsupported slicing: slice(None, None, -1)
>>> b = np.flip(a)

Maybe this code could check if step == -1 and run np.flip instead.
https://github.com/nv-legate/legate.core/blob/08da13fc544f3db26bf1ef7ce9bdb85e72a9d9fb/legate/core/store.py#L1353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant