Skip to content

Commit 8cacea6

Browse files
studyingeugenefracape
authored andcommitted
refactor: replace uniform_ noise with rand-based formulation for torch.compile
- Replace `empty_like(...).uniform_()` with `rand_like()`-based expression - Avoid in-place random ops that are problematic for torch.compile / dynamo - Preserve identical noise range [-half, half] and statistical behavior
1 parent 4fbc02f commit 8cacea6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

compressai/entropy_models/entropy_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def quantize(
158158

159159
if mode == "noise":
160160
half = float(0.5)
161-
noise = torch.empty_like(inputs).uniform_(-half, half)
161+
noise = 2*half*torch.rand_like(inputs) - half
162162
inputs = inputs + noise
163163
return inputs
164164

0 commit comments

Comments
 (0)