numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
_greedy_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 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 .

Examples

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

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.gradient

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#312
type: <class 'function'>
Commit: