fix(datasets): avoid uint8 overflow in image stats (#3697)

* fix(datasets): avoid uint8 overflow in image stats

* fix(datasets): promote stats batches dynamically
This commit is contained in:
Altman
2026-06-13 18:09:43 +08:00
committed by GitHub
parent 30790de178
commit 8515d456be
2 changed files with 25 additions and 0 deletions
+2
View File
@@ -59,6 +59,8 @@ class RunningQuantileStats:
batch: An array where all dimensions except the last are batch dimensions.
"""
batch = batch.reshape(-1, batch.shape[-1])
# Promote integer and low-precision inputs before computing squared statistics.
batch = batch.astype(np.result_type(batch.dtype, np.float32), copy=False)
num_elements, vector_length = batch.shape
if self._count == 0: