Expand description
Safe ownership and interoperability helpers for DLPack.
Producers convert into a Builder, which keeps the producer alive until
it builds a ManagedBox. ManagedBox calls the DLPack deleter on drop.
use dlpark::{Builder, DlpackFlags, versioned};
use ndarray::arr1;
let array = Box::new(arr1(&[1_i32, 2, 3]));
let tensor: versioned::Dlpack = Builder::from(array)
.insert_flags(DlpackFlags::READ_ONLY)
.unwrap()
.try_build()
.unwrap();
assert_eq!(tensor.shape().unwrap(), &[3]);legacy::Dlpack uses DLManagedTensor; versioned::Dlpack uses
DLManagedTensorVersioned and exposes version and flags.
Re-exports§
pub use builder::Builder;pub use dlpack::ManagedBox;
Modules§
- builder
- Deferred construction of legacy and versioned managed tensors. Deferred DLPack builder.
- dlpack
- Owning managed-tensor handles and data accessors. Owning handles for DLPack managed tensors.
- ffi
- Raw C ABI declarations generated from the bundled DLPack headers.
- interop
- Adapters for supported Rust tensor and image libraries. Conversions between DLPack and supported container libraries.
- legacy
- Legacy
DLManagedTensorownership type. Legacy DLPack managed tensor ownership. - metadata
- Shape and stride storage strategies used by
Builder. Shape and stride allocation strategies forcrate::Builder. - tensor
- Validation and data access methods for raw
DLTensorvalues. Validation, layout inspection, and CPU data access for raw DLPack tensors. - versioned
- Versioned
DLManagedTensorVersionedownership type. Versioned DLPack managed tensor ownership.
Structs§
- Borrowed
- Owns a resource together with a view that may depend on that owner.
- Dlpack
Flags - Flags carried by
DLManagedTensorVersioned.
Traits§
- Dlpack
Element - Maps a Rust element type to its DLPack data type descriptor.
- Managed
Tensor Base - Common operations implemented by the legacy and versioned managed tensor ABIs.
- Opaque
Context - Owns or tracks the opaque context stored in a DLPack managed tensor.