Skip to main content

Representation

Trait Representation 

Source
pub trait Representation: Sealed + 'static { }
Expand description

Sealed selector for the owned payload representation of a TypedTensor.

The three markers are Host, Gpu and Dynamic. The trait is sealed: downstream crates select an existing representation, they do not define one.

§Examples

use tenferro_tensor::{Dynamic, DynRank, Host, Representation, TypedTensor};

fn extent<D: Representation>(tensor: &TypedTensor<f64, DynRank, D>) -> usize {
    tensor.shape()[0]
}
let host = TypedTensor::<f64, DynRank, Host>::from_host_vec_col_major(vec![3], vec![0.0; 3])?;
assert_eq!(extent(&host), 3);
let dynamic: TypedTensor<f64, DynRank, Dynamic> = host.into_dynamic();
assert_eq!(extent(&dynamic), 3);

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§