module Num::Einsum
Extended Modules
Defined in:
einsum/contractors/pair.creinsum/optimizers.cr
einsum/strategies.cr
einsum/validation.cr
Instance Method Summary
-
#einsum(input_string : String, operands : Array(Tensor(U, CPU(U)))) forall U
Evaluates the Einstein summation convention on the operands.
-
#einsum(input_string : String, *operands : Tensor(U, CPU(U))) forall U
Evaluates the Einstein summation convention on the operands.
Instance Method Detail
Evaluates the Einstein summation convention on the operands.
The Einstein summation convention can be used to compute many multi-dimensional, linear algebraic array operations. einsum provides a succinct way of representing these.
A non-exhaustive list of these operations, which can be computed by einsum, is shown below:
Trace of an array
Return a diagonal
Array axis summations
Transpositions and permutations
Matrix multiplication and dot product
Vector inner and outer products
Broadcasting, element-wise and scalar multiplication
Tensor contractions
The subscripts string is a comma-separated list of subscript labels,
where each label refers to a dimension of the corresponding operand.
Whenever a label is repeated it is summed, so
Num::Einsum.einsum("i,i", a, b)
is equivalent to an inner operation.
If a label appears only once, it is not summed, so
Num::Einsum.einsum("i", a)
produces a view of a with no changes.
A further example Num::Einsum.einsum("ij,jk", a, b)
describes traditional
matrix multiplication and is equivalent to a.matmul(b). Repeated
subscript labels in one operand take the diagonal. For example,
Num::Einsum.einsum("ii", a)
gets the trace of a matrix
Evaluates the Einstein summation convention on the operands.
The Einstein summation convention can be used to compute many multi-dimensional, linear algebraic array operations. einsum provides a succinct way of representing these.
A non-exhaustive list of these operations, which can be computed by einsum, is shown below:
Trace of an array
Return a diagonal
Array axis summations
Transpositions and permutations
Matrix multiplication and dot product
Vector inner and outer products
Broadcasting, element-wise and scalar multiplication
Tensor contractions
The subscripts string is a comma-separated list of subscript labels,
where each label refers to a dimension of the corresponding operand.
Whenever a label is repeated it is summed, so
Num::Einsum.einsum("i,i", a, b)
is equivalent to an inner operation.
If a label appears only once, it is not summed, so
Num::Einsum.einsum("i", a)
produces a view of a with no changes.
A further example Num::Einsum.einsum("ij,jk", a, b)
describes traditional
matrix multiplication and is equivalent to a.matmul(b). Repeated
subscript labels in one operand take the diagonal. For example,
Num::Einsum.einsum("ii", a)
gets the trace of a matrix