12
12
from numba .core .types .npytypes import Array
13
13
from numba .np .numpy_support import from_dtype
14
14
15
+ from numba_dpex .core .types .dpctl_types import DpctlSyclQueue
15
16
from numba_dpex .utils import address_space
16
17
17
18
@@ -31,15 +32,10 @@ def __init__(
31
32
aligned = True ,
32
33
addrspace = address_space .GLOBAL ,
33
34
):
34
- if not isinstance ( device , str ) :
35
+ if queue is not None and device != "unknown" :
35
36
raise TypeError (
36
- "The device keyword arg should be a str object specifying "
37
- "a SYCL filter selector"
38
- )
39
-
40
- if not isinstance (queue , dpctl .SyclQueue ) and queue is not None :
41
- raise TypeError (
42
- "The queue keyword arg should be a dpctl.SyclQueue object or None"
37
+ "numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
38
+ "`device` and `sycl_queue` are exclusive keywords, i.e. use one or other."
43
39
)
44
40
45
41
self .usm_type = usm_type
@@ -48,18 +44,28 @@ def __init__(
48
44
if device == "unknown" :
49
45
device = None
50
46
51
- if queue is not None and device is not None :
52
- raise TypeError (
53
- "'queue' and 'device' keywords can not be both specified"
54
- )
55
-
56
47
if queue is not None :
48
+ if not isinstance (queue , dpctl .SyclQueue ):
49
+ raise TypeError (
50
+ "numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
51
+ "The queue keyword arg should be a dpctl.SyclQueue object or None."
52
+ )
57
53
self .queue = queue
58
54
else :
59
55
if device is None :
60
- device = dpctl .SyclDevice ()
61
-
62
- self .queue = dpctl .get_device_cached_queue (device )
56
+ sycl_device = dpctl .SyclDevice ()
57
+ else :
58
+ if not isinstance (device , str ):
59
+ raise TypeError (
60
+ "numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
61
+ "The device keyword arg should be a str object specifying "
62
+ "a SYCL filter selector."
63
+ )
64
+ sycl_device = dpctl .SyclDevice (device )
65
+
66
+ self .queue = dpctl ._sycl_queue_manager .get_device_cached_queue (
67
+ sycl_device
68
+ )
63
69
64
70
self .device = self .queue .sycl_device .filter_string
65
71
0 commit comments