Skip to content

Commit 6579e6b

Browse files
Data members renamed, accessors added
Data members are renamed to reflect their internal status, since some of them are read-accessible from Python. Cython visible field accessors added to retrieve their value. Made usm_ndarray weak-referenceable https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#making-extension-types-weak-referenceable
1 parent 3fb04d2 commit 6579e6b

File tree

2 files changed

+191
-99
lines changed

2 files changed

+191
-99
lines changed

dpctl/tensor/_usmarray.pxd

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
11
# distutils: language = c++
22
# cython: language_level=3
33

4+
cimport dpctl
5+
6+
47
cdef public int USM_ARRAY_C_CONTIGUOUS
58
cdef public int USM_ARRAY_F_CONTIGUOUS
69
cdef public int USM_ARRAY_WRITEABLE
710

811

912
cdef public class usm_ndarray [object PyUSMArrayObject, type PyUSMArrayType]:
10-
cdef char* data
11-
cdef int nd
12-
cdef Py_ssize_t *shape
13-
cdef Py_ssize_t *strides
14-
cdef int typenum
15-
cdef int flags
16-
cdef object base
13+
# data fields
14+
cdef char* data_
15+
cdef readonly int nd_
16+
cdef Py_ssize_t *shape_
17+
cdef Py_ssize_t *strides_
18+
cdef readonly int typenum_
19+
cdef readonly int flags_
20+
cdef readonly object base_
21+
# make usm_ndarray weak-referenceable
22+
cdef object __weakref__
1723

1824
cdef void _reset(usm_ndarray self)
1925
cdef void _cleanup(usm_ndarray self)
2026
cdef usm_ndarray _clone(usm_ndarray self)
2127
cdef Py_ssize_t get_offset(usm_ndarray self) except *
2228

29+
cdef char* get_data(self)
30+
cdef int get_ndim(self)
31+
cdef Py_ssize_t * get_shape(self)
32+
cdef Py_ssize_t * get_strides(self)
33+
cdef int get_typenum(self)
34+
cdef int get_itemsize(self)
35+
cdef int get_flags(self)
36+
cdef object get_base(self)
37+
cdef dpctl.DPCTLSyclQueueRef get_queue_ref(self) except *
38+
cdef dpctl.SyclQueue get_sycl_queue(self)
39+
2340
cdef __cythonbufferdefaults__ = {"mode": "strided"}

0 commit comments

Comments
 (0)