Skip to main content

Array

Trait Array 

Source
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§

Source

fn as_any(&self) -> &dyn Any

&dyn Any access for downcast (mirrors metatensor’s pattern).

Source

fn as_any_mut(&mut self) -> &mut dyn Any

&mut dyn Any access for downcast.

Source

fn shape(&self) -> Vec<usize>

Shape of the underlying tensor.

Source

fn dtype(&self) -> DLDataType

DLPack dtype of the elements.

Source

fn device(&self) -> DLDevice

Device residency of the storage.

Source

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.

Source

fn copy(&self) -> Box<dyn Array>

Deep-copy this array (used by ConFrameBuilder::clone + move_data-style ops). Default impl just clones through the implementor’s natural mechanism.

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.

Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

fn shape(&self) -> Vec<usize>

Source§

fn dtype(&self) -> DLDataType

Source§

fn device(&self) -> DLDevice

Source§

fn as_dlpack( &self, device: DLDevice, _stream: Option<i64>, _max_version: DLPackVersion, ) -> Result<DLPackTensor, ParseError>

Source§

fn copy(&self) -> Box<dyn Array>

Implementors§