Closed
Description
The below example raised an exception:
import numpy, dpctl, dpctl.tensor as dpt
dpctl.__version__
# Out: '0.20.0dev0+139.gf3b70eda45'
def func(x):
axes = [2, 0, 1]
x = dpt.permute_dims(x, axes)
sh = [4, 2, 3]
return dpt.reshape(x, sh)
def test():
a = dpt.ones((2, 3, 4), dtype=numpy.ulonglong)
r0 = func(a)
r1 = func(a)
mask = (dpt.asnumpy(r1) >= 0)
r0[dpt.asarray(mask)]
test()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File dpctl/tensor/_usmarray.pyx:1425, in dpctl.tensor._usmarray.usm_ndarray.__setitem__()
File ~/miniforge3/envs/dpnp_dev/lib/python3.12/site-packages/dpctl/tensor/_copy_utils.py:114, in _copy_from_numpy_into(dst, np_ary)
113 # synchronizing call
--> 114 ti._copy_numpy_ndarray_into_usm_ndarray(
115 src=src_ary, dst=dst, sycl_queue=copy_q, depends=dep_ev
116 )
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[7], line 1
----> 1 test()
Cell In[6], line 6, in test()
4 r1 = func(a)
5 mask = (dpt.asnumpy(r1) >= 0)
----> 6 r0[dpt.asarray(mask)]
File ~/miniforge3/envs/dpnp_dev/lib/python3.12/site-packages/dpctl/tensor/_ctors.py:612, in asarray(obj, dtype, device, copy, usm_type, sycl_queue, order)
608 if copy is False:
609 raise ValueError(
610 "Converting numpy.ndarray to usm_ndarray requires a copy"
611 )
--> 612 return _asarray_from_numpy_ndarray(
613 obj,
614 dtype=dtype,
615 usm_type=usm_type,
616 sycl_queue=sycl_queue,
617 order=order,
618 )
619 if _is_object_with_buffer_protocol(obj):
620 if copy is False:
File ~/miniforge3/envs/dpnp_dev/lib/python3.12/site-packages/dpctl/tensor/_ctors.py:273, in _asarray_from_numpy_ndarray(ary, dtype, usm_type, sycl_queue, order)
265 _ensure_native_dtype_device_support(dtype, copy_q.sycl_device)
266 res = dpt.usm_ndarray(
267 ary.shape,
268 dtype=dtype,
(...) 271 buffer_ctor_kwargs={"queue": copy_q},
272 )
--> 273 res[...] = ary
274 return res
File dpctl/tensor/_usmarray.pyx:1427, in dpctl.tensor._usmarray.usm_ndarray.__setitem__()
ValueError: Input of type <class 'numpy.ndarray'> could not be copied into dpctl.tensor.usm_ndarray