3434 ],
3535)
3636def test_asarray_change_usm_type (src_usm_type , dst_usm_type ):
37- d = dpctl .SyclDevice ()
37+ try :
38+ d = dpctl .SyclDevice ()
39+ except dpctl .SyclDeviceCreationError :
40+ pytest .skip ("No SYCL devices available" )
3841 X = dpt .empty (10 , dtype = "u1" , usm_type = src_usm_type )
3942 Y = dpt .asarray (X , usm_type = dst_usm_type )
4043 assert X .shape == Y .shape
@@ -61,7 +64,10 @@ def test_asarray_change_usm_type(src_usm_type, dst_usm_type):
6164
6265def test_asarray_from_numpy ():
6366 Xnp = np .arange (10 )
64- Y = dpt .asarray (Xnp , usm_type = "device" )
67+ try :
68+ Y = dpt .asarray (Xnp , usm_type = "device" )
69+ except dpctl .SyclDeviceCreationError :
70+ pytest .skip ("No SYCL devices available" )
6571 assert type (Y ) is dpt .usm_ndarray
6672 assert Y .shape == Xnp .shape
6773 assert Y .dtype == Xnp .dtype
@@ -81,7 +87,10 @@ def test_asarray_from_numpy():
8187
8288def test_asarray_from_sequence ():
8389 X = [1 , 2 , 3 ]
84- Y = dpt .asarray (X , usm_type = "device" )
90+ try :
91+ Y = dpt .asarray (X , usm_type = "device" )
92+ except dpctl .SyclDeviceCreationError :
93+ pytest .skip ("No SYCL devices available" )
8594 assert type (Y ) is dpt .usm_ndarray
8695
8796 X = [(1 , 1 ), (2.0 , 2.0 + 1.0j ), range (4 , 6 ), np .array ([3 , 4 ], dtype = "c16" )]
@@ -114,7 +123,10 @@ def __init__(self, obj, iface):
114123 self .obj = obj
115124 self .__sycl_usm_array_interface__ = iface
116125
117- X = dpt .empty ((2 , 3 , 4 ), dtype = "f4" )
126+ try :
127+ X = dpt .empty ((2 , 3 , 4 ), dtype = "f4" )
128+ except dpctl .SyclDeviceCreationError :
129+ pytest .skip ("No SYCL devices available" )
118130 Y = dpt .asarray (Dummy (X , X .__sycl_usm_array_interface__ ))
119131 assert Y .shape == X .shape
120132 assert X .usm_type == Y .usm_type
@@ -141,9 +153,14 @@ def test_asarray_input_validation():
141153 with pytest .raises (ValueError ):
142154 # usm_type has wrong value
143155 dpt .asarray ([1 ], usm_type = "mistake" )
156+ try :
157+ wrong_queue_type = dpctl .SyclContext ()
158+ except dpctl .SyclContextCreationError :
159+ # use any other type
160+ wrong_queue_type = Ellipsis
144161 with pytest .raises (TypeError ):
145162 # sycl_queue type is not right
146- dpt .asarray ([1 ], sycl_queue = dpctl . SyclContext () )
163+ dpt .asarray ([1 ], sycl_queue = wrong_queue_type )
147164 with pytest .raises (ValueError ):
148165 # sequence is not rectangular
149166 dpt .asarray ([[1 ], 2 ])
@@ -170,7 +187,10 @@ def test_asarray_input_validation2():
170187def test_asarray_scalars ():
171188 import ctypes
172189
173- Y = dpt .asarray (5 )
190+ try :
191+ Y = dpt .asarray (5 )
192+ except dpctl .SyclDeviceCreationError :
193+ pytest .skip ("No SYCL devices available" )
174194 assert Y .dtype == dpt .dtype (int )
175195 Y = dpt .asarray (5.2 )
176196 if Y .sycl_device .has_aspect_fp64 :
0 commit comments