Skip to content

usm_ndarray.T returns incorrect value after slicing #649

Closed

Description

@densmirn

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

Activity

  1. oleksandr-pavlyk commented on Nov 3, 2021

    @oleksandr-pavlyk
    Contributor

    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.]])
    
  2. added 3 commits that reference this issue on Nov 3, 2021
    e2185e9
    b1a1b50
    d8c670a
  3. added a commit that references this issue on Nov 8, 2021
    9b04a9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions