34
34
],
35
35
)
36
36
def 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" )
38
41
X = dpt .empty (10 , dtype = "u1" , usm_type = src_usm_type )
39
42
Y = dpt .asarray (X , usm_type = dst_usm_type )
40
43
assert X .shape == Y .shape
@@ -61,7 +64,10 @@ def test_asarray_change_usm_type(src_usm_type, dst_usm_type):
61
64
62
65
def test_asarray_from_numpy ():
63
66
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" )
65
71
assert type (Y ) is dpt .usm_ndarray
66
72
assert Y .shape == Xnp .shape
67
73
assert Y .dtype == Xnp .dtype
@@ -81,7 +87,10 @@ def test_asarray_from_numpy():
81
87
82
88
def test_asarray_from_sequence ():
83
89
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" )
85
94
assert type (Y ) is dpt .usm_ndarray
86
95
87
96
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):
114
123
self .obj = obj
115
124
self .__sycl_usm_array_interface__ = iface
116
125
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" )
118
130
Y = dpt .asarray (Dummy (X , X .__sycl_usm_array_interface__ ))
119
131
assert Y .shape == X .shape
120
132
assert X .usm_type == Y .usm_type
@@ -141,9 +153,14 @@ def test_asarray_input_validation():
141
153
with pytest .raises (ValueError ):
142
154
# usm_type has wrong value
143
155
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
144
161
with pytest .raises (TypeError ):
145
162
# sycl_queue type is not right
146
- dpt .asarray ([1 ], sycl_queue = dpctl . SyclContext () )
163
+ dpt .asarray ([1 ], sycl_queue = wrong_queue_type )
147
164
with pytest .raises (ValueError ):
148
165
# sequence is not rectangular
149
166
dpt .asarray ([[1 ], 2 ])
@@ -170,7 +187,10 @@ def test_asarray_input_validation2():
170
187
def test_asarray_scalars ():
171
188
import ctypes
172
189
173
- Y = dpt .asarray (5 )
190
+ try :
191
+ Y = dpt .asarray (5 )
192
+ except dpctl .SyclDeviceCreationError :
193
+ pytest .skip ("No SYCL devices available" )
174
194
assert Y .dtype == dpt .dtype (int )
175
195
Y = dpt .asarray (5.2 )
176
196
if Y .sycl_device .has_aspect_fp64 :
0 commit comments