Function sequant::eval::detail::apply_persistence_frontier¶
Defined in File cell_table_builder.hpp
Function Documentation¶
-
inline void sequant::eval::detail::apply_persistence_frontier(CellTable &table, std::function<bool(std::size_t)> const &volatile_of)¶
Demotes every persistence candidate (
set_residency_flags:no volatile leaf, bound to no enclosing loop) that is not on the frontier of the invariant region, so thatpersistent== carries no volatile leaf and is bound to no enclosing loop instance and (some consumer of it is produced again on a later evaluation or it has no consumer at all – a forest root; validator rule 4 admits a zero-consumer cell only at the root scope).A cell is produced again on a later evaluation iff it is not persistent and either holds a volatile value or feeds a cell that is produced again. That covers the amplitude-dependent cells, and also the amplitude- independent ones that cannot persist because they are bound to a loop – a slice built inside a batch loop that a volatile consumer reads. Such a cell is rebuilt on every evaluation and reads its sources again each time, so an unbound source of it must persist, or the whole chain below it is rebuilt on every evaluation too.
The consumers of a cell are the consumer cells of every
Readwhosesourceis it, plus everyAssemblewhoseproduction.sourceis it – the same edge set the runtime’s cache-halt closure walks, by source cell and not by value, so the two cannot disagree about what reads a form.Why the frontier and not the whole invariant region: a persistent cell is held across evaluations and skipped by cache-halt on every later one. A candidate none of whose consumers is produced again is never read again. Keeping such a cell resident across evaluations buys nothing and costs its bytes in the persistent value store for the life of the cache handle.
Leaves follow the same rule: an input tensor none of whose consumers is produced again is re-fetched on the (rare) evaluation that actually needs it rather than held forever.