Skip to content
class

PassSlots

PassSlots

A barrier's slots, kept per backward pass.

What a barrier is handed belongs to the pass that handed it. A pass that delivered and never gave the barrier its turn — an exception, a pruned autograd.grad — must not seed the next pass. A pass opened inside another that crosses the same barrier must neither add onto the outer pass's gradients nor wipe them: they are set aside while it runs and put back when the outer pass resumes, as each pass of the reference has input buffers of its own.

The barrier keeps the running pass's slots where it reads them; this keeps the pass they belong to and those of outer passes still open.

Methods

2
fn

enter

bool enter(Slots & live, Slots empty)

Make live the running pass's slots. When they belong to another pass they are set aside if that pass is still open and dropped if it is not; live becomes what the running pass set aside earlier, or empty. Returns whether live changed hands.

fnconst

is_running

bool is_running()

Whether the slots the barrier holds are the running pass's already.