Currently the weight_norm and spectral_norm are patching a passed module + implement special functions for adding/removing these from a module.
Some ideas for refactoring to make it less tricky:
- provide a stable signature for getting weight, then they can be cleanly used with methods such as
torch.matmul and F.conv2d
- if module patching (adding some new buffers as parameters and registering a hook) is needed and is a reasonable pattern, provide a user-facing stable abstraction for it (especially adding and removal of parameters). It seems we have a chain of decorators-hooks, and each of them may have some extra buffers, and currently they are all patched into the passed module object.
cc @jerryzh168 @jianyuh @dzhulgakov
Currently the weight_norm and spectral_norm are patching a passed module + implement special functions for adding/removing these from a module.
Some ideas for refactoring to make it less tricky:
torch.matmulandF.conv2dcc @jerryzh168 @jianyuh @dzhulgakov