MCPcopy Create free account
hub / github.com/pytorch/tutorials / hook

Function hook

intermediate_source/visualizing_gradients_tutorial.py:145–147  ·  view source on GitHub ↗

Forward pass hook which attaches backward pass hooks to intermediate tensors

(module, args, output)

Source from the content-addressed store, hash-verified

143
144def hook_forward(module_name, grads, hook_backward):
145 def hook(module, args, output):
146 """Forward pass hook which attaches backward pass hooks to intermediate tensors"""
147 output.register_hook(hook_backward(module_name, grads))
148 return hook
149
150def hook_backward(module_name, grads):

Callers

nothing calls this directly

Calls 1

hook_backwardFunction · 0.85

Tested by

no test coverage detected