_optimal_path(input_sets, output_set, idx_dict, memory_limit)
List of sets that represent the lhs side of the einsum subscript
Set that represents the rhs side of the overall einsum subscript
Dictionary of index sizes
The maximum number of elements in a temporary array
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
.
>>> isets = [set('abd'), set('ac'), set('bdc')]See :
... oset = set()
... idx_sizes = {'a': 1, 'b':2, 'c':3, 'd':4}
... _optimal_path(isets, oset, idx_sizes, 5000) [(0, 2), (0, 1)]
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