pub unsafe fn uninitialized_aligned<T: Datum>(
        shape: &[usize],
        alignment: usize,
    ) -> TractResult<Tensor> {
        assert!((alignment as u32).count_ones() == 1, "Invalid alignment required ({})", alignment);
        let len = shape.iter().cloned().product::<usize>() * size_of::<T>();
        let data = if len == 0 {
            vec![]
        } else {
            let aligned_buffer =
                alloc::alloc(alloc::Layout::from_size_align(len, alignment).map_err(|e| {
                    format!("Memory layout error: {:?} ({}, {})", e, len, alignment)
                })?);
            Vec::from_raw_parts(aligned_buffer as _, len, len)
        };
        Ok(Tensor { null: false, dt: T::datum_type(), shape: shape.into(), alignment, data })
    }
/// Create an uninitialized tensor with a given alignment (in bytes).
Create an uninitialized tensor with a given alignment (in bytes).
Create an uninitialized tensor with a given alignment ( in bytes ) .
pub unsafe fn uninitialized_aligned<T: Datum>(
        shape: &[usize],
        alignment: usize,
    ) -> TractResult<Tensor> {
        assert!((alignment as u32).count_ones() == 1, "Invalid alignment required ({})", alignment);
        let len = shape.iter().cloned().product::<usize>() * size_of::<T>();
        let data = if len == 0 {
            vec![]
        } else {
            let aligned_buffer =
                alloc::alloc(alloc::Layout::from_size_align(len, alignment).map_err(|e| {
                    format!("Memory layout error: {:?} ({}, {})", e, len, alignment)
                })?);
            Vec::from_raw_parts(aligned_buffer as _, len, len)
        };
        Ok(Tensor { null: false, dt: T::datum_type(), shape: shape.into(), alignment, data })
    }
pub unsafe fn uninitialized_aligned < T : Datum > ( shape : & [ usize ] , alignment : usize , ) -> TractResult < Tensor > { assert ! ( ( alignment as u32 ) count_ones ( ) 1 " " alignment ) ; let len = shape . iter ( ) . cloned ( ) . product :: < usize > ( ) * size_of :: < T > ( ) ; let data = if len == 0 { vec ! [ ] } else { let aligned_buffer = alloc :: alloc ( alloc :: Layout :: from_size_align ( len , alignment ) . map_err ( | e | { format ! ( " " e len alignment ) } ) ? ) ; Vec :: from_raw_parts ( aligned_buffer as _ , len , len ) } ; Ok ( Tensor { null : false , dt : T :: datum_type ( ) , shape : shape . into ( ) , alignment , data } ) }
Create an uninitialized tensor with a given alignment (in bytes).
Create an uninitialized tensor with a given alignment ( in bytes ) .
shape
&[usize]
alignment
usize
shape
&[usize]
alignment
usize