@@ -32,26 +32,36 @@ __all__ = ["get_execution_queue", "get_coerced_usm_type", "ExecutionPlacementErr
32
32
33
33
34
34
class ExecutionPlacementError (Exception ):
35
- """ Exception raised when execution placement target can be determined
36
- from input arrays.
35
+ """ Exception raised when execution placement target can not
36
+ be unambiguously determined from input arrays.
37
37
38
- Make sure that input arrays are associated with the same SyclQueue,
39
- or migrate data to the same SyclQueue using usm_ndarray.to_device
40
- method.
38
+ Make sure that input arrays are associated with the same
39
+ :class:`dpctl.SyclQueue`,
40
+ or migrate data to the same :class:`dpctl.SyclQueue` using
41
+ :meth:`dpctl.tensor.usm_ndarray.to_device` method.
41
42
"""
42
43
pass
43
44
44
45
45
46
cdef bint queue_equiv(SyclQueue q1, SyclQueue q2):
46
- """ Queues are equivalent if q1 == q2, that is they are copies
47
+ """ Queues are equivalent if `` q1 == q2`` , that is they are copies
47
48
of the same underlying SYCL object and hence are the same."""
48
49
return q1.__eq__ (q2)
49
50
50
51
51
52
def get_execution_queue (qs , /):
52
- """ Given a list of :class:`dpctl.SyclQueue` objects
53
- returns the execution queue under compute follows data paradigm,
54
- or returns `None` if queues are not equal.
53
+ """
54
+ Get execution queue from queues associated with input arrays.
55
+
56
+ Args:
57
+ qs (List[SyclQueue]):
58
+ a list or a tuple of :class:`dpctl.SyclQueue` objects
59
+ corresponding to arrays that are being combined.
60
+
61
+ Returns:
62
+ SyclQueue:
63
+ execution queue under compute follows data paradigm,
64
+ or ``None`` if queues are not equal.
55
65
"""
56
66
if not isinstance (qs, (list , tuple )):
57
67
raise TypeError (
@@ -72,10 +82,21 @@ def get_execution_queue(qs, /):
72
82
73
83
74
84
def get_coerced_usm_type (usm_types , /):
75
- """ Given a list of strings denoting the types of USM allocations
76
- for input arrays returns the type of USM allocation for the output
77
- array(s) per compute follows data paradigm.
78
- Returns `None` if the type can not be deduced."""
85
+ """
86
+ Get USM type of the output array for a function combining
87
+ arrays of given USM type using compute-follows-data execution
88
+ model.
89
+
90
+ Args:
91
+ usm_types (List[str]):
92
+ a list or a tuple of strings of ``.usm_types`` atributes
93
+ for input arrays
94
+
95
+ Returns:
96
+ str
97
+ type of USM allocation for the output arrays (s).
98
+ ``None`` if any of the input string is not recognized.
99
+ """
79
100
if not isinstance (usm_types, (list , tuple )):
80
101
raise TypeError (
81
102
" Expected a list or a tuple, got {}" .format(type (usm_types))
@@ -130,16 +151,24 @@ def validate_usm_type(usm_type, /, *, allow_none=True):
130
151
Args:
131
152
usm_type:
132
153
Specification for USM allocation type. Valid specifications
133
- are `"device"`, `"shared"`, or `"host"`. If `allow_none`
134
- keyword argument is set, a value of `None` is also permitted.
154
+ are:
155
+
156
+ * ``"device"``
157
+ * ``"shared"``
158
+ * ``"host"``
159
+
160
+ If ``allow_none`` keyword argument is set, a value of
161
+ ``None`` is also permitted.
135
162
allow_none (bool, optional):
136
- Whether `usm_type` value of `None` is considered valid.
163
+ Whether `` usm_type`` value of `` None` ` is considered valid.
137
164
Default: `True`.
138
165
139
166
Raises:
140
- ValueError: if `usm_type` is an unrecognized string.
141
- TypeError: if `usm_type` is not a string, and `usm_type` is not `None`
142
- provided `allow_none` is `True`.
167
+ ValueError:
168
+ if ``usm_type`` is not a recognized string.
169
+ TypeError:
170
+ if ``usm_type`` is not a string, and ``usm_type`` is
171
+ not ``None`` provided ``allow_none`` is ``True``.
143
172
"""
144
173
if allow_none:
145
174
_validate_usm_type_allow_none(usm_type)
0 commit comments