Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Align SequentialModule.add_module behavior with torch.nn.Module.add_module#82

Open
dmklee wants to merge 1 commit intoQUVA-Lab:masterfrom
dmklee:fix_add_module
Open

Align SequentialModule.add_module behavior with torch.nn.Module.add_module#82
dmklee wants to merge 1 commit intoQUVA-Lab:masterfrom
dmklee:fix_add_module

Conversation

Copy link

dmklee commented Sep 11, 2023

The assertion checks in SequentialModule.add_module assume that the module is
being added to the end of the sequence. However, it calls torch.nn.Module.add_module
which allows for overwriting existing modules by name. So, if one tries to overwrite an
existing module by name, an assertion error is raised. I modified the assertion checks
so that modules can be overwritten so long as they have the correct in_type and out_type
according to the modules before and after them in the sequence.

I encountered this issue when trying to call torch.nn.SyncBatchNorm.convert_sync_batchnorm
on a SequentialModule. With this change, you can sync InnerBatchNorm's across machines during
training since they use torch.nn.BatchNormXd under the hood.

Gabri95 reacted with heart emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant