Skip to content

usm_ndarray.T returns incorrect value after slicing #649

Closed
@densmirn

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

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