1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Safe ownership and interoperability helpers for [DLPack].
//!
//! Producers convert into an allocation-specific [`allocation::Initialized`],
//! configure scalar fields, and finish it as a locally produced tensor.
//!
//! ```
//! # #[cfg(feature = "ndarray")]
//! # {
//! use dlpark::{DlpackFlags, allocation::dynamic, ffi::DLManagedTensorVersioned, versioned};
//! use ndarray::arr1;
//!
//! let mut initialized: dynamic::Initialized<DLManagedTensorVersioned> =
//! Box::new(arr1(&[1_i32, 2, 3])).try_into().unwrap();
//! initialized.set_flags(DlpackFlags::READ_ONLY).unwrap();
//! let tensor: versioned::Dlpack = unsafe { initialized.finish() };
//! assert_eq!(tensor.validate().unwrap().shape(), &[3]);
//! # }
//! ```
//!
//! [`legacy::Dlpack`] uses the legacy ABI; [`versioned::Dlpack`] uses the
//! versioned ABI and exposes version and flags.
//!
//! [DLPack]: https://dmlc.github.io/dlpack/latest/
/// Owning managed-tensor handles and data accessors.
/// Adapters for supported Rust tensor and image libraries.
/// Legacy `DLManagedTensor` ownership alias.
/// Python DLPack capsule, stream, and exchange API support.
/// Validation and data access methods for raw `DLTensor` values.
/// Versioned `DLManagedTensorVersioned` ownership alias.
/// Shape and stride metadata composed with managed tensor allocations.
pub use Borrowed;
pub use OpaqueContext;
pub use TryFromDlpack;
pub use DlpackElement;
pub use Managed;
pub use ;
pub use ;
pub use VersionError;