pub struct ErasedRawStridedUninitMut<'a> { /* private fields */ }Expand description
Borrowed dtype-erased raw strided output whose reachable elements may be uninitialized.
This descriptor is only accepted by operations that prove and perform a full overwrite of every reachable logical destination element. The backing allocation may contain non-reachable holes, which remain uninitialized.
Implementations§
Source§impl<'a> ErasedRawStridedUninitMut<'a>
impl<'a> ErasedRawStridedUninitMut<'a>
Sourcepub fn from_uninit_slice<T: KernelStorageElement>(
data: &'a mut [MaybeUninit<T>],
dims: &'a [usize],
strides: &'a [isize],
offset: isize,
) -> Result<Self>
pub fn from_uninit_slice<T: KernelStorageElement>( data: &'a mut [MaybeUninit<T>], dims: &'a [usize], strides: &'a [isize], offset: isize, ) -> Result<Self>
Create an uninitialized erased output descriptor from typed storage.
§Errors
Returns StridedError::StrideLengthMismatch when dims and
strides have different lengths, and
StridedError::OffsetOverflow when a reachable offset is not
representable: dim - 1 of a non-unit extent does not fit isize, a
stride times that last index or the accumulated offsets overflow
isize or go negative, or the highest reachable offset is not below
the buffer length. A layout with a zero extent skips this check. The
byte-length and alignment checks
cannot fail for a typed &mut [MaybeUninit<T>].
Sourcepub unsafe fn from_raw_parts(
dtype: KernelDType,
data: NonNull<u8>,
byte_len: usize,
dims: &'a [usize],
strides: &'a [isize],
offset: isize,
) -> Result<Self>
pub unsafe fn from_raw_parts( dtype: KernelDType, data: NonNull<u8>, byte_len: usize, dims: &'a [usize], strides: &'a [isize], offset: isize, ) -> Result<Self>
Construct from erased uninitialized storage.
§Safety
data..data + byte_len must be an aligned, writable allocation valid
for 'a, with provenance and extent sufficient for all reachable
elements. The caller must ensure every reachable element is completely
overwritten before it is read or exposed as initialized storage. The
allocation’s alignment is an allocation property independent of the
observed address, and the descriptor must have exclusive access with no
mutable alias or concurrent mutation during use.
§Errors
Returns StridedError::ByteLengthMismatch when byte_len is not
a whole number of dtype elements, and
StridedError::DataAlignmentMismatch when a non-empty data is
not aligned for dtype. Returns
StridedError::StrideLengthMismatch when dims and strides
have different lengths, and StridedError::OffsetOverflow when
a reachable offset is not representable: dim - 1 of a non-unit
extent does not fit isize, a stride times that last index or the
accumulated offsets overflow isize or go negative, or the highest
reachable offset is not below the storage length. A layout with a zero
extent skips this check.
Sourcepub fn data_as_uninit_mut<T: KernelStorageElement>(
&mut self,
) -> Result<&mut [MaybeUninit<T>]>
pub fn data_as_uninit_mut<T: KernelStorageElement>( &mut self, ) -> Result<&mut [MaybeUninit<T>]>
Borrow the uninitialized storage as its concrete scalar type.
§Errors
Returns StridedError::DTypeMismatch when T is not the
descriptor’s dtype.