Skip to content
Merged
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
6 changes: 3 additions & 3 deletions chelombus/clustering/PyQKmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _predict_numba(pq_codes, centers, dtables):
n = pq_codes.shape[0]
m = pq_codes.shape[1]
n_centers = centers.shape[0]
labels = np.empty(n, dtype=np.int64)
labels = np.empty(n, dtype=np.int32)
for i in prange(n):
best_dist = np.inf
best_label = 0
Expand All @@ -62,7 +62,7 @@ def _predict_numba(pq_codes, centers, dtables):
if dist < best_dist:
best_dist = dist
best_label = c
labels[i] = best_label
labels[i] = np.int32(best_label)
return labels


Expand Down Expand Up @@ -101,7 +101,7 @@ def _update_centers(
hist = np.zeros(K * k_cb, dtype=np.int64)
for start in range(0, N, chunk_size):
end = min(start + chunk_size, N)
flat = (labels[start:end] * k_cb
flat = (labels[start:end].astype(np.int64) * k_cb
+ pq_codes[start:end, s].astype(np.int64))
hist += np.bincount(flat, minlength=K * k_cb)

Expand Down
4 changes: 2 additions & 2 deletions chelombus/clustering/_gpu_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def predict_gpu(
verbose: Print per-batch progress (useful for billion-scale runs).

Returns:
(N,) int64 cluster labels (same dtype as CPU path).
(N,) int32 cluster labels (same dtype as CPU path).
"""
import time as _time

Expand All @@ -157,7 +157,7 @@ def predict_gpu(
if batch_size <= 0:
batch_size = _auto_batch_size(N, M)

labels_out = np.empty(N, dtype=np.int64)
labels_out = np.empty(N, dtype=np.int32)

# Adaptive BLOCK_K: larger M means more registers per subvector,
# so reduce BLOCK_K to avoid register spill.
Expand Down
Loading