Template Function sequant::recycle_intermediate_names

Function Documentation

template<std::ranges::range Groups, typename Predicate>
opt::NameRecyclingResult sequant::recycle_intermediate_names(Groups &groups, const ExportContext &ctx, const Predicate &overwrites, opt::ShapeCompatibility compatibility, opt::IntermediateNamePool::LabelGenerator label_gen = opt::IntermediateNamePool::default_label_generator(), bool conflicts_only = false)

Recycles names of intermediates in the given groups of expressions to be exported (see opt::recycle_intermediate_names). Names are recycled within each group, i.e. intermediates must be defined and used within the same group. Two intermediates may only share a name if they are batched over the same indices and, if ctx has an IRREP context, span the same IRREPs (where IRREPs are propagated across all groups) and a name already used for different IRREPs in a previous group is never assigned. Loops over batch indices are taken into account when determining the lifetime of intermediates (see batch_loop_regions). Tensors are identified the way the export does, i.e. after being rewritten by ctx. Trees that need rebuilding are rebuilt via to_export_tree, retaining their IDs such that information associated with them (e.g. batch indices) stays valid.

Parameters:
  • groups – Range of groups of expressions in the order of export, where every group is a random-access range of expression trees in the order of export

  • ctx – The context used for the export

  • overwrites – Predicate determining whether a given expression tree overwrites rather than adds to the previous value of its result. Only the results of such trees are considered for name recycling.

  • compatibility – Shape compatibility required for recycling a name

  • label_gen – Generator for new names of intermediates

  • conflicts_only – If true, no names are recycled and only the intermediates whose name is used for different IRREPs in different groups are renamed (to names not used anywhere else). This requires an IRREP context in ctx, otherwise nothing is renamed.

Returns:

Statistics about the renaming (accumulated over all groups)