bundles / numpy latest / numpy / _core / einsumfunc / _optimal_path
function
numpy._core.einsumfunc:_optimal_path
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/einsumfunc.py :150
Signature
def _optimal_path ( input_sets , output_set , idx_dict , memory_limit ) Summary
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.
Parameters
input_sets: listList of sets that represent the lhs side of the einsum subscript
output_set: setSet that represents the rhs side of the overall einsum subscript
idx_dict: dictionaryDictionary of index sizes
memory_limit: intThe maximum number of elements in a temporary array
Returns
path: listThe optimal contraction order within the memory limit constraint.
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)
Aliases
-
numpy._core.einsumfunc._optimal_path