11 unstable releases (3 breaking)

Uses new Rust 2024

0.4.1 Jul 27, 2026
0.3.1 Jun 12, 2026
0.1.4 Mar 10, 2026
0.1.0 Dec 1, 2025

#87 in Machine learning

Download history 1089/week @ 2026-04-24 1402/week @ 2026-05-01 2484/week @ 2026-05-08 2792/week @ 2026-05-15 1301/week @ 2026-05-22 746/week @ 2026-05-29 951/week @ 2026-06-05 665/week @ 2026-06-12 1736/week @ 2026-06-19 1084/week @ 2026-06-26 2678/week @ 2026-07-03 1164/week @ 2026-07-10 5667/week @ 2026-07-17 3414/week @ 2026-07-24 1924/week @ 2026-07-31 4474/week @ 2026-08-07

15,644 downloads per month
Used in 7 crates (6 directly)

MIT/Apache

160KB
3K SLoC

DLPack integration for Rust.

This crate provides wrappers around the DLPack C API, allowing to exchange tensors with other libraries that support DLPack, such as PyTorch, TensorFlow, MXNet, CuPy, JAX, etc.

The C API is available in the sys module, and the following higher-level wrappers are provided:

We also provide tools to convert from and to other rust types, using the TryFrom trait. Conversions to and from std::vec::Vec and slices are always enabled, in the [vec] module.

Features

  • sync: enable sharing data behind Arc<Mutex<_>> and Arc<RwLock<_>> with DLPack, enforcing Rust's borrowing rules at runtime through the locks.
  • ndarray: enable conversion from and to ndarray::Array
  • pyo3: enable passing data from and to python, following the dlpack protocol (the data is passed through a PyCapsule object).

dlpk: DLPack integration for Rust

This crate contains a direct translation of the C header for DLPack, which is intended to be used inside Rust projects that want to offer a C API.

We also provide some tools to convert to and from other types, through the following cargo features:

Conversions to and from std::vec::Vec and slice are always enabled.

License

This crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Dependencies

~0–1.5MB
~30K SLoC