pub trait RealizeTo: HasErr + HasShape {
    // Required method
    fn try_realize<Dst: Shape<Concrete = <<Self as HasShape>::Shape as Shape>::Concrete>>(
        self
    ) -> Result<Self::WithShape<Dst>, Self>
       where Self::Shape: RealizeShapeTo<Dst>;

    // Provided method
    fn realize<Dst: Shape<Concrete = <<Self as HasShape>::Shape as Shape>::Concrete>>(
        self
    ) -> Self::WithShape<Dst>
       where Self::Shape: RealizeShapeTo<Dst>,
             Self: Debug { ... }
}
Expand description

Realizes the concrete shape of the tensor as another compatable shape, or returns the original tensor if the new shape’s dimensions are incompatable.

let a: Tensor<Rank2<2, 3>, f32, _> = dev.zeros();
let a = a.realize::<(usize, usize)>();
let mut a = a.realize::<Rank2<2, 3>>();
match a.try_realize::<(usize, Const<4>)>() {
    Ok(new) => println!("Shape was properly realized, returned new tensor"),
    Err(old) => println!("Shape could not be realized, returned the original tensor"),
}

Required Methods§

source

fn try_realize<Dst: Shape<Concrete = <<Self as HasShape>::Shape as Shape>::Concrete>>( self ) -> Result<Self::WithShape<Dst>, Self>where Self::Shape: RealizeShapeTo<Dst>,

Realizes the concrete shape of the tensor as another compatable shape, or returns the original tensor if the new shape’s dimensions are incompatable.

Provided Methods§

source

fn realize<Dst: Shape<Concrete = <<Self as HasShape>::Shape as Shape>::Concrete>>( self ) -> Self::WithShape<Dst>where Self::Shape: RealizeShapeTo<Dst>, Self: Debug,

Realizes the concrete shape of the tensor as another compatable shape, or returns the original tensor if the new shape’s dimensions are incompatable.

Implementors§

source§

impl<S: Shape, E, D: Storage<E>, T: Tape<E, D>> RealizeTo for Tensor<S, E, D, T>