Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Mar 14, 2024
1 parent 1af45c4 commit 054a41b
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ def change_values_1d(item: Item, x, v):
i = item.get_id(0)
x[i] = v

@exp_dpex.kernel
def change_values_1d_dbg(item: Item, x, dbg, v):
"""Assign values in a 1d dpnp.ndarray
Args:
x (dpnp.ndarray): Input array.
v (int): Value to be assigned.
"""
i = item.get_id(0)
x[i] = v
# dbg[i] = v.strides[0]
dbg[i] = 1


def change_values_1d_func(a, p):
"""Assign values in a 1d numpy.ndarray
Expand Down Expand Up @@ -122,15 +135,20 @@ def test_1d_strided_dpnp_array_in_kernel(s):
u = dpnp.asarray(t)

v = u[::s]
print(v.strides)
print(u)
print(v)
exp_dpex.call_kernel(change_values_1d, Range(v.shape[0]), v, k)
dbg = dpnp.zeros(v.size, dtype=dpnp.int64)
exp_dpex.call_kernel(change_values_1d_dbg, Range(v.shape[0]), v, dbg, k)
# v[0]=-1
print(dbg)

x = t[::s]
change_values_1d_func(x, k)
print(x)
print(t)
print(u)
print(v)

# check the value of the array view
# assert np.all(dpnp.asnumpy(v) == x)
Expand Down

0 comments on commit 054a41b

Please sign in to comment.