目录

torch.utils.dlpack

torch.utils.dlpack.from_dlpack(ext_tensor)Tensor[source]

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.

Parameters

ext_tensor (object with __dlpack__ attribute or DLPack capsule) – The tensor or DLPack capsule to convert.

torch.utils.dlpack.to_dlpack(tensor)PyCapsule

Returns a DLPack representing the tensor.

Parameters

tensor – a tensor to be exported

The DLPack shares the tensors memory. Note that each DLPack can only be consumed once.

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源