pub struct ErasedRawStridedPtr<'a> { /* private fields */ }Expand description
Pointer-backed dtype-erased input used by one-shot write entry points.
Unlike ErasedRawStridedRef, this descriptor does not create a shared
Rust reference at construction time. That lets the entry point reject an
input/output overlap before forming references to either side.
Implementations§
Source§impl<'a> ErasedRawStridedPtr<'a>
impl<'a> ErasedRawStridedPtr<'a>
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>
Create a pointer-backed descriptor from erased storage.
§Safety
data must point into an allocation whose alignment is suitable for
dtype, independently of the observed address. The allocation must
provide byte_len initialized, readable bytes with valid provenance
for 'a, and remain alive for 'a. For bool, the bytes may contain
invalid values temporarily. They must not be read or used to form a
typed reference until a caller has rejected overlap and
Self::try_as_ref_after_no_overlap has validated the complete extent.
The allocation may overlap a destination.
The original owner may perform synchronized sequential mutation through
the same-provenance raw pointer before conversion. No concurrent
mutation or conflicting access is permitted during overlap checking,
conversion, or consumer access.
Sourcepub fn from_ref(input: &ErasedRawStridedRef<'a>) -> Self
pub fn from_ref(input: &ErasedRawStridedRef<'a>) -> Self
Borrow a safe erased input as a pointer descriptor.
Sourcepub unsafe fn try_as_ref_after_no_overlap(
&self,
) -> Result<ErasedRawStridedRef<'_>>
pub unsafe fn try_as_ref_after_no_overlap( &self, ) -> Result<ErasedRawStridedRef<'_>>
Convert this pointer to an initialized descriptor after overlap checks.
§Safety
The caller must have proved that no mutable allocation overlaps this
pointer’s complete byte extent.
The allocation contract from Self::from_raw_parts must still hold.
No mutation or other conflicting access may occur during this conversion
or for the duration of the returned descriptor’s consumer access.
Bool bytes are validated here, immediately before typed access.
pub fn dtype(&self) -> KernelDType
Sourcepub fn overlaps_mut(&self, dest: &ErasedRawStridedMut<'_>) -> Result<bool>
pub fn overlaps_mut(&self, dest: &ErasedRawStridedMut<'_>) -> Result<bool>
Check overlap with initialized mutable storage without reading it.
Sourcepub fn overlaps_uninit_mut(
&self,
dest: &ErasedRawStridedUninitMut<'_>,
) -> Result<bool>
pub fn overlaps_uninit_mut( &self, dest: &ErasedRawStridedUninitMut<'_>, ) -> Result<bool>
Check overlap with uninitialized mutable storage without reading it.
pub fn dims(&self) -> &'a [usize]
pub fn strides(&self) -> &'a [isize]
pub fn offset(&self) -> isize
Trait Implementations§
Source§impl<'a> Clone for ErasedRawStridedPtr<'a>
impl<'a> Clone for ErasedRawStridedPtr<'a>
Source§fn clone(&self) -> ErasedRawStridedPtr<'a>
fn clone(&self) -> ErasedRawStridedPtr<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more