xorbits.numpy.from_dlpack#
- xorbits.numpy.from_dlpack(x, /)#
Create a NumPy array from an object implementing the
__dlpack__
protocol. Generally, the returned NumPy array is a read-only view of the input object. See 1 and 2 for more details.- 参数
x (object) – A Python object that implements the
__dlpack__
and__dlpack_device__
methods.- 返回
out
- 返回类型
ndarray
引用
- 1
Array API documentation, https://data-apis.org/array-api/latest/design_topics/data_interchange.html#syntax-for-data-interchange-with-dlpack
- 2
Python specification for DLPack, https://dmlc.github.io/dlpack/latest/python_spec.html
实际案例
>>> import torch >>> x = torch.arange(10) >>> # create a view of the torch tensor "x" in NumPy >>> y = np.from_dlpack(x)
警告
This method has not been implemented yet. Xorbits will try to execute it with numpy.
This docstring was copied from numpy.