/usr/local/lib64/python3.6/site-packages/torch/utils/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/utils/__pycache__/dlpack.cpython-36.pyc (1894B)
3
Eg @ sj d dl mZ d dlZd dlZd dlmZ d dlmZ G dd dejZ ej
jed eejdd d
Z
dS ) )AnyN)_from_dlpack)
_to_dlpackc @ s0 e Zd ZdZdZd
ZdZdZdZdZ dZ
dZd
S )DLDeviceType
N)r )r )r )r )r
)r )r )r
)r )__name__
__module____qualname__ZkDLCPUkDLGPUZkDLCPUPinnedZ kDLOpenCLZ kDLVulkanZkDLMetalZkDLVPIkDLROCMZ kDLExtDev r r >/usr/local/lib64/python3.6/site-packages/torch/utils/dlpack.pyr
s r zto_dlpack(tensor) -> PyCapsule
Returns a DLPack representing the tensor.
Args:
tensor: a tensor to be exported
The DLPack shares the tensors memory.
Note that each DLPack can only be consumed once.
)
ext_tensorreturnc C sb t | drV| j }|d tjtjfkrLtjjdj|d }| j |j
d}qZ| j }n| }t|S )a from_dlpack(ext_tensor) -> Tensor
Convers a tensor from a external library into a ``torch.Tensor``
by means of the ``__dlpack__`` protocol.
The tensor will share the memory with the object represented
in the DLPack.
.. warning::
Only call from_dlpack once per capsule. Its behavior when used
on the same capsule multiple times is undefined.
Args:
ext_tensor (object with __dlpack__ attribute or DLPack capsule):
The tensor or DLPack capsule to convert.
__dlpack__r zcuda:{}r )stream)hasattrZ__dlpack_device__r r r torchZcudaZcurrent_streamformatr Zcuda_streamr )r Zdevicer Zdlpackr r r from_dlpack$ s
r )typingr r enumZtorch._Cr r Z to_dlpackIntEnumr _CZ_add_docstrZTensorr r r r r
s