The create_graph half of the barrier protocol.
Eager backward hands a barrier each arriving gradient together with its
slot (Node::accumulate_barrier_grad) and runs the barrier once,
after every gradient has arrived. Graph-mode backward kept one pending
tensor per node and summed every arrival into it whatever its slot — right
for a node with a single slot, wrong for one with several, whose gradients
it added together. A barrier that implements this interface receives its
graph-mode gradients the way eager backward delivers them.
The engine finds it with graph_barrier_of; a barrier that does not
implement it keeps the single-pending-tensor path.
Destructor
1~GraphBarrier
void ~GraphBarrier()Virtual methods
2accumulate_barrier_grad_for_graph
void accumulate_barrier_grad_for_graph(int input_nr, int grad)Add grad to what slot input_nr holds. The sum is a graph op, so it stays differentiable.
Whether the barrier runs on its turn even when no gradient reached its slots — e.g. a hooked module's input barrier once its output barrier has run, which materializes zeros for the inputs as the reference's Function does.