-
Notifications
You must be signed in to change notification settings - Fork 26
Convert .pxi include files to .pxd/.pyx in dpnp/tensor #2913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ae9c548
e08ccbb
ec340fd
2ad80a8
bfb3bc2
af6227b
ef9c4f1
6debec8
48c96e6
4c1155c
0240b5f
a422032
e2e6b73
4ac3cb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # ***************************************************************************** | ||
| # Copyright (c) 2026, Intel Corporation | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # - Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # - Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # - Neither the name of the copyright holder nor the names of its contributors | ||
| # may be used to endorse or promote products derived from this software | ||
| # without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| # distutils: language = c++ | ||
| # cython: language_level=3 | ||
|
|
||
| cdef bint _is_buffer(object o) | ||
|
|
||
| cdef Py_ssize_t _slice_len( | ||
| Py_ssize_t sl_start, | ||
| Py_ssize_t sl_stop, | ||
| Py_ssize_t sl_step | ||
| ) | ||
|
|
||
| cdef bint _is_integral(object x) except * | ||
|
|
||
| cdef bint _is_boolean(object x) except * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,11 +26,15 @@ | |
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| import numbers | ||
| # distutils: language = c++ | ||
| # cython: language_level=3 | ||
|
|
||
| from operator import index | ||
| from cpython.buffer cimport PyObject_CheckBuffer | ||
| from numpy import ndarray | ||
|
|
||
| from ._usmarray cimport usm_ndarray | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not that produce a circular dependency? (_usmarray ↔ _slicing)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| cdef bint _is_buffer(object o): | ||
| return PyObject_CheckBuffer(o) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # ***************************************************************************** | ||
| # Copyright (c) 2026, Intel Corporation | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # - Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # - Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # - Neither the name of the copyright holder nor the names of its contributors | ||
| # may be used to endorse or promote products derived from this software | ||
| # without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| # distutils: language = c++ | ||
| # cython: language_level=3 | ||
|
|
||
| cdef extern from "usm_ndarray_constants.h": | ||
| int USM_ARRAY_C_CONTIGUOUS_VALUE | ||
| int USM_ARRAY_F_CONTIGUOUS_VALUE | ||
| int USM_ARRAY_WRITABLE_VALUE | ||
|
|
||
| cdef int USM_ARRAY_C_CONTIGUOUS | ||
| cdef int USM_ARRAY_F_CONTIGUOUS | ||
| cdef int USM_ARRAY_WRITABLE | ||
|
|
||
| cdef int ERROR_MALLOC | ||
| cdef int ERROR_INTERNAL | ||
| cdef int ERROR_INCORRECT_ORDER | ||
| cdef int ERROR_UNEXPECTED_STRIDES | ||
|
|
||
| cdef Py_ssize_t shape_to_elem_count(int nd, Py_ssize_t *shape_arr) | ||
|
|
||
| cdef int _from_input_shape_strides( | ||
| int nd, object shape, object strides, int itemsize, char order, | ||
| Py_ssize_t **shape_ptr, Py_ssize_t **strides_ptr, | ||
| Py_ssize_t *nelems, Py_ssize_t *min_disp, Py_ssize_t *max_disp, | ||
| int *contig | ||
| ) | ||
|
|
||
| cdef object _make_int_tuple(int nd, const Py_ssize_t *ary) | ||
|
|
||
| cdef object _make_reversed_int_tuple(int nd, const Py_ssize_t *ary) | ||
|
|
||
| cdef object _c_contig_strides(int nd, Py_ssize_t *shape) | ||
|
|
||
| cdef object _f_contig_strides(int nd, Py_ssize_t *shape) | ||
|
|
||
| cdef object _swap_last_two(tuple t) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # ***************************************************************************** | ||
| # Copyright (c) 2026, Intel Corporation | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # - Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # - Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # - Neither the name of the copyright holder nor the names of its contributors | ||
| # may be used to endorse or promote products derived from this software | ||
| # without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| # distutils: language = c++ | ||
| # cython: language_level=3 | ||
|
|
||
| cdef extern from "usm_ndarray_constants.h": | ||
| int UAR_BOOL_VALUE | ||
| int UAR_BYTE_VALUE | ||
| int UAR_UBYTE_VALUE | ||
| int UAR_SHORT_VALUE | ||
| int UAR_USHORT_VALUE | ||
| int UAR_INT_VALUE | ||
| int UAR_UINT_VALUE | ||
| int UAR_LONG_VALUE | ||
| int UAR_ULONG_VALUE | ||
| int UAR_LONGLONG_VALUE | ||
| int UAR_ULONGLONG_VALUE | ||
| int UAR_FLOAT_VALUE | ||
| int UAR_DOUBLE_VALUE | ||
| int UAR_CFLOAT_VALUE | ||
| int UAR_CDOUBLE_VALUE | ||
| int UAR_TYPE_SENTINEL_VALUE | ||
| int UAR_HALF_VALUE | ||
|
|
||
| cdef int UAR_BOOL | ||
| cdef int UAR_BYTE | ||
| cdef int UAR_UBYTE | ||
| cdef int UAR_SHORT | ||
| cdef int UAR_USHORT | ||
| cdef int UAR_INT | ||
| cdef int UAR_UINT | ||
| cdef int UAR_LONG | ||
| cdef int UAR_ULONG | ||
| cdef int UAR_LONGLONG | ||
| cdef int UAR_ULONGLONG | ||
| cdef int UAR_FLOAT | ||
| cdef int UAR_DOUBLE | ||
| cdef int UAR_CFLOAT | ||
| cdef int UAR_CDOUBLE | ||
| cdef int UAR_TYPE_SENTINEL | ||
| cdef int UAR_HALF | ||
|
|
||
| cdef int type_bytesize(int typenum) | ||
|
|
||
| cdef str _make_typestr(int typenum) | ||
|
|
||
| cdef int typenum_from_format(str s) | ||
|
|
||
| cdef int descr_to_typenum(object dtype) | ||
|
|
||
| cdef int dtype_to_typenum(dtype) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,25 +26,30 @@ | |
| # THE POSSIBILITY OF SUCH DAMAGE. | ||
| # ***************************************************************************** | ||
|
|
||
| # these typenum values are aligned to values in NumPy | ||
| cdef: | ||
| int UAR_BOOL = 0 # pragma: no cover | ||
| int UAR_BYTE = 1 # pragma: no cover | ||
| int UAR_UBYTE = 2 # pragma: no cover | ||
| int UAR_SHORT = 3 # pragma: no cover | ||
| int UAR_USHORT = 4 # pragma: no cover | ||
| int UAR_INT = 5 # pragma: no cover | ||
| int UAR_UINT = 6 # pragma: no cover | ||
| int UAR_LONG = 7 # pragma: no cover | ||
| int UAR_ULONG = 8 # pragma: no cover | ||
| int UAR_LONGLONG = 9 # pragma: no cover | ||
| int UAR_ULONGLONG = 10 # pragma: no cover | ||
| int UAR_FLOAT = 11 # pragma: no cover | ||
| int UAR_DOUBLE = 12 # pragma: no cover | ||
| int UAR_CFLOAT = 14 # pragma: no cover | ||
| int UAR_CDOUBLE = 15 # pragma: no cover | ||
| int UAR_TYPE_SENTINEL = 17 # pragma: no cover | ||
| int UAR_HALF = 23 # pragma: no cover | ||
| # distutils: language = c++ | ||
| # cython: language_level=3 | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
| cdef int UAR_BOOL = UAR_BOOL_VALUE | ||
| cdef int UAR_BYTE = UAR_BYTE_VALUE | ||
| cdef int UAR_UBYTE = UAR_UBYTE_VALUE | ||
| cdef int UAR_SHORT = UAR_SHORT_VALUE | ||
| cdef int UAR_USHORT = UAR_USHORT_VALUE | ||
| cdef int UAR_INT = UAR_INT_VALUE | ||
| cdef int UAR_UINT = UAR_UINT_VALUE | ||
| cdef int UAR_LONG = UAR_LONG_VALUE | ||
| cdef int UAR_ULONG = UAR_ULONG_VALUE | ||
| cdef int UAR_LONGLONG = UAR_LONGLONG_VALUE | ||
| cdef int UAR_ULONGLONG = UAR_ULONGLONG_VALUE | ||
| cdef int UAR_FLOAT = UAR_FLOAT_VALUE | ||
| cdef int UAR_DOUBLE = UAR_DOUBLE_VALUE | ||
| cdef int UAR_CFLOAT = UAR_CFLOAT_VALUE | ||
| cdef int UAR_CDOUBLE = UAR_CDOUBLE_VALUE | ||
| cdef int UAR_TYPE_SENTINEL = UAR_TYPE_SENTINEL_VALUE | ||
| cdef int UAR_HALF = UAR_HALF_VALUE | ||
|
Comment on lines
+35
to
+51
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems redundant to cdef them here and in usmarray.pyx, is there a way to do it in something common? |
||
|
|
||
|
|
||
| cdef int type_bytesize(int typenum): | ||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.