Skip to content

Commit

Permalink
make recorder work for t2t and deepvit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Mar 30, 2021
1 parent 8135d70 commit d04ce06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'vit-pytorch',
packages = find_packages(exclude=['examples']),
version = '0.10.1',
version = '0.10.2',
license='MIT',
description = 'Vision Transformer (ViT) - Pytorch',
author = 'Phil Wang',
Expand Down
5 changes: 1 addition & 4 deletions vit_pytorch/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

from vit_pytorch.vit import Attention

def exists(val):
return val is not None

def find_modules(nn_module, type):
return [module for module in nn_module.modules() if isinstance(module, type)]

Expand All @@ -25,7 +22,7 @@ def _hook(self, _, input, output):
self.recordings.append(output.clone().detach())

def _register_hook(self):
modules = find_modules(self, Attention)
modules = find_modules(self.vit.transformer, Attention)
for module in modules:
handle = module.attend.register_forward_hook(self._hook)
self.hooks.append(handle)
Expand Down

0 comments on commit d04ce06

Please sign in to comment.