Skip to content

Commit

Permalink
Sync 20200323. (#1157)
Browse files Browse the repository at this point in the history
* Sync 20200323.

* Bump version.

* Remove warning filter.
  • Loading branch information
Lucas Hosseini committed Mar 24, 2020
1 parent fc2a1c1 commit a17a631
Show file tree
Hide file tree
Showing 45 changed files with 3,528 additions and 361 deletions.
12 changes: 6 additions & 6 deletions Clustering.h
Expand Up @@ -34,19 +34,19 @@ struct ClusteringParameters {

int seed; ///< seed for the random number generator

size_t decode_block_size; /// < how many vectors at a time to decode
size_t decode_block_size; ///< how many vectors at a time to decode

/// sets reasonable defaults
ClusteringParameters ();
};


struct ClusteringIterationStats {
float obj; /// objective values (sum of distances reported by index)
double time; /// seconds for iteration
double time_search; /// seconds for just search
double imbalance_factor; /// imbalance factor of iteration
int nsplit; /// number of cluster splits
float obj; ///< objective values (sum of distances reported by index)
double time; ///< seconds for iteration
double time_search; ///< seconds for just search
double imbalance_factor; ///< imbalance factor of iteration
int nsplit; ///< number of cluster splits
};


Expand Down
10 changes: 4 additions & 6 deletions Index.h
Expand Up @@ -18,7 +18,7 @@

#define FAISS_VERSION_MAJOR 1
#define FAISS_VERSION_MINOR 6
#define FAISS_VERSION_PATCH 2
#define FAISS_VERSION_PATCH 3

/**
* @namespace faiss
Expand All @@ -44,12 +44,10 @@ struct IDSelector;
struct RangeSearchResult;
struct DistanceComputer;

/** Abstract structure for an index
/** Abstract structure for an index, supports adding vectors and searching them.
*
* Supports adding vertices and searching them.
*
* Currently only asymmetric queries are supported:
* database-to-database queries are not implemented.
* All vectors provided at add or search time are 32-bit float arrays,
* although the internal representation may vary.
*/
struct Index {
using idx_t = int64_t; ///< all indices are this type
Expand Down
10 changes: 7 additions & 3 deletions IndexBinary.h
Expand Up @@ -99,9 +99,13 @@ struct IndexBinary {

/** Query n vectors of dimension d to the index.
*
* return all vectors with distance < radius. Note that many
* indexes do not implement the range_search (only the k-NN search
* is mandatory).
* return all vectors with distance < radius. Note that many indexes
* do not implement the range_search (only the k-NN search is
* mandatory). The distances are converted to float to reuse the
* RangeSearchResult structure, but they are integer. By convention,
* only distances < radius (strict comparison) are returned,
* ie. radius = 0 does not return any result and 1 returns only
* exact same vectors.
*
* @param x input vectors to search, size n * d / 8
* @param radius search radius
Expand Down
5 changes: 5 additions & 0 deletions IndexBinaryFlat.cpp
Expand Up @@ -79,5 +79,10 @@ void IndexBinaryFlat::reconstruct(idx_t key, uint8_t *recons) const {
memcpy(recons, &(xb[code_size * key]), sizeof(*recons) * code_size);
}

void IndexBinaryFlat::range_search(idx_t n, const uint8_t *x, int radius,
RangeSearchResult *result) const
{
hamming_range_search (x, xb.data(), n, ntotal, radius, code_size, result);
}

} // namespace faiss
3 changes: 3 additions & 0 deletions IndexBinaryFlat.h
Expand Up @@ -38,6 +38,9 @@ struct IndexBinaryFlat : IndexBinary {
void search(idx_t n, const uint8_t *x, idx_t k,
int32_t *distances, idx_t *labels) const override;

void range_search(idx_t n, const uint8_t *x, int radius,
RangeSearchResult *result) const override;

void reconstruct(idx_t key, uint8_t *recons) const override;

/** Remove some ids. Note that because of the indexing structure,
Expand Down

0 comments on commit a17a631

Please sign in to comment.