22# SPDX-License-Identifier: Apache-2.0
33
44# This code was automatically generated across versions from 1.5.0 to 13.3.0. Do not modify it directly.
5- # CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=3c177b7a0328c0f6f16067c8c9f4e5a002bd019e8c17c017ba9f77af21da8d75
5+ # CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=5c0d6715f105108fd83cc471fd0978ecab1f1cdfdd78f41ac3bcf7dc1a470ab5
66
77
88# <<<< PREAMBLE CONTENT >>>>
99
1010cimport cpython as _cyb_cpython
1111cimport cpython.buffer as _cyb_cpython_buffer
12- from cython cimport view as _cyb_view
12+ from cpython.memoryview cimport PyMemoryView_FromMemory as _cyb_PyMemoryView_FromMemory
1313from libc.stdint cimport (
1414 intptr_t,
1515 uint32_t,
@@ -604,19 +604,21 @@ cdef class ModuleTensorDescriptor:
604604 @property
605605 def stride (self ):
606606 """ ~_numpy.uint32: (array of length 8)."""
607- cdef _cyb_view.array arr = _cyb_view.array(shape = (8 ,), itemsize = sizeof(uint32_t), format = " I" , mode = " c" , allocate_buffer = False )
608- arr.data = < char * > (& (self ._ptr[0 ].stride))
609- return _numpy.asarray(arr)
607+ cdef object _mv_ = _cyb_PyMemoryView_FromMemory(
608+ < char * > (& (self ._ptr[0 ].stride)),
609+ < Py_ssize_t> (sizeof(uint32_t) * (8 )),
610+ _cyb_cpython_buffer.PyBUF_WRITE if not self ._readonly else _cyb_cpython_buffer.PyBUF_READ,
611+ )
612+ return _numpy.frombuffer(_mv_, dtype = _numpy.uint32)
610613
611614 @stride.setter
612615 def stride (self , val ):
613616 if self ._readonly:
614617 raise ValueError (" This ModuleTensorDescriptor instance is read-only" )
615618 if len (val) != 8 :
616619 raise ValueError (f" Expected length { 8 } for field stride, got {len(val)}" )
617- cdef _cyb_view.array arr = _cyb_view.array(shape = (8 ,), itemsize = sizeof(uint32_t), format = " I" , mode = " c" )
618- arr[:] = _numpy.asarray(val, dtype = _numpy.uint32)
619- _cyb_memcpy(< void * > (& (self ._ptr[0 ].stride)), < void * > (arr.data), sizeof(uint32_t) * len (val))
620+ _val_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype = _numpy.uint32))
621+ _cyb_memcpy(< void * > (& (self ._ptr[0 ].stride)), < void * >< intptr_t> (_val_.ctypes.data), sizeof(uint32_t) * (8 ))
620622
621623 @staticmethod
622624 def from_buffer (buffer ):
@@ -1344,10 +1346,13 @@ cdef class SignalEvents:
13441346 def dev_ptrs (self ):
13451347 """ int: """
13461348 if self ._ptr[0 ].devPtrs == NULL or self ._ptr[0 ].numEvents == 0 :
1347- return _cyb_view.array(shape = (1 ,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )[:0 ]
1348- cdef _cyb_view.array arr = _cyb_view.array(shape = (self ._ptr[0 ].numEvents,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" , allocate_buffer = False )
1349- arr.data = < char * > (self ._ptr[0 ].devPtrs)
1350- return arr
1349+ return _numpy.empty(0 , dtype = _numpy.intp)
1350+ cdef object _mv_ = _cyb_PyMemoryView_FromMemory(
1351+ < char * > (self ._ptr[0 ].devPtrs),
1352+ < Py_ssize_t> (self ._ptr[0 ].numEvents * sizeof(intptr_t)),
1353+ _cyb_cpython_buffer.PyBUF_WRITE,
1354+ )
1355+ return _numpy.frombuffer(_mv_, dtype = _numpy.intp)
13511356
13521357 @dev_ptrs.setter
13531358 def dev_ptrs (self , val ):
@@ -1357,13 +1362,9 @@ cdef class SignalEvents:
13571362 self ._ptr[0 ].numEvents = _n
13581363 if _n == 0 :
13591364 return
1360- cdef _cyb_view.array arr = _cyb_view.array(shape = (_n,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )
1361- cdef intptr_t[:] mv = arr
1362- cdef Py_ssize_t i
1363- for i in range (_n):
1364- mv[i] = val[i]
1365- self ._ptr[0 ].devPtrs = < uint64_t** >< intptr_t> (arr.data)
1366- self ._refs[" dev_ptrs" ] = arr
1365+ _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype = _numpy.intp))
1366+ self ._ptr[0 ].devPtrs = < uint64_t** >< intptr_t> _arr_.ctypes.data
1367+ self ._refs[" dev_ptrs" ] = _arr_
13671368
13681369 @property
13691370 def eof_fences (self ):
@@ -1530,10 +1531,13 @@ cdef class Task:
15301531 def output_tensor (self ):
15311532 """ int: """
15321533 if self ._ptr[0 ].outputTensor == NULL or self ._ptr[0 ].numOutputTensors == 0 :
1533- return _cyb_view.array(shape = (1 ,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )[:0 ]
1534- cdef _cyb_view.array arr = _cyb_view.array(shape = (self ._ptr[0 ].numOutputTensors,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" , allocate_buffer = False )
1535- arr.data = < char * > (self ._ptr[0 ].outputTensor)
1536- return arr
1534+ return _numpy.empty(0 , dtype = _numpy.intp)
1535+ cdef object _mv_ = _cyb_PyMemoryView_FromMemory(
1536+ < char * > (self ._ptr[0 ].outputTensor),
1537+ < Py_ssize_t> (self ._ptr[0 ].numOutputTensors * sizeof(intptr_t)),
1538+ _cyb_cpython_buffer.PyBUF_WRITE,
1539+ )
1540+ return _numpy.frombuffer(_mv_, dtype = _numpy.intp)
15371541
15381542 @output_tensor.setter
15391543 def output_tensor (self , val ):
@@ -1543,22 +1547,21 @@ cdef class Task:
15431547 self ._ptr[0 ].numOutputTensors = _n
15441548 if _n == 0 :
15451549 return
1546- cdef _cyb_view.array arr = _cyb_view.array(shape = (_n,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )
1547- cdef intptr_t[:] mv = arr
1548- cdef Py_ssize_t i
1549- for i in range (_n):
1550- mv[i] = val[i]
1551- self ._ptr[0 ].outputTensor = < uint64_t** >< intptr_t> (arr.data)
1552- self ._refs[" output_tensor" ] = arr
1550+ _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype = _numpy.intp))
1551+ self ._ptr[0 ].outputTensor = < uint64_t** >< intptr_t> _arr_.ctypes.data
1552+ self ._refs[" output_tensor" ] = _arr_
15531553
15541554 @property
15551555 def input_tensor (self ):
15561556 """ int: """
15571557 if self ._ptr[0 ].inputTensor == NULL or self ._ptr[0 ].numInputTensors == 0 :
1558- return _cyb_view.array(shape = (1 ,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )[:0 ]
1559- cdef _cyb_view.array arr = _cyb_view.array(shape = (self ._ptr[0 ].numInputTensors,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" , allocate_buffer = False )
1560- arr.data = < char * > (self ._ptr[0 ].inputTensor)
1561- return arr
1558+ return _numpy.empty(0 , dtype = _numpy.intp)
1559+ cdef object _mv_ = _cyb_PyMemoryView_FromMemory(
1560+ < char * > (self ._ptr[0 ].inputTensor),
1561+ < Py_ssize_t> (self ._ptr[0 ].numInputTensors * sizeof(intptr_t)),
1562+ _cyb_cpython_buffer.PyBUF_WRITE,
1563+ )
1564+ return _numpy.frombuffer(_mv_, dtype = _numpy.intp)
15621565
15631566 @input_tensor.setter
15641567 def input_tensor (self , val ):
@@ -1568,13 +1571,9 @@ cdef class Task:
15681571 self ._ptr[0 ].numInputTensors = _n
15691572 if _n == 0 :
15701573 return
1571- cdef _cyb_view.array arr = _cyb_view.array(shape = (_n,), itemsize = sizeof(intptr_t), format = " q" , mode = " c" )
1572- cdef intptr_t[:] mv = arr
1573- cdef Py_ssize_t i
1574- for i in range (_n):
1575- mv[i] = val[i]
1576- self ._ptr[0 ].inputTensor = < uint64_t** >< intptr_t> (arr.data)
1577- self ._refs[" input_tensor" ] = arr
1574+ _arr_ = _numpy.ascontiguousarray(_numpy.asarray(val, dtype = _numpy.intp))
1575+ self ._ptr[0 ].inputTensor = < uint64_t** >< intptr_t> _arr_.ctypes.data
1576+ self ._refs[" input_tensor" ] = _arr_
15781577
15791578 @property
15801579 def wait_events (self ):
0 commit comments