register_forward_hook()
register_full_backward_hook()
register_forward_pre_hook()
Forward (post)
Forward pre
Backward
Modules — PyTorch 2.2 documentation
Building blocks of stateful computation.
PyTorch provides a robust library of modules and makes it simple to define new custom modules, allowing for
easy construction of elaborate, multi-layer neural networks.
https://pytorch.org/docs/stable/notes/modules.html#module-hooks
torch.nn.modules.module.register_module_forward_hook — PyTorch 2.2 documentation
This adds global state to the nn.module module
and it is only intended for debugging/profiling purposes.
https://pytorch.org/docs/stable/generated/torch.nn.modules.module.register_module_forward_hook.html

Seonglae Cho