cuquantum.densitymat.CPUCallback¶
- class cuquantum.densitymat.CPUCallback(callback, is_inplace=False)[source]¶
Wrapper for CPU callback functions.
Note
Out-of-place callback functions have a signature of
(t: float, args: np.ndarray) -> np.ndarray
.Inplace callback functions have a signature of
(t: float, args: np.ndarray, arr: np.ndarray) -> None
.Callback functions are invoked in a stream and device context and are assumed to return (for out-of-place callbacks) an
np.ndarray
on the current device.Callback functions receive
Beyond sys.argv
argument as np.ndarray of shape (num_params, batch_size).
- Parameters
callback – The callback function to be wrapped, which can be either an inplace callback modifying its third argument, or an out-of-place callback returning a
np.ndarray
.is_inplace – Specifies whether the callback is inplace.
Methods
- __init__(callback: Union[Callable[[float, numpy.ndarray], numpy.ndarray], Callable[[float, numpy.ndarray, numpy.ndarray], None]], is_inplace: bool = False)[source]¶
Attributes
- callback¶
Return the callback function wrapped by this
Callback
.
- inplace_callback¶
Return the inplace version of the callback function wrapped by this
Callback
.
- is_gpu_callback¶
Return whether the callback function operates on GPU arrays.