opt_einsum.paths.BranchBound¶
-
class
opt_einsum.paths.
BranchBound
(nbranch=None, cutoff_flops_factor=4, minimize='flops', cost_fn='memory-removed')[source]¶ Explores possible pair contractions in a depth-first recursive manner like the
optimal
approach, but with extra heuristic early pruning of branches as well sieving bymemory_limit
and the best path found so far. Returns the lowest cost path. This algorithm still scales factorially with respect to the elements in the listinput_sets
ifnbranch
is not set, but it scales exponentially likenbranch**len(input_sets)
otherwise.- Parameters
nbranch (None or int, optional) – How many branches to explore at each contraction step. If None, explore all possible branches. If an integer, branch into this many paths at each step. Defaults to None.
cutoff_flops_factor (float, optional) – If at any point, a path is doing this much worse than the best path found so far was, terminate it. The larger this is made, the more paths will be fully explored and the slower the algorithm. Defaults to 4.
minimize ({‘flops’, ‘size’}, optional) – Whether to optimize the path with regard primarily to the total estimated flop-count, or the size of the largest intermediate. The option not chosen will still be used as a secondary criterion.
cost_fn (callable, optional) – A function that returns a heuristic ‘cost’ of a potential contraction with which to sort candidates. Should have signature
cost_fn(size12, size1, size2, k12, k1, k2)
.
-
__init__
(nbranch=None, cutoff_flops_factor=4, minimize='flops', cost_fn='memory-removed')[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__call__
(inputs, output, size_dict[, …])- Parameters
input_sets (list) – List of sets that represent the lhs side of the einsum subscript
__delattr__
(name, /)Implement delattr(self, name).
__dir__
()Default dir() implementation.
__eq__
(value, /)Return self==value.
__format__
(format_spec, /)Default object formatter.
__ge__
(value, /)Return self>=value.
__getattribute__
(name, /)Return getattr(self, name).
__gt__
(value, /)Return self>value.
__hash__
()Return hash(self).
__init__
([nbranch, cutoff_flops_factor, …])Initialize self.
__init_subclass__
This method is called when a class is subclassed.
__le__
(value, /)Return self<=value.
__lt__
(value, /)Return self<value.
__ne__
(value, /)Return self!=value.
__new__
(**kwargs)Create and return a new object.
__reduce__
()Helper for pickle.
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
__sizeof__
()Size of object in memory, in bytes.
__str__
()Return str(self).
__subclasshook__
Abstract classes can override this to customize issubclass().
_check_args_against_first_call
(inputs, …)Utility that stateful optimizers can use to ensure they are not called with different contractions across separate runs.
Attributes
__dict__
__doc__
__module__
__weakref__
list of weak references to the object (if defined)
path