Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions compressai/entropy_models/entropy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,18 @@ def decompress(
cdf = self._quantized_cdf
outputs = cdf.new_empty(indexes.size())

# CDF tables are shared by all strings: convert them only once
cdf_list = cdf.tolist()
cdf_length = self._cdf_length.reshape(-1).int().tolist()
offset = self._offset.reshape(-1).int().tolist()

for i, s in enumerate(strings):
values = self.entropy_coder.decode_with_indexes(
s,
indexes[i].reshape(-1).int().tolist(),
cdf.tolist(),
self._cdf_length.reshape(-1).int().tolist(),
self._offset.reshape(-1).int().tolist(),
s, indexes[i].reshape(-1).int().tolist(), cdf_list, cdf_length, offset
)
outputs[i] = torch.tensor(
values, device=outputs.device, dtype=outputs.dtype
).reshape(outputs[i].size())
# numpy converts large int lists much faster than torch.tensor
values = np.fromiter(values, dtype=np.int32, count=len(values))
outputs[i] = torch.from_numpy(values).reshape(outputs[i].size())
outputs = self.dequantize(outputs, means, dtype)
return outputs

Expand Down