gguf : free tensors as they are written

This commit is contained in:
Cebtenzzre 2023-10-01 21:42:42 -04:00 committed by cebtenzzre
parent d97afcfc02
commit 389d2e6b9e

View file

@ -863,7 +863,11 @@ class GGUFWriter:
self.write_padding(self.fout, self.fout.tell()) self.write_padding(self.fout, self.fout.tell())
if self.temp_file is None: if self.temp_file is None:
for tensor in self.tensors: while True:
try:
tensor = self.tensors.pop(0)
except IndexError:
break
tensor.tofile(self.fout) tensor.tofile(self.fout)
self.write_padding(self.fout, tensor.nbytes) self.write_padding(self.fout, tensor.nbytes)
return return