Skip to content

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

Open
13015517713 wants to merge 1 commit intoJiahuiYu:masterfrom
13015517713:master
Open

fix up the problem in model_profiling when fed 'Modulelist'#59
13015517713 wants to merge 1 commit intoJiahuiYu:masterfrom
13015517713:master

Conversation

@13015517713
Copy link
Copy Markdown

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.

1 participant