Caffe2 - Python API
A deep learning, cross platform ML framework
dlpack.py
1 from __future__ import absolute_import, division, print_function, unicode_literals
2 import torch
3 
4 from torch._C import _from_dlpack as from_dlpack
5 from torch._C import _to_dlpack as to_dlpack
6 
7 torch._C._add_docstr(from_dlpack, r"""from_dlpack(dlpack) -> Tensor
8 
9 Decodes a DLPack to a tensor.
10 
11 Args:
12  dlpack: a PyCapsule object with the dltensor
13 
14 The tensor will share the memory with the object represented
15 in the dlpack.
16 Note that each dlpack can only be consumed once.
17 """)
18 
19 torch._C._add_docstr(to_dlpack, r"""to_dlpack(tensor) -> PyCapsule
20 
21 Returns a DLPack representing the tensor.
22 
23 Args:
24  tensor: a tensor to be exported
25 
26 The dlpack shares the tensors memory.
27 Note that each dlpack can only be consumed once.
28 """)