latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
DLPack
DLPack is a neutral, zero-copy exchange format for tensors.
It lets two different libraries hand a tensor back and forth without copying the data,
describing only the shape, strides, data type, and device. TensorPlay interoperates with it
through tensorplay.from_dlpack.
import tensorplay as tp
# a DLPack capsule is an opaque handle to a tensor
x = tp.ones(3, 4)
capsule = tp.to_dlpack(x)
y = tp.from_dlpack(capsule) # wraps the same data, no copy
print(y.shape) # (3, 4)
tensorplay.from_dlpack wraps data owned by another library, and tensorplay.to_dlpack
hands ours out in the same format. Because the data is shared rather than copied, both ends
must respect the tensor’s lifetime and the device contract — the capsule owns the underlying
memory and the two sides agree on when it is valid.
|
Exports |
Where to go next
Tensors — the tensor APIs
from_dlpackandto_dlpackinteroperate with.NumPy interop — the other zero-copy conversion path.
Help improve this page
Found an error, an unclear step, or a missing example?
Distributed communication package - tensorplay.distributed
Note
Environment variables
TensorPlay reads a small set of environment variables to adjust runtime behavior: where downloaded files are cached, whether out-of-tree device backends load at import, how errors are reported, and how the experimental g

