from_dlpack(ext_tensor) → Tensor¶
Convers a tensor from a external library into a
torch.Tensorby means of the
The tensor will share the memory with the object represented in the DLPack.
Only call from_dlpack once per capsule. Its behavior when used on the same capsule multiple times is undefined.
ext_tensor (object with __dlpack__ attribute or DLPack capsule) – The tensor or DLPack capsule to convert.
to_dlpack(tensor) → PyCapsule¶
Returns a DLPack representing the tensor.
tensor – a tensor to be exported
The DLPack shares the tensors memory. Note that each DLPack can only be consumed once.