-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
It looks there is prohibited to use slice indexing while initialize dpctl usm_ndarray
array which was built with self-overlapping strides:
import numpy, dpctl, dpctl.tensor as dpt
dpctl.__version__
# Out: '0.18.0dev0+158.g7450558d25'
b = dpt.usm_ndarray(20, numpy.uint8)
# self-overlapping strides
a = dpt.usm_ndarray((2, 3), numpy.float32, buffer=b, strides=(2, 1))
a[:] = 1
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File dpctl/tensor/_usmarray.pyx:1337, in dpctl.tensor._usmarray.usm_ndarray.__setitem__()
File ~/miniforge3/envs/dpnp_dev/lib/python3.11/site-packages/dpctl/tensor/_copy_utils.py:113, in _copy_from_numpy_into(dst, np_ary)
112 # synchronizing call
--> 113 ti._copy_numpy_ndarray_into_usm_ndarray(
114 src=src_ary, dst=dst, sycl_queue=copy_q, depends=dep_ev
115 )
ValueError: Memory addressed by the output array is not sufficiently ample.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[23], line 1
----> 1 a[:] = 1
File dpctl/tensor/_usmarray.pyx:1339, in dpctl.tensor._usmarray.usm_ndarray.__setitem__()
ValueError: Input of type <class 'int'> could not be copied into dpctl.tensor.usm_ndarray
# that works fine:
a[0, 2] = 1
# works for numpy
b = numpy.ndarray(20, numpy.uint8)
# self-overlapping strides
a = numpy.ndarray((2, 3), numpy.float32, buffer=b, strides=(8, 4))
a[:] = 1
Metadata
Metadata
Assignees
Labels
No labels