pub fn random(sizes: Vec<usize>, datum_type: DatumType) -> Tensor {
    use std::iter::repeat_with;
    fn make<D>(shape: Vec<usize>) -> Tensor
    where
        D: Datum,
        rand::distributions::Standard: rand::distributions::Distribution<D>,
    {
        let len = shape.iter().product();
        tract_core::ndarray::ArrayD::from_shape_vec(
            shape,
            repeat_with(|| rand::random::<D>()).take(len).collect(),
        )
        .unwrap()
        .into()
    }

    match datum_type {
        DatumType::F64 => make::<f64>(sizes),
        DatumType::F32 => make::<f32>(sizes),
        DatumType::I32 => make::<i32>(sizes),
        DatumType::I8 => make::<i8>(sizes),
        DatumType::U8 => make::<u8>(sizes),
        _ => unimplemented!("missing type"),
    }
}
/// Generates a random tensor of a given size and type.
Generates a random tensor of a given size and type.
Generates a random tensor of a given size and type .
pub fn random(sizes: Vec<usize>, datum_type: DatumType) -> Tensor {
    use std::iter::repeat_with;
    fn make<D>(shape: Vec<usize>) -> Tensor
    where
        D: Datum,
        rand::distributions::Standard: rand::distributions::Distribution<D>,
    {
        let len = shape.iter().product();
        tract_core::ndarray::ArrayD::from_shape_vec(
            shape,
            repeat_with(|| rand::random::<D>()).take(len).collect(),
        )
        .unwrap()
        .into()
    }
    match datum_type {
        DatumType::F64 => make::<f64>(sizes),
        DatumType::F32 => make::<f32>(sizes),
        DatumType::I32 => make::<i32>(sizes),
        DatumType::I8 => make::<i8>(sizes),
        DatumType::U8 => make::<u8>(sizes),
        _ => unimplemented!("missing type"),
    }
}
pub fn random ( sizes : Vec < usize > , datum_type : DatumType ) -> Tensor { use std :: iter :: repeat_with ; fn make < D > ( shape : Vec < usize > ) -> Tensor where D : Datum , rand :: distributions :: Standard : rand :: distributions :: Distribution < D > , { let len = shape . iter ( ) . product ( ) ; tract_core :: ndarray :: ArrayD :: from_shape_vec ( shape , repeat_with ( | | rand :: random :: < D > ( ) ) . take ( len ) . collect ( ) , ) . unwrap ( ) . into ( ) } match datum_type { DatumType :: F64 => make :: < f64 > ( sizes ) , DatumType :: F32 => make :: < f32 > ( sizes ) , DatumType :: I32 => make :: < i32 > ( sizes ) , DatumType :: I8 => make :: < i8 > ( sizes ) , DatumType :: U8 => make :: < u8 > ( sizes ) , _ => unimplemented ! ( " " ) , } }
Generates a random tensor of a given size and type.
Generates a random tensor of a given size and type .
sizes
Vec<usize>
datum_type
DatumType