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.
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.
Solution: I handle ModuleList specially, recording to each non-ModuleList submodule.