Skip to main content

Steps

Enum Steps 

Source
pub enum Steps {
    Stride {
        start: usize,
        len: usize,
        step: isize,
    },
    Padded {
        start: i128,
        len: usize,
        size: usize,
        stride: usize,
        edge: Edge,
    },
    Rotated {
        shift: usize,
        len: usize,
        stride: usize,
    },
    Table(Table),
}
Expand description

The source offsets of one result axis. Regular patterns need no position table; a missing offset reads fill.

Variants§

§

Stride

Consecutive offsets with a signed step.

Fields

§start: usize
§len: usize
§step: isize
§

Padded

Positions along one source axis, reading past its ends under the edge mode.

Fields

§start: i128
§len: usize
§size: usize
§stride: usize
§edge: Edge
§

Rotated

A whole source axis beginning at the shift and wrapping to the start.

Fields

§shift: usize
§len: usize
§stride: usize
§

Table(Table)

Explicit source offsets.

Implementations§

Source§

impl Steps

Source

pub const FILL: usize = usize::MAX

The table entry that marks a fill.

Source

pub fn along(len: usize, stride: usize) -> Self

Every position of an axis of len items with stride, in order.

Source

pub fn row_major( lens: &[usize], scale: usize, start: usize, ) -> impl Iterator<Item = Self> + '_

One entry for each of lens, reading an array of those lengths in row-major order from position start, with every stride multiplied by scale.

Source

pub fn table(offsets: Vec<usize>) -> Self

A table of offsets, with Steps::FILL where a fill goes.

Source

pub fn scaled(self, k: usize) -> Self

This entry with its offsets k times as far apart, as where each position it reads is a cell of k items.

Source

pub fn padded( start: i128, len: usize, size: usize, stride: usize, edge: Edge, ) -> Self

len positions from start along an axis of size items with stride, read past the axis’s ends by edge: a Padded entry where a position falls outside the axis, the Rotated entry for a wrapped stretch as long as the axis, a Stride of step 0 for an axis of one item that an edge other than Fill reads, and otherwise the Stride that reads the same offsets.

Source

pub fn clipped(start: i128, len: usize, size: usize, stride: usize) -> Self

padded with a fill past the axis’s ends.

Source

pub fn rotated(shift: usize, len: usize, stride: usize) -> Self

All len positions of an axis with stride, from position shift, wrapping round: a Rotated entry, or the Stride that reads the same offsets where the shift is a whole turn.

Source

pub fn len(&self) -> usize

The number of offsets.

Source

pub fn footprint(&self) -> usize

The bytes this entry takes: itself, and a table’s listed offsets.

Source

pub fn get(&self, j: usize) -> Option<usize>

Offset j, or None for a fill.

Source

pub fn offsets(&self) -> impl ExactSizeIterator<Item = Option<usize>> + '_

Every offset, in order, None for a fill.

Source

pub fn for_each(&self, each: impl FnMut(usize, Option<usize>))

Calls each with each position along this axis and its offset, or None where it gives a fill. It matches the kind of step once, before its loop. A loop through Steps::offsets or Steps::get matches it at every position, and makes a call there wherever LLVM keeps get out of line, as it can despite #[inline].

Source

pub fn count(steps: &[impl Borrow<Self>]) -> usize

How many positions steps reach: the product of their lengths.

Source

pub fn combined(base: usize, steps: &[impl Borrow<Self>]) -> Vec<usize>

The offset of every position that steps reach from base, in the order that walk visits them, with Steps::FILL where a fill goes. Steps::reach gives one of them.

Source

pub fn reach( base: usize, steps: &[impl Borrow<Self>], i: usize, ) -> Option<usize>

The offset that steps, one entry for each axis, outermost first, reach from base for item i of their frame, or None for a fill.

Source

pub fn furthest(base: usize, steps: &[impl Borrow<Self>]) -> Option<usize>

An offset that no item of steps passes from base: base plus each entry’s furthest offset, where a fill reaches none and a padded entry stops at the end of its axis. Only a table’s entry reads its offsets to find it. None where an entry has no items, so the walk reads nothing.

Source

pub fn run( base: usize, steps: &[impl Borrow<Self>], start: usize, n: usize, ) -> Option<(usize, isize)>

The first source offset and stride of items start..start + n, where they form one regular run. Singleton axes disappear and neighbouring strides can form one run. Padded and rotated reads must stay within their valid, unwrapped part.

Source

pub fn regular(steps: &[Self]) -> (usize, isize)

The innermost stretch of the frame whose items read at one regular stride, as its length and that stride: the product of the lengths of the innermost axes, outward, while each axis steps on from the ones inside it. Edges of padded and rotated axes don’t count, because only the runs that cross them copy. A run reads through run only where it lies inside one such stretch.

Source

pub fn contiguous(steps: &[Self]) -> usize

How many consecutive items of the frame read adjacent offsets: the stretch that regular gives where its stride is 1. A run reads in place only inside one such stretch, so a frame whose stretches are shorter than its blocks copies every block.

Source

pub fn skips(&self) -> bool

Whether this entry reads items that aren’t adjacent: a step or stride of more than 1, as a transpose’s innermost axis has.

Source

pub fn fills(&self) -> bool

Whether this entry gives a fill at some position: a Padded entry does where its edge mode is fill, and a table does where it holds Steps::FILL.

Source

pub fn affine(&self) -> Option<(usize, isize)>

This entry’s first offset and step, where it reads its whole axis as one regular run with no fill: a Stride, or a Rotated entry that doesn’t rotate.

Source

pub fn in_order(tables: &[Self]) -> bool

Whether a walk through tables reads offsets 0, 1, 2 and so on, in order. A copy through such tables of a source with as many items as the walk reads is the source unchanged. Only Stride entries that start at 0 qualify, and tables whose offsets run 0, 1, 2 and so on at their axis’s stride.

Source

pub fn spreads(&self) -> bool

Whether this entry repeats an offset or gives a fill. Applying an element-wise function to the items it reads, in place of reading the function’s results, would then compute an item more than once, or apply the function to a fill.

Source

pub fn per_axis(tables: &[Self], shape: &[usize]) -> Option<(usize, Vec<Self>)>

tables, a walk’s entries for a result of shape, as one entry for each axis of shape, with the offset of each entry of one item moved into the base. Neighbouring entries that step as one axis merge first (simplify), so that one axis of shape can read several of them, as a view that merges axes does. An entry over several axes splits into one Stride for each. None where an entry that isn’t a Stride covers several axes, or where one axis of shape reads entries that don’t merge.

Source

pub fn with_base(base: usize, steps: Vec<Self>) -> Vec<Self>

The tables of a walk from base whose entries are steps: steps, after an entry of one item at base where base isn’t 0. per_axis splits such tables back into base and steps.

Source

pub fn through( outer: &[Self], shape: &[usize], base: usize, inner: &[Self], ) -> Option<(usize, Vec<Self>)>

outer’s reads of an array of shape, composed with inner, which maps the positions along each axis of shape to offsets from base, with the new base. Walking the result reads what walking inner and then outer reads. Where an entry of outer walks several whole axes of shape, as a reshape of a view reads them, the walk splits it into one entry for each of those axes (by_axes), and the result holds one entry for each. None where outer’s entries don’t each walk one axis of shape even so (Walk::new), where two entries walk one axis that inner doesn’t map by a Stride, or where an entry reads part of an axis that inner rotates or clips. Callers then force the copy that inner describes, in one walk.

Source

pub fn rereads(outer: &[Self], shape: &[usize]) -> bool

Whether two of outer’s entries walk one axis of shape, as overlapping windows do. Applying an element-wise function to the items they read, in place of reading its results, would then compute each item once for every window that holds it.

Trait Implementations§

Source§

impl Clone for Steps

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Steps

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Steps

Source§

impl PartialEq for Steps

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Steps

Auto Trait Implementations§

§

impl !RefUnwindSafe for Steps

§

impl !UnwindSafe for Steps

§

impl Forget for Steps

§

impl Freeze for Steps

§

impl Send for Steps

§

impl Sync for Steps

§

impl Unpin for Steps

§

impl UnsafeUnpin for Steps

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.