Skip to content

Commit 7a71627

Browse files
author
Diptorup Deb
committed
Fix stride computation when unboxing a dpnp array.
1 parent c630052 commit 7a71627

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

numba_dpex/core/runtime/_dpexrt_python.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
731731
arystruct_t *arystruct)
732732
{
733733
struct PyUSMArrayObject *arrayobj = NULL;
734-
int i = 0, ndim = 0, exp = 0;
734+
int i = 0, j = 0, k = 0, ndim = 0, exp = 0;
735735
npy_intp *shape = NULL, *strides = NULL;
736736
npy_intp *p = NULL, nitems;
737737
void *data = NULL;
@@ -812,10 +812,12 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
812812
}
813813
}
814814
else {
815-
for (i = 1; i < ndim; ++i, ++p) {
816-
*p = shape[i] << exp;
815+
for (i = ndim * 2 - 1; i >= ndim; --i, ++p) {
816+
*p = 1;
817+
for (j = i, k = ndim - 1; j > ndim; --j, --k)
818+
*p *= shape[k];
819+
*p <<= exp;
817820
}
818-
*p = 1;
819821
}
820822

821823
return 0;

0 commit comments

Comments
 (0)