Skip to content

Commit

Permalink
added test based on example from #583
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk committed Sep 11, 2021
1 parent 7666803 commit 0fe8333
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import pytest

import dpctl

# import dpctl.memory as dpmem
import dpctl.memory as dpm
import dpctl.tensor as dpt
from dpctl.tensor._usmarray import Device

Expand Down Expand Up @@ -224,3 +223,14 @@ def test_slice_constructor_3d():
assert np.array_equal(
_to_numpy(Xusm[ind]), Xh[ind]
), "Failed for {}".format(ind)


@pytest.mark.parametrize("usm_type", ["device", "shared", "host"])
def test_slice_suai(usm_type):
Xh = np.arange(0, 10, dtype="u1")
default_device = dpctl.select_default_device()
Xusm = _from_numpy(Xh, device=default_device, usm_type=usm_type)
for ind in [slice(2, 3, None), slice(5, 7, None), slice(3, 9, None)]:
assert np.array_equal(
dpm.as_usm_memory(Xusm[ind]).copy_to_host(), Xh[ind]
), "Failed for {}".format(ind)

0 comments on commit 0fe8333

Please sign in to comment.