Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the peak memory usage when loading dataset. #514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ann_benchmarks/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def dataset_transform(dataset: h5py.Dataset) -> Tuple[Union[np.ndarray, List[np.
Tuple[Union[np.ndarray, List[np.ndarray]], Union[np.ndarray, List[np.ndarray]]]: Tuple of training and testing data in conventional format.
"""
if dataset.attrs.get("type", "dense") != "sparse":
return np.array(dataset["train"]), np.array(dataset["test"])
return np.asarray(dataset["train"]), np.asarray(dataset["test"])

# we store the dataset as a list of integers, accompanied by a list of lengths in hdf5
# so we transform it back to the format expected by the algorithms here (array of array of ints)
Expand Down
4 changes: 2 additions & 2 deletions ann_benchmarks/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def load_and_transform_dataset(dataset_name: str) -> Tuple[
Tuple: Transformed datasets.
"""
D, dimension = get_dataset(dataset_name)
X_train = numpy.array(D["train"])
X_test = numpy.array(D["test"])
X_train = numpy.asarray(D["train"])
X_test = numpy.asarray(D["test"])
distance = D.attrs["distance"]

print(f"Got a train set of size ({X_train.shape[0]} * {dimension})")
Expand Down
Loading