numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturns
_optimal_path(input_sets, output_set, idx_dict, memory_limit)

Parameters

input_sets : list

List of sets that represent the lhs side of the einsum subscript

output_set : set

Set that represents the rhs side of the overall einsum subscript

idx_dict : dictionary

Dictionary of index sizes

memory_limit : int

The maximum number of elements in a temporary array

Returns

path : list

The optimal contraction order within the memory limit constraint.

Computes all possible pair contractions, sieves the results based on memory_limit and returns the lowest cost path. This algorithm scales factorial with respect to the elements in the list input_sets .

Examples

>>> isets = [set('abd'), set('ac'), set('bdc')]
... oset = set()
... idx_sizes = {'a': 1, 'b':2, 'c':3, 'd':4}
... _optimal_path(isets, oset, idx_sizes, 5000) [(0, 2), (0, 1)]
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/einsumfunc.py#145
type: <class 'function'>
Commit: