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

dpctl.tensor.asarray must support sequences of usm_ndarrays #1134

Closed
oleksandr-pavlyk opened this issue Mar 22, 2023 · 0 comments · Fixed by #1139
Closed

dpctl.tensor.asarray must support sequences of usm_ndarrays #1134

oleksandr-pavlyk opened this issue Mar 22, 2023 · 0 comments · Fixed by #1139
Assignees
Labels
bug Something isn't working tensor

Comments

@oleksandr-pavlyk
Copy link
Collaborator

oleksandr-pavlyk commented Mar 22, 2023

An example where this arises naturally is

   x = dpt.arange(3)
   dpt.asarray([
       x[0], x[1], x[2]
   ])

It would arise even more naturally with addition of dpt.unstack where it would be as simple as dpt.asarray( dpt.unstack(x)).

The present work-around is to use dpt.stack:

In [13]: x = dpt.arange(5)

In [14]: dpt.stack([ x[i] for i in range(x.shape[0])])
Out[14]: usm_ndarray([0, 1, 2, 3, 4])
@oleksandr-pavlyk oleksandr-pavlyk self-assigned this Mar 22, 2023
@oleksandr-pavlyk oleksandr-pavlyk added tensor bug Something isn't working labels Mar 22, 2023
oleksandr-pavlyk added a commit that referenced this issue Mar 27, 2023
Examples:

```
import dpctl.tensor as dpt

m = dpt.ones((2,4), dtype='i4')
w = dpt.zeros(4)
v = dpt.full(4, -1)

ar = dpt.asarray([m, [w, v]])
ar2 = dpt.asarray([m, [w, v]], device='cpu')
```
oleksandr-pavlyk added a commit that referenced this issue Mar 29, 2023
Examples:

```
import dpctl.tensor as dpt

m = dpt.ones((2,4), dtype='i4')
w = dpt.zeros(4)
v = dpt.full(4, -1)

ar = dpt.asarray([m, [w, v]])
ar2 = dpt.asarray([m, [w, v]], device='cpu')
```
oleksandr-pavlyk added a commit that referenced this issue Mar 29, 2023
Examples:

```
import dpctl.tensor as dpt

m = dpt.ones((2,4), dtype='i4')
w = dpt.zeros(4)
v = dpt.full(4, -1)

ar = dpt.asarray([m, [w, v]])
ar2 = dpt.asarray([m, [w, v]], device='cpu')
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tensor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant