pub struct PadPlan { /* private fields */ }Expand description
A compiled pad traversal.
Replay fills every destination element with the caller-provided fill scalar, then copies reachable input positions into the padded output. A dense column-major destination with a unit-stride axis-0 operand and non-negative edges without interior spacing instead writes disjoint spans (low pad, operand run, high pad) per column so each element is written once.
Implementations§
Source§impl PadPlan
impl PadPlan
Sourcepub fn compile(
operand_dims: &[usize],
operand_strides: &[isize],
dest_dims: &[usize],
dest_strides: &[isize],
edge_padding_low: &[i64],
edge_padding_high: &[i64],
interior_padding: &[i64],
) -> Result<Self>
pub fn compile( operand_dims: &[usize], operand_strides: &[isize], dest_dims: &[usize], dest_strides: &[isize], edge_padding_low: &[i64], edge_padding_high: &[i64], interior_padding: &[i64], ) -> Result<Self>
Compile a pad plan for one operand layout and destination layout.
§Errors
Returns StridedError::StrideLengthMismatch when the operand or
destination layout lengths differ from the operand rank, and
StridedError::RankMismatch when the edge or interior padding
lengths differ from it. Returns StridedError::InvalidAxis for a
negative interior padding or a padded extent that does not fit
usize, StridedError::ShapeMismatch when the destination dims are
not the padded extents, and
StridedError::NonInjectiveOutputLayout when two destination
elements map onto one offset, or the layout span is not representable.
Returns
StridedError::OffsetOverflow when an element count, a padded
extent or a cursor stride computation overflows.
Sourcepub fn execute<T>(
&self,
dest: &mut RawStridedMut<'_, T>,
operand: &RawStridedRef<'_, T>,
fill: T,
exec: Exec<'_>,
) -> Result<()>
pub fn execute<T>( &self, dest: &mut RawStridedMut<'_, T>, operand: &RawStridedRef<'_, T>, fill: T, exec: Exec<'_>, ) -> Result<()>
Execute the prepared pad traversal.
§Errors
Returns StridedError::PlanLayoutMismatch when the views do not
carry the compiled operand and destination layouts, and
StridedError::OffsetOverflow when the destination base offset or
its contiguous fill span cannot be expressed in usize.
Sourcepub fn execute_uninit<T>(
&self,
dest: &mut RawStridedMut<'_, MaybeUninit<T>>,
operand: &RawStridedRef<'_, T>,
fill: T,
exec: Exec<'_>,
) -> Result<()>
pub fn execute_uninit<T>( &self, dest: &mut RawStridedMut<'_, MaybeUninit<T>>, operand: &RawStridedRef<'_, T>, fill: T, exec: Exec<'_>, ) -> Result<()>
Execute pad into storage whose reachable destination elements are uninitialized.
§Errors
Returns StridedError::PlanLayoutMismatch when the views do not
carry the compiled operand and destination layouts, and
StridedError::OffsetOverflow when the destination base offset or
its contiguous fill span cannot be expressed in usize.