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

usm_ndarray.T returns incorrect value after slicing #649

Closed
densmirn opened this issue Nov 2, 2021 · 1 comment · Fixed by #653
Closed

usm_ndarray.T returns incorrect value after slicing #649

densmirn opened this issue Nov 2, 2021 · 1 comment · Fixed by #653
Assignees

Comments

@densmirn
Copy link
Contributor

densmirn commented Nov 2, 2021

Reproducer:

import dpctl.tensor as dpt

n, m = 2, 3
shape = (n, m)
a = dpt.usm_ndarray(shape)

for i in range(n):
    for j in range(m):
        a[i][j] = i * m + j

a0 = a[:1]
a1 = a[1:]

print("a =", dpt.to_numpy(a))

print("a0 =", dpt.to_numpy(a0))
print("a1 =", dpt.to_numpy(a1))

print("a0.T =", dpt.to_numpy(a0.T))
print("a1.T =", dpt.to_numpy(a1.T))

print("a0.descr =", a0.__sycl_usm_array_interface__)
print("a1.descr =", a1.__sycl_usm_array_interface__)

print("a0.T.descr =", a0.T.__sycl_usm_array_interface__)
print("a1.T.descr =", a1.T.__sycl_usm_array_interface__)

Output:

a = [[0. 1. 2.]
 [3. 4. 5.]]
a0 = [[0. 1. 2.]]
a1 = [[3. 4. 5.]]
a0.T = [[0.]
 [1.]
 [2.]]
a1.T = [[0.]
 [1.]
 [2.]]
a0.descr = {'data': (18446697166937128960, True), 'shape': (1, 3), 'strides': (3, 1), 'typestr': '|f8', 'version': 1, 'syclobj': <dpctl.SyclQueue at 0x7f9405279980>, 'offset': 0}
a1.descr = {'data': (18446697166937128960, True), 'shape': (1, 3), 'strides': (3, 1), 'typestr': '|f8', 'version': 1, 'syclobj': <dpctl.SyclQueue at 0x7f9405279980>, 'offset': 3}
a0.T.descr = {'data': (18446697166937128960, True), 'shape': (3, 1), 'strides': (1, 3), 'typestr': '|f8', 'version': 1, 'syclobj': <dpctl.SyclQueue at 0x7f9405279980>, 'offset': 0}
a1.T.descr = {'data': (18446697166937128960, True), 'shape': (3, 1), 'strides': (1, 3), 'typestr': '|f8', 'version': 1, 'syclobj': <dpctl.SyclQueue at 0x7f9405279980>, 'offset': 0}

dpctl of version:
dpctl 0.11.0rc2 py39hbd01409_0 http://satpkgserver.an.intel.com:8081

@oleksandr-pavlyk
Copy link
Collaborator

After parsing which part of the reproducer asserts an error, the report states that a1.T is at fault:

In [8]: dpt.to_numpy(a)[1:].T
Out[8]:
array([[3.],
       [4.],
       [5.]])

In [9]: dpt.to_numpy(a[1:].T)
Out[9]:
array([[0.],
       [1.],
       [2.]])

oleksandr-pavlyk added a commit that referenced this issue Nov 3, 2021
```

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

In [2]: a = dpt.usm_ndarray((2,3))

In [3]: for i,j in itertools.product(range(2), range(3)): a[i, j] = i*3 + j

In [4]: dpt.to_numpy(a)[1:].T
Out[4]:
array([[3.],
       [4.],
       [5.]])

In [5]: dpt.to_numpy(a[1:].T)
Out[5]:
array([[3.],
       [4.],
       [5.]])

```
oleksandr-pavlyk added a commit that referenced this issue Nov 3, 2021
These were similar to those reported in #649
@oleksandr-pavlyk oleksandr-pavlyk self-assigned this Nov 3, 2021
oleksandr-pavlyk added a commit that referenced this issue Nov 8, 2021
* Fixes #649

```

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

In [2]: a = dpt.usm_ndarray((2,3))

In [3]: for i,j in itertools.product(range(2), range(3)): a[i, j] = i*3 + j

In [4]: dpt.to_numpy(a)[1:].T
Out[4]:
array([[3.],
       [4.],
       [5.]])

In [5]: dpt.to_numpy(a[1:].T)
Out[5]:
array([[3.],
       [4.],
       [5.]])

```

* Fixed issues with `.real` and `.imag` of usm_ndarray

These were similar to those reported in #649

* Added tests for T, real, imag methods of the object inspired by #649
@PokhodenkoSA PokhodenkoSA mentioned this issue Nov 24, 2021
2 tasks
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