_greedy_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 greedy contraction order within the memory limit constraint.
Finds the path by contracting the best pair until the input list is exhausted. The best pair is found by minimizing the tuple (-prod(indices_removed), cost)
. What this amounts to is prioritizing matrix multiplication or inner product operations, then Hadamard like operations, and finally outer operations. Outer products are limited by memory_limit
. This algorithm scales cubically with respect to the number of 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}
... _greedy_path(isets, oset, idx_sizes, 5000) [(0, 2), (0, 1)]
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.gradient
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