Expand description
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->ilijk,jkl->ijklijk,ijk->
Examples of einsum strings with two tensors that are NOT simplified:
iijk,jkl->ilNot simplified becauseiappears twice in the LHS tensorijk,jkl->iNot simplified becauselonly 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ยง
- Broadcast
Product General - 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.
- Hadamard
Product - Computes the Hadamard (element-wise) product of two tensors.
- Hadamard
Product General - 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.
- Matrix
Scalar Product - Multiplies every element of the LHS tensor by the single scalar in the 0-d RHS tensor.
- Matrix
Scalar Product General - 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.
- Scalar
Matrix Product - Multiplies every element of the RHS tensor by the single scalar in the 0-d LHS tensor.
- Scalar
Matrix Product General - 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.
- Stacked
Tensordot General - Repeatedly computes the tensor dot of subviews of the two tensors, iterating over indices which appear in the LHS, RHS, and output.
- Tensordot
Fixed Position - Performs tensor dot product for two tensors where no permutation needs to be performed,
e.g.
ijk,jkl->ilorijk,klm->ijlm. - Tensordot
General - 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
permuted_axes.