amzn / pecos

PECOS - Prediction for Enormous and Correlated Spaces
https://libpecos.org/
Apache License 2.0
517 stars 105 forks source link

Fix train/predict bugs in PairwiseANN #271

Closed OctoberChang closed 11 months ago

OctoberChang commented 11 months ago

Issue #, if available:

Description of changes: Fix train/predict bugs in PairwiseANN: (1) For training, deep copy the X_trn and Y_csc matrix, to prevent pX/pY being modified and deleted at Python level. Otherwise, the PairwiseANN index may save the wrong content, or facing sagmentation fault. (2) For inference, searchers take in the pred_params, which pre-allocate the memory of return numpy array. We do not accept different topk at PairwiseANN.predict(), as it cause complexity to slice the returned matrix back.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.