Skip to main content

SpecTensor

Trait SpecTensor 

Source
pub trait SpecTensor:
    Send
    + Sync
    + 'static {
    // Required methods
    fn shape(&self) -> &[usize];
    fn dtype(&self) -> Symbol;
    fn to_uniform(&self) -> Tensor;
    fn from_uniform(tensor: &Tensor) -> Option<Self>
       where Self: Sized;
}
Expand description

Interface a specialized element-type tensor backend implements to bridge its typed view and the uniform Tensor value.

Typed backends (for example dense f64 or i64 tensors) wrap the canonical Tensor value and use typed TensorStorage implementations for their native cells. Conversions should clone that canonical tensor when storage already matches the backend, preserving shared storage identity for runtime projection and Citizen round-trips.

Required Methods§

Source

fn shape(&self) -> &[usize]

The length of each axis of the specialized tensor, outermost first.

Source

fn dtype(&self) -> Symbol

The element number domain (dtype) of the specialized tensor’s cells.

Source

fn to_uniform(&self) -> Tensor

Returns the canonical uniform Tensor backing this typed view.

Source

fn from_uniform(tensor: &Tensor) -> Option<Self>
where Self: Sized,

Rebuilds a specialized tensor view from uniform storage, or None if the uniform tensor’s dtype or shape does not fit this backend.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§