Template Function sequant::batch_loop_regions

Function Documentation

template<std::ranges::random_access_range Range>
std::vector<std::pair<std::size_t, std::size_t>> sequant::batch_loop_regions(const Range &expressions, const ExportContext &ctx)

Determines ranges of consecutive expressions that might be executed repeatedly as part of a loop over batch indices. The result is conservative: for every depth k, every maximal range of consecutive expressions whose (first k) batch indices agree is reported, which covers every loop a generator may create when fusing the batching of consecutive expressions.

Parameters:
  • expressions – Range of expression trees in the order of export

  • ctx – The context holding the batch indices of the expressions

Returns:

Ranges [begin, end) of positions in expressions