pub trait Array:
Any
+ Send
+ Sync {
// Required methods
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn shape(&self) -> Vec<usize>;
fn dtype(&self) -> DLDataType;
fn device(&self) -> DLDevice;
fn as_dlpack(
&self,
device: DLDevice,
stream: Option<i64>,
max_version: DLPackVersion,
) -> Result<DLPackTensor, ParseError>;
fn copy(&self) -> Box<dyn Array>;
}Expand description
Storage hook for one per-atom field of a ConFrameBuilder.
Implementors hold the raw bytes for a single field (e.g. all atom
positions as a (N, 3) f64 block) and expose them via DLPack so
downstream consumers can map a numpy / Eigen / torch view onto
the same memory zero-copy.
Required Methods§
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any access for downcast.
Sourcefn dtype(&self) -> DLDataType
fn dtype(&self) -> DLDataType
DLPack dtype of the elements.
Sourcefn as_dlpack(
&self,
device: DLDevice,
stream: Option<i64>,
max_version: DLPackVersion,
) -> Result<DLPackTensor, ParseError>
fn as_dlpack( &self, device: DLDevice, stream: Option<i64>, max_version: DLPackVersion, ) -> Result<DLPackTensor, ParseError>
Export a DLPack-managed tensor view of this array.
device requests the consumer’s preferred device; CPU
implementors return Err(ParseError::ValidationError(...))
when asked for a non-CPU device they cannot service.
stream is the consumer’s stream (CUDA / ROCm / SYCL); CPU
backings ignore it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T> Array for Arc<RwLock<ArrayD<T>>>
Default Rust backing for the Array trait: shared, lockable,
dynamic-rank ndarray. Matches metatensor v2’s
Arc<RwLock<ArrayD<T>>> choice and inherits its DLPack +
concurrency semantics.
impl<T> Array for Arc<RwLock<ArrayD<T>>>
Default Rust backing for the Array trait: shared, lockable,
dynamic-rank ndarray. Matches metatensor v2’s
Arc<RwLock<ArrayD<T>>> choice and inherits its DLPack +
concurrency semantics.