Barrier autograd node inserted on each gradient-bearing input of a hooked nn.Module.
Mirrors ModuleOutputHookNode but on the other side of the
module: it collects the gradients flowing back into the module's inputs
and fires the full backward hooks (which receive both grad_input and
grad_output tuples) before forwarding the (possibly replaced)
gradients to the upstream graph.
See Also
ModuleOutputHookNode : sibling barrier on the output side.
Notes
Hooks may return None (keep current gradients) or a tuple matching
the positional input signature with None entries for slots that
should remain untouched. Hooks may NOT change the dtype / shape of
returned gradients — downstream nodes rely on the original metadata
captured in ModuleBackwardHookState::input_metas.
Constructors
1ModuleInputHookNode
void ModuleInputHookNode(int state)Construct an input-side barrier bound to shared hook state.
Parameters
statestd::shared_ptr<ModuleBackwardHookState>Virtual methods
1Methods
4Park an incoming input gradient into the shared state.
Parameters
input_nrstd::uint32_tModuleBackwardHookState::grad_inputs). Out-of-range values are ignored.gradStorageConvenience non-barrier entry point — see ModuleOutputHookNode::apply.
Parameters
grad_outStorageReturns
std::vector<Storage>One Storage per outgoing edge.
Fire the full-backward hooks and emit one gradient per outgoing edge.
Returns
std::vector<Storage>One Storage per input edge in declaration order. Hooks may have replaced individual entries via their return tuple; empty slots become empty CpuStorage placeholders.
Graph label — "ModuleInputHook" — for debug printing and profiler traces. Overrides Node::node_name.