Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix up the problem in model_profiling when fed 'Modulelist' #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

13015517713
Copy link

Problem Introduction:
  Module.register_forward_hook function adds hooks to each module (with forward function) without ModuleList. So ModuleList module does not record the profile including macs and params. When traversing deep-first module.children fcuntion does not calculate the profile when this module is a instance of ModuleList.

Problem Reproduction:
  You can try to modify "self.blocks" in model.py to the instance of ModuleList.

def __init__(self):
  self.blocks = nn.ModuleList()
def forward(self, x):
  for block in self.blocks:
    x = block(x)

Solution:
  I handle ModuleList specially, recording to each non-ModuleList submodule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant