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

Fix bug in basic slicing of empty arrays #1680

Merged
merged 1 commit into from
May 16, 2024

Conversation

oleksandr-pavlyk
Copy link
Collaborator

Reproducer provided by @ndgrigorian:

import dpctl.tensor as dpt
x = dpt.ones((0, 10))
y = dpt.moveaxis(x, 1, 0)
y[1] # raises ValueError

Now this returns empty 1d array like y[0] does.

A test is added for both integral basic indexing,
and for simple slice.


  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you opening the PR as a draft?

Reproducer provided by @ndgrigorian:

```
import dpctl.tensor as dpt
x = dpt.ones((0, 10))
y = dpt.moveaxis(x, 1, 0)
y[1] # raises ValueError
```

Now this returns empty 1d array like `y[0]` does.

A test is added for both integral basic indexing,
and for simple slice.
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the fix-basic-slicing-on-empty-arrays branch from d221a81 to 9fa1aec Compare May 16, 2024 14:37
Copy link

github-actions bot commented May 16, 2024

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@coveralls
Copy link
Collaborator

coveralls commented May 16, 2024

Coverage Status

coverage: 87.953% (+0.005%) from 87.948%
when pulling 9fa1aec on fix-basic-slicing-on-empty-arrays
into d840cee on master.

Copy link

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_353 ran successfully.
Passed: 889
Failed: 16
Skipped: 91

@oleksandr-pavlyk oleksandr-pavlyk requested a review from vtavana May 16, 2024 15:13
Copy link

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_353 ran successfully.
Passed: 889
Failed: 16
Skipped: 91

oleksandr-pavlyk added a commit that referenced this pull request May 16, 2024
Copy link
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolves the array API test failure. I've also tested it out in some edge cases and it seems to work as intended.

In [1]: import dpctl.tensor as dpt, dpctl, numpy as np

In [2]: x = dpt.arange(100, dtype="f4")

In [3]: x1 = dpt.reshape(x[2:], (7, 14))

In [4]: x1[-1:0, :].mT[2]
Out[4]: usm_ndarray([], dtype=float32)

In [5]: _.shape
Out[5]: (0,)

In [6]: test = x1[-1:0, :]

In [7]: test.shape
Out[7]: (0, 14)

In [8]: test.shape = (0, 100)

In [9]: test.mT[2]
Out[9]: usm_ndarray([], dtype=float32)

In [10]: test[:, 2]
Out[10]: usm_ndarray([], dtype=float32)

Windows CI break is unrelated...

@oleksandr-pavlyk oleksandr-pavlyk merged commit f3d8ee7 into master May 16, 2024
43 of 58 checks passed
@oleksandr-pavlyk oleksandr-pavlyk deleted the fix-basic-slicing-on-empty-arrays branch May 16, 2024 20:29
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

Successfully merging this pull request may close these issues.

3 participants