Skip to content

Commit af32cbd

Browse files
fix diff function (#966)
1 parent 0254f47 commit af32cbd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

dpnp/dpnp_algo/dpnp_algo_mathematical.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ cpdef object dpnp_diff(utils.dpnp_descriptor input, int n):
196196
for i in range(arr.size):
197197
if counter < size_idx:
198198
counter += 1
199-
arr_elem = arr.item(i + 1) - arr.item(i)
199+
arr_elem = arr[numpy.unravel_index(i + 1, arr.shape)] - arr[numpy.unravel_index(i, arr.shape)]
200200
res.append(arr_elem)
201201
else:
202202
counter = 0

dpnp/dpnp_iface.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import dpnp.config as config
4747
import collections
4848

49+
import dpctl
50+
4951
from dpnp.dpnp_algo import *
5052
from dpnp.dpnp_utils import *
5153
from dpnp.fft import *
@@ -134,8 +136,7 @@ def asnumpy(input, order='C'):
134136
135137
"""
136138
if config.__DPNP_OUTPUT_DPCTL__ and hasattr(input, "__sycl_usm_array_interface__"):
137-
strides = (x * input.itemsize for x in input.strides)
138-
return np_st.as_strided(input.usm_data.copy_to_host().view(input.dtype), shape=input.shape, strides=strides)
139+
return dpctl.tensor.to_numpy(input)
139140

140141
return numpy.asarray(input, order=order)
141142

0 commit comments

Comments
 (0)