Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions transformer_lens/hook_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ def full_hook(
module_output = module_output[0]
return hook(module_output, hook=self)

full_hook.__name__ = (
hook.__repr__()
) # annotate the `full_hook` with the string representation of the `hook` function
# annotate the `full_hook` with the string representation of the `hook` function
if isinstance(hook, partial):
# partial.__repr__() can be extremely slow if arguments contain large objects, which
# is common when caching tensors.
full_hook.__name__ = f"partial({hook.func.__repr__()},...)"
else:
full_hook.__name__ = hook.__repr__()

if dir == "fwd":
pt_handle = self.register_forward_hook(full_hook)
Expand Down
Loading