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

Improved error handling for usm_ndarray.__setitem__ #1146

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

oleksandr-pavlyk
Copy link
Collaborator

While reviewing #1139 the following suboptimal behavior was highlighted:

import dpctl.tensor as dpt, numpy as np

u, n = dpt.empty(5), np.ones(5, dtype="O")
u[...] = n

This example used to raise a cascade of exceptions starting with cryptic "RuntimeError: Unrecogized typenum 17 encountered.", where typenum 17 corresponds to type object. The latest exception raised was ValueError.

After this change, the error message is crisper:

ValueError: Input of type <class 'numpy.ndarray'> can not be \
    assigned to usm_ndarray because of unsupported data \
    type 'object'

Tests exist.

  • 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?

```python
import dpctl.tensor as dpt, numpy as np

u, n = dpt.empty(5), np.ones(5, dtype="O")
u[...] = n
```

This example used to raise a cascade of exceptions starting
with cryptic  "RuntimeError: Unrecogized typenum 17 encountered.",
where typenum 17 corresponds to type object.

After this change, the error message is crisper:

```
ValueError: Input of type <class 'numpy.ndarray'> can not be \
    assigned to usm_ndarray because of unsupported data \
    type 'object'
```
@github-actions
Copy link

@coveralls
Copy link
Collaborator

Coverage Status

Coverage: 82.799% (-0.003%) from 82.802% when pulling 5929d6b on improve-assignment-error-handling into df25aa0 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_38 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk merged commit 9ca3b6b into master Mar 30, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the improve-assignment-error-handling branch March 30, 2023 00:29
@github-actions
Copy link

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

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_56 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

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