Einsum Interface

This interface implements tensor variable elimination among tensors. In particular it does not implement continuous variable elimination.

naive_contract_einsum(eqn, *terms, **kwargs)[source]

Use for testing Contract against einsum

naive_einsum(eqn, *terms, **kwargs)[source]

Implements standard variable elimination.

naive_plated_einsum(eqn, *terms, **kwargs)[source]

Implements Tensor Variable Elimination (Algorithm 1 in [Obermeyer et al 2019])

[Obermeyer et al 2019] Obermeyer, F., Bingham, E., Jankowiak, M., Chiu, J.,
Pradhan, N., Rush, A., and Goodman, N. Tensor Variable Elimination for Plated Factor Graphs, 2019
einsum(eqn, *terms, **kwargs)[source]

Top-level interface for optimized tensor variable elimination.

Parameters:
  • equation (str) – An einsum equation.
  • *terms (funsor.terms.Funsor) – One or more operands.
  • plates (set) – Optional keyword argument denoting which funsor dimensions are plate dimensions. Among all input dimensions (from terms): dimensions in plates but not in outputs are product-reduced; dimensions in neither plates nor outputs are sum-reduced.