einsums::compute_graph::plan_nary_einsum_with_spaces#

Note

Generated from the C++ headers by apiary --emit-cpp-docs-json.

Defined in header Einsums/ComputeGraph/NaryEinsum.hpp.

std::vector<NaryEinsumStep> plan_nary_einsum_with_spaces(const Graph &graph, std::string spec, std::vector<std::vector<std::size_t>> dims, std::vector<std::vector<SpaceId>> spaces, std::size_t max_intermediate_elements)#

The cheapest order to contract an einsum’s operands, ranked by the index spaces they are annotated with.

plan_nary_einsum with each letter bound to the space its axes are annotated with, by the rules a two-operand einsum binds its letters at capture, and ranked by the scaling graph's registry declares: an order that is cheaper asymptotically wins even where these extents would favour another, as MultiTermFactorization ranks it. A letter no annotated axis carries is anonymous and ranked by its extent.

Added in version 2.0.0.

Parameters:
  • graph – The graph whose space registry the annotations belong to.

  • spec – The spec, three or more operands; two are planned too, as one step.

  • dims – Each operand’s extents, in the spec’s order.

  • spaces – Each operand’s per-axis spaces in the spec’s order, then C’s, each empty where the tensor is not annotated; or empty altogether.

  • max_intermediate_elements – As for plan_nary_einsum.

Throws:

std::invalid_argument – as plan_nary_einsum does, when spaces does not hold one entry per operand and one for C, or when one letter is annotated with two different spaces.

Returns:

The steps, in the order to run them.