File: utils.pxd

package info (click to toggle)
python-suitesparse-graphblas 7.4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 956 kB
  • sloc: ansic: 9,939; python: 3,575; sh: 52; makefile: 13
file content (40 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from libc.stdint cimport uint64_t
from numpy cimport dtype as dtype_t
from numpy cimport ndarray, npy_intp


cdef extern from "numpy/arrayobject.h" nogil:
    # These aren't public (i.e., "extern"), but other projects use them too
    void *PyDataMem_NEW(size_t size)
    void *PyDataMem_NEW_ZEROED(size_t nmemb, size_t size)
    void *PyDataMem_RENEW(void *ptr, size_t size)
    void PyDataMem_FREE(void *ptr)
    # These are available in newer Cython versions
    void PyArray_ENABLEFLAGS(ndarray array, int flags)
    void PyArray_CLEARFLAGS(ndarray array, int flags)
    # Not exposed by Cython (b/c it steals a reference from dtype)
    ndarray PyArray_NewFromDescr(
        type subtype, dtype_t dtype, int nd, npy_intp *dims, npy_intp *strides, void *data, int flags, object obj
    )

ctypedef enum GrB_Mode:
    GrB_NONBLOCKING
    GrB_BLOCKING

ctypedef uint64_t (*GxB_init)(
    GrB_Mode,
    void *(*user_malloc_function)(size_t),
    void *(*user_calloc_function)(size_t, size_t),
    void *(*user_realloc_function)(void *, size_t),
    void (*user_free_function)(void *),
)

cpdef int call_gxb_init(object ffi, object lib, int mode)

cpdef ndarray claim_buffer(object ffi, object cdata, size_t size, dtype_t dtype)

cpdef ndarray claim_buffer_2d(
    object ffi, object cdata, size_t cdata_size, size_t nrows, size_t ncols, dtype_t dtype, bint is_c_order
)

cpdef unclaim_buffer(ndarray array)