Template Function sequant::opt::detail::single_term_opt¶
Defined in File single_term.hpp
Function Documentation¶
-
template<ObjectiveFunction Metric, has_index_extent IdxToSz>
EvalSequence sequant::opt::detail::single_term_opt(TensorNetwork const &network, IdxToSz &&idxsz, bool subnet_cse, std::function<bool(Tensor const&)> const &is_volatile_leaf = {}, double volatile_weight = 1.0, double footprint_weight = 0.0)¶ - Template Parameters:
Metric – Objective function (ObjectiveFunction::DenseFLOPs or ObjectiveFunction::DenseSize).
IdxToSz – Invocable type mapping an Index to its extent.
- Parameters:
network – A TensorNetwork object.
idxsz – An invocable on Index, that maps Index to its dimension.
subnet_cse – Whether to recognize equivalent subnetworks to try minimizing the ops counts.
is_volatile_leaf – Predicate marking a leaf tensor as volatile (its value changes on every replay); empty disables weighting. The predicate MUST be invariant under slot/index canonicalization — key on tensor label or structure, NOT on anonymous index identity — so that two subnetworks deemed equivalent by the subnet-CSE canonicalization also agree on volatility (the CSE path stores one cost per canonical subnet). ObjectiveFunction::DenseFLOPs only.
volatile_weight – Multiplier applied to the cost of each volatile-result contraction (volatile contractions are re-evaluated on every replay); persistent contractions are counted once. 1 (default) disables weighting.
footprint_weight – Per-intermediate storage-footprint penalty added to the cost (ObjectiveFunction::DenseFLOPs only); 0 (default) disables.
- Returns:
Optimal evaluation sequence under the chosen cost metric. If there are equivalent optimal sequences then the result is the one that keeps the order of tensors in the network as original as possible.