Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bench' into bench
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lykov committed Aug 30, 2024
2 parents b68571e + fdbff76 commit 893eeb1
Show file tree
Hide file tree
Showing 154 changed files with 21,652 additions and 21,045 deletions.
11 changes: 6 additions & 5 deletions qtensor/compression/Compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,22 +513,23 @@ def __init__(self, path):
from pathlib import Path
Path(path).mkdir(exist_ok=True, parents=True)
self.path = path
self.counter = 0
self.counter = 1

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

def compress(self, data):
import cupy
if isinstance(data, cupy.ndarray):
isCupy=False
else:
isCupy=True
fname = self._gen_random_filename((data.dtype, data.shape, isCupy))
self.counter += 1
fname = self._gen_filename((data.dtype, data.shape, isCupy))
data.tofile(fname)
return (fname, data.dtype, data.shape, isCupy)

Expand Down
Loading

0 comments on commit 893eeb1

Please sign in to comment.