Skip to content

Commit b887a26

Browse files
Merge pull request #435 from IntelPython/usm-array-accessors
Data members renamed, accessors added
2 parents 3fb04d2 + b4a2ad2 commit b887a26

File tree

3 files changed

+196
-99
lines changed

3 files changed

+196
-99
lines changed

dpctl/tensor/_slicing.pxi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import numbers
2020
cdef object _basic_slice_meta(object ind, tuple shape,
2121
tuple strides, Py_ssize_t offset):
2222
"""
23+
Give basic slicing index `ind` and array layout information produce
24+
a tuple (resulting_shape, resulting_strides, resultin_offset)
25+
used to contruct a view into underlying array.
2326
27+
Raises IndexError for invalid index `ind`, and NotImplementedError
28+
if `ind` is an array.
2429
"""
2530
if ind is Ellipsis:
2631
return (shape, strides, offset)

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)