Skip to content

Commit 9309367

Browse files
committed
Add docstrings to LocalAccessor
Also improve messages in errors
1 parent c6f4485 commit 9309367

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

dpctl/_sycl_queue.pyx

+40-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,41 @@ cdef class kernel_arg_type_attribute:
123123

124124

125125
cdef class LocalAccessor:
126+
"""
127+
LocalAccessor(ndim, dtype, dim0, dim1, dim2)
128+
129+
Python class for specifying the dimensionality and type of a
130+
``sycl::local_accessor``, to be used as a kernel argument type.
131+
132+
Args:
133+
ndim (size_t):
134+
number of dimensions.
135+
Can be between one and three.
136+
dtype (str):
137+
the data type of the local memory.
138+
The permitted values are
139+
140+
`'i1'`, `'i2'`, `'i4'`, `'i8'`:
141+
signed integral types int8_t, int16_t, int32_t, int64_t
142+
`'u1'`, `'u2'`, `'u4'`, `'u8'`
143+
unsigned integral types uint8_t, uint16_t, uint32_t,
144+
uint64_t
145+
`'f4'`, `'f8'`,
146+
single- and double-precision floating-point types float and
147+
double
148+
dim0 (size_t):
149+
Size of the first dimension.
150+
dim1 (size_t):
151+
Size of the second dimension.
152+
dim2 (size_t):
153+
Size of the third dimension.
154+
155+
Raises:
156+
ValueError:
157+
If the given dimension is not between one and three.
158+
ValueError:
159+
If the dtype string is unrecognized.
160+
"""
126161
cdef _md_local_accessor lacc
127162

128163
def __cinit__(self, size_t ndim, str dtype, size_t dim0, size_t dim1, size_t dim2):
@@ -132,7 +167,7 @@ cdef class LocalAccessor:
132167
self.lacc.dim2 = dim2
133168

134169
if ndim < 1 or ndim > 3:
135-
raise ValueError
170+
raise ValueError("LocalAccessor must have dimension between one and three")
136171
if dtype == 'i1':
137172
self.lacc.dpctl_type_id = _arg_data_type._INT8_T
138173
elif dtype == 'u1':
@@ -160,6 +195,10 @@ cdef class LocalAccessor:
160195
return "LocalAccessor(" + self.ndim + ")"
161196

162197
cdef size_t addressof(self):
198+
"""
199+
Returns the address of the _md_local_accessor for this LocalAccessor
200+
cast to ``size_t``.
201+
"""
163202
return <size_t>&self.lacc
164203

165204

0 commit comments

Comments
 (0)