Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests for dpnp.to_device
  • Loading branch information
antonwolfy committed Jan 17, 2025
commit 6a33f0d2d13c810d833d98dbfeaee9c8d96af4c3
17 changes: 16 additions & 1 deletion dpnp/tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -1949,12 +1949,14 @@ def test_basic(self, device_from, device_to):

y = x.to_device(device_to)
assert y.sycl_device == device_to
Comment thread
antonwolfy marked this conversation as resolved.
assert (x.asnumpy() == y.asnumpy()).all()

def test_to_queue(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")

y = x.to_device(q_prof)
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

def test_stream(self):
Expand All @@ -1963,21 +1965,34 @@ def test_stream(self):
q_exec = dpctl.SyclQueue(x.sycl_device)

y = x.to_device(q_prof, stream=q_exec)
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

q_exec = dpctl.SyclQueue(x.sycl_device)
_ = dpnp.linspace(0, 20, num=10**5, sycl_queue=q_exec)
y = x.to_device(q_prof, stream=q_exec)
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)
Comment thread
antonwolfy marked this conversation as resolved.

def test_stream_no_sync(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")

for stream in [None, 1, dpctl.SyclDevice(), x.sycl_queue]:
for stream in [None, x.sycl_queue]:
y = x.to_device(q_prof, stream=stream)
assert (x.asnumpy() == y.asnumpy()).all()
assert_sycl_queue_equal(y.sycl_queue, q_prof)

@pytest.mark.parametrize(
"stream",
[1, dict(), dpctl.SyclDevice()],
ids=["scalar", "dictionary", "device"],
)
def test_invalid_stream(self, stream):
x = dpnp.ones(2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")
assert_raises(TypeError, x.to_device, q_prof, stream=stream)


@pytest.mark.parametrize(
"device",
Expand Down