Einsum2Plan

Struct Einsum2Plan 

Source
pub struct Einsum2Plan<ID: AxisId> {
    pub batch: Vec<ID>,
    pub lo: Vec<ID>,
    pub ro: Vec<ID>,
    pub sum: Vec<ID>,
    pub left_trace: Vec<ID>,
    pub right_trace: Vec<ID>,
    pub left_perm: Vec<usize>,
    pub right_perm: Vec<usize>,
    pub c_to_internal_perm: Vec<usize>,
}
Expand description

Pre-computed execution plan for a binary einsum contraction.

Classifies axes into groups and precomputes the permutations needed to arrange operands for batched matrix multiplication.

Fields§

§batch: Vec<ID>

Batch axes: present in A, B, and C.

§lo: Vec<ID>

Left-output axes: present in A and C, not in B.

§ro: Vec<ID>

Right-output axes: present in B and C, not in A.

§sum: Vec<ID>

Contraction axes: present in A and B, not in C.

§left_trace: Vec<ID>

Left trace axes: present only in A.

§right_trace: Vec<ID>

Right trace axes: present only in B.

§left_perm: Vec<usize>

Permutation to reorder A to [lo, sum, batch] after trace reduction.

§right_perm: Vec<usize>

Permutation to reorder B to [sum, ro, batch] after trace reduction.

§c_to_internal_perm: Vec<usize>

Permutation to reorder C from IC order to [lo, ro, batch] order.

Implementations§

Source§

impl<ID: AxisId> Einsum2Plan<ID>

Source

pub fn new(ia: &[ID], ib: &[ID], ic: &[ID]) -> Result<Self, EinsumError>

Build a plan from axis labels.

ia, ib, ic are the axis labels for A, B, C respectively.

Uses linear scans instead of hash collections for axis classification, which is faster for the small label sets typical in einsum contractions.

Source

pub fn left_trace_indices(&self, ia: &[ID]) -> Vec<usize>

Get the indices of left_trace axes in the original ia array.

Source

pub fn right_trace_indices(&self, ib: &[ID]) -> Vec<usize>

Get the indices of right_trace axes in the original ib array.

Source

pub fn internal_to_c_perm(&self) -> Vec<usize>

Get the inverse of c_to_internal_perm (maps \[batch, lo, ro\] back to IC order).

Trait Implementations§

Source§

impl<ID: Clone + AxisId> Clone for Einsum2Plan<ID>

Source§

fn clone(&self) -> Einsum2Plan<ID>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<ID: Debug + AxisId> Debug for Einsum2Plan<ID>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<ID> Freeze for Einsum2Plan<ID>

§

impl<ID> RefUnwindSafe for Einsum2Plan<ID>
where ID: RefUnwindSafe,

§

impl<ID> Send for Einsum2Plan<ID>
where ID: Send,

§

impl<ID> Sync for Einsum2Plan<ID>
where ID: Sync,

§

impl<ID> Unpin for Einsum2Plan<ID>
where ID: Unpin,

§

impl<ID> UnwindSafe for Einsum2Plan<ID>
where ID: UnwindSafe,

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

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
§

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

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> MaybeSync for T