Commit fd12fdc
Fix non-functional jitter in Warp.get_reference_grid (#8953)
### Description
Little messy description as trying to fix multiple things but the jist
is: `Warp.get_reference_grid` never applied the `jitter` it advertises
and crashed whenever `jitter=True`.
The grid is built from `torch.arange` (integer dtype) and
`self.ref_grid` was assigned `grid.to(ddf)` before the jitter block, so
`grid += torch.rand_like(grid)` mutated a local that was never returned,
and `torch.rand_like` raises `NotImplementedError` on an integer tensor
anyway. Separately, `fork_rng(enabled=seed)` disabled RNG forking when
`seed` took its default of `0`, leaking the seeded state into the global
RNG.
The grid is now cast to `ddf` before jittering, the jittered tensor is
assigned to `self.ref_grid`, and `fork_rng()` isolates the seeded draw.
The non-jitter path is unchanged. A regression test covers the
float/non-integer jittered grid, the integer un-jittered grid, and
per-seed reproducibility; it fails before this change with
`NotImplementedError`.
### Types of changes
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] New tests added to cover the changes.
---------
Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
Signed-off-by: Soumya Snigdha Kundu <soumyawork15@gmail.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>1 parent 3bd4c4f commit fd12fdc
2 files changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
142 | 157 | | |
143 | 158 | | |
144 | 159 | | |
| |||
0 commit comments