hqs_distiller.cupy_numpy_dispatch
Dispatch for CuPy and NumPy.
@private
Copyright © 2025 HQS Quantum Simulations GmbH. All Rights Reserved.
def
as_xp(array: numpy.ndarray) -> numpy.ndarray:
Move NumPy array to xp.ndarray.
This operation copies a NumPy array to a generic CuPy / NumPy array,
changing the dtype to the DEFAULT_DTYPE.
NOTE: Since the dtype is changed this potentially throws a warning if a complex dtype is converted to a float dtype.
Arguments:
- array (np.ndarray): Generic CuPy / NumPy array.
Returns:
np.ndarray: Numpy array.
def
as_np(array: numpy.ndarray) -> numpy.ndarray:
Get generic CuPy / NumPy array as a NumPy array.
This operation does nothing, since CuPy is not available.
Arguments:
- array (xp.ndarray): Generic CuPy / NumPy array.
Returns:
np.ndarray: Numpy array.