cupy.from_dlpack#

cupy.from_dlpack(array)#

Zero-copy conversion between array objects compliant with the DLPack data exchange protocol.

Parameters:

array (object) – an array object that implements two methods: __dlpack__() and __dlpack_device__().

Returns:

a CuPy array that can be safely accessed on CuPy’s current stream.

Return type:

cupy.ndarray

Note

This function is different from CuPy’s legacy fromDlpack() function. This function takes any object implementing the DLPack data exchange protocol, as well as a raw PyCapsule object that contains the DLPack tensor as input (for backward compatibility), whereas fromDlpack() only accepts PyCapsule objects. If the input object is not compliant with the protocol, users are responsible to ensure data safety.