pub struct GatherPlan { /* private fields */ }Expand description
A compiled gather traversal for one value layout, index layout, and output layout.
Implementations§
Source§impl GatherPlan
impl GatherPlan
Sourcepub fn compile(
operand_dims: &[usize],
operand_strides: &[isize],
index_dims: &[usize],
index_strides: &[isize],
dest_dims: &[usize],
dest_strides: &[isize],
spec: GatherSpec,
) -> Result<Self>
pub fn compile( operand_dims: &[usize], operand_strides: &[isize], index_dims: &[usize], index_strides: &[isize], dest_dims: &[usize], dest_strides: &[isize], spec: GatherSpec, ) -> Result<Self>
Compile a gather plan for fixed operand, index, and destination layouts.
§Errors
Returns StridedError::StrideLengthMismatch when a stride list does
not match its dimension list, StridedError::OffsetOverflow when an
element count or a layout span does not fit usize/isize,
StridedError::NonInjectiveOutputLayout when the destination layout
maps two logical indices onto one offset.
StridedError::RankMismatch reports spec.slice_sizes or
spec.offset_dims of the wrong length, or an index vector that does not
match spec.start_index_map;
StridedError::InvalidAxis reports collapsed_slice_dims,
start_index_map, or offset_dims that repeat or exceed their rank,
index_vector_dim beyond the index rank, a slice size beyond its
operand extent, or a collapsed axis whose slice size is not one; and
StridedError::ShapeMismatch reports a dest_dims that is not the
gathered window/batch shape.
pub fn spec(&self) -> &GatherSpec
pub fn dest_dims(&self) -> &[usize]
Sourcepub fn execute<T, I>(
&self,
dest: &mut RawStridedMut<'_, T>,
operand: &RawStridedRef<'_, T>,
start_indices: &RawStridedRef<'_, I>,
exec: Exec<'_>,
) -> Result<()>
pub fn execute<T, I>( &self, dest: &mut RawStridedMut<'_, T>, operand: &RawStridedRef<'_, T>, start_indices: &RawStridedRef<'_, I>, exec: Exec<'_>, ) -> Result<()>
Execute the prepared gather traversal.
§Errors
Returns StridedError::PlanLayoutMismatch when the operand, index,
or destination view does not carry its compiled extents and strides,
before any destination write, and
StridedError::OffsetOverflow when a replayed chunk’s offset
arithmetic cannot be represented. Start indices are clamped into the
operand window, so an out-of-range index is not an error. The offset
arithmetic runs per worker above the threading threshold, so a
destination split across workers may be partially written when that
error surfaces.