Skip to content

Commit 3e15bd9

Browse files
authored
Add torch.nn.utils.weight_norm to deprecated symbols (#9)
1 parent 03ea18c commit 3e15bd9

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,27 @@ To get the LU factorization see `torch.lu`, which can be used with `torch.lu_sol
6767

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

70+
### TOR101 Use of deprecated function
71+
72+
#### torch.nn.utils.weight_norm
73+
74+
This function is deprecated. Use :func:`torch.nn.utils.parametrizations.weight_norm`
75+
which uses the modern parametrization API. The new ``weight_norm`` is compatible
76+
with ``state_dict`` generated from old ``weight_norm``.
77+
78+
Migration guide:
79+
80+
* The magnitude (``weight_g``) and direction (``weight_v``) are now expressed
81+
as ``parametrizations.weight.original0`` and ``parametrizations.weight.original1``
82+
respectively.
83+
84+
* To remove the weight normalization reparametrization, use
85+
`torch.nn.utils.parametrize.remove_parametrizations`.
86+
87+
* The weight is no longer recomputed once at module forward; instead, it will
88+
be recomputed on every access. To restore the old behavior, use
89+
`torch.nn.utils.parametrize.cached` before invoking the module
90+
in question.
91+
7092
## License
7193
TorchFix is BSD License licensed, as found in the LICENSE file.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from torch import nn
2+
m = nn.utils.weight_norm(nn.Linear(20, 40), name='weight')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2:5 TOR101 Use of deprecated function torch.nn.utils.weight_norm: https://github.com/pytorch-labs/torchfix#torchnnutilsweight_norm

torchfix/deprecated_symbols.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
deprecate_pr: TBA
6161
remove_pr:
6262

63+
- name: torch.nn.utils.weight_norm
64+
deprecate_pr: https://github.com/pytorch/pytorch/pull/103001
65+
remove_pr:
66+
reference: https://github.com/pytorch-labs/torchfix#torchnnutilsweight_norm
67+
6368
# functorch
6469
- name: functorch.vmap
6570
deprecate_pr: TBA

0 commit comments

Comments
 (0)