[ANN] DLPack.jl - Share CPU and CUDA arrays between Julia and Python

Hello, I’m pleased to announce the release of DLPack.jl. DLPack is a C API that has continuously been adopted as a the base protocol for exchanging tensor data structures between different python libraries including JAX, Pytorch, CuPy, among others.

It supports working with PyCall, PythonCall and allows sharing and wrapping CPU and CUDA arrays.

Here’s an example from the README:

using DLPack
using PyCall

np = pyimport("jax.numpy")
dl = pyimport("jax.dlpack")

pyv = np.arange(10)
v = DLPack.wrap(pyv, o -> @pycall dl.to_dlpack(o)::PyObject)

(pyv[1] == 1).item()  # This is false since the first element is 0

# Let's mutate an immutable jax DeviceArray
v[1] = 1

(pyv[1] == 1).item()  # true

Hope you find it as a nice addition to interoperate with python libraries.

Best,
Pablo

6 Likes