Create a NumPy array from an object implementing the __dlpack__
protocol. Generally, the returned NumPy array is a view of the input object. See [1] and [2] for more details.
A Python object that implements the __dlpack__
and __dlpack_device__
methods.
Device on which to place the created array. Default: None
. Must be "cpu"
if passed which may allow importing an array that is not already CPU available.
Boolean indicating whether or not to copy the input. If True
, the copy will be made. If False
, the function will never copy, and will raise BufferError
in case a copy is deemed necessary. Passing it requests a copy from the exporter who may or may not implement the capability. If None
, the function will reuse the existing memory buffer if possible and copy otherwise. Default: None
.
References
Examples
>>> import torch >>> x = torch.arange(10) >>> # create a view of the torch tensor "x" in NumPy >>> y = np.from_dlpack(x)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4