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§
Sourcefn shape(&self) -> &[usize]
fn shape(&self) -> &[usize]
The length of each axis of the specialized tensor, outermost first.
Sourcefn to_uniform(&self) -> Tensor
fn to_uniform(&self) -> Tensor
Converts this specialized tensor into the uniform Tensor storage.
Sourcefn from_uniform(tensor: &Tensor) -> Option<Self>where
Self: Sized,
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".