Closed
Description
An example code below works fine with numpy but fails in dpctl:
import numpy, dpctl.tensor as dpt
ndim = 32
idx = [1]*ndim
idx[-1] = ndim
a = numpy.ones(ndim)
a = a.reshape(idx)
d = dpt.ones(ndim)
d = dpt.reshape(d, idx)
Out:
ValueError Traceback (most recent call last)
Cell In[15], line 1
----> 1 d = dpt.reshape(d, idx)
File /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_reshape.py:131, in reshape(X, shape, order, copy)
129 raise ValueError(f"Can not reshape into {shape}")
130 if X.size:
--> 131 newsts = reshaped_strides(X.shape, X.strides, shape, order=order)
132 else:
133 newsts = (1,) * len(shape)
File /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_reshape.py:53, in reshaped_strides(old_sh, old_sts, new_sh, order)
40 """
41 When reshaping array with `old_sh` shape and `old_sts` strides
42 into the new shape `new_sh`, returns the new stride if the reshape
43 can be a view, otherwise returns `None`.
44 """
45 eye_new_mi = _make_unit_indexes(new_sh)
46 new_sts = [
47 sum(
48 st_i * ind_i
49 for st_i, ind_i in zip(
50 old_sts, np.unravel_index(flat_index, old_sh, order=order)
51 )
52 )
---> 53 for flat_index in [
54 np.ravel_multi_index(unitvec, new_sh, order=order)
55 for unitvec in eye_new_mi
56 ]
57 ]
58 eye_old_mi = _make_unit_indexes(old_sh)
59 check_sts = [
60 sum(
61 st_i * ind_i
(...)
69 ]
70 ]
File /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_reshape.py:54, in <listcomp>(.0)
40 """
41 When reshaping array with `old_sh` shape and `old_sts` strides
42 into the new shape `new_sh`, returns the new stride if the reshape
43 can be a view, otherwise returns `None`.
44 """
45 eye_new_mi = _make_unit_indexes(new_sh)
46 new_sts = [
47 sum(
48 st_i * ind_i
49 for st_i, ind_i in zip(
50 old_sts, np.unravel_index(flat_index, old_sh, order=order)
51 )
52 )
53 for flat_index in [
---> 54 np.ravel_multi_index(unitvec, new_sh, order=order)
55 for unitvec in eye_new_mi
56 ]
57 ]
58 eye_old_mi = _make_unit_indexes(old_sh)
59 check_sts = [
60 sum(
61 st_i * ind_i
(...)
69 ]
70 ]
File <__array_function__ internals>:180, in ravel_multi_index(*args, **kwargs)
ValueError: too many dimensions passed to ravel_multi_index
There is no issue in dpctl with ndim=31
.
Metadata
Metadata
Assignees
Labels
No labels