Skip to content

style: make torch.nn imports more uniform#626

Merged
DaniBodor merged 3 commits intodevfrom
269_unify_torch_imports_dbodor
Jul 11, 2024
Merged

style: make torch.nn imports more uniform#626
DaniBodor merged 3 commits intodevfrom
269_unify_torch_imports_dbodor

Conversation

@DaniBodor
Copy link
Copy Markdown
Collaborator

@DaniBodor DaniBodor commented Jul 9, 2024

  • All functions from torch.nn.functional are now explicitly imported by name and used directly.
  • In all other cases where classes from torch.nn are used, we do from torch import nn and then use nn.<Class> throughout.

Note that this was also changed in one docstring in fba9e56. Not sure if that messes up the rendering of the documents. That commit can easily be dropped if needed.

fix #269

@DaniBodor DaniBodor linked an issue Jul 9, 2024 that may be closed by this pull request
@DaniBodor DaniBodor requested a review from gcroci2 July 11, 2024 13:17
Copy link
Copy Markdown
Collaborator

@gcroci2 gcroci2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For being sure that Sphinx is able to solve the reference, you should use the fully qualified name (:class:torch.nn.Module). But it may be able to solve it also with the short version - not entirely clear. You should see after #625 is merged (now the trainer module is not correctly rendered) by activating the branch on readthedocs. Maybe just revert it for simplicity.

@DaniBodor
Copy link
Copy Markdown
Collaborator Author

DaniBodor commented Jul 11, 2024

Maybe just revert it for simplicity.

I reverted it.

@DaniBodor DaniBodor merged commit fe0bdfa into dev Jul 11, 2024
@DaniBodor DaniBodor deleted the 269_unify_torch_imports_dbodor branch July 11, 2024 14:33
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.

Unify torch imports

2 participants