There is no builtin solution for that. If you think about it, it is a hard question: How would you print skip connections? Or how would you handle simple operations or function calls within the forward function (e. g. +, torch.cat, or torch.mean)? What about recurrent networks?