Commit dc0f59c
authored
Make get_norm_layer repr test tolerant of PyTorch bias= field (#8880)
PyTorch >= 2.13 adds an optional 'bias=' token to GroupNorm/InstanceNorm
__repr__, breaking the exact-string match in test_norm_layer. Normalize
the repr by stripping the bias= field so the test passes on PyTorch
versions with or without it (backward- and forward-compatible).
### Description
test_norm_layer in tests/networks/layers/test_get_layers.py asserts that
a norm layer's repr() exactly equals a hard-coded string. PyTorch >=
2.13 added an optional bias= token to GroupNorm /
InstanceNorm __repr__, which breaks that exact-string match. This
normalizes both the actual and expected repr by stripping the bias=
field, so the test passes on PyTorch versions with or without
it — backward- and forward-compatible, with no change to production
code.
### Types of changes
- [x] Non-breaking change (fix that would not break existing
functionality).
- [x] Quick tests passed locally (python -m
tests.networks.layers.test_get_layers — 7/7).
PyTorch < 2.13: GroupNorm(1, 1, eps=1e-05, affine=True)
PyTorch >= 2.13: GroupNorm(1, 1, eps=1e-05, affine=True, bias=True)
The fix strips , bias=(True|False) from both sides before comparison.
Local checks: targeted test 7/7 OK; black/isort/ruff clean; full
pre-commit hooks pass.
Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>1 parent e33941c commit dc0f59c
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
20 | 34 | | |
21 | 35 | | |
22 | 36 | | |
| |||
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
44 | | - | |
| 58 | + | |
45 | 59 | | |
46 | 60 | | |
47 | 61 | | |
| |||
0 commit comments