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

Documentation fixes #3092

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
21 changes: 18 additions & 3 deletions faiss/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct Index {
* Vectors are implicitly assigned labels ntotal .. ntotal + n - 1
* This function slices the input vectors in chunks smaller than
* blocksize_add and calls add_core.
* @param n number of vectors
* @param x input matrix, size n * d
*/
virtual void add(idx_t n, const float* x) = 0;
Expand All @@ -108,7 +109,9 @@ struct Index {
* The default implementation fails with an assertion, as it is
* not supported by all indexes.
*
* @param xids if non-null, ids to store for the vectors (size n)
* @param n number of vectors
* @param x input vectors, size n * d
* @param xids if non-null, ids to store for the vectors (size n)
*/
virtual void add_with_ids(idx_t n, const float* x, const idx_t* xids);

Expand All @@ -117,9 +120,11 @@ struct Index {
* return at most k vectors. If there are not enough results for a
* query, the result array is padded with -1s.
*
* @param n number of vectors
* @param x input vectors to search, size n * d
* @param labels output labels of the NNs, size n*k
* @param k number of extracted vectors
* @param distances output pairwise distances, size n*k
* @param labels output labels of the NNs, size n*k
*/
virtual void search(
idx_t n,
Expand All @@ -135,6 +140,7 @@ struct Index {
* indexes do not implement the range_search (only the k-NN search
* is mandatory).
*
* @param n number of vectors
* @param x input vectors to search, size n * d
* @param radius search radius
* @param result result table
Expand All @@ -149,8 +155,10 @@ struct Index {
/** return the indexes of the k vectors closest to the query x.
*
* This function is identical as search but only return labels of neighbors.
* @param n number of vectors
* @param x input vectors to search, size n * d
* @param labels output labels of the NNs, size n*k
* @param k number of nearest neighbours
*/
virtual void assign(idx_t n, const float* x, idx_t* labels, idx_t k = 1)
const;
Expand All @@ -174,7 +182,7 @@ struct Index {
/** Reconstruct several stored vectors (or an approximation if lossy coding)
*
* this function may not be defined for some indexes
* @param n number of vectors to reconstruct
* @param n number of vectors to reconstruct
* @param keys ids of the vectors to reconstruct (size n)
* @param recons reconstucted vector (size n * d)
*/
Expand All @@ -184,6 +192,8 @@ struct Index {
/** Reconstruct vectors i0 to i0 + ni - 1
*
* this function may not be defined for some indexes
* @param i0 index of the first vector in the sequence
* @param ni number of vectors in the sequence
* @param recons reconstucted vector (size ni * d)
*/
virtual void reconstruct_n(idx_t i0, idx_t ni, float* recons) const;
Expand All @@ -194,6 +204,11 @@ struct Index {
* If there are not enough results for a query, the resulting arrays
* is padded with -1s.
*
* @param n number of vectors
* @param x input vectors to search, size n * d
* @param k number of extracted vectors
* @param distances output pairwise distances, size n*k
* @param labels output labels of the NNs, size n*k
* @param recons reconstructed vectors size (n, k, d)
**/
virtual void search_and_reconstruct(
Expand Down
7 changes: 6 additions & 1 deletion faiss/IndexFlat.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace faiss {

/** Index that stores the full vectors and performs exhaustive search */
struct IndexFlat : IndexFlatCodes {
explicit IndexFlat(idx_t d, MetricType metric = METRIC_L2);
explicit IndexFlat(
idx_t d, ///< dimensionality of the input vectors
MetricType metric = METRIC_L2);

void search(
idx_t n,
Expand Down Expand Up @@ -82,6 +84,9 @@ struct IndexFlatL2 : IndexFlat {
// and l2 norms.
std::vector<float> cached_l2norms;

/**
* @param d dimensionality of the input vectors
*/
explicit IndexFlatL2(idx_t d) : IndexFlat(d, METRIC_L2) {}
IndexFlatL2() {}

Expand Down
8 changes: 7 additions & 1 deletion faiss/IndexFlatCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ struct IndexFlatCodes : Index {

void reset() override;

/// reconstruction using the codec interface
/** Reconstruct vectors i0 to i0 + ni - 1
*
epishchik marked this conversation as resolved.
Show resolved Hide resolved
* this function may not be defined for some indexes
* @param i0 index of the first vector in the sequence
* @param ni number of vectors in the sequence
* @param recons reconstucted vector (size ni * d)
*/
void reconstruct_n(idx_t i0, idx_t ni, float* recons) const override;

void reconstruct(idx_t key, float* recons) const override;
Expand Down
4 changes: 0 additions & 4 deletions faiss/IndexPQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ struct IndexPQ : IndexFlatCodes {
ProductQuantizer pq;

/** Constructor.
epishchik marked this conversation as resolved.
Show resolved Hide resolved
*
* @param d dimensionality of the input vectors
* @param M number of subquantizers
* @param nbits number of bit per subvector index
*/
IndexPQ(int d, ///< dimensionality of the input vectors
size_t M, ///< number of subquantizers
Expand Down