Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add torch.nn.utils.weight_norm to deprecated symbols #9

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,27 @@ To get the LU factorization see `torch.lu`, which can be used with `torch.lu_sol

`X = torch.solve(B, A).solution` should be replaced with `X = torch.linalg.solve(A, B)`.

### TOR101 Use of deprecated function

#### torch.nn.utils.weight_norm

This function is deprecated. Use :func:`torch.nn.utils.parametrizations.weight_norm`
which uses the modern parametrization API. The new ``weight_norm`` is compatible
with ``state_dict`` generated from old ``weight_norm``.

Migration guide:

* The magnitude (``weight_g``) and direction (``weight_v``) are now expressed
as ``parametrizations.weight.original0`` and ``parametrizations.weight.original1``
respectively.

* To remove the weight normalization reparametrization, use
`torch.nn.utils.parametrize.remove_parametrizations`.

* The weight is no longer recomputed once at module forward; instead, it will
be recomputed on every access. To restore the old behavior, use
`torch.nn.utils.parametrize.cached` before invoking the module
in question.

## License
TorchFix is BSD License licensed, as found in the LICENSE file.
2 changes: 2 additions & 0 deletions tests/fixtures/deprecated_symbols/checker/weight_norm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from torch import nn
m = nn.utils.weight_norm(nn.Linear(20, 40), name='weight')
1 change: 1 addition & 0 deletions tests/fixtures/deprecated_symbols/checker/weight_norm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2:5 TOR101 Use of deprecated function torch.nn.utils.weight_norm: https://github.com/pytorch-labs/torchfix#torchnnutilsweight_norm
5 changes: 5 additions & 0 deletions torchfix/deprecated_symbols.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
deprecate_pr: TBA
remove_pr:

- name: torch.nn.utils.weight_norm
deprecate_pr: https://github.com/pytorch/pytorch/pull/103001
remove_pr:
reference: https://github.com/pytorch-labs/torchfix#torchnnutilsweight_norm

# functorch
- name: functorch.vmap
deprecate_pr: TBA
Expand Down