Memory operations
Collection of functions to manage memory on the device, e.g. to allocate and free memory. And to send or retrieve data from the device.
- create(dim, dtype: type | None = None, mtype: str | None = None, device: pyclesperanto._pyclesperanto._Device | None = None) pyclesperanto._pyclesperanto._Array[source]
Create a new image on the device.
- Parameters:
shape (Tuple[int, ...]) – Shape of the image in (z,y,x)
dtype (type, optional) – Data type of the image (np.int8, np.float32, etc.), np.float32 by default if None
mtype (str, optional) – Memory type of the image (buffer, image), buffer by default if None
device (Device, optional) – Device on which the image is created, current device by default if None
- Returns:
Created an empty Array on the device
- Return type:
Array
- create_like(array: ndarray | pyclesperanto._pyclesperanto._Array, dtype: type | None = None, mtype: str | None = None, device: pyclesperanto._pyclesperanto._Device | None = None) pyclesperanto._pyclesperanto._Array[source]
Create a new image on the device with the same shape and dtype as the input image.
- Parameters:
array (Image) – Input image
dtype (type, optional) – Data type of the image (np.int8, np.float32, etc.), np.float32 by default if None
mtype (str, optional) – Memory type of the image (buffer, image), buffer by default if None
device (Device, optional) – Device on which the image is created, current device by default if None
- Returns:
Created an empty Array on the device
- Return type:
Array
- pull(array: ndarray | pyclesperanto._pyclesperanto._Array) ndarray[source]
Pull the input image from the device to the host.
- Parameters:
array (Image) – Input image
- Returns:
Image data
- Return type:
np.ndarray
- push(array, dtype: type | None = None, mtype: str | None = None, device: pyclesperanto._pyclesperanto._Device | None = None) pyclesperanto._pyclesperanto._Array[source]
Create a new image on the device and push the input image into it.
- Parameters:
array (Image) – Input image
dtype (type, optional) – If provided, the input image is cast to the given dtype before being pushed to the device. Examples are np.int8, np.float32, etc. By default, no casting is performed and the dtype of the pushed image will match the dtype of the input image.
mtype (str, optional) – Memory type of the image (buffer, image), buffer by default if None
device (Device, optional) – Device on which the image is created, current device by default if None
- Returns:
Created Array on the device with the input image data
- Return type:
Array