We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ec999c commit 173f7cbCopy full SHA for 173f7cb
python/ctranslate2/specs/model_spec.py
@@ -749,15 +749,15 @@ def num_bytes(self) -> int:
749
def to_bytes(self) -> bytes:
750
max_size = 2**31 - 1
751
num_bytes = self.num_bytes()
752
- output = b""
+ chunks = []
753
offset = 0
754
while num_bytes > 0:
755
chunk_size = max_size if num_bytes > max_size else num_bytes
756
chunk = ctypes.string_at(self.tensor.data_ptr() + offset, chunk_size)
757
- output += chunk
+ chunks.append(chunk) # Collect chunks in a list
758
offset += chunk_size
759
num_bytes -= chunk_size
760
- return output
+ return b"".join(chunks)
761
762
def _to(self, dtype: str) -> Variable:
763
dtype = getattr(torch, dtype)
0 commit comments