pub trait TensorInit<'a, T: Scalar>: Sized {
    // Required methods
    fn from_data(
        context: &Context,
        shape: Shape,
        data: impl Into<Cow<'a, [T]>>
    ) -> Result<Self, TensorError>;
    fn init(context: &Context, shape: Shape) -> Self;

    // Provided method
    fn from_safetensors(
        context: &Context,
        tensor: TensorView<'a>
    ) -> Result<Self, TensorError> { ... }
}

Required Methods§

source

fn from_data( context: &Context, shape: Shape, data: impl Into<Cow<'a, [T]>> ) -> Result<Self, TensorError>

source

fn init(context: &Context, shape: Shape) -> Self

Provided Methods§

source

fn from_safetensors( context: &Context, tensor: TensorView<'a> ) -> Result<Self, TensorError>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, T: Scalar> TensorInit<'a, T> for TensorCpu<'a, T>

source§

impl<'a, T: Scalar, K: Kind> TensorInit<'a, T> for TensorGpu<T, K>