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
Add test coverage
  • Loading branch information
antonwolfy committed Jan 15, 2025
commit b950e842c72dd1ee0a47e3b83c66fbbbc935d149
58 changes: 43 additions & 15 deletions dpnp/tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,23 +1932,51 @@ def test_svd(shape, full_matrices, compute_uv, device):
assert_sycl_queue_equal(dpnp_s_queue, expected_queue)


@pytest.mark.parametrize(
"device_from",
valid_devices,
ids=[device.filter_string for device in valid_devices],
)
@pytest.mark.parametrize(
"device_to",
valid_devices,
ids=[device.filter_string for device in valid_devices],
)
def test_to_device(device_from, device_to):
data = [1.0, 1.0, 1.0, 1.0, 1.0]
class TestToDevice:
@pytest.mark.parametrize(
"device_from",
valid_devices,
ids=[device.filter_string for device in valid_devices],
)
@pytest.mark.parametrize(
"device_to",
valid_devices,
ids=[device.filter_string for device in valid_devices],
)
def test_basic(self, device_from, device_to):
data = [1.0, 1.0, 1.0, 1.0, 1.0]
x = dpnp.array(data, dtype=dpnp.float32, device=device_from)

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

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_sycl_queue_equal(y.sycl_queue, q_prof)

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

y = x.to_device(q_prof, stream=q_exec)
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_sycl_queue_equal(y.sycl_queue, q_prof)
Comment thread
antonwolfy marked this conversation as resolved.

x = dpnp.array(data, dtype=dpnp.float32, device=device_from)
y = x.to_device(device_to)
def test_stream_no_sync(self):
x = dpnp.full(100, 2, dtype=dpnp.int64)
q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling")

assert y.sycl_device == device_to
for stream in [None, 1, dpctl.SyclDevice(), x.sycl_queue]:
Comment thread
antonwolfy marked this conversation as resolved.
Outdated
y = x.to_device(q_prof, stream=stream)
assert_sycl_queue_equal(y.sycl_queue, q_prof)


@pytest.mark.parametrize(
Expand Down