From 9242c334d2a2a72ddd25ae585570851e1e3fa8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=83=9C=ED=99=94?= <102410772+studyingeugene@users.noreply.github.com> Date: Sat, 18 Oct 2025 02:05:48 +0900 Subject: [PATCH] refactor: remove redundant Tensor allocation in GaussianConditional.update() In GaussianConditional.update(), a temporary Tensor is allocated: quantized_cdf = torch.Tensor(len(pmf_length), max_length + 2) quantized_cdf = self._pmf_to_cdf(pmf, tail_mass, pmf_length, max_length) The first line is a dead store: the variable is immediately overwritten by the result of _pmf_to_cdf(). This removes the unnecessary allocation. - No functional changes - Slightly reduces heap traffic and avoids creating an uninitialized Tensor - Keeps dtype/device fully defined by _pmf_to_cdf() --- compressai/entropy_models/entropy_models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/compressai/entropy_models/entropy_models.py b/compressai/entropy_models/entropy_models.py index 6c309cdb..c3ccb4d9 100644 --- a/compressai/entropy_models/entropy_models.py +++ b/compressai/entropy_models/entropy_models.py @@ -677,7 +677,6 @@ def update(self): tail_mass = 2 * lower[:, :1] - quantized_cdf = torch.Tensor(len(pmf_length), max_length + 2) quantized_cdf = self._pmf_to_cdf(pmf, tail_mass, pmf_length, max_length) self._quantized_cdf = quantized_cdf self._offset = -pmf_center