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 own storage and the uniform Tensor value.

Typed backends (for example dense f64 or i64 tensors) keep their own packed representation and use this trait to convert to and from the shared uniform storage the numbers/tensor domain operates on.

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

Converts this specialized tensor into the uniform Tensor storage.

Source

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

Rebuilds a specialized tensor 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§