Skip to content
class

BackwardPass

BackwardPass

The backward pass running on this thread.

A barrier keeps the gradients delivered to it until its own turn comes. A pass can deliver to a barrier and never give it that turn — autograd.grad skips a node that leads to no requested input — and the next pass over the same graph (retain_graph=True) must not add onto what that one left. Engine::backward and Engine::grad each open a pass; a barrier holding gradients from a different pass discards them first.

A pass opened inside another — a hook that calls autograd.grad — gets its own id and hands the outer one back when it closes. The outer pass is still open meanwhile, and what it delivered to a barrier the inner pass crosses is set aside rather than discarded (PassSlots).

Constructors

1

Destructor

1

Static methods

2
static

current

int current()

Id of the innermost pass open on this thread; 0 outside any pass.

static

is_open

bool is_open(int id)

Whether pass id is open on this thread — running, or waiting for a pass opened inside it to finish.

Operators

1
op

operator=

BackwardPass & operator=(const BackwardPass &)