TensordotFixedPosition

Struct TensordotFixedPosition 

Source
pub struct TensordotFixedPosition {
    len_uncontracted_lhs: usize,
    len_uncontracted_rhs: usize,
    len_contracted_axes: usize,
    output_shape: Vec<usize>,
}
Expand description

Performs tensor dot product for two tensors where no permutation needs to be performed, e.g. ijk,jkl->il or ijk,klm->ijlm.

The axes to be contracted must be the last axes of the LHS tensor and the first axes of the RHS tensor, and the axis order for the output tensor must be all the uncontracted axes of the LHS tensor followed by all the uncontracted axes of the RHS tensor, in the orders those originally appear in the LHS and RHS tensors.

The contraction is performed by reshaping the LHS into a matrix (2-D tensor) of shape [len_uncontracted_lhs, len_contracted_axes], reshaping the RHS into shape [len_contracted_axes, len_contracted_rhs], matrix-multiplying the two reshaped tensor, and then reshaping the result into […self.output_shape].

Fields§

§len_uncontracted_lhs: usize

The product of the lengths of all the uncontracted axes in the LHS (or 1 if all of the LHS axes are contracted)

§len_uncontracted_rhs: usize

The product of the lengths of all the uncontracted axes in the RHS (or 1 if all of the RHS axes are contracted)

§len_contracted_axes: usize

The product of the lengths of all the contracted axes (or 1 if no axes are contracted, i.e. the outer product is computed)

§output_shape: Vec<usize>

The shape that the tensor dot product will be recast to

Implementations§

Source§

impl TensordotFixedPosition

Source

pub fn new(sc: &SizedContraction) -> Self

Source

pub fn from_shapes_and_number_of_contracted_axes( lhs_shape: &[usize], rhs_shape: &[usize], num_contracted_axes: usize, ) -> Self

Compute the uncontracted and contracted axis lengths and the output shape based on the input shapes and how many axes should be contracted from each tensor.

TODO: The assert_eq! here could be tightened up by verifying that the last num_contracted_axes of the LHS match the first num_contracted_axes of the RHS axis-by-axis (as opposed to only checking the product as is done here.)

Trait Implementations§

Source§

impl Clone for TensordotFixedPosition

Source§

fn clone(&self) -> TensordotFixedPosition

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 Debug for TensordotFixedPosition

Source§

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

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

impl<A> PairContractor<A> for TensordotFixedPosition

Source§

fn contract_pair<'a, 'b, 'c, 'd>( &self, lhs: &'b ArrayViewD<'a, A>, rhs: &'d ArrayViewD<'c, A>, ) -> ArrayD<A>
where A: Clone + LinalgScalar, 'a: 'b, 'c: 'd,

Source§

fn contract_and_assign_pair<'a, 'b, 'c, 'd, 'e, 'f>( &self, lhs: &'b ArrayViewD<'a, A>, rhs: &'d ArrayViewD<'c, A>, out: &'f mut ArrayViewMutD<'e, A>, )
where A: Clone + LinalgScalar, 'a: 'b, 'c: 'd, 'e: 'f,

Auto Trait Implementations§

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