hip._util.types#
- class hip._util.types.Pointer(pyobj=None)#
Bases:
object
Datatype for handling Python arguments that need to be converted to a pointer type.
Datatype for handling Python arguments that need to be converted to a pointer type when passed to an underlying C function.
This type stores a C
void *
pointer to the original Python object’s data plus an additionalPy_buffer
object if the pointer has ben acquired from a Python object that implements the Python buffer protocol.This type can be constructed from input objects that are implementors of the CUDA Array Interface protocol.
In summary, the type can be initialized from the following Python objects:
None
:This will set the
self._ptr
attribute toNULL
.-
Takes the pointer address
pyobj.value
and writes it toself._ptr
. Note thatctypes.c_void_p
seems to be identified as Python buffer for unknown reasons. Therefore, it must be checked for this type first. object
that implements the Python buffer protocol:If the object represents a simple contiguous array, writes the
Py_buffer
associated withpyobj
toself._py_buffer
, sets theself._py_buffer_acquired
flag toTrue
, and writesself._py_buffer.buf
to the data pointerself._ptr
.object
that implements the CUDA Array Interface protocol:Takes the integer-valued pointer address, i.e. the first entry of the
data
tuple frompyobj
’s member__cuda_array_interface__
and writes it toself._ptr
.-
Copies
pyobj._ptr
toself._ptr
.Py_buffer
object ownership is not transferred! int
:Interprets the integer value as pointer address and writes it to
self._ptr
.object
that hasas_c_void_p(self)
method:Takes the pointer address
pyobj.as_c_void_p().value
and writes it toself._ptr
.
Type checks are performed in the above order.
- Note:
When initializing
Pointer
instances from a Python input object, buffer types are checked first by purpose. Acquiring/releasing a buffer typically implies that the reference count of the buffer is incremented/decremented. If the Python input object releases a buffer but aPointer
instance still has acquired it, the buffer data will not be freed until thePointer
instance is deleted.- C Attributes:
- _ptr (C type
void *
, protected): Stores a pointer to the data of the original Python object.
- _py_buffer (C type ``Py_buffer`, protected):
Stores a pointer to the data of the original Python object.
- _py_buffer_acquired (C type
bint
, protected): Stores a pointer to the data of the original Python object.
- _ptr (C type
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a Pointer from the given object.
In case
pyobj
is itself aPointer
instance, this method returns it directly. No newPointer
is created.
- is_ptr_null#
If data pointer is NULL.
- class hip._util.types.CStr(pyobj)#
Bases:
Pointer
Datatype for handling C strings (
char *
and related).Datatype for handling C strings (
char *
). Cython’s parameter autoconversion creates duplicates of C strings and hence loses the original data’s address, which can be an issue.This implementation assumes that this type is mainly used like a Python
str
in cases where it is returned by a function. Hence, the__getitem__
,__repr__
and__str__
implementation of this class decode the underlying data asUTF-8
string. ASCII is a subset of UTF-8. Note that this design choice is irrelevant for the case where the type is used as adapter to convert Python arguments to a C string.This datatype implements the Python buffer protocol. Therefore, different decoding of the underlying data can be achieved by passing this type to the constructor of
bytes
or to other array types or memory views that can deal with Python buffers.- Warning:
When using this type as adapter, be aware that
bytes
andstr
objects passed to the constructor of this class might get garbage collected. If the called C library stores pointers to the data of these Python objects into a library-managed data structure and the latter is then used outside of the original scope, you might experience memory errors.- Limitation:
This class is only designed for handling strings that encode each character with 8 bits (ASCII and UTF-8). Smaller or larger symbols are not supported.
The type can be initialized from the following Python objects:
-
Takes the pointer address
pyobj.value
and writes it toself._ptr
. Length information is obtained viastrlen
in this case. Note thatctypes.c_void_p
seems to be identified as Python buffer for unknown reasons. Therefore, it must be checked for this type first. object
that implements the Python buffer protocol:If the object represents a simple contiguous array, writes the
Py_buffer
associated withpyobj
toself._py_buffer
, sets theself._py_buffer_acquired
flag toTrue
, and writesself._py_buffer.buf
to the data pointerself._ptr
.
Type checks are performed in the above order.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _shape (
Py_size_t[1]
, protected): Size of the wrapped zero-terminated C char, stored into first array element.
- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.
- _ptr (
- __getitem__()#
Get individual chars or slice the underlying chars.
- Note:
Copies into a temporary str object if
subscript
is a slice.
- __init__()#
Constructor.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- decode(self, /, encoding='utf-8', errors='strict')#
Return a
str
object with respect to the enconding.- See:
- encode(self, /, encoding='utf-8', errors='strict')#
Return a
bytes
object with respect to the encoding.- See:
- free(self) void #
Free dynamically allocated data.
- Note:
Simply returns if the data pointer is NULL.
- Note:
Throws
RuntimeError
if this instance does not own the data that ought to be freed.- Note:
Unsets the _is_ptr_owner flag.
- static fromObj(pyobj)#
Creates a CStr from the given object.
In case
pyobj
is itself aCStr
instance, this method returns it directly. No newCStr
is created.
- is_ptr_null#
If data pointer is NULL.
- malloc(self, Py_ssize_t size_bytes) void #
Dynamically allocate a buffer of bytes for this CStr.
- Args:
size_bytes (
Py_ssize_t
): The number of bytes to allocate.- Note:
Throws
RuntimeError
if the data pointer is not NULL as this indicates that this instance handles external data.- Note:
Sets the _is_ptr_owner flag.
- class hip._util.types.ImmortalCStr(pyobj)#
Bases:
CStr
Immortal version of
CStr
that sets the reference count of itself1
initially, which prevents it from getting garbage collected. Furthermore, increases the reference count of wrapped bytes- Note:
Class name and implementation inspired from: https://peps.python.org/pep-0683
- __getitem__()#
Get individual chars or slice the underlying chars.
- Note:
Copies into a temporary str object if
subscript
is a slice.
- __init__()#
Constructor.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- decode(self, /, encoding='utf-8', errors='strict')#
Return a
str
object with respect to the enconding.- See:
- encode(self, /, encoding='utf-8', errors='strict')#
Return a
bytes
object with respect to the encoding.- See:
- free(self) void #
Free dynamically allocated data.
- Note:
Simply returns if the data pointer is NULL.
- Note:
Throws
RuntimeError
if this instance does not own the data that ought to be freed.- Note:
Unsets the _is_ptr_owner flag.
- static fromObj(pyobj)#
Creates an ImmortalCStr from the given object.
In case
pyobj
is itself aImmortalCStr
instance, this method returns it directly. No newImmortalCStr
is created.
- is_ptr_null#
If data pointer is NULL.
- malloc(self, Py_ssize_t size_bytes) void #
Dynamically allocate a buffer of bytes for this CStr.
- Args:
size_bytes (
Py_ssize_t
): The number of bytes to allocate.- Note:
Throws
RuntimeError
if the data pointer is not NULL as this indicates that this instance handles external data.- Note:
Sets the _is_ptr_owner flag.
- class hip._util.types.DeviceArray#
Bases:
NDBuffer
Datatype for handling device buffers.
Datatype for handling device buffers returned by
hipMalloc
and related device memory allocation routines.This type implements the CUDA Array Interface protocol.
It can be initialized from the following Python objects:
None
:This will set the
self._ptr
attribute toNULL
. No shape and type information is available in this case!
int
:Interprets the integer value as pointer address and writes it to
self._ptr
. No shape and type information is available in this case!
ctypes.c_void_p
:Takes the pointer address
pyobj.value
and writes it toself._ptr
. No shape and type information is available in this case!
object
with__cuda_array_interface__
member:Takes the integer-valued pointer address, i.e. the first entry of the
data
tuple frompyobj
’s member__cuda_array_interface__
and writes it toself._ptr
. Copies shape and type information.
- Note:
Type checks are performed in the above order.
- Note:
Shape and type information and other metadata can be modified or overwritten after creation via the
configure
member function. be aware that you might need to pass the_force=True
keyword argument — in particular if your instance was created from a type that does not implement the CUDA Array Interface protocol.- See:
- C Attributes:
- _ptr (
void *
, protected): Stores a pointer to the data of the original Python object.
- _py_buffer (
Py_buffer
, protected): Stores a pointer to the data of the original Python object.
- _py_buffer_acquired (
bool
, protected): Stores a pointer to the data of the original Python object.
- _itemsize (
size_t
, protected): Stores the itemsize.
- __dict__ (
dict
, protected): Dict with member
__cuda_array_interface__
.
- _ptr (
- static DeviceArray(pyobj)#
Creates a NDBuffer from the given object.
In case
pyobj
is itself aNDBuffer
instance, this method returns it directly. No newNDBuffer
is created.
- NUMPY_CHAR_CODES = ('?', '=?', '<?', '>?', 'bool', 'bool_', 'bool8', 'uint8', 'u1', '=u1', '<u1', '>u1', 'uint16', 'u2', '=u2', '<u2', '>u2', 'uint32', 'u4', '=u4', '<u4', '>u4', 'uint64', 'u8', '=u8', '<u8', '>u8', 'int8', 'i1', '=i1', '<i1', '>i1', 'int16', 'i2', '=i2', '<i2', '>i2', 'int32', 'i4', '=i4', '<i4', '>i4', 'int64', 'i8', '=i8', '<i8', '>i8', 'float16', 'f2', '=f2', '<f2', '>f2', 'float32', 'f4', '=f4', '<f4', '>f4', 'float64', 'f8', '=f8', '<f8', '>f8', 'complex64', 'c8', '=c8', '<c8', '>c8', 'complex128', 'c16', '=c16', '<c16', '>c16', 'byte', 'b', '=b', '<b', '>b', 'short', 'h', '=h', '<h', '>h', 'intc', 'i', '=i', '<i', '>i', 'intp', 'int0', 'p', '=p', '<p', '>p', 'long', 'int', 'int_', 'l', '=l', '<l', '>l', 'longlong', 'q', '=q', '<q', '>q', 'ubyte', 'B', '=B', '<B', '>B', 'ushort', 'H', '=H', '<H', '>H', 'uintc', 'I', '=I', '<I', '>I', 'uintp', 'uint0', 'P', '=P', '<P', '>P', 'ulong', 'uint', 'L', '=L', '<L', '>L', 'ulonglong', 'Q', '=Q', '<Q', '>Q', 'half', 'e', '=e', '<e', '>e', 'single', 'f', '=f', '<f', '>f', 'double', 'float', 'float_', 'd', '=d', '<d', '>d', 'longdouble', 'longfloat', 'g', '=g', '<g', '>g', 'csingle', 'singlecomplex', 'F', '=F', '<F', '>F', 'cdouble', 'complex', 'complex_', 'cfloat', 'D', '=D', '<D', '>D', 'clongdouble', 'clongfloat', 'longcomplex', 'G', '=G', '<G', '>G', 'str', 'str_', 'str0', 'unicode', 'unicode_', 'U', '=U', '<U', '>U', 'bytes', 'bytes_', 'bytes0', 'S', '=S', '<S', '>S', 'void', 'void0', 'V', '=V', '<V', '>V', 'object', 'object_', 'O', '=O', '<O', '>O', 'datetime64', '=datetime64', '<datetime64', '>datetime64', 'datetime64[Y]', '=datetime64[Y]', '<datetime64[Y]', '>datetime64[Y]', 'datetime64[M]', '=datetime64[M]', '<datetime64[M]', '>datetime64[M]', 'datetime64[W]', '=datetime64[W]', '<datetime64[W]', '>datetime64[W]', 'datetime64[D]', '=datetime64[D]', '<datetime64[D]', '>datetime64[D]', 'datetime64[h]', '=datetime64[h]', '<datetime64[h]', '>datetime64[h]', 'datetime64[m]', '=datetime64[m]', '<datetime64[m]', '>datetime64[m]', 'datetime64[s]', '=datetime64[s]', '<datetime64[s]', '>datetime64[s]', 'datetime64[ms]', '=datetime64[ms]', '<datetime64[ms]', '>datetime64[ms]', 'datetime64[us]', '=datetime64[us]', '<datetime64[us]', '>datetime64[us]', 'datetime64[ns]', '=datetime64[ns]', '<datetime64[ns]', '>datetime64[ns]', 'datetime64[ps]', '=datetime64[ps]', '<datetime64[ps]', '>datetime64[ps]', 'datetime64[fs]', '=datetime64[fs]', '<datetime64[fs]', '>datetime64[fs]', 'datetime64[as]', '=datetime64[as]', '<datetime64[as]', '>datetime64[as]', 'M', '=M', '<M', '>M', 'M8', '=M8', '<M8', '>M8', 'M8[Y]', '=M8[Y]', '<M8[Y]', '>M8[Y]', 'M8[M]', '=M8[M]', '<M8[M]', '>M8[M]', 'M8[W]', '=M8[W]', '<M8[W]', '>M8[W]', 'M8[D]', '=M8[D]', '<M8[D]', '>M8[D]', 'M8[h]', '=M8[h]', '<M8[h]', '>M8[h]', 'M8[m]', '=M8[m]', '<M8[m]', '>M8[m]', 'M8[s]', '=M8[s]', '<M8[s]', '>M8[s]', 'M8[ms]', '=M8[ms]', '<M8[ms]', '>M8[ms]', 'M8[us]', '=M8[us]', '<M8[us]', '>M8[us]', 'M8[ns]', '=M8[ns]', '<M8[ns]', '>M8[ns]', 'M8[ps]', '=M8[ps]', '<M8[ps]', '>M8[ps]', 'M8[fs]', '=M8[fs]', '<M8[fs]', '>M8[fs]', 'M8[as]', '=M8[as]', '<M8[as]', '>M8[as]', 'timedelta64', '=timedelta64', '<timedelta64', '>timedelta64', 'timedelta64[Y]', '=timedelta64[Y]', '<timedelta64[Y]', '>timedelta64[Y]', 'timedelta64[M]', '=timedelta64[M]', '<timedelta64[M]', '>timedelta64[M]', 'timedelta64[W]', '=timedelta64[W]', '<timedelta64[W]', '>timedelta64[W]', 'timedelta64[D]', '=timedelta64[D]', '<timedelta64[D]', '>timedelta64[D]', 'timedelta64[h]', '=timedelta64[h]', '<timedelta64[h]', '>timedelta64[h]', 'timedelta64[m]', '=timedelta64[m]', '<timedelta64[m]', '>timedelta64[m]', 'timedelta64[s]', '=timedelta64[s]', '<timedelta64[s]', '>timedelta64[s]', 'timedelta64[ms]', '=timedelta64[ms]', '<timedelta64[ms]', '>timedelta64[ms]', 'timedelta64[us]', '=timedelta64[us]', '<timedelta64[us]', '>timedelta64[us]', 'timedelta64[ns]', '=timedelta64[ns]', '<timedelta64[ns]', '>timedelta64[ns]', 'timedelta64[ps]', '=timedelta64[ps]', '<timedelta64[ps]', '>timedelta64[ps]', 'timedelta64[fs]', '=timedelta64[fs]', '<timedelta64[fs]', '>timedelta64[fs]', 'timedelta64[as]', '=timedelta64[as]', '<timedelta64[as]', '>timedelta64[as]', 'm', '=m', '<m', '>m', 'm8', '=m8', '<m8', '>m8', 'm8[Y]', '=m8[Y]', '<m8[Y]', '>m8[Y]', 'm8[M]', '=m8[M]', '<m8[M]', '>m8[M]', 'm8[W]', '=m8[W]', '<m8[W]', '>m8[W]', 'm8[D]', '=m8[D]', '<m8[D]', '>m8[D]', 'm8[h]', '=m8[h]', '<m8[h]', '>m8[h]', 'm8[m]', '=m8[m]', '<m8[m]', '>m8[m]', 'm8[s]', '=m8[s]', '<m8[s]', '>m8[s]', 'm8[ms]', '=m8[ms]', '<m8[ms]', '>m8[ms]', 'm8[us]', '=m8[us]', '<m8[us]', '>m8[us]', 'm8[ns]', '=m8[ns]', '<m8[ns]', '>m8[ns]', 'm8[ps]', '=m8[ps]', '<m8[ps]', '>m8[ps]', 'm8[fs]', '=m8[fs]', '<m8[fs]', '>m8[fs]', 'm8[as]', '=m8[as]', '<m8[as]', '>m8[as]')#
- __getitem__()#
Returns a contiguous subarray according to the subscript expression.
Returns a contiguous subarray according to the subscript expression.
- Args:
- Note:
If the subscript is a single integer, e.g.
[i]
, the subarray[i,:,:,...,:]
is returned. AKeyError
is raised if the extent of axis 0 is surpassed. This behavior is identical to that of numpy.- Raises:
TypeError
: If the subscript types are not ‘int’, ‘slice’ or a ‘tuple’ thereof.ValueError
: If the subscripts do not yield an contiguous subarray. A single array element is regarded as contiguous array of size 1.
- __init__()#
Constructor.
- Args:
- pyobj (
object
): See the class description
NDBuffer
for information about accepted types forpyobj
.
- pyobj (
- Raises:
TypeError
: If the input objectpyobj
is not of the right type.- Note:
Shape and type information and other metadata can be modified or overwritten after creation via the
configure
member function. be aware that you might need to pass the_force=True
keyword argument — in particular if your instance was created from a type that does not implement the CUDA Array Interface protocol.- See:
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- configure(self, **kwargs)#
(Re-)configure this contiguous n-dimensional buffer.
- Warning:
When you reconfigure the buffer shape, previously acquired views on this NDBuffer via the Python buffer protocol might become invalid. Therefore, a
RuntimeException
is thrown if this method is called while the view count is greater than zero.- Keyword arguments:
- shape (
tuple
): A tuple that describes the extent per dimension. The length of the tuple is the number of dimensions.
- typestr (
str
): A numpy typestr, see the notes for more details.
- stream (
int
orNone
): The stream to synchronize before consuming this array. See first note for more details. Only makes sense if this buffer wraps device data.
- itemsize (
int
): Size in bytes of each item. Defaults to 1. See the notes.
- read_only (
bool
): NDBuffer
is read_only. Second entry of the CUDA array interface ‘data’ tuple. Defaults to False.- _force(
bool
): Ignore changes in the total number of bytes when overriding shape, typestr, and/or itemsize.
- shape (
- Note:
More details on the keyword arguments can be found here: https://numba.readthedocs.io/en/stable/cuda/cuda_array_interface.html
- Note:
This method does not automatically map all existing numpy/numba typestr to appropriate number of bytes, i.e.
itemsize
. Hence, you need to specify itemsize additionally when dealing with other datatypes than bytes (typestr:'b'
).
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a NDBuffer from the given object.
In case
pyobj
is itself aNDBuffer
instance, this method returns it directly. No newNDBuffer
is created.
- is_ptr_null#
If data pointer is NULL.
- is_read_only#
If the data is read only, i.e. must not be modified.
- itemsize#
Number of bytes required to store a single element of the array.
- rank#
Rank of the underlying data.
- See:
set_bounds
- shape#
A tuple of int (or long) representing the size of each dimension.
- stream_as_int#
Returns the stream address as integer value.
- typestr#
The type string (see CUDA Array Interface specification).
- class hip._util.types.ListOfBytes(pyobj)#
Bases:
Pointer
Datatype for handling Python
list
ortuple
objects with entries of typebytes
orCStr
.Datatype for handling Python
list
andtuple
objects with entries of typebytes
that need to be converted to a pointer type when passed to the underlying C function.The type can be initialized from the following Python objects:
- Note:
Type checks are performed in the above order.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.- _is_ptr_owner (
bint
, protected): If this object is the owner of the allocated buffer. Defaults to
False
.
- _ptr (
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- Args:
- pyobj (
object
): See the class description
ListOfBytes
for information about accepted types forpyobj
.
- pyobj (
- Raises:
TypeError
: If the input objectpyobj
is not of the right type.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a ListOfBytes from the given object.
In case
pyobj
is itself anListOfBytes
instance, this method returns it directly. No newListOfBytes
is created.
- is_ptr_null#
If data pointer is NULL.
- class hip._util.types.ListOfPointer(pyobj)#
Bases:
Pointer
Datatype for handling Python
list
ortuple
objects with entries that can be converted to typePointer
.Datatype for handling Python
list
andtuple
objects with entries that can be converted to typePointer
. Such entries might be of typeNone
,int
,ctypes.c_void_p
, Python buffer interface implementors, CUDA Array Interface implementors,Pointer
, subclasses of Pointer.The type can be initialized from the following Python objects:
- Note:
Type checks are performed in the above order.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.- _is_ptr_owner (
bint
, protected): If this object is the owner of the allocated buffer. Defaults to
False
.
- _ptr (
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- Args:
- pyobj (
object
): See the class description
ListOfPointer
for information about accepted types forpyobj
.
- pyobj (
- Raises:
TypeError
: If the input objectpyobj
is not of the right type.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a ListOfPointer from the given object.
In case
pyobj
is itself aListOfPointer
instance, this method returns it directly. No newListOfPointer
is created.
- is_ptr_null#
If data pointer is NULL.
- class hip._util.types.ListOfInt(pyobj)#
Bases:
Pointer
Datatype for handling Python
list
ortuple
objects with entries that can be converted to C typeint
.Datatype for handling Python
list
andtuple
objects with entries that can be converted to C typeint
. Such entries might be of Python typeNone
,int
, or of anyctypes
integer type.The type can be initialized from the following Python objects:
list
/tuple
of types that can be converted to C typeint
:object
that is accepted as input by__init__
:
- Note:
Type checks are performed in the above order.
- Note:
Simple, contiguous numpy and Python 3 array types can be passed directly to this routine as they implement the Python buffer protocol.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.- _is_ptr_owner (
bint
, protected): If this object is the owner of the allocated buffer. Defaults to
False
.
- _ptr (
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a ListOfInt from the given object.
In case
pyobj
is itself aListOfInt
instance, this method returns it directly. No newListOfInt
is created.
- is_ptr_null#
If data pointer is NULL.
- class hip._util.types.ListOfUnsigned(pyobj)#
Bases:
Pointer
Datatype for handling Python
list
ortuple
objects with entries that can be converted to C typeunsigned
.Datatype for handling Python
list
andtuple
objects with entries that can be converted to C typeunsigned
. Such entries might be of Python typeNone
,int
, or of anyctypes
integer type.The type can be initialized from the following Python objects:
list
/tuple
of types that can be converted to C typeunsigned
:object
that is accepted as input by__init__
:
- Note:
Type checks are performed in the above order.
- Note:
Simple, contiguous numpy and Python 3 array types can be passed directly to this routine as they implement the Python buffer protocol.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.- _is_ptr_owner (
bint
, protected): If this object is the owner of the allocated buffer. Defaults to
False
.
- _ptr (
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- Args:
- pyobj (
object
): See the class description
ListOfUnsigned
for information about accepted types forpyobj
.
- pyobj (
- Raises:
TypeError
: If the input objectpyobj
is not of the right type.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a ListOfUnsigned from the given object.
In case
pyobj
is itself anListOfUnsigned
instance, this method returns it directly. No newListOfUnsigned
is created.
- is_ptr_null#
If data pointer is NULL.
- class hip._util.types.ListOfUnsignedLong(pyobj)#
Bases:
Pointer
Datatype for handling Python
list
ortuple
objects with entries that can be converted to C typeunsigned long
.Datatype for handling Python
list
andtuple
objects with entries that can be converted to C typeunsigned long
. Such entries might be of Python typeNone
,int
, or of anyctypes
integer type.The type can be initialized from the following Python objects:
list
/tuple
of types that can be converted to C typeunsigned long
:object
that is accepted as input by__init__
:
- Note:
Type checks are performed in the above order.
- Note:
Simple, contiguous numpy and Python 3 array types can be passed directly to this routine as they implement the Python buffer protocol.
- C Attributes:
- _ptr (
void *
, protected): See
Pointer
for more information.- _py_buffer (
Py_buffer
, protected): See
Pointer
for more information.- _py_buffer_acquired (
bool
, protected): See
Pointer
for more information.- _is_ptr_owner (
bint
, protected): If this object is the owner of the allocated buffer. Defaults to
False
.
- _ptr (
- __getitem__()#
Returns a new Pointer whose pointer is this instance’s pointer offsetted by
offset
.- Args:
offset (
int
): Offset (in bytes) to add to this instance’s pointer.
- __init__()#
Constructor.
- Args:
- pyobj (
object
): See the class description
ListOfUnsigned
for information about accepted types forpyobj
.
- pyobj (
- Raises:
TypeError
: If the input objectpyobj
is not of the right type.
- as_c_void_p(self)#
Data pointer as
ctypes.c_void_p
.
- createRef(self) Pointer #
Creates are reference to this pointer.
Returns a
Pointer
that stores the address of this `~.Pointer’s data pointer.- Note:
No ownership information is transferred.
- static fromObj(pyobj)#
Creates a ListOfUnsignedLong from the given object.
In case
pyobj
is itself anListOfUnsignedLong
instance, this method returns it directly. No newListOfUnsignedLong
is created.
- is_ptr_null#
If data pointer is NULL.