Skip to content

Unhelpful error message when calling asnumpy with non-usm_array type #1457

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

Closed
Hardcode84 opened this issue Oct 26, 2023 · 1 comment · Fixed by #1460
Closed

Unhelpful error message when calling asnumpy with non-usm_array type #1457

Hardcode84 opened this issue Oct 26, 2023 · 1 comment · Fixed by #1460

Comments

@Hardcode84
Copy link

  File "C:\Users\Vano\miniconda3\envs\dpcomp-env-intel\lib\site-packages\dpctl\tensor\_copy_utils.py", line 183, in asnumpy
    return _copy_to_numpy(usm_ary)
  File "C:\Users\Vano\miniconda3\envs\dpcomp-env-intel\lib\site-packages\dpctl\tensor\_copy_utils.py", line 40, in _copy_to_numpy
    raise TypeError
TypeError

https://github.com/IntelPython/dpctl/blob/master/dpctl/tensor/_copy_utils.py#L40

@oleksandr-pavlyk
Copy link
Contributor

Reproducer:

import dpctl.tensor as dpt
# raises unhelpful TypeError with empty message
dpt.asnumpy([1,2,3])

oleksandr-pavlyk added a commit that referenced this issue Oct 28, 2023
Closes gh-1457

```

In [1]: import dpctl.tensor as dpt

In [2]: dpt.asnumpy([1,2,3])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 dpt.asnumpy([1,2,3])

File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:185, in asnumpy(usm_ary)
    169 def asnumpy(usm_ary):
    170     """
    171     asnumpy(usm_ary)
    172
   (...)
    183             of `usm_ary`
    184     """
--> 185     return _copy_to_numpy(usm_ary)

File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:40, in _copy_to_numpy(ary)
     38 def _copy_to_numpy(ary):
     39     if not isinstance(ary, dpt.usm_ndarray):
---> 40         raise TypeError(
     41             f"Expected dpctl.tensor.usm_ndarray, got {type(ary)}"
     42         )
     43     nb = ary.usm_data.nbytes
     44     hh = dpm.MemoryUSMHost(nb, queue=ary.sycl_queue)

TypeError: Expected dpctl.tensor.usm_ndarray, got <class 'list'>

In [3]: quit
```
ndgrigorian pushed a commit that referenced this issue Oct 31, 2023
Closes gh-1457

```

In [1]: import dpctl.tensor as dpt

In [2]: dpt.asnumpy([1,2,3])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 dpt.asnumpy([1,2,3])

File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:185, in asnumpy(usm_ary)
    169 def asnumpy(usm_ary):
    170     """
    171     asnumpy(usm_ary)
    172
   (...)
    183             of `usm_ary`
    184     """
--> 185     return _copy_to_numpy(usm_ary)

File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:40, in _copy_to_numpy(ary)
     38 def _copy_to_numpy(ary):
     39     if not isinstance(ary, dpt.usm_ndarray):
---> 40         raise TypeError(
     41             f"Expected dpctl.tensor.usm_ndarray, got {type(ary)}"
     42         )
     43     nb = ary.usm_data.nbytes
     44     hh = dpm.MemoryUSMHost(nb, queue=ary.sycl_queue)

TypeError: Expected dpctl.tensor.usm_ndarray, got <class 'list'>

In [3]: quit
```
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 a pull request may close this issue.

2 participants