[−][src]Module ndarray_einsum_beta::contractors::pair_contractors
Contains the specific implementations of PairContractor
that represent the base-case ways
to contract two simplified tensors.
A tensor is simplified with respect to another tensor and a set of output indices if two conditions are met:
- Each index in the tensor is present in either the other tensor or in the output indices.
- Each index in the tensor appears only once.
Examples of einsum
strings with two simplified tensors:
ijk,jkl->il
ijk,jkl->ijkl
ijk,ijk->
Examples of einsum
strings with two tensors that are NOT simplified:
iijk,jkl->il
Not simplified becausei
appears twice in the LHS tensorijk,jkl->i
Not simplified becausel
only appears in the RHS tensor
If the two input tensors are both simplified, all instances of tensor contraction can be expressed as one of a small number of cases. Note that there may be more than one way to express the same contraction; some preliminary benchmarking has been done to identify the faster choice.
Structs
BroadcastProductGeneral | Permutes the axes of the LHS and RHS tensor, broadcasts into the output shape, and then computes the element-wise product of the two broadcast tensors. |
HadamardProduct | Computes the Hadamard (element-wise) product of two tensors. |
HadamardProductGeneral | Permutes the axes of the LHS and RHS tensors to the order in which those axes appear in the output before computing the Hadamard (element-wise) product. |
MatrixScalarProduct | Multiplies every element of the LHS tensor by the single scalar in the 0-d RHS tensor. |
MatrixScalarProductGeneral | Permutes the axes of the LHS tensor to the output order and multiply all elements by the single scalar in the 0-d RHS tensor. |
ScalarMatrixProduct | Multiplies every element of the RHS tensor by the single scalar in the 0-d LHS tensor. |
ScalarMatrixProductGeneral | Permutes the axes of the RHS tensor to the output order and multiply all elements by the single scalar in the 0-d LHS tensor. |
StackedTensordotGeneral | Repeatedly computes the tensor dot of subviews of the two tensors, iterating over indices which appear in the LHS, RHS, and output. |
TensordotFixedPosition | Performs tensor dot product for two tensors where no permutation needs to be performed,
e.g. |
TensordotGeneral | Computes the tensor dot product of two tensors, with individual permutations of the LHS and RHS performed as necessary, as well as a final permutation of the output. |
Functions
find_outputs_in_inputs_unique | |
maybe_find_outputs_in_inputs_unique | Helper function used throughout this module to find the positions of one set of indices
in a second set of indices. The most common case is generating a permutation to
be supplied to |