Skip to content

Commit

Permalink
add counter to write_to_disk compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lykov committed Aug 30, 2024
1 parent 576acfb commit b68571e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qtensor/compression/Compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,13 @@ def __init__(self, path):
from pathlib import Path
Path(path).mkdir(exist_ok=True, parents=True)
self.path = path
self.counter = 0

def _gen_random_filename(self, info):
dtype, shape, isCupy = info
k = np.random.randint(0, 100000000)
s = hex(k)[2:]
return self.path + f'/qtensor_data_{s}_{str(dtype)}.bin'
return self.path + f'/qtensor_data_{self.counter}_{s}_{str(dtype)}.bin'

def compress(self, data):
import cupy
Expand All @@ -527,6 +528,7 @@ def compress(self, data):
else:
isCupy=True
fname = self._gen_random_filename((data.dtype, data.shape, isCupy))
self.counter += 1
data.tofile(fname)
return (fname, data.dtype, data.shape, isCupy)

Expand Down

0 comments on commit b68571e

Please sign in to comment.