You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
from_dlpack raises unexpected error on strided dpctl.tensor.usm_ndarray input #1071
In [13]: x_dpt = dpt.reshape(dpt.arange(4*30),(10,12))[::2,::-2]
In [14]: x_dpt.shape, x_dpt.strides, x_dpt.__sycl_usm_array_interface__['offset']
Out[14]: ((5, 6), (24, -2), 11)
In [15]: dpt.from_dlpack(x_dpt)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [15], in <cell line: 1>()
----> 1 dpt.from_dlpack(x_dpt)
File ~/repos/dpctl/dpctl/tensor/_dlpack.pyx:449, in dpctl.tensor._dlpack.from_dlpack()
File ~/repos/dpctl/dpctl/tensor/_dlpack.pyx:499, in dpctl.tensor._dlpack.from_dlpack()
File ~/repos/dpctl/dpctl/tensor/_dlpack.pyx:435, in dpctl.tensor._dlpack.from_dlpack_capsule()
File ~/repos/dpctl/dpctl/tensor/_usmarray.pyx:257, in dpctl.tensor._usmarray.usm_ndarray.__cinit__()
ValueError: buffer='<SYCL(TM) USM-device allocation of 856 bytes at 0xffffb80200020400>' can not accomodate the requested array.
The code apparently does not take into account non-zero offset correctly, since strided input with zero offset works fine:
Activity
Fixes gh-1071
Extended test_usm_ndarray_dlpack with example from gh-1071