Skip to content

Commit df8c1f3

Browse files
Add tests to_device method with stream keyword arg
1 parent 5025510 commit df8c1f3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,30 @@ def test_to_device():
13801380
assert Y.sycl_device == dev
13811381

13821382

1383+
def test_to_device_stream_validation():
1384+
try:
1385+
X = dpt.usm_ndarray(1, "f4")
1386+
except dpctl.SyclDeviceCreationError:
1387+
pytest.skip("No SYCL devices available")
1388+
# invalid type of stream keyword
1389+
with pytest.raises(TypeError):
1390+
X.to_device(X.sycl_queue, stream=dict())
1391+
# stream is keyword-only arg
1392+
with pytest.raises(TypeError):
1393+
X.to_device(X.sycl_queue, X.sycl_queue)
1394+
1395+
1396+
def test_to_device_stream_use():
1397+
try:
1398+
X = dpt.usm_ndarray(1, "f4")
1399+
except dpctl.SyclDeviceCreationError:
1400+
pytest.skip("No SYCL devices available")
1401+
q1 = dpctl.SyclQueue(
1402+
X.sycl_context, X.sycl_device, property="enable_profiling"
1403+
)
1404+
X.to_device(q1, stream=q1)
1405+
1406+
13831407
def test_to_device_migration():
13841408
q1 = get_queue_or_skip() # two distinct copies of default-constructed queue
13851409
q2 = get_queue_or_skip()

0 commit comments

Comments
 (0)