Skip to main content

TensorStorage

Trait TensorStorage 

Source
pub trait TensorStorage:
    Send
    + Sync
    + 'static {
    // Required methods
    fn dtype(&self) -> &Symbol;
    fn len(&self) -> usize;
    fn location(&self) -> TensorLocation;
    fn cell(&self, index: usize) -> Result<Value>;
    fn materialize(&self) -> Result<Arc<dyn TensorStorage>>;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Storage behind the canonical Tensor value.

Implementations may keep cells in host-native or resident layouts. Observation is fallible: a resident implementation performs and caches its checked readback in materialize. A successful materialization must return host storage with the same dtype and length.

Required Methods§

Source

fn dtype(&self) -> &Symbol

The logical scalar domain of every cell.

Source

fn len(&self) -> usize

The logical row-major cell count.

Source

fn location(&self) -> TensorLocation

The current storage placement.

Source

fn cell(&self, index: usize) -> Result<Value>

Observes one row-major cell.

Source

fn materialize(&self) -> Result<Arc<dyn TensorStorage>>

Returns a host-observable form of this storage.

Resident implementations cache both success and failure so repeated or concurrent observations perform at most one readback.

Source

fn as_any(&self) -> &dyn Any

Exposes the concrete storage for safe downcasting by typed adapters.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether the storage has no logical cells.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§