From 435cc21b8783b8439782cb11f89f139b8328f09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=83=9C=ED=99=94?= Date: Tue, 16 Dec 2025 21:04:57 +0900 Subject: [PATCH] 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 --- compressai/entropy_models/entropy_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compressai/entropy_models/entropy_models.py b/compressai/entropy_models/entropy_models.py index acb98333..58501e8c 100644 --- a/compressai/entropy_models/entropy_models.py +++ b/compressai/entropy_models/entropy_models.py @@ -158,7 +158,7 @@ def quantize( if mode == "noise": half = float(0.5) - noise = torch.empty_like(inputs).uniform_(-half, half) + noise = 2*half*torch.rand_like(inputs) - half inputs = inputs + noise return inputs