Skip to main content

ClikaRT::ops::einsum

function

einsum()

Tensor einsum(std::string_view equation, ClikaRT::Span<const Tensor> operands)

Einstein-summation contraction from a notation string.

equation names each operand's axes and (after ->) the output axes; omitting -> keeps the once-appearing labels in alphabetical order. One- and two-operand equations are served: one operand reduces and permutes; two operands contract through a single batched matmul.

Parameters

  • equation: the contraction, e.g. "bij,bjk->bik".
  • operands: the tensors, one per comma-separated input group.

Returns: the contracted tensor, shaped by the output labels.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the equation is malformed, a label's extents disagree, or more than two operands are passed.
ClikaRT::Tensor ops[] = {q, k};
auto scores = ClikaRT::ops::einsum("bhid,bhjd->bhij", ops);

Declared in ClikaRT/compute/ops.h, line 2709