From f7aedbdfc0c142443d597a34871b15f40da1a280 Mon Sep 17 00:00:00 2001 From: matthijs Date: Tue, 18 Jul 2017 02:51:27 -0700 Subject: [PATCH] sync with FB version 2017-07-18 - implemented ScalarQuantizer (without IVF) - implemented update for IndexIVFFlat - implemented L2 normalization preproc --- AutoTune.cpp | 92 +- AuxIndexStructures.cpp | 7 + AuxIndexStructures.h | 9 - FaissException.cpp | 6 +- FaissException.h | 4 +- IndexIVF.cpp | 73 +- IndexIVF.h | 19 +- IndexIVFScalarQuantizer.cpp | 895 ---------------- IndexIVFScalarQuantizer.h | 118 --- Makefile | 17 +- MetaIndexes.cpp | 42 + MetaIndexes.h | 23 + VectorTransform.cpp | 41 +- VectorTransform.h | 15 +- faiss.py | 38 +- index_io.cpp | 43 +- python/swigfaiss.py | 80 +- python/swigfaiss_gpu.py | 80 +- python/swigfaiss_gpu_wrap.cxx | 1835 +++++++++++++++++++++++++++++++-- python/swigfaiss_wrap.cxx | 1764 +++++++++++++++++++++++++++++-- swigfaiss.swig | 6 +- tests/test_build_blocks.py | 12 + tests/test_index.py | 48 +- utils.cpp | 12 +- 24 files changed, 3961 insertions(+), 1318 deletions(-) delete mode 100644 IndexIVFScalarQuantizer.cpp delete mode 100644 IndexIVFScalarQuantizer.h diff --git a/AutoTune.cpp b/AutoTune.cpp index 011cc5907..a3f2117ce 100644 --- a/AutoTune.cpp +++ b/AutoTune.cpp @@ -22,7 +22,7 @@ #include "IndexIVF.h" #include "IndexIVFPQ.h" #include "MetaIndexes.h" -#include "IndexIVFScalarQuantizer.h" +#include "IndexScalarQuantizer.h" namespace faiss { @@ -623,18 +623,28 @@ void ParameterSpace::explore (Index *index, * index_factory ***************************************************************/ +namespace { +struct VTChain { + std::vector chain; + ~VTChain () { + for (int i = 0; i < chain.size(); i++) { + delete chain[i]; + } + } +}; + +} Index *index_factory (int d, const char *description_in, MetricType metric) { - VectorTransform *vt = nullptr; + VTChain vts; Index *coarse_quantizer = nullptr; Index *index = nullptr; bool add_idmap = false; bool make_IndexRefineFlat = false; ScopeDeleter1 del_coarse_quantizer, del_index; - ScopeDeleter1 del_vt; char description[strlen(description_in) + 1]; char *ptr; @@ -656,18 +666,27 @@ Index *index_factory (int d, const char *description_in, MetricType metric) Index *index_1 = nullptr; // VectorTransforms - if (!vt && sscanf (tok, "PCA%d", &d_out) == 1) { + if (sscanf (tok, "PCA%d", &d_out) == 1) { vt_1 = new PCAMatrix (d, d_out); d = d_out; - } else if (!vt && sscanf (tok, "PCAR%d", &d_out) == 1) { + } else if (sscanf (tok, "PCAR%d", &d_out) == 1) { vt_1 = new PCAMatrix (d, d_out, 0, true); d = d_out; - } else if (!vt && sscanf (tok, "OPQ%d_%d", &opq_M, &d_out) == 2) { + } else if (sscanf (tok, "PCAW%d", &d_out) == 1) { + vt_1 = new PCAMatrix (d, d_out, -0.5, false); + d = d_out; + } else if (sscanf (tok, "PCAWR%d", &d_out) == 1) { + vt_1 = new PCAMatrix (d, d_out, -0.5, true); + d = d_out; + } else if (sscanf (tok, "OPQ%d_%d", &opq_M, &d_out) == 2) { vt_1 = new OPQMatrix (d, opq_M, d_out); d = d_out; - } else if (!vt && sscanf (tok, "OPQ%d", &opq_M) == 1) { + } else if (sscanf (tok, "OPQ%d", &opq_M) == 1) { vt_1 = new OPQMatrix (d, opq_M); - // coarse quantizers + } else if (stok == "L2norm") { + vt_1 = new NormalizationTransform (d, 2.0); + + // coarse quantizers } else if (!coarse_quantizer && sscanf (tok, "IVF%d", &ncentroids) == 1) { if (metric == METRIC_L2) { @@ -698,28 +717,25 @@ Index *index_factory (int d, const char *description_in, MetricType metric) index_1 = index_ivf; } else { index_1 = new IndexFlat (d, metric); - if (add_idmap) { - IndexIDMap *idmap = new IndexIDMap(index_1); - idmap->own_fields = true; - index_1 = idmap; - add_idmap = false; - } } } else if (!index && (stok == "SQ8" || stok == "SQ4")) { - FAISS_THROW_IF_NOT_MSG(coarse_quantizer, - "ScalarQuantizer works only with an IVF"); ScalarQuantizer::QuantizerType qt = stok == "SQ8" ? ScalarQuantizer::QT_8bit : stok == "SQ4" ? ScalarQuantizer::QT_4bit : ScalarQuantizer::QT_4bit; - IndexIVFScalarQuantizer *index_ivf = new IndexIVFScalarQuantizer ( - coarse_quantizer, d, ncentroids, qt, metric); - index_ivf->quantizer_trains_alone = - dynamic_cast(coarse_quantizer) - != nullptr; - del_coarse_quantizer.release (); - index_ivf->own_fields = true; - index_1 = index_ivf; + if (coarse_quantizer) { + IndexIVFScalarQuantizer *index_ivf = + new IndexIVFScalarQuantizer ( + coarse_quantizer, d, ncentroids, qt, metric); + index_ivf->quantizer_trains_alone = + dynamic_cast(coarse_quantizer) + != nullptr; + del_coarse_quantizer.release (); + index_ivf->own_fields = true; + index_1 = index_ivf; + } else { + index_1 = new IndexScalarQuantizer (d, qt, metric); + } } else if (!index && sscanf (tok, "PQ%d+%d", &M, &M2) == 2) { FAISS_THROW_IF_NOT_MSG(coarse_quantizer, "PQ with + works only with an IVF"); @@ -750,13 +766,6 @@ Index *index_factory (int d, const char *description_in, MetricType metric) IndexPQ *index_pq = new IndexPQ (d, M, 8, metric); index_pq->do_polysemous_training = true; index_1 = index_pq; - if (add_idmap) { - IndexIDMap *idmap = new IndexIDMap(index_1); - del_index.set (idmap); - idmap->own_fields = true; - index_1 = idmap; - add_idmap = false; - } } } else if (stok == "RFlat") { make_IndexRefineFlat = true; @@ -765,9 +774,16 @@ Index *index_factory (int d, const char *description_in, MetricType metric) tok, description_in); } + if (index_1 && add_idmap) { + IndexIDMap *idmap = new IndexIDMap(index_1); + del_index.set (idmap); + idmap->own_fields = true; + index_1 = idmap; + add_idmap = false; + } + if (vt_1) { - vt = vt_1; - del_vt.set (vt); + vts.chain.push_back (vt_1); } if (coarse_quantizer_1) { @@ -793,10 +809,14 @@ Index *index_factory (int d, const char *description_in, MetricType metric) "IDMap option not used\n"); } - if (vt) { - IndexPreTransform *index_pt = new IndexPreTransform (vt, index); - del_vt.release (); + if (vts.chain.size() > 0) { + IndexPreTransform *index_pt = new IndexPreTransform (index); index_pt->own_fields = true; + // add from back + while (vts.chain.size() > 0) { + index_pt->prepend_transform (vts.chain.back()); + vts.chain.pop_back (); + } index = index_pt; } diff --git a/AuxIndexStructures.cpp b/AuxIndexStructures.cpp index 01d5508e5..05987af9e 100644 --- a/AuxIndexStructures.cpp +++ b/AuxIndexStructures.cpp @@ -158,6 +158,10 @@ void RangeSearchPartialResult::set_result (bool incremental) } +/*********************************************************************** + * IDSelectorRange + ***********************************************************************/ + IDSelectorRange::IDSelectorRange (idx_t imin, idx_t imax): imin (imin), imax (imax) { @@ -169,6 +173,9 @@ bool IDSelectorRange::is_member (idx_t id) const } +/*********************************************************************** + * IDSelectorBatch + ***********************************************************************/ IDSelectorBatch::IDSelectorBatch (long n, const idx_t *indices) { diff --git a/AuxIndexStructures.h b/AuxIndexStructures.h index 6003e82e5..7574c9e93 100644 --- a/AuxIndexStructures.h +++ b/AuxIndexStructures.h @@ -15,12 +15,7 @@ #define FAISS_AUX_INDEX_STRUCTURES_H #include - -#if __cplusplus >= 201103L #include -#endif - -#include #include "Index.h" @@ -80,11 +75,7 @@ struct IDSelectorRange: IDSelector { * hash collisions if lsb's are always the same */ struct IDSelectorBatch: IDSelector { -#if __cplusplus >= 201103L std::unordered_set set; -#else - std::set set; -#endif typedef unsigned char uint8_t; std::vector bloom; // assumes low bits of id are a good hash value diff --git a/FaissException.cpp b/FaissException.cpp index e8f942f9e..774cbbe11 100644 --- a/FaissException.cpp +++ b/FaissException.cpp @@ -9,7 +9,6 @@ // Copyright 2004-present Facebook. All Rights Reserved. #include "FaissException.h" -#include namespace faiss { @@ -28,4 +27,9 @@ FaissException::FaissException(const std::string& m, funcName, file, line, m.c_str()); } +const char* +FaissException::what() const noexcept { + return msg.c_str(); +} + } diff --git a/FaissException.h b/FaissException.h index 426b1dec0..330936967 100644 --- a/FaissException.h +++ b/FaissException.h @@ -27,9 +27,7 @@ class FaissException : public std::exception { int line); /// from std::exception - const char* what() const noexcept override - { return msg.c_str(); } - ~FaissException () noexcept override {} + const char* what() const noexcept override; std::string msg; }; diff --git a/IndexIVF.cpp b/IndexIVF.cpp index 6e8f79d18..d1f8d476a 100644 --- a/IndexIVF.cpp +++ b/IndexIVF.cpp @@ -65,21 +65,28 @@ void IndexIVF::add (idx_t n, const float * x) add_with_ids (n, x, nullptr); } -void IndexIVF::make_direct_map () +void IndexIVF::make_direct_map (bool new_maintain_direct_map) { - if (maintain_direct_map) return; + // nothing to do + if (new_maintain_direct_map == maintain_direct_map) + return; - direct_map.resize (ntotal, -1); - for (size_t key = 0; key < nlist; key++) { - const std::vector & idlist = ids[key]; + if (new_maintain_direct_map) { + direct_map.resize (ntotal, -1); + for (size_t key = 0; key < nlist; key++) { + const std::vector & idlist = ids[key]; - for (long ofs = 0; ofs < idlist.size(); ofs++) { - direct_map [idlist [ofs]] = - key << 32 | ofs; + for (long ofs = 0; ofs < idlist.size(); ofs++) { + FAISS_THROW_IF_NOT_MSG ( + 0 <= idlist [ofs] && idlist[ofs] < ntotal, + "direct map supported only for seuquential ids"); + direct_map [idlist [ofs]] = key << 32 | ofs; + } } + } else { + direct_map.clear (); } - - maintain_direct_map = true; + maintain_direct_map = new_maintain_direct_map; } @@ -183,7 +190,6 @@ void IndexIVF::merge_from (IndexIVF &other, idx_t add_id) - IndexIVF::~IndexIVF() { if (own_fields) delete quantizer; @@ -217,6 +223,8 @@ void IndexIVFFlat::add_core (idx_t n, const float * x, const long *xids, { FAISS_THROW_IF_NOT (is_trained); + FAISS_THROW_IF_NOT_MSG (!(maintain_direct_map && xids), + "cannot have direct map and add with ids"); const long * idx; ScopeDeleter del; @@ -477,6 +485,49 @@ void IndexIVFFlat::copy_subset_to (IndexIVFFlat & other, int subset_type, } } +void IndexIVFFlat::update_vectors (int n, idx_t *new_ids, const float *x) +{ + FAISS_THROW_IF_NOT (maintain_direct_map); + FAISS_THROW_IF_NOT (is_trained); + std::vector assign (n); + quantizer->assign (n, x, assign.data()); + + for (int i = 0; i < n; i++) { + idx_t id = new_ids[i]; + FAISS_THROW_IF_NOT_MSG (0 <= id && id < ntotal, + "id to update out of range"); + { // remove old one + long dm = direct_map[id]; + long ofs = dm & 0xffffffff; + long il = dm >> 32; + size_t l = ids[il].size(); + if (ofs != l - 1) { + long id2 = ids[il].back(); + ids[il][ofs] = id2; + direct_map[id2] = (il << 32) | ofs; + memcpy (vecs[il].data() + ofs * d, + vecs[il].data() + (l - 1) * d, + d * sizeof(vecs[il][0])); + } + ids[il].pop_back(); + vecs[il].resize((l - 1) * d); + } + { // insert new one + long il = assign[i]; + size_t l = ids[il].size(); + long dm = (il << 32) | l; + direct_map[id] = dm; + ids[il].push_back (id); + vecs[il].resize((l + 1) * d); + memcpy (vecs[il].data() + l * d, + x + i * d, + d * sizeof(vecs[il][0])); + } + } + +} + + void IndexIVFFlat::reset() diff --git a/IndexIVF.h b/IndexIVF.h index 54cd3044d..2382853c3 100644 --- a/IndexIVF.h +++ b/IndexIVF.h @@ -91,9 +91,12 @@ struct IndexIVF: Index { size_t get_list_size (size_t list_no) const { return ids[list_no].size(); } - - /// intialize a direct map - void make_direct_map (); + /** intialize a direct map + * + * @param new_maintain_direct_map if true, create a direct map, + * else clear it + */ + void make_direct_map (bool new_maintain_direct_map=true); /// 1= perfectly balanced, >1: imbalanced double imbalance_factor () const; @@ -184,6 +187,16 @@ struct IndexIVFFlat: IndexIVF { const long * keys, float_maxheap_array_t * res) const; + /** Update a subset of vectors. + * + * The index must have a direct_map + * + * @param nv nb of vectors to update + * @param idx vector indices to update, size nv + * @param v vectors of new values, size nv*d + */ + void update_vectors (int nv, idx_t *idx, const float *v); + void reconstruct(idx_t key, float* recons) const override; void merge_from_residuals(IndexIVF& other) override; diff --git a/IndexIVFScalarQuantizer.cpp b/IndexIVFScalarQuantizer.cpp deleted file mode 100644 index f83562f84..000000000 --- a/IndexIVFScalarQuantizer.cpp +++ /dev/null @@ -1,895 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the CC-by-NC license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "IndexIVFScalarQuantizer.h" - -#include -#include - -#include - -#include - -#include "utils.h" - -#include "FaissAssert.h" - -namespace faiss { - -/******************************************************************* - * IndexIVFScalarQuantizer implementation - * - * The main source of complexity is to support combinations of 4 - * variants without incurring runtime tests or virtual function calls: - * - * - 4 / 8 bits per code component - * - uniform / non-uniform - * - IP / L2 distance search - * - scalar / AVX distance computation - * - * The appropriate Quantizer object is returned via select_quantizer - * that hides the template mess. - ********************************************************************/ - -#ifdef __AVX__ -#define USE_AVX -#endif - - -namespace { - -typedef Index::idx_t idx_t; -typedef ScalarQuantizer::QuantizerType QuantizerType; -typedef ScalarQuantizer::RangeStat RangeStat; - - -/******************************************************************* - * Codec: converts between values in [0, 1] and an index in a code - * array. The "i" parameter is the vector component index (not byte - * index). - */ - -struct Codec8bit { - - static void encode_component (float x, uint8_t *code, int i) { - code[i] = (int)(255 * x); - } - - static float decode_component (const uint8_t *code, int i) { - return (code[i] + 0.5f) / 255.0f; - } - -#ifdef USE_AVX - static __m256 decode_8_components (const uint8_t *code, int i) { - uint64_t c8 = *(uint64_t*)(code + i); - __m128i c4lo = _mm_cvtepu8_epi32 (_mm_set1_epi32(c8)); - __m128i c4hi = _mm_cvtepu8_epi32 (_mm_set1_epi32(c8 >> 32)); - // __m256i i8 = _mm256_set_m128i(c4lo, c4hi); - __m256i i8 = _mm256_castsi128_si256 (c4lo); - i8 = _mm256_insertf128_si256 (i8, c4hi, 1); - __m256 f8 = _mm256_cvtepi32_ps (i8); - __m256 half = _mm256_set1_ps (0.5f); - f8 += half; - __m256 one_255 = _mm256_set1_ps (1.f / 255.f); - return f8 * one_255; - } -#endif -}; - - -struct Codec4bit { - - static void encode_component (float x, uint8_t *code, int i) { - code [i / 2] |= (int)(x * 15.0) << ((i & 1) << 2); - } - - static float decode_component (const uint8_t *code, int i) { - return (((code[i / 2] >> ((i & 1) << 2)) & 0xf) + 0.5f) / 15.0f; - } - - -#ifdef USE_AVX - static __m256 decode_8_components (const uint8_t *code, int i) { - uint32_t c4 = *(uint32_t*)(code + (i >> 1)); - uint32_t mask = 0x0f0f0f0f; - uint32_t c4ev = c4 & mask; - uint32_t c4od = (c4 >> 4) & mask; - - // the 8 lower bytes of c8 contain the values - __m128i c8 = _mm_unpacklo_epi8 (_mm_set1_epi32(c4ev), - _mm_set1_epi32(c4od)); - __m128i c4lo = _mm_cvtepu8_epi32 (c8); - __m128i c4hi = _mm_cvtepu8_epi32 (_mm_srli_si128(c8, 4)); - __m256i i8 = _mm256_castsi128_si256 (c4lo); - i8 = _mm256_insertf128_si256 (i8, c4hi, 1); - __m256 f8 = _mm256_cvtepi32_ps (i8); - __m256 half = _mm256_set1_ps (0.5f); - f8 += half; - __m256 one_255 = _mm256_set1_ps (1.f / 15.f); - return f8 * one_255; - } -#endif -}; - - -/******************************************************************* - * Similarity: gets vector components and computes a similarity wrt. a - * query vector stored in the object - */ - -struct SimilarityL2 { - const float *y, *yi; - explicit SimilarityL2 (const float * y): y(y) {} - - - /******* scalar accumulator *******/ - - float accu; - - void begin () { - accu = 0; - yi = y; - } - - void add_component (float x) { - float tmp = *yi++ - x; - accu += tmp * tmp; - } - - float result () { - return accu; - } - -#ifdef USE_AVX - /******* AVX accumulator *******/ - - __m256 accu8; - - void begin_8 () { - accu8 = _mm256_setzero_ps(); - yi = y; - } - - void add_8_components (__m256 x) { - __m256 yiv = _mm256_loadu_ps (yi); - yi += 8; - __m256 tmp = yiv - x; - accu8 += tmp * tmp; - } - - float result_8 () { - __m256 sum = _mm256_hadd_ps(accu8, accu8); - __m256 sum2 = _mm256_hadd_ps(sum, sum); - // now add the 0th and 4th component - return - _mm_cvtss_f32 (_mm256_castps256_ps128(sum2)) + - _mm_cvtss_f32 (_mm256_extractf128_ps(sum2, 1)); - } -#endif -}; - -struct SimilarityIP { - const float *y, *yi; - const float accu0; - - /******* scalar accumulator *******/ - - float accu; - - SimilarityIP (const float * y, float accu0): - y (y), accu0 (accu0) {} - - void begin () { - accu = accu0; - yi = y; - } - - void add_component (float x) { - accu += *yi++ * x; - } - - float result () { - return accu; - } - -#ifdef USE_AVX - /******* AVX accumulator *******/ - - __m256 accu8; - - void begin_8 () { - accu8 = _mm256_setzero_ps(); - yi = y; - } - - void add_8_components (__m256 x) { - __m256 yiv = _mm256_loadu_ps (yi); - yi += 8; - accu8 += yiv * x; - } - - float result_8 () { - __m256 sum = _mm256_hadd_ps(accu8, accu8); - __m256 sum2 = _mm256_hadd_ps(sum, sum); - // now add the 0th and 4th component - return - accu0 + - _mm_cvtss_f32 (_mm256_castps256_ps128(sum2)) + - _mm_cvtss_f32 (_mm256_extractf128_ps(sum2, 1)); - } -#endif -}; - - -/******************************************************************* - * templatized distance functions - */ - - -template -float compute_distance(const Quantizer & quant, Similarity & sim, - const uint8_t *code) -{ - sim.begin(); - for (size_t i = 0; i < quant.d; i++) { - float xi = quant.reconstruct_component (code, i); - sim.add_component (xi); - } - return sim.result(); -} - -#ifdef USE_AVX -template -float compute_distance_8(const Quantizer & quant, Similarity & sim, - const uint8_t *code) -{ - sim.begin_8(); - for (size_t i = 0; i < quant.d; i += 8) { - __m256 xi = quant.reconstruct_8_components (code, i); - sim.add_8_components (xi); - } - return sim.result_8(); -} -#endif - - -/******************************************************************* - * Quantizer range training - */ - -static float sqr (float x) { - return x * x; -} - - -void train_Uniform(RangeStat rs, float rs_arg, - idx_t n, int k, const float *x, - std::vector & trained) -{ - trained.resize (2); - float & vmin = trained[0]; - float & vmax = trained[1]; - - if (rs == ScalarQuantizer::RS_minmax) { - vmin = HUGE_VAL; vmax = -HUGE_VAL; - for (size_t i = 0; i < n; i++) { - if (x[i] < vmin) vmin = x[i]; - if (x[i] > vmax) vmax = x[i]; - } - float vexp = (vmax - vmin) * rs_arg; - vmin -= vexp; - vmax += vexp; - } else if (rs == ScalarQuantizer::RS_meanstd) { - double sum = 0, sum2 = 0; - for (size_t i = 0; i < n; i++) { - sum += x[i]; - sum2 += x[i] * x[i]; - } - float mean = sum / n; - float var = sum2 / n - mean * mean; - float std = var <= 0 ? 1.0 : sqrt(var); - - vmin = mean - std * rs_arg ; - vmax = mean + std * rs_arg ; - } else if (rs == ScalarQuantizer::RS_quantiles) { - std::vector x_copy(n); - memcpy(x_copy.data(), x, n * sizeof(*x)); - // TODO just do a qucikselect - std::sort(x_copy.begin(), x_copy.end()); - int o = int(rs_arg * n); - if (o < 0) o = 0; - if (o > n - o) o = n / 2; - vmin = x_copy[o]; - vmax = x_copy[n - 1 - o]; - - } else if (rs == ScalarQuantizer::RS_optim) { - float a, b; - float sx = 0; - { - vmin = HUGE_VAL, vmax = -HUGE_VAL; - for (size_t i = 0; i < n; i++) { - if (x[i] < vmin) vmin = x[i]; - if (x[i] > vmax) vmax = x[i]; - sx += x[i]; - } - b = vmin; - a = (vmax - vmin) / (k - 1); - } - int verbose = false; - int niter = 2000; - float last_err = -1; - int iter_last_err = 0; - for (int it = 0; it < niter; it++) { - float sn = 0, sn2 = 0, sxn = 0, err1 = 0; - - for (idx_t i = 0; i < n; i++) { - float xi = x[i]; - float ni = floor ((xi - b) / a + 0.5); - if (ni < 0) ni = 0; - if (ni >= k) ni = k - 1; - err1 += sqr (xi - (ni * a + b)); - sn += ni; - sn2 += ni * ni; - sxn += ni * xi; - } - - if (err1 == last_err) { - iter_last_err ++; - if (iter_last_err == 16) break; - } else { - last_err = err1; - iter_last_err = 0; - } - - float det = sqr (sn) - sn2 * n; - - b = (sn * sxn - sn2 * sx) / det; - a = (sn * sx - n * sxn) / det; - if (verbose) { - printf ("it %d, err1=%g \r", it, err1); - fflush(stdout); - } - } - if (verbose) printf("\n"); - - vmin = b; - vmax = b + a * (k - 1); - - } else { - FAISS_THROW_MSG ("Invalid qtype"); - } - vmax -= vmin; -} - -void train_NonUniform(RangeStat rs, float rs_arg, - idx_t n, int d, int k, const float *x, - std::vector & trained) -{ - trained.resize (2 * d); - float * vmin = trained.data(); - float * vmax = trained.data() + d; - if (rs == ScalarQuantizer::RS_minmax) { - memcpy (vmin, x, sizeof(*x) * d); - memcpy (vmax, x, sizeof(*x) * d); - for (size_t i = 1; i < n; i++) { - const float *xi = x + i * d; - for (size_t j = 0; j < d; j++) { - if (xi[j] < vmin[j]) vmin[j] = xi[j]; - if (xi[j] > vmax[j]) vmax[j] = xi[j]; - } - } - float *vdiff = vmax; - for (size_t j = 0; j < d; j++) { - float vexp = (vmax[j] - vmin[j]) * rs_arg; - vmin[j] -= vexp; - vmax[j] += vexp; - vdiff [j] = vmax[j] - vmin[j]; - } - } else { - // transpose - std::vector xt(n * d); - for (size_t i = 1; i < n; i++) { - const float *xi = x + i * d; - for (size_t j = 0; j < d; j++) { - xt[j * n + i] = xi[j]; - } - } - std::vector trained_d(2); -#pragma omp parallel for - for (size_t j = 0; j < d; j++) { - train_Uniform(rs, rs_arg, - n, k, xt.data() + j * n, - trained_d); - vmin[j] = trained_d[0]; - vmax[j] = trained_d[1]; - } - } -} - - -/******************************************************************* - * Quantizer: normalizes scalar vector components, then passes them - * through a codec - */ - - - -struct Quantizer { - virtual void encode_vector(const float *x, uint8_t *code) const = 0; - virtual void decode_vector(const uint8_t *code, float *x) const = 0; - - virtual float compute_distance_L2 (SimilarityL2 &sim, - const uint8_t * codes) const = 0; - virtual float compute_distance_IP (SimilarityIP &sim, - const uint8_t * codes) const = 0; - - virtual ~Quantizer() {} -}; - - - - -template -struct QuantizerUniform: Quantizer { - const size_t d; - const float vmin, vdiff; - - QuantizerUniform(size_t d, const std::vector &trained): - d(d), vmin(trained[0]), vdiff(trained[1]) { - } - - void encode_vector(const float* x, uint8_t* code) const override { - for (size_t i = 0; i < d; i++) { - float xi = (x[i] - vmin) / vdiff; - if (xi < 0) - xi = 0; - if (xi > 1.0) - xi = 1.0; - Codec::encode_component(xi, code, i); - } - } - - void decode_vector(const uint8_t* code, float* x) const override { - for (size_t i = 0; i < d; i++) { - float xi = Codec::decode_component(code, i); - x[i] = vmin + xi * vdiff; - } - } - - float reconstruct_component (const uint8_t * code, int i) const - { - float xi = Codec::decode_component (code, i); - return vmin + xi * vdiff; - } - -#ifdef USE_AVX - __m256 reconstruct_8_components (const uint8_t * code, int i) const - { - __m256 xi = Codec::decode_8_components (code, i); - return _mm256_set1_ps(vmin) + xi * _mm256_set1_ps (vdiff); - } -#endif - - float compute_distance_L2(SimilarityL2& sim, const uint8_t* codes) - const override { - return compute_distance(*this, sim, codes); - } - - float compute_distance_IP(SimilarityIP& sim, const uint8_t* codes) - const override { - return compute_distance(*this, sim, codes); - } -}; - -#ifdef USE_AVX -template -struct QuantizerUniform8: QuantizerUniform { - - QuantizerUniform8 (size_t d, const std::vector &trained): - QuantizerUniform (d, trained) {} - - float compute_distance_L2(SimilarityL2& sim, const uint8_t* codes) - const override { - return compute_distance_8(*this, sim, codes); - } - - float compute_distance_IP(SimilarityIP& sim, const uint8_t* codes) - const override { - return compute_distance_8(*this, sim, codes); - } -}; -#endif - - - - - -template -struct QuantizerNonUniform: Quantizer { - const size_t d; - const float *vmin, *vdiff; - - QuantizerNonUniform(size_t d, const std::vector &trained): - d(d), vmin(trained.data()), vdiff(trained.data() + d) {} - - void encode_vector(const float* x, uint8_t* code) const override { - for (size_t i = 0; i < d; i++) { - float xi = (x[i] - vmin[i]) / vdiff[i]; - if (xi < 0) - xi = 0; - if (xi > 1.0) - xi = 1.0; - Codec::encode_component(xi, code, i); - } - } - - void decode_vector(const uint8_t* code, float* x) const override { - for (size_t i = 0; i < d; i++) { - float xi = Codec::decode_component(code, i); - x[i] = vmin[i] + xi * vdiff[i]; - } - } - - float reconstruct_component (const uint8_t * code, int i) const - { - float xi = Codec::decode_component (code, i); - return vmin[i] + xi * vdiff[i]; - } - -#ifdef USE_AVX - __m256 reconstruct_8_components (const uint8_t * code, int i) const - { - __m256 xi = Codec::decode_8_components (code, i); - return _mm256_loadu_ps(vmin + i) + xi * _mm256_loadu_ps (vdiff + i); - } -#endif - - float compute_distance_L2(SimilarityL2& sim, const uint8_t* codes) - const override { - return compute_distance(*this, sim, codes); - } - - float compute_distance_IP(SimilarityIP& sim, const uint8_t* codes) - const override { - return compute_distance(*this, sim, codes); - } -}; - -#ifdef USE_AVX -template -struct QuantizerNonUniform8: QuantizerNonUniform { - - QuantizerNonUniform8 (size_t d, const std::vector &trained): - QuantizerNonUniform (d, trained) {} - - float compute_distance_L2(SimilarityL2& sim, const uint8_t* codes) - const override { - return compute_distance_8(*this, sim, codes); - } - - float compute_distance_IP(SimilarityIP& sim, const uint8_t* codes) - const override { - return compute_distance_8(*this, sim, codes); - } -}; -#endif - - - - - -Quantizer *select_quantizer ( - QuantizerType qtype, - size_t d, const std::vector & trained) -{ -#ifdef USE_AVX - if (d % 8 == 0) { - switch(qtype) { - case ScalarQuantizer::QT_8bit: - return new QuantizerNonUniform8(d, trained); - case ScalarQuantizer::QT_4bit: - return new QuantizerNonUniform8(d, trained); - case ScalarQuantizer::QT_8bit_uniform: - return new QuantizerUniform8(d, trained); - case ScalarQuantizer::QT_4bit_uniform: - return new QuantizerUniform8(d, trained); - } - } else -#endif - { - switch(qtype) { - case ScalarQuantizer::QT_8bit: - return new QuantizerNonUniform(d, trained); - case ScalarQuantizer::QT_4bit: - return new QuantizerNonUniform(d, trained); - case ScalarQuantizer::QT_8bit_uniform: - return new QuantizerUniform(d, trained); - case ScalarQuantizer::QT_4bit_uniform: - return new QuantizerUniform(d, trained); - } - } - FAISS_THROW_MSG ("unknown qtype"); - return nullptr; -} - -Quantizer *select_quantizer (const ScalarQuantizer &sq) -{ - return select_quantizer (sq.qtype, sq.d, sq.trained); -} - - -} // anonymous namespace - - - -/******************************************************************* - * ScalarQuantizer implementation - ********************************************************************/ - -ScalarQuantizer::ScalarQuantizer - (size_t d, QuantizerType qtype): - qtype (qtype), rangestat(RS_minmax), rangestat_arg(0), d (d) -{ - switch (qtype) { - case QT_8bit: case QT_8bit_uniform: - code_size = d; - break; - case QT_4bit: case QT_4bit_uniform: - code_size = (d + 1) / 2; - break; - } - -} - -ScalarQuantizer::ScalarQuantizer (): - qtype(QT_8bit), - rangestat(RS_minmax), rangestat_arg(0), d (0), code_size(0) -{} - -void ScalarQuantizer::train (size_t n, const float *x) -{ - int bit_per_dim = - qtype == QT_4bit_uniform ? 4 : - qtype == QT_4bit ? 4 : - qtype == QT_8bit_uniform ? 8 : - qtype == QT_8bit ? 8 : -1; - - switch (qtype) { - case QT_4bit_uniform: case QT_8bit_uniform: - train_Uniform (rangestat, rangestat_arg, - n * d, 1 << bit_per_dim, x, trained); - break; - case QT_4bit: case QT_8bit: - train_NonUniform (rangestat, rangestat_arg, - n, d, 1 << bit_per_dim, x, trained); - break; - } -} - -void ScalarQuantizer::compute_codes (const float * x, - uint8_t * codes, - size_t n) const -{ - Quantizer *squant = select_quantizer (*this); -#pragma omp parallel for - for (size_t i = 0; i < n; i++) - squant->encode_vector (x + i * d, codes + i * code_size); - delete squant; -} - -void ScalarQuantizer::decode (const uint8_t *codes, float *x, size_t n) const -{ - Quantizer *squant = select_quantizer (*this); -#pragma omp parallel for - for (size_t i = 0; i < n; i++) - squant->decode_vector (codes + i * code_size, x + i * d); - delete squant; -} - - - -/******************************************************************* - * IndexIVFScalarQuantizer implementation - ********************************************************************/ - -IndexIVFScalarQuantizer::IndexIVFScalarQuantizer - (Index *quantizer, size_t d, size_t nlist, - QuantizerType qtype, MetricType metric): - IndexIVF (quantizer, d, nlist, metric), - sq (d, qtype) -{ - code_size = sq.code_size; - codes.resize(nlist); -} - -IndexIVFScalarQuantizer::IndexIVFScalarQuantizer (): - IndexIVF (), code_size (0) -{} - -void IndexIVFScalarQuantizer::train_residual (idx_t n, const float *x) -{ - long * idx = new long [n]; - ScopeDeleter del (idx); - quantizer->assign (n, x, idx); - float *residuals = new float [n * d]; - ScopeDeleter del2 (residuals); - -#pragma omp parallel for - for (idx_t i = 0; i < n; i++) { - quantizer->compute_residual (x + i * d, residuals + i * d, idx[i]); - } - - sq.train (n, residuals); - -} - - -void IndexIVFScalarQuantizer::add_with_ids - (idx_t n, const float * x, const long *xids) -{ - FAISS_THROW_IF_NOT (is_trained); - long * idx = new long [n]; - ScopeDeleter del (idx); - quantizer->assign (n, x, idx); - size_t nadd = 0; - Quantizer *squant = select_quantizer (sq); - ScopeDeleter1 del2 (squant); - -#pragma omp parallel reduction(+: nadd) - { - std::vector residual (d); - int nt = omp_get_num_threads(); - int rank = omp_get_thread_num(); - - for (size_t i = 0; i < n; i++) { - - long list_no = idx [i]; - if (list_no >= 0 && list_no % nt == rank) { - long id = xids ? xids[i] : ntotal + i; - - assert (list_no < nlist); - - ids[list_no].push_back (id); - nadd++; - quantizer->compute_residual ( - x + i * d, residual.data(), list_no); - - size_t cur_size = codes[list_no].size(); - codes[list_no].resize (cur_size + code_size); - - squant->encode_vector (residual.data(), - codes[list_no].data() + cur_size); - } - } - } - ntotal += nadd; -} - - -void search_with_probes_ip (const IndexIVFScalarQuantizer & index, - const float *x, - const idx_t *cent_ids, const float *cent_dis, - const Quantizer & quant, - int k, float *simi, idx_t *idxi) -{ - int nprobe = index.nprobe; - size_t code_size = index.code_size; - size_t d = index.d; - std::vector decoded(d); - minheap_heapify (k, simi, idxi); - for (int i = 0; i < nprobe; i++) { - idx_t list_no = cent_ids[i]; - if (list_no < 0) break; - float accu0 = cent_dis[i]; - - const std::vector & ids = index.ids[list_no]; - const uint8_t* codes = index.codes[list_no].data(); - - SimilarityIP sim(x, accu0); - - for (size_t j = 0; j < ids.size(); j++) { - - float accu = quant.compute_distance_IP(sim, codes); - - if (accu > simi [0]) { - minheap_pop (k, simi, idxi); - minheap_push (k, simi, idxi, accu, ids[j]); - } - codes += code_size; - } - - } - minheap_reorder (k, simi, idxi); -} - -void search_with_probes_L2 (const IndexIVFScalarQuantizer & index, - const float *x_in, - const idx_t *cent_ids, - const Index *quantizer, - const Quantizer & quant, - int k, float *simi, idx_t *idxi) -{ - int nprobe = index.nprobe; - size_t code_size = index.code_size; - size_t d = index.d; - std::vector decoded(d), x(d); - maxheap_heapify (k, simi, idxi); - for (int i = 0; i < nprobe; i++) { - idx_t list_no = cent_ids[i]; - if (list_no < 0) break; - - const std::vector & ids = index.ids[list_no]; - const uint8_t* codes = index.codes[list_no].data(); - - // shift of x_in wrt centroid - quantizer->compute_residual (x_in, x.data(), list_no); - - SimilarityL2 sim(x.data()); - - for (size_t j = 0; j < ids.size(); j++) { - - float dis = quant.compute_distance_L2 (sim, codes); - - if (dis < simi [0]) { - maxheap_pop (k, simi, idxi); - maxheap_push (k, simi, idxi, dis, ids[j]); - } - codes += code_size; - } - } - maxheap_reorder (k, simi, idxi); -} - - -void IndexIVFScalarQuantizer::search (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const -{ - FAISS_THROW_IF_NOT (is_trained); - idx_t *idx = new idx_t [n * nprobe]; - ScopeDeleter del (idx); - float *dis = new float [n * nprobe]; - ScopeDeleter del2 (dis); - - quantizer->search (n, x, nprobe, dis, idx); - - Quantizer *squant = select_quantizer (sq); - ScopeDeleter1 del3(squant); - - if (metric_type == METRIC_INNER_PRODUCT) { -#pragma omp parallel for - for (size_t i = 0; i < n; i++) { - search_with_probes_ip (*this, x + i * d, - idx + i * nprobe, dis + i * nprobe, *squant, - k, distances + i * k, labels + i * k); - } - } else { -#pragma omp parallel for - for (size_t i = 0; i < n; i++) { - search_with_probes_L2 (*this, x + i * d, - idx + i * nprobe, quantizer, *squant, - k, distances + i * k, labels + i * k); - } - } - -} - - -void IndexIVFScalarQuantizer::merge_from_residuals (IndexIVF & other_in) { - IndexIVFScalarQuantizer &other = - dynamic_cast (other_in); - for (int i = 0; i < nlist; i++) { - std::vector & src = other.codes[i]; - std::vector & dest = codes[i]; - dest.insert (dest.end(), src.begin (), src.end ()); - src.clear (); - } - -} - - -} diff --git a/IndexIVFScalarQuantizer.h b/IndexIVFScalarQuantizer.h deleted file mode 100644 index 66d3d86ac..000000000 --- a/IndexIVFScalarQuantizer.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the CC-by-NC license found in the - * LICENSE file in the root directory of this source tree. - */ - -#ifndef FAISS_INDEX_IVF_SCALAR_QUANTIZER_H -#define FAISS_INDEX_IVF_SCALAR_QUANTIZER_H - -#include - - -#include - - -#include "IndexIVF.h" - - -namespace faiss { - -/** An IVF implementation where the components of the residuals are - * encoded with a scalar uniform quantizer. All distance computations - * are asymmetric, so the encoded vectors are decoded and approximate - * distances are computed. - * - * The uniform quantizer has a range [vmin, vmax]. The range can be - * the same for all dimensions (uniform) or specific per dimension - * (default). - */ - - -struct ScalarQuantizer { - - enum QuantizerType { - QT_8bit, ///< 8 bits per component - QT_4bit, ///< 4 bits per component - QT_8bit_uniform, ///< same, shared range for all dimensions - QT_4bit_uniform, - }; - - QuantizerType qtype; - - /** The uniform encoder can estimate the range of representable - * values of the unform encoder using different statistics. Here - * rs = rangestat_arg */ - - // rangestat_arg. - enum RangeStat { - RS_minmax, ///< [min - rs*(max-min), max + rs*(max-min)] - RS_meanstd, ///< [mean - std * rs, mean + std * rs] - RS_quantiles, ///< [Q(rs), Q(1-rs)] - RS_optim, ///< alternate optimization of reconstruction error - }; - - RangeStat rangestat; - float rangestat_arg; - - /// dimension of input vectors - size_t d; - - /// bytes per vector - size_t code_size; - - /// trained values (including the range) - std::vector trained; - - ScalarQuantizer (size_t d, QuantizerType qtype); - ScalarQuantizer (); - - void train (size_t n, const float *x); - - - /// same as compute_code for several vectors - void compute_codes (const float * x, - uint8_t * codes, - size_t n) const ; - - /// decode a vector from a given code (or n vectors if third argument) - void decode (const uint8_t *code, float *x, size_t n) const; - -}; - - -struct IndexIVFScalarQuantizer:IndexIVF { - ScalarQuantizer sq; - - size_t code_size; - - /// inverted list codes. - std::vector > codes; - - IndexIVFScalarQuantizer(Index *quantizer, size_t d, size_t nlist, - ScalarQuantizer::QuantizerType qtype, - MetricType metric = METRIC_L2); - - IndexIVFScalarQuantizer(); - - void train_residual(idx_t n, const float* x) override; - - void add_with_ids(idx_t n, const float* x, const long* xids) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void merge_from_residuals(IndexIVF& other) override; -}; - - -} - - -#endif diff --git a/Makefile b/Makefile index 98981cc92..ebca3de37 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ LIBOBJ=hamming.o utils.o \ Clustering.o Heap.o VectorTransform.o index_io.o \ PolysemousTraining.o MetaIndexes.o Index.o \ ProductQuantizer.o AutoTune.o AuxIndexStructures.o \ - IndexIVFScalarQuantizer.o FaissException.o + IndexScalarQuantizer.o FaissException.o $(LIBNAME).a: $(LIBOBJ) @@ -71,7 +71,7 @@ tests/demo_sift1M: tests/demo_sift1M.cpp $(LIBNAME).a HFILES = IndexFlat.h Index.h IndexLSH.h IndexPQ.h IndexIVF.h \ IndexIVFPQ.h VectorTransform.h index_io.h utils.h \ PolysemousTraining.h Heap.h MetaIndexes.h AuxIndexStructures.h \ - Clustering.h hamming.h AutoTune.h IndexIVFScalarQuantizer.h FaissException.h + Clustering.h hamming.h AutoTune.h IndexScalarQuantizer.h FaissException.h # also silently generates python/swigfaiss.py python/swigfaiss_wrap.cxx: swigfaiss.swig $(HFILES) @@ -89,11 +89,12 @@ _swigfaiss.so: python/_swigfaiss.so ############################# # Dependencies -# for i in *.cpp ; do gcc -I.. -MM $i -msse4; done +# for i in *.cpp ; do g++ -std=c++11 -I.. -MM $i -msse4; done + AutoTune.o: AutoTune.cpp AutoTune.h Index.h FaissAssert.h \ FaissException.h utils.h Heap.h IndexFlat.h VectorTransform.h IndexLSH.h \ IndexPQ.h ProductQuantizer.h Clustering.h PolysemousTraining.h \ - IndexIVF.h IndexIVFPQ.h MetaIndexes.h IndexIVFScalarQuantizer.h + IndexIVF.h IndexIVFPQ.h MetaIndexes.h IndexScalarQuantizer.h AuxIndexStructures.o: AuxIndexStructures.cpp AuxIndexStructures.h Index.h Clustering.o: Clustering.cpp Clustering.h Index.h utils.h Heap.h \ FaissAssert.h FaissException.h IndexFlat.h @@ -106,7 +107,7 @@ IndexFlat.o: IndexFlat.cpp IndexFlat.h Index.h utils.h Heap.h \ index_io.o: index_io.cpp index_io.h FaissAssert.h FaissException.h \ IndexFlat.h Index.h VectorTransform.h IndexLSH.h IndexPQ.h \ ProductQuantizer.h Clustering.h Heap.h PolysemousTraining.h IndexIVF.h \ - IndexIVFPQ.h MetaIndexes.h IndexIVFScalarQuantizer.h + IndexIVFPQ.h MetaIndexes.h IndexScalarQuantizer.h IndexIVF.o: IndexIVF.cpp IndexIVF.h Index.h Clustering.h Heap.h utils.h \ hamming.h FaissAssert.h FaissException.h IndexFlat.h \ AuxIndexStructures.h @@ -114,13 +115,13 @@ IndexIVFPQ.o: IndexIVFPQ.cpp IndexIVFPQ.h IndexIVF.h Index.h Clustering.h \ Heap.h IndexPQ.h ProductQuantizer.h PolysemousTraining.h utils.h \ IndexFlat.h hamming.h FaissAssert.h FaissException.h \ AuxIndexStructures.h -IndexIVFScalarQuantizer.o: IndexIVFScalarQuantizer.cpp \ - IndexIVFScalarQuantizer.h IndexIVF.h Index.h Clustering.h Heap.h utils.h \ - FaissAssert.h FaissException.h IndexLSH.o: IndexLSH.cpp IndexLSH.h Index.h VectorTransform.h utils.h \ Heap.h hamming.h FaissAssert.h FaissException.h IndexPQ.o: IndexPQ.cpp IndexPQ.h Index.h ProductQuantizer.h Clustering.h \ Heap.h PolysemousTraining.h FaissAssert.h FaissException.h hamming.h +IndexScalarQuantizer.o: IndexScalarQuantizer.cpp IndexScalarQuantizer.h \ + IndexIVF.h Index.h Clustering.h Heap.h utils.h FaissAssert.h \ + FaissException.h MetaIndexes.o: MetaIndexes.cpp MetaIndexes.h Index.h FaissAssert.h \ FaissException.h Heap.h AuxIndexStructures.h PolysemousTraining.o: PolysemousTraining.cpp PolysemousTraining.h \ diff --git a/MetaIndexes.cpp b/MetaIndexes.cpp index 1dec238d3..c2042c1c5 100644 --- a/MetaIndexes.cpp +++ b/MetaIndexes.cpp @@ -120,6 +120,48 @@ IndexIDMap::~IndexIDMap () if (own_fields) delete index; } +/***************************************************** + * IndexIDMap2 implementation + *******************************************************/ + +IndexIDMap2::IndexIDMap2 (Index *index): IndexIDMap (index) +{} + +void IndexIDMap2::add_with_ids(idx_t n, const float* x, const long* xids) +{ + size_t prev_ntotal = ntotal; + IndexIDMap::add_with_ids (n, x, xids); + for (size_t i = prev_ntotal; i < ntotal; i++) { + rev_map [id_map [i]] = i; + } +} + +void IndexIDMap2::construct_rev_map () +{ + rev_map.clear (); + for (size_t i = 0; i < ntotal; i++) { + rev_map [id_map [i]] = i; + } +} + + +long IndexIDMap2::remove_ids(const IDSelector& sel) +{ + // This is quite inefficient + long nremove = IndexIDMap::remove_ids (sel); + construct_rev_map (); + return nremove; +} + +void IndexIDMap2::reconstruct (idx_t key, float * recons) const +{ + try { + index->reconstruct (rev_map.at (key), recons); + } catch (const std::out_of_range& e) { + FAISS_THROW_FMT ("key %ld not found", key); + } +} + /***************************************************** diff --git a/MetaIndexes.h b/MetaIndexes.h index 00fbdd393..13c78e34a 100644 --- a/MetaIndexes.h +++ b/MetaIndexes.h @@ -14,6 +14,7 @@ #include +#include #include "Index.h" @@ -54,6 +55,28 @@ struct IndexIDMap : Index { IndexIDMap () {own_fields=false; index=nullptr; } }; +/** same as IndexIDMap but also provides an efficient reconstruction + implementation via a 2-way index */ +struct IndexIDMap2 : IndexIDMap { + + std::unordered_map rev_map; + + explicit IndexIDMap2 (Index *index); + + /// make the rev_map from scratch + void construct_rev_map (); + + void add_with_ids(idx_t n, const float* x, const long* xids) override; + + long remove_ids(const IDSelector& sel) override; + + void reconstruct (idx_t key, float * recons) const override; + + ~IndexIDMap2() override {} + IndexIDMap2 () {} +}; + + /** Index that concatenates the results from several sub-indexes * */ diff --git a/VectorTransform.cpp b/VectorTransform.cpp index 9acad8ff0..c7d14bb11 100644 --- a/VectorTransform.cpp +++ b/VectorTransform.cpp @@ -711,6 +711,32 @@ void OPQMatrix::reverse_transform (idx_t n, const float * xt, transform_transpose (n, xt, x); } + +/********************************************* + * NormalizationTransform + *********************************************/ + +NormalizationTransform::NormalizationTransform (int d, float norm): + VectorTransform (d, d), norm (norm) +{ +} + +NormalizationTransform::NormalizationTransform (): + VectorTransform (-1, -1), norm (-1) +{ +} + +void NormalizationTransform::apply_noalloc + (idx_t n, const float* x, float* xt) const +{ + if (norm == 2.0) { + memcpy (xt, x, sizeof (x[0]) * n * d_in); + fvec_renorm_L2 (d_in, n, xt); + } else { + FAISS_THROW_MSG ("not implemented"); + } +} + /********************************************* * IndexPreTransform *********************************************/ @@ -730,8 +756,6 @@ IndexPreTransform::IndexPreTransform ( } - - IndexPreTransform::IndexPreTransform ( VectorTransform * ltrans, Index * index): @@ -766,9 +790,16 @@ IndexPreTransform::~IndexPreTransform () void IndexPreTransform::train (idx_t n, const float *x) { int last_untrained = 0; - for (int i = 0; i < chain.size(); i++) - if (!chain[i]->is_trained) last_untrained = i; - if (!index->is_trained) last_untrained = chain.size(); + if (index->is_trained) { + last_untrained = chain.size(); + } else { + for (int i = chain.size() - 1; i >= 0; i--) { + if (!chain[i]->is_trained) { + last_untrained = i; + break; + } + } + } const float *prev_x = x; ScopeDeleter del; diff --git a/VectorTransform.h b/VectorTransform.h index d5e6bdcc1..ef0b9de0c 100644 --- a/VectorTransform.h +++ b/VectorTransform.h @@ -76,7 +76,6 @@ struct VectorTransform { */ struct LinearTransform: VectorTransform { - bool have_bias; ///! whether to use the bias term /// Transformation matrix, size d_out * d_in @@ -85,7 +84,6 @@ struct LinearTransform: VectorTransform { /// bias vector, size d_out std::vector b; - /// both d_in > d_out and d_out < d_in are supported explicit LinearTransform (int d_in = 0, int d_out = 0, bool have_bias = false); @@ -204,7 +202,6 @@ struct OPQMatrix: LinearTransform { * to compute it with matrix multiplies */ struct RemapDimensionsTransform: VectorTransform { - /// map from output dimension to input, size d_out /// -1 -> set output to 0 std::vector map; @@ -225,6 +222,18 @@ struct RemapDimensionsTransform: VectorTransform { }; +/** per-vector normalization */ +struct NormalizationTransform: VectorTransform { + float norm; + + explicit NormalizationTransform (int d, float norm = 2.0); + NormalizationTransform (); + + void apply_noalloc(idx_t n, const float* x, float* xt) const override; +}; + + + /** Index that applies a LinearTransform transform on vectors before * handing them over to a sub-index */ struct IndexPreTransform: Index { diff --git a/faiss.py b/faiss.py index 20ceab635..274f0f313 100644 --- a/faiss.py +++ b/faiss.py @@ -34,8 +34,13 @@ except ImportError as e: ################################################################## -def replace_method(the_class, name, replacement): - orig_method = getattr(the_class, name) +def replace_method(the_class, name, replacement, ignore_missing=False): + try: + orig_method = getattr(the_class, name) + except AttributeError: + if ignore_missing: + return + raise if orig_method.__name__ == 'replacement_' + name: # replacement was done in parent class return @@ -123,12 +128,31 @@ def handle_Index(the_class): sel = IDSelectorBatch(x.size, swig_ptr(x)) return self.remove_ids_c(sel) + def replacement_reconstruct(self, key): + x = np.empty(self.d, dtype=np.float32) + self.reconstruct_c(key, swig_ptr(x)) + return x + + def replacement_reconstruct_n(self, n0, ni): + x = np.empty((ni, self.d), dtype=np.float32) + self.reconstruct_n_c(n0, ni, swig_ptr(x)) + return x + + def replacement_update_vectors(self, keys, x): + n = keys.size + assert keys.shape == (n, ) + assert x.shape == (n, self.d) + self.update_vectors_c(n, swig_ptr(keys), swig_ptr(x)) + replace_method(the_class, 'add', replacement_add) replace_method(the_class, 'add_with_ids', replacement_add_with_ids) replace_method(the_class, 'train', replacement_train) replace_method(the_class, 'search', replacement_search) replace_method(the_class, 'remove_ids', replacement_remove_ids) - + replace_method(the_class, 'reconstruct', replacement_reconstruct) + replace_method(the_class, 'reconstruct_n', replacement_reconstruct_n) + replace_method(the_class, 'update_vectors', replacement_update_vectors, + ignore_missing=True) def handle_VectorTransform(the_class): @@ -228,12 +252,13 @@ def vector_float_to_array(v): class Kmeans: - def __init__(self, d, k, niter=25, verbose=False): + def __init__(self, d, k, niter=25, verbose=False, spherical = False): self.d = d self.k = k self.cp = ClusteringParameters() self.cp.niter = niter self.cp.verbose = verbose + self.cp.spherical = spherical self.centroids = None def train(self, x): @@ -241,7 +266,10 @@ class Kmeans: n, d = x.shape assert d == self.d clus = Clustering(d, self.k, self.cp) - self.index = IndexFlatL2(d) + if self.cp.spherical: + self.index = IndexFlatIP(d) + else: + self.index = IndexFlatL2(d) clus.train(x, self.index) centroids = vector_float_to_array(clus.centroids) self.centroids = centroids.reshape(self.k, d) diff --git a/index_io.cpp b/index_io.cpp index f36f460a0..6e7487461 100644 --- a/index_io.cpp +++ b/index_io.cpp @@ -24,7 +24,7 @@ #include "IndexIVF.h" #include "IndexIVFPQ.h" #include "MetaIndexes.h" -#include "IndexIVFScalarQuantizer.h" +#include "IndexScalarQuantizer.h" /************************************************************* * The I/O format is the content of the class. For objects that are @@ -184,6 +184,11 @@ void write_VectorTransform (const VectorTransform *vt, FILE *f) { uint32_t h = fourcc ("RmDT"); WRITE1 (h); WRITEVECTOR (rdt->map); + } else if (const NormalizationTransform *nt = + dynamic_cast(vt)) { + uint32_t h = fourcc ("VNrm"); + WRITE1 (h); + WRITE1 (nt->norm); } else { FAISS_THROW_MSG ("cannot serialize this"); } @@ -261,6 +266,13 @@ void write_index (const Index *idx, FILE *f) { WRITE1 (idxp->search_type); WRITE1 (idxp->encode_signs); WRITE1 (idxp->polysemous_ht); + } else if(const IndexScalarQuantizer * idxs = + dynamic_cast (idx)) { + uint32_t h = fourcc ("IxSQ"); + WRITE1 (h); + write_index_header (idx, f); + write_ScalarQuantizer (&idxs->sq, f); + WRITEVECTOR (idxs->codes); } else if(const IndexIVFFlat * ivfl = dynamic_cast (idx)) { uint32_t h = fourcc ("IvFl"); @@ -329,7 +341,10 @@ void write_index (const Index *idx, FILE *f) { WRITE1 (idxrf->k_factor); } else if(const IndexIDMap * idxmap = dynamic_cast (idx)) { - uint32_t h = fourcc ("IxMp"); + uint32_t h = + dynamic_cast (idx) ? fourcc ("IxM2") : + fourcc ("IxMp"); + // no need to store additional info for IndexIDMap2 WRITE1 (h); write_index_header (idxmap, f); write_index (idxmap->index, f); @@ -400,6 +415,10 @@ VectorTransform* read_VectorTransform (FILE *f) { RemapDimensionsTransform *rdt = new RemapDimensionsTransform (); READVECTOR (rdt->map); vt = rdt; + } else if (h == fourcc ("VNrm")) { + NormalizationTransform *nt = new NormalizationTransform (); + READ1 (nt->norm); + vt = nt; } else { FAISS_THROW_MSG("fourcc not recognized"); } @@ -582,6 +601,13 @@ Index *read_index (FILE * f, bool try_mmap) { for (size_t i = 0; i < ivfl->nlist; i++) READVECTOR (ivfl->vecs[i]); idx = ivfl; + } else if (h == fourcc ("IxSQ")) { + IndexScalarQuantizer * idxs = new IndexScalarQuantizer (); + read_index_header (idxs, f); + read_ScalarQuantizer (&idxs->sq, f); + READVECTOR (idxs->codes); + idxs->code_size = idxs->sq.code_size; + idx = idxs; } else if(h == fourcc ("IvSQ")) { IndexIVFScalarQuantizer * ivsc = new IndexIVFScalarQuantizer(); read_ivf_header (ivsc, f); @@ -606,8 +632,9 @@ Index *read_index (FILE * f, bool try_mmap) { } else { READ1 (nt); } - for (int i = 0; i < nt; i++) + for (int i = 0; i < nt; i++) { ixpt->chain.push_back (read_VectorTransform (f)); + } ixpt->index = read_index (f); idx = ixpt; } else if(h == fourcc ("Imiq")) { @@ -625,12 +652,16 @@ Index *read_index (FILE * f, bool try_mmap) { delete rf; READ1 (idxrf->k_factor); idx = idxrf; - } else if(h == fourcc ("IxMp")) { - IndexIDMap * idxmap = new IndexIDMap (); + } else if(h == fourcc ("IxMp") || h == fourcc ("IxM2")) { + bool is_map2 = h == fourcc ("IxM2"); + IndexIDMap * idxmap = is_map2 ? new IndexIDMap2 () : new IndexIDMap (); read_index_header (idxmap, f); idxmap->index = read_index (f); idxmap->own_fields = true; READVECTOR (idxmap->id_map); + if (is_map2) { + static_cast(idxmap)->construct_rev_map (); + } idx = idxmap; } else { fprintf (stderr, "Index type 0x%08x not supported\n", h); @@ -698,6 +729,7 @@ IndexIVF * Cloner::clone_IndexIVF (const IndexIVF *ivf) TRYCLONE (IndexIVFPQR, ivf) TRYCLONE (IndexIVFPQ, ivf) TRYCLONE (IndexIVFFlat, ivf) + TRYCLONE (IndexIVFScalarQuantizer, ivf) { FAISS_THROW_MSG("clone not supported for this type of IndexIVF"); } @@ -711,6 +743,7 @@ Index *Cloner::clone_Index (const Index *index) TRYCLONE (IndexFlatL2, index) TRYCLONE (IndexFlatIP, index) TRYCLONE (IndexFlat, index) + TRYCLONE (IndexScalarQuantizer, index) TRYCLONE (MultiIndexQuantizer, index) if (const IndexIVF * ivf = dynamic_cast(index)) { IndexIVF *res = clone_IndexIVF (ivf); diff --git a/python/swigfaiss.py b/python/swigfaiss.py index 22aa08208..bd84a178f 100644 --- a/python/swigfaiss.py +++ b/python/swigfaiss.py @@ -1094,6 +1094,27 @@ class RemapDimensionsTransform(VectorTransform): RemapDimensionsTransform_swigregister = _swigfaiss.RemapDimensionsTransform_swigregister RemapDimensionsTransform_swigregister(RemapDimensionsTransform) +class NormalizationTransform(VectorTransform): + __swig_setmethods__ = {} + for _s in [VectorTransform]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, NormalizationTransform, name, value) + __swig_getmethods__ = {} + for _s in [VectorTransform]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, NormalizationTransform, name) + __repr__ = _swig_repr + __swig_setmethods__["norm"] = _swigfaiss.NormalizationTransform_norm_set + __swig_getmethods__["norm"] = _swigfaiss.NormalizationTransform_norm_get + if _newclass:norm = _swig_property(_swigfaiss.NormalizationTransform_norm_get, _swigfaiss.NormalizationTransform_norm_set) + def __init__(self, *args): + this = _swigfaiss.new_NormalizationTransform(*args) + try: self.this.append(this) + except: self.this = this + def apply_noalloc(self, *args): return _swigfaiss.NormalizationTransform_apply_noalloc(self, *args) + __swig_destroy__ = _swigfaiss.delete_NormalizationTransform + __del__ = lambda self : None; +NormalizationTransform_swigregister = _swigfaiss.NormalizationTransform_swigregister +NormalizationTransform_swigregister(NormalizationTransform) + class IndexPreTransform(Index): __swig_setmethods__ = {} for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) @@ -1635,7 +1656,7 @@ class IndexIVF(Index): __swig_destroy__ = _swigfaiss.delete_IndexIVF __del__ = lambda self : None; def get_list_size(self, *args): return _swigfaiss.IndexIVF_get_list_size(self, *args) - def make_direct_map(self): return _swigfaiss.IndexIVF_make_direct_map(self) + def make_direct_map(self, new_maintain_direct_map=True): return _swigfaiss.IndexIVF_make_direct_map(self, new_maintain_direct_map) def imbalance_factor(self): return _swigfaiss.IndexIVF_imbalance_factor(self) def print_stats(self): return _swigfaiss.IndexIVF_print_stats(self) IndexIVF_swigregister = _swigfaiss.IndexIVF_swigregister @@ -1690,6 +1711,7 @@ class IndexIVFFlat(IndexIVF): def remove_ids(self, *args): return _swigfaiss.IndexIVFFlat_remove_ids(self, *args) def search_knn_inner_product(self, *args): return _swigfaiss.IndexIVFFlat_search_knn_inner_product(self, *args) def search_knn_L2sqr(self, *args): return _swigfaiss.IndexIVFFlat_search_knn_L2sqr(self, *args) + def update_vectors(self, *args): return _swigfaiss.IndexIVFFlat_update_vectors(self, *args) def reconstruct(self, *args): return _swigfaiss.IndexIVFFlat_reconstruct(self, *args) def merge_from_residuals(self, *args): return _swigfaiss.IndexIVFFlat_merge_from_residuals(self, *args) def __init__(self, *args): @@ -1770,6 +1792,38 @@ class ScalarQuantizer(_object): ScalarQuantizer_swigregister = _swigfaiss.ScalarQuantizer_swigregister ScalarQuantizer_swigregister(ScalarQuantizer) +class IndexScalarQuantizer(Index): + __swig_setmethods__ = {} + for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, IndexScalarQuantizer, name, value) + __swig_getmethods__ = {} + for _s in [Index]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, IndexScalarQuantizer, name) + __repr__ = _swig_repr + __swig_setmethods__["sq"] = _swigfaiss.IndexScalarQuantizer_sq_set + __swig_getmethods__["sq"] = _swigfaiss.IndexScalarQuantizer_sq_get + if _newclass:sq = _swig_property(_swigfaiss.IndexScalarQuantizer_sq_get, _swigfaiss.IndexScalarQuantizer_sq_set) + __swig_setmethods__["codes"] = _swigfaiss.IndexScalarQuantizer_codes_set + __swig_getmethods__["codes"] = _swigfaiss.IndexScalarQuantizer_codes_get + if _newclass:codes = _swig_property(_swigfaiss.IndexScalarQuantizer_codes_get, _swigfaiss.IndexScalarQuantizer_codes_set) + __swig_setmethods__["code_size"] = _swigfaiss.IndexScalarQuantizer_code_size_set + __swig_getmethods__["code_size"] = _swigfaiss.IndexScalarQuantizer_code_size_get + if _newclass:code_size = _swig_property(_swigfaiss.IndexScalarQuantizer_code_size_get, _swigfaiss.IndexScalarQuantizer_code_size_set) + def __init__(self, *args): + this = _swigfaiss.new_IndexScalarQuantizer(*args) + try: self.this.append(this) + except: self.this = this + def train(self, *args): return _swigfaiss.IndexScalarQuantizer_train(self, *args) + def add(self, *args): return _swigfaiss.IndexScalarQuantizer_add(self, *args) + def search(self, *args): return _swigfaiss.IndexScalarQuantizer_search(self, *args) + def reset(self): return _swigfaiss.IndexScalarQuantizer_reset(self) + def reconstruct_n(self, *args): return _swigfaiss.IndexScalarQuantizer_reconstruct_n(self, *args) + def reconstruct(self, *args): return _swigfaiss.IndexScalarQuantizer_reconstruct(self, *args) + __swig_destroy__ = _swigfaiss.delete_IndexScalarQuantizer + __del__ = lambda self : None; +IndexScalarQuantizer_swigregister = _swigfaiss.IndexScalarQuantizer_swigregister +IndexScalarQuantizer_swigregister(IndexScalarQuantizer) + class IndexIVFScalarQuantizer(IndexIVF): __swig_setmethods__ = {} for _s in [IndexIVF]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) @@ -2024,6 +2078,30 @@ class IndexIDMap(Index): IndexIDMap_swigregister = _swigfaiss.IndexIDMap_swigregister IndexIDMap_swigregister(IndexIDMap) +class IndexIDMap2(IndexIDMap): + __swig_setmethods__ = {} + for _s in [IndexIDMap]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, IndexIDMap2, name, value) + __swig_getmethods__ = {} + for _s in [IndexIDMap]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, IndexIDMap2, name) + __repr__ = _swig_repr + __swig_setmethods__["rev_map"] = _swigfaiss.IndexIDMap2_rev_map_set + __swig_getmethods__["rev_map"] = _swigfaiss.IndexIDMap2_rev_map_get + if _newclass:rev_map = _swig_property(_swigfaiss.IndexIDMap2_rev_map_get, _swigfaiss.IndexIDMap2_rev_map_set) + def construct_rev_map(self): return _swigfaiss.IndexIDMap2_construct_rev_map(self) + def add_with_ids(self, *args): return _swigfaiss.IndexIDMap2_add_with_ids(self, *args) + def remove_ids(self, *args): return _swigfaiss.IndexIDMap2_remove_ids(self, *args) + def reconstruct(self, *args): return _swigfaiss.IndexIDMap2_reconstruct(self, *args) + __swig_destroy__ = _swigfaiss.delete_IndexIDMap2 + __del__ = lambda self : None; + def __init__(self, *args): + this = _swigfaiss.new_IndexIDMap2(*args) + try: self.this.append(this) + except: self.this = this +IndexIDMap2_swigregister = _swigfaiss.IndexIDMap2_swigregister +IndexIDMap2_swigregister(IndexIDMap2) + class IndexShards(Index): __swig_setmethods__ = {} for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) diff --git a/python/swigfaiss_gpu.py b/python/swigfaiss_gpu.py index a389bed76..5a1ab39e8 100644 --- a/python/swigfaiss_gpu.py +++ b/python/swigfaiss_gpu.py @@ -1163,6 +1163,27 @@ class RemapDimensionsTransform(VectorTransform): RemapDimensionsTransform_swigregister = _swigfaiss_gpu.RemapDimensionsTransform_swigregister RemapDimensionsTransform_swigregister(RemapDimensionsTransform) +class NormalizationTransform(VectorTransform): + __swig_setmethods__ = {} + for _s in [VectorTransform]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, NormalizationTransform, name, value) + __swig_getmethods__ = {} + for _s in [VectorTransform]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, NormalizationTransform, name) + __repr__ = _swig_repr + __swig_setmethods__["norm"] = _swigfaiss_gpu.NormalizationTransform_norm_set + __swig_getmethods__["norm"] = _swigfaiss_gpu.NormalizationTransform_norm_get + if _newclass:norm = _swig_property(_swigfaiss_gpu.NormalizationTransform_norm_get, _swigfaiss_gpu.NormalizationTransform_norm_set) + def __init__(self, *args): + this = _swigfaiss_gpu.new_NormalizationTransform(*args) + try: self.this.append(this) + except: self.this = this + def apply_noalloc(self, *args): return _swigfaiss_gpu.NormalizationTransform_apply_noalloc(self, *args) + __swig_destroy__ = _swigfaiss_gpu.delete_NormalizationTransform + __del__ = lambda self : None; +NormalizationTransform_swigregister = _swigfaiss_gpu.NormalizationTransform_swigregister +NormalizationTransform_swigregister(NormalizationTransform) + class IndexPreTransform(Index): __swig_setmethods__ = {} for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) @@ -1704,7 +1725,7 @@ class IndexIVF(Index): __swig_destroy__ = _swigfaiss_gpu.delete_IndexIVF __del__ = lambda self : None; def get_list_size(self, *args): return _swigfaiss_gpu.IndexIVF_get_list_size(self, *args) - def make_direct_map(self): return _swigfaiss_gpu.IndexIVF_make_direct_map(self) + def make_direct_map(self, new_maintain_direct_map=True): return _swigfaiss_gpu.IndexIVF_make_direct_map(self, new_maintain_direct_map) def imbalance_factor(self): return _swigfaiss_gpu.IndexIVF_imbalance_factor(self) def print_stats(self): return _swigfaiss_gpu.IndexIVF_print_stats(self) IndexIVF_swigregister = _swigfaiss_gpu.IndexIVF_swigregister @@ -1759,6 +1780,7 @@ class IndexIVFFlat(IndexIVF): def remove_ids(self, *args): return _swigfaiss_gpu.IndexIVFFlat_remove_ids(self, *args) def search_knn_inner_product(self, *args): return _swigfaiss_gpu.IndexIVFFlat_search_knn_inner_product(self, *args) def search_knn_L2sqr(self, *args): return _swigfaiss_gpu.IndexIVFFlat_search_knn_L2sqr(self, *args) + def update_vectors(self, *args): return _swigfaiss_gpu.IndexIVFFlat_update_vectors(self, *args) def reconstruct(self, *args): return _swigfaiss_gpu.IndexIVFFlat_reconstruct(self, *args) def merge_from_residuals(self, *args): return _swigfaiss_gpu.IndexIVFFlat_merge_from_residuals(self, *args) def __init__(self, *args): @@ -1839,6 +1861,38 @@ class ScalarQuantizer(_object): ScalarQuantizer_swigregister = _swigfaiss_gpu.ScalarQuantizer_swigregister ScalarQuantizer_swigregister(ScalarQuantizer) +class IndexScalarQuantizer(Index): + __swig_setmethods__ = {} + for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, IndexScalarQuantizer, name, value) + __swig_getmethods__ = {} + for _s in [Index]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, IndexScalarQuantizer, name) + __repr__ = _swig_repr + __swig_setmethods__["sq"] = _swigfaiss_gpu.IndexScalarQuantizer_sq_set + __swig_getmethods__["sq"] = _swigfaiss_gpu.IndexScalarQuantizer_sq_get + if _newclass:sq = _swig_property(_swigfaiss_gpu.IndexScalarQuantizer_sq_get, _swigfaiss_gpu.IndexScalarQuantizer_sq_set) + __swig_setmethods__["codes"] = _swigfaiss_gpu.IndexScalarQuantizer_codes_set + __swig_getmethods__["codes"] = _swigfaiss_gpu.IndexScalarQuantizer_codes_get + if _newclass:codes = _swig_property(_swigfaiss_gpu.IndexScalarQuantizer_codes_get, _swigfaiss_gpu.IndexScalarQuantizer_codes_set) + __swig_setmethods__["code_size"] = _swigfaiss_gpu.IndexScalarQuantizer_code_size_set + __swig_getmethods__["code_size"] = _swigfaiss_gpu.IndexScalarQuantizer_code_size_get + if _newclass:code_size = _swig_property(_swigfaiss_gpu.IndexScalarQuantizer_code_size_get, _swigfaiss_gpu.IndexScalarQuantizer_code_size_set) + def __init__(self, *args): + this = _swigfaiss_gpu.new_IndexScalarQuantizer(*args) + try: self.this.append(this) + except: self.this = this + def train(self, *args): return _swigfaiss_gpu.IndexScalarQuantizer_train(self, *args) + def add(self, *args): return _swigfaiss_gpu.IndexScalarQuantizer_add(self, *args) + def search(self, *args): return _swigfaiss_gpu.IndexScalarQuantizer_search(self, *args) + def reset(self): return _swigfaiss_gpu.IndexScalarQuantizer_reset(self) + def reconstruct_n(self, *args): return _swigfaiss_gpu.IndexScalarQuantizer_reconstruct_n(self, *args) + def reconstruct(self, *args): return _swigfaiss_gpu.IndexScalarQuantizer_reconstruct(self, *args) + __swig_destroy__ = _swigfaiss_gpu.delete_IndexScalarQuantizer + __del__ = lambda self : None; +IndexScalarQuantizer_swigregister = _swigfaiss_gpu.IndexScalarQuantizer_swigregister +IndexScalarQuantizer_swigregister(IndexScalarQuantizer) + class IndexIVFScalarQuantizer(IndexIVF): __swig_setmethods__ = {} for _s in [IndexIVF]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) @@ -2093,6 +2147,30 @@ class IndexIDMap(Index): IndexIDMap_swigregister = _swigfaiss_gpu.IndexIDMap_swigregister IndexIDMap_swigregister(IndexIDMap) +class IndexIDMap2(IndexIDMap): + __swig_setmethods__ = {} + for _s in [IndexIDMap]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) + __setattr__ = lambda self, name, value: _swig_setattr(self, IndexIDMap2, name, value) + __swig_getmethods__ = {} + for _s in [IndexIDMap]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) + __getattr__ = lambda self, name: _swig_getattr(self, IndexIDMap2, name) + __repr__ = _swig_repr + __swig_setmethods__["rev_map"] = _swigfaiss_gpu.IndexIDMap2_rev_map_set + __swig_getmethods__["rev_map"] = _swigfaiss_gpu.IndexIDMap2_rev_map_get + if _newclass:rev_map = _swig_property(_swigfaiss_gpu.IndexIDMap2_rev_map_get, _swigfaiss_gpu.IndexIDMap2_rev_map_set) + def construct_rev_map(self): return _swigfaiss_gpu.IndexIDMap2_construct_rev_map(self) + def add_with_ids(self, *args): return _swigfaiss_gpu.IndexIDMap2_add_with_ids(self, *args) + def remove_ids(self, *args): return _swigfaiss_gpu.IndexIDMap2_remove_ids(self, *args) + def reconstruct(self, *args): return _swigfaiss_gpu.IndexIDMap2_reconstruct(self, *args) + __swig_destroy__ = _swigfaiss_gpu.delete_IndexIDMap2 + __del__ = lambda self : None; + def __init__(self, *args): + this = _swigfaiss_gpu.new_IndexIDMap2(*args) + try: self.this.append(this) + except: self.this = this +IndexIDMap2_swigregister = _swigfaiss_gpu.IndexIDMap2_swigregister +IndexIDMap2_swigregister(IndexIDMap2) + class IndexShards(Index): __swig_setmethods__ = {} for _s in [Index]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) diff --git a/python/swigfaiss_gpu_wrap.cxx b/python/swigfaiss_gpu_wrap.cxx index e227fbf7d..faafea633 100644 --- a/python/swigfaiss_gpu_wrap.cxx +++ b/python/swigfaiss_gpu_wrap.cxx @@ -2973,105 +2973,110 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { #define SWIGTYPE_p_faiss__IndexFlatL2 swig_types[36] #define SWIGTYPE_p_faiss__IndexFlatL2BaseShift swig_types[37] #define SWIGTYPE_p_faiss__IndexIDMap swig_types[38] -#define SWIGTYPE_p_faiss__IndexIVF swig_types[39] -#define SWIGTYPE_p_faiss__IndexIVFFlat swig_types[40] -#define SWIGTYPE_p_faiss__IndexIVFFlatIPBounds swig_types[41] -#define SWIGTYPE_p_faiss__IndexIVFFlatStats swig_types[42] -#define SWIGTYPE_p_faiss__IndexIVFPQ swig_types[43] -#define SWIGTYPE_p_faiss__IndexIVFPQCompact swig_types[44] -#define SWIGTYPE_p_faiss__IndexIVFPQR swig_types[45] -#define SWIGTYPE_p_faiss__IndexIVFPQStats swig_types[46] -#define SWIGTYPE_p_faiss__IndexIVFScalarQuantizer swig_types[47] -#define SWIGTYPE_p_faiss__IndexLSH swig_types[48] -#define SWIGTYPE_p_faiss__IndexPQ swig_types[49] -#define SWIGTYPE_p_faiss__IndexPQStats swig_types[50] -#define SWIGTYPE_p_faiss__IndexPreTransform swig_types[51] -#define SWIGTYPE_p_faiss__IndexRefineFlat swig_types[52] -#define SWIGTYPE_p_faiss__IndexShards swig_types[53] -#define SWIGTYPE_p_faiss__IndexSplitVectors swig_types[54] -#define SWIGTYPE_p_faiss__IntersectionCriterion swig_types[55] -#define SWIGTYPE_p_faiss__LinearTransform swig_types[56] -#define SWIGTYPE_p_faiss__MultiIndexQuantizer swig_types[57] -#define SWIGTYPE_p_faiss__OPQMatrix swig_types[58] -#define SWIGTYPE_p_faiss__OneRecallAtRCriterion swig_types[59] -#define SWIGTYPE_p_faiss__OperatingPoint swig_types[60] -#define SWIGTYPE_p_faiss__OperatingPoints swig_types[61] -#define SWIGTYPE_p_faiss__PCAMatrix swig_types[62] -#define SWIGTYPE_p_faiss__ParameterRange swig_types[63] -#define SWIGTYPE_p_faiss__ParameterSpace swig_types[64] -#define SWIGTYPE_p_faiss__PermutationObjective swig_types[65] -#define SWIGTYPE_p_faiss__PolysemousTraining swig_types[66] -#define SWIGTYPE_p_faiss__ProductQuantizer swig_types[67] -#define SWIGTYPE_p_faiss__RandomGenerator swig_types[68] -#define SWIGTYPE_p_faiss__RandomRotationMatrix swig_types[69] -#define SWIGTYPE_p_faiss__RangeSearchPartialResult swig_types[70] -#define SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult swig_types[71] -#define SWIGTYPE_p_faiss__RangeSearchResult swig_types[72] -#define SWIGTYPE_p_faiss__RemapDimensionsTransform swig_types[73] -#define SWIGTYPE_p_faiss__ReproduceDistancesObjective swig_types[74] -#define SWIGTYPE_p_faiss__ScalarQuantizer swig_types[75] -#define SWIGTYPE_p_faiss__SimulatedAnnealingOptimizer swig_types[76] -#define SWIGTYPE_p_faiss__SimulatedAnnealingParameters swig_types[77] -#define SWIGTYPE_p_faiss__VectorTransform swig_types[78] -#define SWIGTYPE_p_faiss__gpu__FlatIndex swig_types[79] -#define SWIGTYPE_p_faiss__gpu__GpuClonerOptions swig_types[80] -#define SWIGTYPE_p_faiss__gpu__GpuIndex swig_types[81] -#define SWIGTYPE_p_faiss__gpu__GpuIndexConfig swig_types[82] -#define SWIGTYPE_p_faiss__gpu__GpuIndexFlat swig_types[83] -#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatConfig swig_types[84] -#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatIP swig_types[85] -#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatL2 swig_types[86] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVF swig_types[87] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFConfig swig_types[88] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFFlat swig_types[89] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFFlatConfig swig_types[90] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFPQ swig_types[91] -#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFPQConfig swig_types[92] -#define SWIGTYPE_p_faiss__gpu__GpuMultipleClonerOptions swig_types[93] -#define SWIGTYPE_p_faiss__gpu__GpuParameterSpace swig_types[94] -#define SWIGTYPE_p_faiss__gpu__GpuResources swig_types[95] -#define SWIGTYPE_p_faiss__gpu__IndexProxy swig_types[96] -#define SWIGTYPE_p_faiss__gpu__StandardGpuResources swig_types[97] -#define SWIGTYPE_p_float swig_types[98] -#define SWIGTYPE_p_idx_t swig_types[99] -#define SWIGTYPE_p_int swig_types[100] -#define SWIGTYPE_p_long swig_types[101] -#define SWIGTYPE_p_p_faiss__LinearTransform swig_types[102] -#define SWIGTYPE_p_p_faiss__OPQMatrix swig_types[103] -#define SWIGTYPE_p_p_faiss__PCAMatrix swig_types[104] -#define SWIGTYPE_p_p_faiss__RandomRotationMatrix swig_types[105] -#define SWIGTYPE_p_p_faiss__RemapDimensionsTransform swig_types[106] -#define SWIGTYPE_p_p_faiss__VectorTransform swig_types[107] -#define SWIGTYPE_p_p_faiss__gpu__GpuResources swig_types[108] -#define SWIGTYPE_p_p_faiss__gpu__StandardGpuResources swig_types[109] -#define SWIGTYPE_p_p_void swig_types[110] -#define SWIGTYPE_p_std__functionT_void_ffaiss__Index_pF_t swig_types[111] -#define SWIGTYPE_p_std__pairT_void_p_unsigned_long_t swig_types[112] -#define SWIGTYPE_p_std__vectorT_cudaStream_t_t swig_types[113] -#define SWIGTYPE_p_std__vectorT_double_t swig_types[114] -#define SWIGTYPE_p_std__vectorT_faiss__BufferList__Buffer_t swig_types[115] -#define SWIGTYPE_p_std__vectorT_faiss__Index_p_t swig_types[116] -#define SWIGTYPE_p_std__vectorT_faiss__OperatingPoint_t swig_types[117] -#define SWIGTYPE_p_std__vectorT_faiss__ParameterRange_t swig_types[118] -#define SWIGTYPE_p_std__vectorT_faiss__RangeSearchPartialResult__QueryResult_t swig_types[119] -#define SWIGTYPE_p_std__vectorT_faiss__VectorTransform_p_t swig_types[120] -#define SWIGTYPE_p_std__vectorT_faiss__gpu__GpuResources_p_t swig_types[121] -#define SWIGTYPE_p_std__vectorT_float_t swig_types[122] -#define SWIGTYPE_p_std__vectorT_int_t swig_types[123] -#define SWIGTYPE_p_std__vectorT_long_t swig_types[124] -#define SWIGTYPE_p_std__vectorT_std__vectorT_float_t_t swig_types[125] -#define SWIGTYPE_p_std__vectorT_std__vectorT_long_t_t swig_types[126] -#define SWIGTYPE_p_std__vectorT_std__vectorT_uint8_t_t_t swig_types[127] -#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[128] -#define SWIGTYPE_p_std__vectorT_unsigned_char_t swig_types[129] -#define SWIGTYPE_p_std__vectorT_unsigned_long_t swig_types[130] -#define SWIGTYPE_p_uint32_t swig_types[131] -#define SWIGTYPE_p_uint8_t swig_types[132] -#define SWIGTYPE_p_unsigned_char swig_types[133] -#define SWIGTYPE_p_unsigned_long swig_types[134] -#define SWIGTYPE_p_void swig_types[135] -static swig_type_info *swig_types[137]; -static swig_module_info swig_module = {swig_types, 136, 0, 0, 0, 0}; +#define SWIGTYPE_p_faiss__IndexIDMap2 swig_types[39] +#define SWIGTYPE_p_faiss__IndexIVF swig_types[40] +#define SWIGTYPE_p_faiss__IndexIVFFlat swig_types[41] +#define SWIGTYPE_p_faiss__IndexIVFFlatIPBounds swig_types[42] +#define SWIGTYPE_p_faiss__IndexIVFFlatStats swig_types[43] +#define SWIGTYPE_p_faiss__IndexIVFPQ swig_types[44] +#define SWIGTYPE_p_faiss__IndexIVFPQCompact swig_types[45] +#define SWIGTYPE_p_faiss__IndexIVFPQR swig_types[46] +#define SWIGTYPE_p_faiss__IndexIVFPQStats swig_types[47] +#define SWIGTYPE_p_faiss__IndexIVFScalarQuantizer swig_types[48] +#define SWIGTYPE_p_faiss__IndexLSH swig_types[49] +#define SWIGTYPE_p_faiss__IndexPQ swig_types[50] +#define SWIGTYPE_p_faiss__IndexPQStats swig_types[51] +#define SWIGTYPE_p_faiss__IndexPreTransform swig_types[52] +#define SWIGTYPE_p_faiss__IndexRefineFlat swig_types[53] +#define SWIGTYPE_p_faiss__IndexScalarQuantizer swig_types[54] +#define SWIGTYPE_p_faiss__IndexShards swig_types[55] +#define SWIGTYPE_p_faiss__IndexSplitVectors swig_types[56] +#define SWIGTYPE_p_faiss__IntersectionCriterion swig_types[57] +#define SWIGTYPE_p_faiss__LinearTransform swig_types[58] +#define SWIGTYPE_p_faiss__MultiIndexQuantizer swig_types[59] +#define SWIGTYPE_p_faiss__NormalizationTransform swig_types[60] +#define SWIGTYPE_p_faiss__OPQMatrix swig_types[61] +#define SWIGTYPE_p_faiss__OneRecallAtRCriterion swig_types[62] +#define SWIGTYPE_p_faiss__OperatingPoint swig_types[63] +#define SWIGTYPE_p_faiss__OperatingPoints swig_types[64] +#define SWIGTYPE_p_faiss__PCAMatrix swig_types[65] +#define SWIGTYPE_p_faiss__ParameterRange swig_types[66] +#define SWIGTYPE_p_faiss__ParameterSpace swig_types[67] +#define SWIGTYPE_p_faiss__PermutationObjective swig_types[68] +#define SWIGTYPE_p_faiss__PolysemousTraining swig_types[69] +#define SWIGTYPE_p_faiss__ProductQuantizer swig_types[70] +#define SWIGTYPE_p_faiss__RandomGenerator swig_types[71] +#define SWIGTYPE_p_faiss__RandomRotationMatrix swig_types[72] +#define SWIGTYPE_p_faiss__RangeSearchPartialResult swig_types[73] +#define SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult swig_types[74] +#define SWIGTYPE_p_faiss__RangeSearchResult swig_types[75] +#define SWIGTYPE_p_faiss__RemapDimensionsTransform swig_types[76] +#define SWIGTYPE_p_faiss__ReproduceDistancesObjective swig_types[77] +#define SWIGTYPE_p_faiss__ScalarQuantizer swig_types[78] +#define SWIGTYPE_p_faiss__SimulatedAnnealingOptimizer swig_types[79] +#define SWIGTYPE_p_faiss__SimulatedAnnealingParameters swig_types[80] +#define SWIGTYPE_p_faiss__VectorTransform swig_types[81] +#define SWIGTYPE_p_faiss__gpu__FlatIndex swig_types[82] +#define SWIGTYPE_p_faiss__gpu__GpuClonerOptions swig_types[83] +#define SWIGTYPE_p_faiss__gpu__GpuIndex swig_types[84] +#define SWIGTYPE_p_faiss__gpu__GpuIndexConfig swig_types[85] +#define SWIGTYPE_p_faiss__gpu__GpuIndexFlat swig_types[86] +#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatConfig swig_types[87] +#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatIP swig_types[88] +#define SWIGTYPE_p_faiss__gpu__GpuIndexFlatL2 swig_types[89] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVF swig_types[90] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFConfig swig_types[91] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFFlat swig_types[92] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFFlatConfig swig_types[93] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFPQ swig_types[94] +#define SWIGTYPE_p_faiss__gpu__GpuIndexIVFPQConfig swig_types[95] +#define SWIGTYPE_p_faiss__gpu__GpuMultipleClonerOptions swig_types[96] +#define SWIGTYPE_p_faiss__gpu__GpuParameterSpace swig_types[97] +#define SWIGTYPE_p_faiss__gpu__GpuResources swig_types[98] +#define SWIGTYPE_p_faiss__gpu__IndexProxy swig_types[99] +#define SWIGTYPE_p_faiss__gpu__StandardGpuResources swig_types[100] +#define SWIGTYPE_p_float swig_types[101] +#define SWIGTYPE_p_idx_t swig_types[102] +#define SWIGTYPE_p_int swig_types[103] +#define SWIGTYPE_p_long swig_types[104] +#define SWIGTYPE_p_p_faiss__LinearTransform swig_types[105] +#define SWIGTYPE_p_p_faiss__NormalizationTransform swig_types[106] +#define SWIGTYPE_p_p_faiss__OPQMatrix swig_types[107] +#define SWIGTYPE_p_p_faiss__PCAMatrix swig_types[108] +#define SWIGTYPE_p_p_faiss__RandomRotationMatrix swig_types[109] +#define SWIGTYPE_p_p_faiss__RemapDimensionsTransform swig_types[110] +#define SWIGTYPE_p_p_faiss__VectorTransform swig_types[111] +#define SWIGTYPE_p_p_faiss__gpu__GpuResources swig_types[112] +#define SWIGTYPE_p_p_faiss__gpu__StandardGpuResources swig_types[113] +#define SWIGTYPE_p_p_void swig_types[114] +#define SWIGTYPE_p_std__functionT_void_ffaiss__Index_pF_t swig_types[115] +#define SWIGTYPE_p_std__pairT_void_p_unsigned_long_t swig_types[116] +#define SWIGTYPE_p_std__unordered_mapT_long_long_t swig_types[117] +#define SWIGTYPE_p_std__vectorT_cudaStream_t_t swig_types[118] +#define SWIGTYPE_p_std__vectorT_double_t swig_types[119] +#define SWIGTYPE_p_std__vectorT_faiss__BufferList__Buffer_t swig_types[120] +#define SWIGTYPE_p_std__vectorT_faiss__Index_p_t swig_types[121] +#define SWIGTYPE_p_std__vectorT_faiss__OperatingPoint_t swig_types[122] +#define SWIGTYPE_p_std__vectorT_faiss__ParameterRange_t swig_types[123] +#define SWIGTYPE_p_std__vectorT_faiss__RangeSearchPartialResult__QueryResult_t swig_types[124] +#define SWIGTYPE_p_std__vectorT_faiss__VectorTransform_p_t swig_types[125] +#define SWIGTYPE_p_std__vectorT_faiss__gpu__GpuResources_p_t swig_types[126] +#define SWIGTYPE_p_std__vectorT_float_t swig_types[127] +#define SWIGTYPE_p_std__vectorT_int_t swig_types[128] +#define SWIGTYPE_p_std__vectorT_long_t swig_types[129] +#define SWIGTYPE_p_std__vectorT_std__vectorT_float_t_t swig_types[130] +#define SWIGTYPE_p_std__vectorT_std__vectorT_long_t_t swig_types[131] +#define SWIGTYPE_p_std__vectorT_std__vectorT_uint8_t_t_t swig_types[132] +#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[133] +#define SWIGTYPE_p_std__vectorT_unsigned_char_t swig_types[134] +#define SWIGTYPE_p_std__vectorT_unsigned_long_t swig_types[135] +#define SWIGTYPE_p_uint32_t swig_types[136] +#define SWIGTYPE_p_uint8_t swig_types[137] +#define SWIGTYPE_p_unsigned_char swig_types[138] +#define SWIGTYPE_p_unsigned_long swig_types[139] +#define SWIGTYPE_p_void swig_types[140] +static swig_type_info *swig_types[142]; +static swig_module_info swig_module = {swig_types, 141, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -3207,7 +3212,7 @@ extern "C" { #include "IndexPQ.h" #include "IndexIVF.h" #include "IndexIVFPQ.h" -#include "IndexIVFScalarQuantizer.h" +#include "IndexScalarQuantizer.h" #include "MetaIndexes.h" #include "FaissAssert.h" @@ -21611,6 +21616,290 @@ SWIGINTERN PyObject *RemapDimensionsTransform_swigregister(PyObject *SWIGUNUSEDP return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_NormalizationTransform_norm_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + float arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + float val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:NormalizationTransform_norm_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_norm_set" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + ecode2 = SWIG_AsVal_float(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NormalizationTransform_norm_set" "', argument " "2"" of type '" "float""'"); + } + arg2 = static_cast< float >(val2); + if (arg1) (arg1)->norm = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_NormalizationTransform_norm_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + float result; + + if (!PyArg_ParseTuple(args,(char *)"O:NormalizationTransform_norm_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_norm_get" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + result = (float) ((arg1)->norm); + resultobj = SWIG_From_float(static_cast< float >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + float arg2 ; + int val1 ; + int ecode1 = 0 ; + float val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_NormalizationTransform",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_NormalizationTransform" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_float(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_NormalizationTransform" "', argument " "2"" of type '" "float""'"); + } + arg2 = static_cast< float >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(arg1,arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_NormalizationTransform",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_NormalizationTransform" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(arg1); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_NormalizationTransform")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_NormalizationTransform__SWIG_2(self, args); + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_NormalizationTransform__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_float(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_NormalizationTransform__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_NormalizationTransform'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::NormalizationTransform::NormalizationTransform(int,float)\n" + " faiss::NormalizationTransform::NormalizationTransform(int)\n" + " faiss::NormalizationTransform::NormalizationTransform()\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_NormalizationTransform_apply_noalloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + faiss::VectorTransform::idx_t arg2 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:NormalizationTransform_apply_noalloc",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "1"" of type '" "faiss::NormalizationTransform const *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "2"" of type '" "faiss::VectorTransform::idx_t""'"); + } + arg2 = static_cast< faiss::VectorTransform::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "4"" of type '" "float *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::NormalizationTransform const *)arg1)->apply_noalloc(arg2,(float const *)arg3,arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_NormalizationTransform(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_NormalizationTransform",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_NormalizationTransform" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *NormalizationTransform_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__NormalizationTransform, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexPreTransform_chain_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexPreTransform *arg1 = (faiss::IndexPreTransform *) 0 ; @@ -30156,7 +30445,47 @@ fail: } -SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIVF_make_direct_map",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIVF, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIVF_make_direct_map" "', argument " "1"" of type '" "faiss::IndexIVF *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIVF * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIVF_make_direct_map" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->make_direct_map(arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; void *argp1 = 0 ; @@ -30187,6 +30516,50 @@ fail: } +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__IndexIVF, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_IndexIVF_make_direct_map__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__IndexIVF, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_bool(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_IndexIVF_make_direct_map__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IndexIVF_make_direct_map'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexIVF::make_direct_map(bool)\n" + " faiss::IndexIVF::make_direct_map()\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_IndexIVF_imbalance_factor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; @@ -31370,6 +31743,64 @@ fail: } +SWIGINTERN PyObject *_wrap_IndexIVFFlat_update_vectors(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIVFFlat *arg1 = (faiss::IndexIVFFlat *) 0 ; + int arg2 ; + faiss::Index::idx_t *arg3 = (faiss::Index::idx_t *) 0 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexIVFFlat_update_vectors",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIVFFlat, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIVFFlat_update_vectors" "', argument " "1"" of type '" "faiss::IndexIVFFlat *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIVFFlat * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIVFFlat_update_vectors" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIVFFlat_update_vectors" "', argument " "3"" of type '" "faiss::Index::idx_t *""'"); + } + arg3 = reinterpret_cast< faiss::Index::idx_t * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexIVFFlat_update_vectors" "', argument " "4"" of type '" "float const *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->update_vectors(arg2,arg3,(float const *)arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_IndexIVFFlat_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVFFlat *arg1 = (faiss::IndexIVFFlat *) 0 ; @@ -32527,6 +32958,678 @@ SWIGINTERN PyObject *ScalarQuantizer_swigregister(PyObject *SWIGUNUSEDPARM(self) return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_sq_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::ScalarQuantizer *arg2 = (faiss::ScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_sq_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_sq_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_faiss__ScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexScalarQuantizer_sq_set" "', argument " "2"" of type '" "faiss::ScalarQuantizer *""'"); + } + arg2 = reinterpret_cast< faiss::ScalarQuantizer * >(argp2); + if (arg1) (arg1)->sq = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_sq_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + faiss::ScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_sq_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_sq_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (faiss::ScalarQuantizer *)& ((arg1)->sq); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__ScalarQuantizer, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_codes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + std::vector< uint8_t > *arg2 = (std::vector< uint8_t > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_codes_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_codes_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_uint8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexScalarQuantizer_codes_set" "', argument " "2"" of type '" "std::vector< uint8_t > *""'"); + } + arg2 = reinterpret_cast< std::vector< uint8_t > * >(argp2); + if (arg1) (arg1)->codes = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_codes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::vector< uint8_t > *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_codes_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_codes_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (std::vector< uint8_t > *)& ((arg1)->codes); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_uint8_t_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_code_size_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_code_size_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_code_size_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_size_t(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_code_size_set" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = static_cast< size_t >(val2); + if (arg1) (arg1)->code_size = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_code_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_code_size_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_code_size_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (size_t) ((arg1)->code_size); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + faiss::ScalarQuantizer::QuantizerType arg2 ; + faiss::MetricType arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_IndexScalarQuantizer",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IndexScalarQuantizer" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IndexScalarQuantizer" "', argument " "2"" of type '" "faiss::ScalarQuantizer::QuantizerType""'"); + } + arg2 = static_cast< faiss::ScalarQuantizer::QuantizerType >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_IndexScalarQuantizer" "', argument " "3"" of type '" "faiss::MetricType""'"); + } + arg3 = static_cast< faiss::MetricType >(val3); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(arg1,arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + faiss::ScalarQuantizer::QuantizerType arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_IndexScalarQuantizer",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IndexScalarQuantizer" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IndexScalarQuantizer" "', argument " "2"" of type '" "faiss::ScalarQuantizer::QuantizerType""'"); + } + arg2 = static_cast< faiss::ScalarQuantizer::QuantizerType >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(arg1,arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_IndexScalarQuantizer")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 3) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_IndexScalarQuantizer__SWIG_2(self, args); + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_IndexScalarQuantizer__SWIG_1(self, args); + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_IndexScalarQuantizer__SWIG_0(self, args); + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_IndexScalarQuantizer'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer(int,faiss::ScalarQuantizer::QuantizerType,faiss::MetricType)\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer(int,faiss::ScalarQuantizer::QuantizerType)\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer()\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_train(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_train",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_train" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_train" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_train" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->train(arg2,(float const *)arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_add",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_add" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_add" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_add" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->add(arg2,(float const *)arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + faiss::Index::idx_t arg4 ; + float *arg5 = (float *) 0 ; + faiss::Index::idx_t *arg6 = (faiss::Index::idx_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + long val4 ; + int ecode4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:IndexScalarQuantizer_search",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_search" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_search" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_search" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + ecode4 = SWIG_AsVal_long(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IndexScalarQuantizer_search" "', argument " "4"" of type '" "faiss::Index::idx_t""'"); + } + arg4 = static_cast< faiss::Index::idx_t >(val4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IndexScalarQuantizer_search" "', argument " "5"" of type '" "float *""'"); + } + arg5 = reinterpret_cast< float * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IndexScalarQuantizer_search" "', argument " "6"" of type '" "faiss::Index::idx_t *""'"); + } + arg6 = reinterpret_cast< faiss::Index::idx_t * >(argp6); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->search(arg2,(float const *)arg3,arg4,arg5,arg6); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_reset",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reset" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->reset(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reconstruct_n(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + faiss::Index::idx_t arg3 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + long val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexScalarQuantizer_reconstruct_n",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + ecode3 = SWIG_AsVal_long(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "3"" of type '" "faiss::Index::idx_t""'"); + } + arg3 = static_cast< faiss::Index::idx_t >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "4"" of type '" "float *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->reconstruct_n(arg2,arg3,arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_reconstruct",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "3"" of type '" "float *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->reconstruct(arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IndexScalarQuantizer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_IndexScalarQuantizer",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IndexScalarQuantizer" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IndexScalarQuantizer_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexIVFScalarQuantizer_sq_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVFScalarQuantizer *arg1 = (faiss::IndexIVFScalarQuantizer *) 0 ; @@ -38514,6 +39617,373 @@ SWIGINTERN PyObject *IndexIDMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyO return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_IndexIDMap2_rev_map_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIDMap2_rev_map_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_rev_map_set" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__unordered_mapT_long_long_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexIDMap2_rev_map_set" "', argument " "2"" of type '" "std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IndexIDMap2_rev_map_set" "', argument " "2"" of type '" "std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >""'"); + } else { + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > * temp = reinterpret_cast< std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + if (arg1) (arg1)->rev_map = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_rev_map_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > result; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexIDMap2_rev_map_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_rev_map_get" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + result = ((arg1)->rev_map); + resultobj = SWIG_NewPointerObj((new std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >(static_cast< const std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >& >(result))), SWIGTYPE_p_std__unordered_mapT_long_long_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::Index *arg1 = (faiss::Index *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + faiss::IndexIDMap2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_IndexIDMap2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__Index, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_IndexIDMap2" "', argument " "1"" of type '" "faiss::Index *""'"); + } + arg1 = reinterpret_cast< faiss::Index * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexIDMap2 *)new faiss::IndexIDMap2(arg1); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_construct_rev_map(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexIDMap2_construct_rev_map",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_construct_rev_map" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->construct_rev_map(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_add_with_ids(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + long *arg4 = (long *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexIDMap2_add_with_ids",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_add_with_ids" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIDMap2_add_with_ids" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIDMap2_add_with_ids" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexIDMap2_add_with_ids" "', argument " "4"" of type '" "long const *""'"); + } + arg4 = reinterpret_cast< long * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->add_with_ids(arg2,(float const *)arg3,(long const *)arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_remove_ids(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::IDSelector *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + long result; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIDMap2_remove_ids",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_remove_ids" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_faiss__IDSelector, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexIDMap2_remove_ids" "', argument " "2"" of type '" "faiss::IDSelector const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IndexIDMap2_remove_ids" "', argument " "2"" of type '" "faiss::IDSelector const &""'"); + } + arg2 = reinterpret_cast< faiss::IDSelector * >(argp2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (long)(arg1)->remove_ids((faiss::IDSelector const &)*arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_From_long(static_cast< long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexIDMap2_reconstruct",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_reconstruct" "', argument " "1"" of type '" "faiss::IndexIDMap2 const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIDMap2_reconstruct" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIDMap2_reconstruct" "', argument " "3"" of type '" "float *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexIDMap2 const *)arg1)->reconstruct(arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IndexIDMap2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_IndexIDMap2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IndexIDMap2" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + delete arg1; + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_IndexIDMap2")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexIDMap2 *)new faiss::IndexIDMap2(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[2]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_IndexIDMap2__SWIG_1(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__Index, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_IndexIDMap2__SWIG_0(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_IndexIDMap2'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexIDMap2::IndexIDMap2(faiss::Index *)\n" + " faiss::IndexIDMap2::IndexIDMap2()\n"); + return 0; +} + + +SWIGINTERN PyObject *IndexIDMap2_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__IndexIDMap2, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexShards_shard_indexes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexShards *arg1 = (faiss::IndexShards *) 0 ; @@ -45881,6 +47351,11 @@ SWIGINTERN PyObject *_wrap_downcast_index(PyObject *SWIGUNUSEDPARM(self), PyObje } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,0); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,0); } else @@ -45993,6 +47468,11 @@ SWIGINTERN PyObject *_wrap_downcast_VectorTransform(PyObject *SWIGUNUSEDPARM(sel } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,0); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,0); } else @@ -46226,6 +47706,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -46363,6 +47848,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -46510,6 +48000,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -46650,6 +48145,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -46876,6 +48376,11 @@ SWIGINTERN PyObject *_wrap_read_VectorTransform(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,SWIG_POINTER_OWN); } else @@ -47050,6 +48555,11 @@ SWIGINTERN PyObject *_wrap_clone_index(PyObject *SWIGUNUSEDPARM(self), PyObject } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -47171,6 +48681,11 @@ SWIGINTERN PyObject *_wrap_Cloner_clone_VectorTransform(PyObject *SWIGUNUSEDPARM } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,SWIG_POINTER_OWN); } else @@ -47274,6 +48789,11 @@ SWIGINTERN PyObject *_wrap_Cloner_clone_Index(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,0); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,0); } else @@ -50429,6 +51949,11 @@ SWIGINTERN PyObject *_wrap_index_factory__SWIG_0(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -50578,6 +52103,11 @@ SWIGINTERN PyObject *_wrap_index_factory__SWIG_1(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -50771,6 +52301,11 @@ SWIGINTERN PyObject *_wrap_index_gpu_to_cpu(PyObject *SWIGUNUSEDPARM(self), PyOb } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -50935,6 +52470,11 @@ SWIGINTERN PyObject *_wrap_index_cpu_to_gpu__SWIG_0(PyObject *SWIGUNUSEDPARM(sel } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -51090,6 +52630,11 @@ SWIGINTERN PyObject *_wrap_index_cpu_to_gpu__SWIG_1(PyObject *SWIGUNUSEDPARM(sel } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -51325,6 +52870,11 @@ SWIGINTERN PyObject *_wrap_index_cpu_to_gpu_multiple__SWIG_0(PyObject *SWIGUNUSE } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -51486,6 +53036,11 @@ SWIGINTERN PyObject *_wrap_index_cpu_to_gpu_multiple__SWIG_1(PyObject *SWIGUNUSE } else /*@SWIG@*/ /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:../swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -58689,6 +60244,12 @@ static PyMethodDef SwigMethods[] = { { (char *)"new_RemapDimensionsTransform", _wrap_new_RemapDimensionsTransform, METH_VARARGS, NULL}, { (char *)"delete_RemapDimensionsTransform", _wrap_delete_RemapDimensionsTransform, METH_VARARGS, NULL}, { (char *)"RemapDimensionsTransform_swigregister", RemapDimensionsTransform_swigregister, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_norm_set", _wrap_NormalizationTransform_norm_set, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_norm_get", _wrap_NormalizationTransform_norm_get, METH_VARARGS, NULL}, + { (char *)"new_NormalizationTransform", _wrap_new_NormalizationTransform, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_apply_noalloc", _wrap_NormalizationTransform_apply_noalloc, METH_VARARGS, NULL}, + { (char *)"delete_NormalizationTransform", _wrap_delete_NormalizationTransform, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_swigregister", NormalizationTransform_swigregister, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_chain_set", _wrap_IndexPreTransform_chain_set, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_chain_get", _wrap_IndexPreTransform_chain_get, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_index_set", _wrap_IndexPreTransform_index_set, METH_VARARGS, NULL}, @@ -58952,6 +60513,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"IndexIVFFlat_remove_ids", _wrap_IndexIVFFlat_remove_ids, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_search_knn_inner_product", _wrap_IndexIVFFlat_search_knn_inner_product, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_search_knn_L2sqr", _wrap_IndexIVFFlat_search_knn_L2sqr, METH_VARARGS, NULL}, + { (char *)"IndexIVFFlat_update_vectors", _wrap_IndexIVFFlat_update_vectors, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_reconstruct", _wrap_IndexIVFFlat_reconstruct, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_merge_from_residuals", _wrap_IndexIVFFlat_merge_from_residuals, METH_VARARGS, NULL}, { (char *)"new_IndexIVFFlat", _wrap_new_IndexIVFFlat, METH_VARARGS, NULL}, @@ -58984,6 +60546,21 @@ static PyMethodDef SwigMethods[] = { { (char *)"ScalarQuantizer_decode", _wrap_ScalarQuantizer_decode, METH_VARARGS, NULL}, { (char *)"delete_ScalarQuantizer", _wrap_delete_ScalarQuantizer, METH_VARARGS, NULL}, { (char *)"ScalarQuantizer_swigregister", ScalarQuantizer_swigregister, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_sq_set", _wrap_IndexScalarQuantizer_sq_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_sq_get", _wrap_IndexScalarQuantizer_sq_get, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_codes_set", _wrap_IndexScalarQuantizer_codes_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_codes_get", _wrap_IndexScalarQuantizer_codes_get, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_code_size_set", _wrap_IndexScalarQuantizer_code_size_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_code_size_get", _wrap_IndexScalarQuantizer_code_size_get, METH_VARARGS, NULL}, + { (char *)"new_IndexScalarQuantizer", _wrap_new_IndexScalarQuantizer, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_train", _wrap_IndexScalarQuantizer_train, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_add", _wrap_IndexScalarQuantizer_add, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_search", _wrap_IndexScalarQuantizer_search, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reset", _wrap_IndexScalarQuantizer_reset, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reconstruct_n", _wrap_IndexScalarQuantizer_reconstruct_n, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reconstruct", _wrap_IndexScalarQuantizer_reconstruct, METH_VARARGS, NULL}, + { (char *)"delete_IndexScalarQuantizer", _wrap_delete_IndexScalarQuantizer, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_swigregister", IndexScalarQuantizer_swigregister, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_sq_set", _wrap_IndexIVFScalarQuantizer_sq_set, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_sq_get", _wrap_IndexIVFScalarQuantizer_sq_get, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_code_size_set", _wrap_IndexIVFScalarQuantizer_code_size_set, METH_VARARGS, NULL}, @@ -59116,6 +60693,15 @@ static PyMethodDef SwigMethods[] = { { (char *)"delete_IndexIDMap", _wrap_delete_IndexIDMap, METH_VARARGS, NULL}, { (char *)"new_IndexIDMap", _wrap_new_IndexIDMap, METH_VARARGS, NULL}, { (char *)"IndexIDMap_swigregister", IndexIDMap_swigregister, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_rev_map_set", _wrap_IndexIDMap2_rev_map_set, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_rev_map_get", _wrap_IndexIDMap2_rev_map_get, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_construct_rev_map", _wrap_IndexIDMap2_construct_rev_map, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_add_with_ids", _wrap_IndexIDMap2_add_with_ids, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_remove_ids", _wrap_IndexIDMap2_remove_ids, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_reconstruct", _wrap_IndexIDMap2_reconstruct, METH_VARARGS, NULL}, + { (char *)"delete_IndexIDMap2", _wrap_delete_IndexIDMap2, METH_VARARGS, NULL}, + { (char *)"new_IndexIDMap2", _wrap_new_IndexIDMap2, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_swigregister", IndexIDMap2_swigregister, METH_VARARGS, NULL}, { (char *)"IndexShards_shard_indexes_set", _wrap_IndexShards_shard_indexes_set, METH_VARARGS, NULL}, { (char *)"IndexShards_shard_indexes_get", _wrap_IndexShards_shard_indexes_get, METH_VARARGS, NULL}, { (char *)"IndexShards_own_fields_set", _wrap_IndexShards_own_fields_set, METH_VARARGS, NULL}, @@ -59619,6 +61205,9 @@ static void *_p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform(void *x, i static void *_p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::VectorTransform **) ((faiss::RemapDimensionsTransform **) x)); } +static void *_p_p_faiss__NormalizationTransformTo_p_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::VectorTransform **) ((faiss::NormalizationTransform **) x)); +} static void *_p_faiss__RandomRotationMatrixTo_p_faiss__LinearTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::LinearTransform *) ((faiss::RandomRotationMatrix *) x)); } @@ -59643,6 +61232,9 @@ static void *_p_faiss__LinearTransformTo_p_faiss__VectorTransform(void *x, int * static void *_p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::VectorTransform *) ((faiss::RemapDimensionsTransform *) x)); } +static void *_p_faiss__NormalizationTransformTo_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::VectorTransform *) ((faiss::NormalizationTransform *) x)); +} static void *_p_faiss__RangeSearchPartialResultTo_p_faiss__BufferList(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::BufferList *) ((faiss::RangeSearchPartialResult *) x)); } @@ -59697,6 +61289,9 @@ static void *_p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index(void *x, int *SWIGU static void *_p_faiss__IndexShardsTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::IndexShards *) x)); } +static void *_p_faiss__IndexIDMap2To_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) (faiss::IndexIDMap *) ((faiss::IndexIDMap2 *) x)); +} static void *_p_faiss__IndexSplitVectorsTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::IndexSplitVectors *) x)); } @@ -59727,12 +61322,15 @@ static void *_p_faiss__gpu__GpuIndexTo_p_faiss__Index(void *x, int *SWIGUNUSEDPA static void *_p_faiss__gpu__GpuIndexIVFPQTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) (faiss::gpu::GpuIndex *)(faiss::gpu::GpuIndexIVF *) ((faiss::gpu::GpuIndexIVFPQ *) x)); } -static void *_p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((faiss::Index *) (faiss::IndexIVF *) ((faiss::IndexIVFScalarQuantizer *) x)); +static void *_p_faiss__IndexScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) ((faiss::IndexScalarQuantizer *) x)); } static void *_p_faiss__MultiIndexQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::MultiIndexQuantizer *) x)); } +static void *_p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) (faiss::IndexIVF *) ((faiss::IndexIVFScalarQuantizer *) x)); +} static void *_p_faiss__ClusteringTo_p_faiss__ClusteringParameters(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::ClusteringParameters *) ((faiss::Clustering *) x)); } @@ -59793,6 +61391,9 @@ static void *_p_faiss__IDSelectorBatchTo_p_faiss__IDSelector(void *x, int *SWIGU static void *_p_faiss__IDSelectorRangeTo_p_faiss__IDSelector(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::IDSelector *) ((faiss::IDSelectorRange *) x)); } +static void *_p_faiss__IndexIDMap2To_p_faiss__IndexIDMap(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::IndexIDMap *) ((faiss::IndexIDMap2 *) x)); +} static swig_type_info _swigt__p_Crev = {"_p_Crev", "Crev *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_T = {"_p_T", "T *", 0, 0, (void*)0, 0}; @@ -59832,6 +61433,7 @@ static swig_type_info _swigt__p_faiss__IndexFlatIP = {"_p_faiss__IndexFlatIP", " static swig_type_info _swigt__p_faiss__IndexFlatL2 = {"_p_faiss__IndexFlatL2", "faiss::IndexFlatL2 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexFlatL2BaseShift = {"_p_faiss__IndexFlatL2BaseShift", "faiss::IndexFlatL2BaseShift *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIDMap = {"_p_faiss__IndexIDMap", "faiss::IndexIDMap *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__IndexIDMap2 = {"_p_faiss__IndexIDMap2", "faiss::IndexIDMap2 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVF = {"_p_faiss__IndexIVF", "faiss::IndexIVF *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVFFlat = {"_p_faiss__IndexIVFFlat", "faiss::IndexIVFFlat *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVFFlatIPBounds = {"_p_faiss__IndexIVFFlatIPBounds", "faiss::IndexIVFFlatIPBounds *", 0, 0, (void*)0, 0}; @@ -59846,11 +61448,13 @@ static swig_type_info _swigt__p_faiss__IndexPQ = {"_p_faiss__IndexPQ", "faiss::I static swig_type_info _swigt__p_faiss__IndexPQStats = {"_p_faiss__IndexPQStats", "faiss::IndexPQStats *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexPreTransform = {"_p_faiss__IndexPreTransform", "faiss::IndexPreTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexRefineFlat = {"_p_faiss__IndexRefineFlat", "faiss::IndexRefineFlat *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__IndexScalarQuantizer = {"_p_faiss__IndexScalarQuantizer", "faiss::IndexScalarQuantizer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexShards = {"_p_faiss__IndexShards", "faiss::IndexShards *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexSplitVectors = {"_p_faiss__IndexSplitVectors", "faiss::IndexSplitVectors *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IntersectionCriterion = {"_p_faiss__IntersectionCriterion", "faiss::IntersectionCriterion *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__LinearTransform = {"_p_faiss__LinearTransform", "faiss::LinearTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__MultiIndexQuantizer = {"_p_faiss__MultiIndexQuantizer", "faiss::MultiIndexQuantizer *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__NormalizationTransform = {"_p_faiss__NormalizationTransform", "faiss::NormalizationTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OPQMatrix = {"_p_faiss__OPQMatrix", "faiss::OPQMatrix *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OneRecallAtRCriterion = {"_p_faiss__OneRecallAtRCriterion", "faiss::OneRecallAtRCriterion *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OperatingPoint = {"_p_faiss__OperatingPoint", "faiss::OperatingPoint *", 0, 0, (void*)0, 0}; @@ -59901,11 +61505,13 @@ static swig_type_info _swigt__p_p_faiss__PCAMatrix = {"_p_p_faiss__PCAMatrix", 0 static swig_type_info _swigt__p_p_faiss__OPQMatrix = {"_p_p_faiss__OPQMatrix", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_faiss__LinearTransform = {"_p_p_faiss__LinearTransform", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_faiss__RemapDimensionsTransform = {"_p_p_faiss__RemapDimensionsTransform", 0, 0, 0, 0, 0}; +static swig_type_info _swigt__p_p_faiss__NormalizationTransform = {"_p_p_faiss__NormalizationTransform", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_faiss__gpu__GpuResources = {"_p_p_faiss__gpu__GpuResources", "faiss::gpu::GpuResources **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_faiss__gpu__StandardGpuResources = {"_p_p_faiss__gpu__StandardGpuResources", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_void = {"_p_p_void", "void **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__functionT_void_ffaiss__Index_pF_t = {"_p_std__functionT_void_ffaiss__Index_pF_t", "std::function< void (faiss::Index *) > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__pairT_void_p_unsigned_long_t = {"_p_std__pairT_void_p_unsigned_long_t", "std::pair< void *,unsigned long > *|std::pair< void *,size_t > *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__unordered_mapT_long_long_t = {"_p_std__unordered_mapT_long_long_t", "std::unordered_map< long,long > *|std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_cudaStream_t_t = {"_p_std__vectorT_cudaStream_t_t", "std::vector< cudaStream_t > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_double_t = {"_p_std__vectorT_double_t", "std::vector< double > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_faiss__BufferList__Buffer_t = {"_p_std__vectorT_faiss__BufferList__Buffer_t", "std::vector< faiss::BufferList::Buffer > *", 0, 0, (void*)0, 0}; @@ -59970,6 +61576,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_faiss__IndexFlatL2, &_swigt__p_faiss__IndexFlatL2BaseShift, &_swigt__p_faiss__IndexIDMap, + &_swigt__p_faiss__IndexIDMap2, &_swigt__p_faiss__IndexIVF, &_swigt__p_faiss__IndexIVFFlat, &_swigt__p_faiss__IndexIVFFlatIPBounds, @@ -59984,11 +61591,13 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_faiss__IndexPQStats, &_swigt__p_faiss__IndexPreTransform, &_swigt__p_faiss__IndexRefineFlat, + &_swigt__p_faiss__IndexScalarQuantizer, &_swigt__p_faiss__IndexShards, &_swigt__p_faiss__IndexSplitVectors, &_swigt__p_faiss__IntersectionCriterion, &_swigt__p_faiss__LinearTransform, &_swigt__p_faiss__MultiIndexQuantizer, + &_swigt__p_faiss__NormalizationTransform, &_swigt__p_faiss__OPQMatrix, &_swigt__p_faiss__OneRecallAtRCriterion, &_swigt__p_faiss__OperatingPoint, @@ -60034,6 +61643,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_int, &_swigt__p_long, &_swigt__p_p_faiss__LinearTransform, + &_swigt__p_p_faiss__NormalizationTransform, &_swigt__p_p_faiss__OPQMatrix, &_swigt__p_p_faiss__PCAMatrix, &_swigt__p_p_faiss__RandomRotationMatrix, @@ -60044,6 +61654,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_p_void, &_swigt__p_std__functionT_void_ffaiss__Index_pF_t, &_swigt__p_std__pairT_void_p_unsigned_long_t, + &_swigt__p_std__unordered_mapT_long_long_t, &_swigt__p_std__vectorT_cudaStream_t_t, &_swigt__p_std__vectorT_double_t, &_swigt__p_std__vectorT_faiss__BufferList__Buffer_t, @@ -60101,13 +61712,14 @@ static swig_cast_info _swigc__p_faiss__HeapArrayT_faiss__CMinT_int_long_t_t[] = static swig_cast_info _swigc__p_faiss__IDSelector[] = { {&_swigt__p_faiss__IDSelector, 0, 0, 0}, {&_swigt__p_faiss__IDSelectorBatch, _p_faiss__IDSelectorBatchTo_p_faiss__IDSelector, 0, 0}, {&_swigt__p_faiss__IDSelectorRange, _p_faiss__IDSelectorRangeTo_p_faiss__IDSelector, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IDSelectorBatch[] = { {&_swigt__p_faiss__IDSelectorBatch, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IDSelectorRange[] = { {&_swigt__p_faiss__IDSelectorRange, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__Index[] = { {&_swigt__p_faiss__IndexPreTransform, _p_faiss__IndexPreTransformTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVF, _p_faiss__IndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVF, _p_faiss__gpu__GpuIndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatL2, _p_faiss__gpu__GpuIndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFFlat, _p_faiss__gpu__GpuIndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatIP, _p_faiss__gpu__GpuIndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexLSH, _p_faiss__IndexLSHTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlat, _p_faiss__gpu__GpuIndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat, _p_faiss__IndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexShards, _p_faiss__IndexShardsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexSplitVectors, _p_faiss__IndexSplitVectorsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__Index, 0, 0, 0}, {&_swigt__p_faiss__IndexRefineFlat, _p_faiss__IndexRefineFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__IndexProxy, _p_faiss__gpu__IndexProxyTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexPQ, _p_faiss__IndexPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap, _p_faiss__IndexIDMapTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFPQ, _p_faiss__gpu__GpuIndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndex, _p_faiss__gpu__GpuIndexTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__MultiIndexQuantizer, _p_faiss__MultiIndexQuantizerTo_p_faiss__Index, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__Index[] = { {&_swigt__p_faiss__IndexPreTransform, _p_faiss__IndexPreTransformTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVF, _p_faiss__IndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVF, _p_faiss__gpu__GpuIndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatL2, _p_faiss__gpu__GpuIndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFFlat, _p_faiss__gpu__GpuIndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatIP, _p_faiss__gpu__GpuIndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexLSH, _p_faiss__IndexLSHTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlat, _p_faiss__gpu__GpuIndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat, _p_faiss__IndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexShards, _p_faiss__IndexShardsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap2, _p_faiss__IndexIDMap2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexSplitVectors, _p_faiss__IndexSplitVectorsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__Index, 0, 0, 0}, {&_swigt__p_faiss__IndexRefineFlat, _p_faiss__IndexRefineFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__IndexProxy, _p_faiss__gpu__IndexProxyTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexPQ, _p_faiss__IndexPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap, _p_faiss__IndexIDMapTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFPQ, _p_faiss__gpu__GpuIndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndex, _p_faiss__gpu__GpuIndexTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexScalarQuantizer, _p_faiss__IndexScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__MultiIndexQuantizer, _p_faiss__MultiIndexQuantizerTo_p_faiss__Index, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlat[] = { {&_swigt__p_faiss__IndexFlat, 0, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__IndexFlat, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlat1D[] = { {&_swigt__p_faiss__IndexFlat1D, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatIP[] = { {&_swigt__p_faiss__IndexFlatIP, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatL2[] = { {&_swigt__p_faiss__IndexFlatL2, 0, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__IndexFlatL2, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__IndexFlatL2, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatL2BaseShift[] = { {&_swigt__p_faiss__IndexFlatL2BaseShift, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__IndexIDMap[] = { {&_swigt__p_faiss__IndexIDMap, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexIDMap[] = { {&_swigt__p_faiss__IndexIDMap2, _p_faiss__IndexIDMap2To_p_faiss__IndexIDMap, 0, 0}, {&_swigt__p_faiss__IndexIDMap, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexIDMap2[] = { {&_swigt__p_faiss__IndexIDMap2, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVF[] = { {&_swigt__p_faiss__IndexIVF, 0, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__IndexIVF, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVFFlat[] = { {&_swigt__p_faiss__IndexIVFFlat, 0, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__IndexIVFFlat, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVFFlatIPBounds[] = { {&_swigt__p_faiss__IndexIVFFlatIPBounds, 0, 0, 0},{0, 0, 0, 0}}; @@ -60122,11 +61734,13 @@ static swig_cast_info _swigc__p_faiss__IndexPQ[] = { {&_swigt__p_faiss__IndexPQ static swig_cast_info _swigc__p_faiss__IndexPQStats[] = { {&_swigt__p_faiss__IndexPQStats, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexPreTransform[] = { {&_swigt__p_faiss__IndexPreTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexRefineFlat[] = { {&_swigt__p_faiss__IndexRefineFlat, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexScalarQuantizer[] = { {&_swigt__p_faiss__IndexScalarQuantizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexShards[] = { {&_swigt__p_faiss__IndexShards, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexSplitVectors[] = { {&_swigt__p_faiss__IndexSplitVectors, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IntersectionCriterion[] = { {&_swigt__p_faiss__IntersectionCriterion, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__LinearTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__LinearTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__MultiIndexQuantizer[] = { {&_swigt__p_faiss__MultiIndexQuantizer, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__NormalizationTransform[] = { {&_swigt__p_faiss__NormalizationTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OPQMatrix[] = { {&_swigt__p_faiss__OPQMatrix, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OneRecallAtRCriterion[] = { {&_swigt__p_faiss__OneRecallAtRCriterion, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OperatingPoint[] = { {&_swigt__p_faiss__OperatingPoint, 0, 0, 0},{0, 0, 0, 0}}; @@ -60147,7 +61761,7 @@ static swig_cast_info _swigc__p_faiss__ReproduceDistancesObjective[] = { {&_swi static swig_cast_info _swigc__p_faiss__ScalarQuantizer[] = { {&_swigt__p_faiss__ScalarQuantizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__SimulatedAnnealingOptimizer[] = { {&_swigt__p_faiss__SimulatedAnnealingOptimizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__SimulatedAnnealingParameters[] = { {&_swigt__p_faiss__SimulatedAnnealingParameters, 0, 0, 0}, {&_swigt__p_faiss__PolysemousTraining, _p_faiss__PolysemousTrainingTo_p_faiss__SimulatedAnnealingParameters, 0, 0}, {&_swigt__p_faiss__SimulatedAnnealingOptimizer, _p_faiss__SimulatedAnnealingOptimizerTo_p_faiss__SimulatedAnnealingParameters, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__VectorTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_faiss__LinearTransform, _p_faiss__LinearTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__RemapDimensionsTransform, _p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__VectorTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_faiss__LinearTransform, _p_faiss__LinearTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__RemapDimensionsTransform, _p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__NormalizationTransform, _p_faiss__NormalizationTransformTo_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__gpu__FlatIndex[] = { {&_swigt__p_faiss__gpu__FlatIndex, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__gpu__GpuClonerOptions[] = { {&_swigt__p_faiss__gpu__GpuClonerOptions, 0, 0, 0}, {&_swigt__p_faiss__gpu__GpuMultipleClonerOptions, _p_faiss__gpu__GpuMultipleClonerOptionsTo_p_faiss__gpu__GpuClonerOptions, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__gpu__GpuIndex[] = { {&_swigt__p_faiss__gpu__GpuIndex, 0, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlat, _p_faiss__gpu__GpuIndexFlatTo_p_faiss__gpu__GpuIndex, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatL2, _p_faiss__gpu__GpuIndexFlatL2To_p_faiss__gpu__GpuIndex, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVF, _p_faiss__gpu__GpuIndexIVFTo_p_faiss__gpu__GpuIndex, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFPQ, _p_faiss__gpu__GpuIndexIVFPQTo_p_faiss__gpu__GpuIndex, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexIVFFlat, _p_faiss__gpu__GpuIndexIVFFlatTo_p_faiss__gpu__GpuIndex, 0, 0}, {&_swigt__p_faiss__gpu__GpuIndexFlatIP, _p_faiss__gpu__GpuIndexFlatIPTo_p_faiss__gpu__GpuIndex, 0, 0},{0, 0, 0, 0}}; @@ -60176,12 +61790,14 @@ static swig_cast_info _swigc__p_p_faiss__PCAMatrix[] = {{&_swigt__p_p_faiss__PCA static swig_cast_info _swigc__p_p_faiss__OPQMatrix[] = {{&_swigt__p_p_faiss__OPQMatrix, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__LinearTransform[] = {{&_swigt__p_p_faiss__LinearTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__RemapDimensionsTransform[] = {{&_swigt__p_p_faiss__RemapDimensionsTransform, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_faiss__VectorTransform[] = { {&_swigt__p_p_faiss__RandomRotationMatrix, _p_p_faiss__RandomRotationMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__PCAMatrix, _p_p_faiss__PCAMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__OPQMatrix, _p_p_faiss__OPQMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_p_faiss__LinearTransform, _p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__RemapDimensionsTransform, _p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_faiss__NormalizationTransform[] = {{&_swigt__p_p_faiss__NormalizationTransform, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_faiss__VectorTransform[] = { {&_swigt__p_p_faiss__RandomRotationMatrix, _p_p_faiss__RandomRotationMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__PCAMatrix, _p_p_faiss__PCAMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__OPQMatrix, _p_p_faiss__OPQMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_p_faiss__LinearTransform, _p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__RemapDimensionsTransform, _p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__NormalizationTransform, _p_p_faiss__NormalizationTransformTo_p_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__gpu__StandardGpuResources[] = {{&_swigt__p_p_faiss__gpu__StandardGpuResources, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__gpu__GpuResources[] = { {&_swigt__p_p_faiss__gpu__GpuResources, 0, 0, 0}, {&_swigt__p_p_faiss__gpu__StandardGpuResources, _p_p_faiss__gpu__StandardGpuResourcesTo_p_p_faiss__gpu__GpuResources, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__functionT_void_ffaiss__Index_pF_t[] = { {&_swigt__p_std__functionT_void_ffaiss__Index_pF_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__pairT_void_p_unsigned_long_t[] = { {&_swigt__p_std__pairT_void_p_unsigned_long_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__unordered_mapT_long_long_t[] = { {&_swigt__p_std__unordered_mapT_long_long_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_cudaStream_t_t[] = { {&_swigt__p_std__vectorT_cudaStream_t_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_double_t[] = { {&_swigt__p_std__vectorT_double_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_faiss__BufferList__Buffer_t[] = { {&_swigt__p_std__vectorT_faiss__BufferList__Buffer_t, 0, 0, 0},{0, 0, 0, 0}}; @@ -60246,6 +61862,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_faiss__IndexFlatL2, _swigc__p_faiss__IndexFlatL2BaseShift, _swigc__p_faiss__IndexIDMap, + _swigc__p_faiss__IndexIDMap2, _swigc__p_faiss__IndexIVF, _swigc__p_faiss__IndexIVFFlat, _swigc__p_faiss__IndexIVFFlatIPBounds, @@ -60260,11 +61877,13 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_faiss__IndexPQStats, _swigc__p_faiss__IndexPreTransform, _swigc__p_faiss__IndexRefineFlat, + _swigc__p_faiss__IndexScalarQuantizer, _swigc__p_faiss__IndexShards, _swigc__p_faiss__IndexSplitVectors, _swigc__p_faiss__IntersectionCriterion, _swigc__p_faiss__LinearTransform, _swigc__p_faiss__MultiIndexQuantizer, + _swigc__p_faiss__NormalizationTransform, _swigc__p_faiss__OPQMatrix, _swigc__p_faiss__OneRecallAtRCriterion, _swigc__p_faiss__OperatingPoint, @@ -60310,6 +61929,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_int, _swigc__p_long, _swigc__p_p_faiss__LinearTransform, + _swigc__p_p_faiss__NormalizationTransform, _swigc__p_p_faiss__OPQMatrix, _swigc__p_p_faiss__PCAMatrix, _swigc__p_p_faiss__RandomRotationMatrix, @@ -60320,6 +61940,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_p_void, _swigc__p_std__functionT_void_ffaiss__Index_pF_t, _swigc__p_std__pairT_void_p_unsigned_long_t, + _swigc__p_std__unordered_mapT_long_long_t, _swigc__p_std__vectorT_cudaStream_t_t, _swigc__p_std__vectorT_double_t, _swigc__p_std__vectorT_faiss__BufferList__Buffer_t, diff --git a/python/swigfaiss_wrap.cxx b/python/swigfaiss_wrap.cxx index 95cf7c76a..c39a16c8b 100644 --- a/python/swigfaiss_wrap.cxx +++ b/python/swigfaiss_wrap.cxx @@ -2971,79 +2971,84 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { #define SWIGTYPE_p_faiss__IndexFlatL2 swig_types[34] #define SWIGTYPE_p_faiss__IndexFlatL2BaseShift swig_types[35] #define SWIGTYPE_p_faiss__IndexIDMap swig_types[36] -#define SWIGTYPE_p_faiss__IndexIVF swig_types[37] -#define SWIGTYPE_p_faiss__IndexIVFFlat swig_types[38] -#define SWIGTYPE_p_faiss__IndexIVFFlatIPBounds swig_types[39] -#define SWIGTYPE_p_faiss__IndexIVFFlatStats swig_types[40] -#define SWIGTYPE_p_faiss__IndexIVFPQ swig_types[41] -#define SWIGTYPE_p_faiss__IndexIVFPQCompact swig_types[42] -#define SWIGTYPE_p_faiss__IndexIVFPQR swig_types[43] -#define SWIGTYPE_p_faiss__IndexIVFPQStats swig_types[44] -#define SWIGTYPE_p_faiss__IndexIVFScalarQuantizer swig_types[45] -#define SWIGTYPE_p_faiss__IndexLSH swig_types[46] -#define SWIGTYPE_p_faiss__IndexPQ swig_types[47] -#define SWIGTYPE_p_faiss__IndexPQStats swig_types[48] -#define SWIGTYPE_p_faiss__IndexPreTransform swig_types[49] -#define SWIGTYPE_p_faiss__IndexRefineFlat swig_types[50] -#define SWIGTYPE_p_faiss__IndexShards swig_types[51] -#define SWIGTYPE_p_faiss__IndexSplitVectors swig_types[52] -#define SWIGTYPE_p_faiss__IntersectionCriterion swig_types[53] -#define SWIGTYPE_p_faiss__LinearTransform swig_types[54] -#define SWIGTYPE_p_faiss__MultiIndexQuantizer swig_types[55] -#define SWIGTYPE_p_faiss__OPQMatrix swig_types[56] -#define SWIGTYPE_p_faiss__OneRecallAtRCriterion swig_types[57] -#define SWIGTYPE_p_faiss__OperatingPoint swig_types[58] -#define SWIGTYPE_p_faiss__OperatingPoints swig_types[59] -#define SWIGTYPE_p_faiss__PCAMatrix swig_types[60] -#define SWIGTYPE_p_faiss__ParameterRange swig_types[61] -#define SWIGTYPE_p_faiss__ParameterSpace swig_types[62] -#define SWIGTYPE_p_faiss__PermutationObjective swig_types[63] -#define SWIGTYPE_p_faiss__PolysemousTraining swig_types[64] -#define SWIGTYPE_p_faiss__ProductQuantizer swig_types[65] -#define SWIGTYPE_p_faiss__RandomGenerator swig_types[66] -#define SWIGTYPE_p_faiss__RandomRotationMatrix swig_types[67] -#define SWIGTYPE_p_faiss__RangeSearchPartialResult swig_types[68] -#define SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult swig_types[69] -#define SWIGTYPE_p_faiss__RangeSearchResult swig_types[70] -#define SWIGTYPE_p_faiss__RemapDimensionsTransform swig_types[71] -#define SWIGTYPE_p_faiss__ReproduceDistancesObjective swig_types[72] -#define SWIGTYPE_p_faiss__ScalarQuantizer swig_types[73] -#define SWIGTYPE_p_faiss__SimulatedAnnealingOptimizer swig_types[74] -#define SWIGTYPE_p_faiss__SimulatedAnnealingParameters swig_types[75] -#define SWIGTYPE_p_faiss__VectorTransform swig_types[76] -#define SWIGTYPE_p_float swig_types[77] -#define SWIGTYPE_p_idx_t swig_types[78] -#define SWIGTYPE_p_int swig_types[79] -#define SWIGTYPE_p_long swig_types[80] -#define SWIGTYPE_p_p_faiss__LinearTransform swig_types[81] -#define SWIGTYPE_p_p_faiss__OPQMatrix swig_types[82] -#define SWIGTYPE_p_p_faiss__PCAMatrix swig_types[83] -#define SWIGTYPE_p_p_faiss__RandomRotationMatrix swig_types[84] -#define SWIGTYPE_p_p_faiss__RemapDimensionsTransform swig_types[85] -#define SWIGTYPE_p_p_faiss__VectorTransform swig_types[86] -#define SWIGTYPE_p_std__vectorT_double_t swig_types[87] -#define SWIGTYPE_p_std__vectorT_faiss__BufferList__Buffer_t swig_types[88] -#define SWIGTYPE_p_std__vectorT_faiss__Index_p_t swig_types[89] -#define SWIGTYPE_p_std__vectorT_faiss__OperatingPoint_t swig_types[90] -#define SWIGTYPE_p_std__vectorT_faiss__ParameterRange_t swig_types[91] -#define SWIGTYPE_p_std__vectorT_faiss__RangeSearchPartialResult__QueryResult_t swig_types[92] -#define SWIGTYPE_p_std__vectorT_faiss__VectorTransform_p_t swig_types[93] -#define SWIGTYPE_p_std__vectorT_float_t swig_types[94] -#define SWIGTYPE_p_std__vectorT_int_t swig_types[95] -#define SWIGTYPE_p_std__vectorT_long_t swig_types[96] -#define SWIGTYPE_p_std__vectorT_std__vectorT_float_t_t swig_types[97] -#define SWIGTYPE_p_std__vectorT_std__vectorT_long_t_t swig_types[98] -#define SWIGTYPE_p_std__vectorT_std__vectorT_uint8_t_t_t swig_types[99] -#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[100] -#define SWIGTYPE_p_std__vectorT_unsigned_char_t swig_types[101] -#define SWIGTYPE_p_std__vectorT_unsigned_long_t swig_types[102] -#define SWIGTYPE_p_uint32_t swig_types[103] -#define SWIGTYPE_p_uint8_t swig_types[104] -#define SWIGTYPE_p_unsigned_char swig_types[105] -#define SWIGTYPE_p_unsigned_long swig_types[106] -#define SWIGTYPE_p_void swig_types[107] -static swig_type_info *swig_types[109]; -static swig_module_info swig_module = {swig_types, 108, 0, 0, 0, 0}; +#define SWIGTYPE_p_faiss__IndexIDMap2 swig_types[37] +#define SWIGTYPE_p_faiss__IndexIVF swig_types[38] +#define SWIGTYPE_p_faiss__IndexIVFFlat swig_types[39] +#define SWIGTYPE_p_faiss__IndexIVFFlatIPBounds swig_types[40] +#define SWIGTYPE_p_faiss__IndexIVFFlatStats swig_types[41] +#define SWIGTYPE_p_faiss__IndexIVFPQ swig_types[42] +#define SWIGTYPE_p_faiss__IndexIVFPQCompact swig_types[43] +#define SWIGTYPE_p_faiss__IndexIVFPQR swig_types[44] +#define SWIGTYPE_p_faiss__IndexIVFPQStats swig_types[45] +#define SWIGTYPE_p_faiss__IndexIVFScalarQuantizer swig_types[46] +#define SWIGTYPE_p_faiss__IndexLSH swig_types[47] +#define SWIGTYPE_p_faiss__IndexPQ swig_types[48] +#define SWIGTYPE_p_faiss__IndexPQStats swig_types[49] +#define SWIGTYPE_p_faiss__IndexPreTransform swig_types[50] +#define SWIGTYPE_p_faiss__IndexRefineFlat swig_types[51] +#define SWIGTYPE_p_faiss__IndexScalarQuantizer swig_types[52] +#define SWIGTYPE_p_faiss__IndexShards swig_types[53] +#define SWIGTYPE_p_faiss__IndexSplitVectors swig_types[54] +#define SWIGTYPE_p_faiss__IntersectionCriterion swig_types[55] +#define SWIGTYPE_p_faiss__LinearTransform swig_types[56] +#define SWIGTYPE_p_faiss__MultiIndexQuantizer swig_types[57] +#define SWIGTYPE_p_faiss__NormalizationTransform swig_types[58] +#define SWIGTYPE_p_faiss__OPQMatrix swig_types[59] +#define SWIGTYPE_p_faiss__OneRecallAtRCriterion swig_types[60] +#define SWIGTYPE_p_faiss__OperatingPoint swig_types[61] +#define SWIGTYPE_p_faiss__OperatingPoints swig_types[62] +#define SWIGTYPE_p_faiss__PCAMatrix swig_types[63] +#define SWIGTYPE_p_faiss__ParameterRange swig_types[64] +#define SWIGTYPE_p_faiss__ParameterSpace swig_types[65] +#define SWIGTYPE_p_faiss__PermutationObjective swig_types[66] +#define SWIGTYPE_p_faiss__PolysemousTraining swig_types[67] +#define SWIGTYPE_p_faiss__ProductQuantizer swig_types[68] +#define SWIGTYPE_p_faiss__RandomGenerator swig_types[69] +#define SWIGTYPE_p_faiss__RandomRotationMatrix swig_types[70] +#define SWIGTYPE_p_faiss__RangeSearchPartialResult swig_types[71] +#define SWIGTYPE_p_faiss__RangeSearchPartialResult__QueryResult swig_types[72] +#define SWIGTYPE_p_faiss__RangeSearchResult swig_types[73] +#define SWIGTYPE_p_faiss__RemapDimensionsTransform swig_types[74] +#define SWIGTYPE_p_faiss__ReproduceDistancesObjective swig_types[75] +#define SWIGTYPE_p_faiss__ScalarQuantizer swig_types[76] +#define SWIGTYPE_p_faiss__SimulatedAnnealingOptimizer swig_types[77] +#define SWIGTYPE_p_faiss__SimulatedAnnealingParameters swig_types[78] +#define SWIGTYPE_p_faiss__VectorTransform swig_types[79] +#define SWIGTYPE_p_float swig_types[80] +#define SWIGTYPE_p_idx_t swig_types[81] +#define SWIGTYPE_p_int swig_types[82] +#define SWIGTYPE_p_long swig_types[83] +#define SWIGTYPE_p_p_faiss__LinearTransform swig_types[84] +#define SWIGTYPE_p_p_faiss__NormalizationTransform swig_types[85] +#define SWIGTYPE_p_p_faiss__OPQMatrix swig_types[86] +#define SWIGTYPE_p_p_faiss__PCAMatrix swig_types[87] +#define SWIGTYPE_p_p_faiss__RandomRotationMatrix swig_types[88] +#define SWIGTYPE_p_p_faiss__RemapDimensionsTransform swig_types[89] +#define SWIGTYPE_p_p_faiss__VectorTransform swig_types[90] +#define SWIGTYPE_p_std__unordered_mapT_long_long_t swig_types[91] +#define SWIGTYPE_p_std__vectorT_double_t swig_types[92] +#define SWIGTYPE_p_std__vectorT_faiss__BufferList__Buffer_t swig_types[93] +#define SWIGTYPE_p_std__vectorT_faiss__Index_p_t swig_types[94] +#define SWIGTYPE_p_std__vectorT_faiss__OperatingPoint_t swig_types[95] +#define SWIGTYPE_p_std__vectorT_faiss__ParameterRange_t swig_types[96] +#define SWIGTYPE_p_std__vectorT_faiss__RangeSearchPartialResult__QueryResult_t swig_types[97] +#define SWIGTYPE_p_std__vectorT_faiss__VectorTransform_p_t swig_types[98] +#define SWIGTYPE_p_std__vectorT_float_t swig_types[99] +#define SWIGTYPE_p_std__vectorT_int_t swig_types[100] +#define SWIGTYPE_p_std__vectorT_long_t swig_types[101] +#define SWIGTYPE_p_std__vectorT_std__vectorT_float_t_t swig_types[102] +#define SWIGTYPE_p_std__vectorT_std__vectorT_long_t_t swig_types[103] +#define SWIGTYPE_p_std__vectorT_std__vectorT_uint8_t_t_t swig_types[104] +#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[105] +#define SWIGTYPE_p_std__vectorT_unsigned_char_t swig_types[106] +#define SWIGTYPE_p_std__vectorT_unsigned_long_t swig_types[107] +#define SWIGTYPE_p_uint32_t swig_types[108] +#define SWIGTYPE_p_uint8_t swig_types[109] +#define SWIGTYPE_p_unsigned_char swig_types[110] +#define SWIGTYPE_p_unsigned_long swig_types[111] +#define SWIGTYPE_p_void swig_types[112] +static swig_type_info *swig_types[114]; +static swig_module_info swig_module = {swig_types, 113, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -3179,7 +3184,7 @@ extern "C" { #include "IndexPQ.h" #include "IndexIVF.h" #include "IndexIVFPQ.h" -#include "IndexIVFScalarQuantizer.h" +#include "IndexScalarQuantizer.h" #include "MetaIndexes.h" #include "FaissAssert.h" @@ -20543,6 +20548,290 @@ SWIGINTERN PyObject *RemapDimensionsTransform_swigregister(PyObject *SWIGUNUSEDP return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_NormalizationTransform_norm_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + float arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + float val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:NormalizationTransform_norm_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_norm_set" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + ecode2 = SWIG_AsVal_float(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NormalizationTransform_norm_set" "', argument " "2"" of type '" "float""'"); + } + arg2 = static_cast< float >(val2); + if (arg1) (arg1)->norm = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_NormalizationTransform_norm_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + float result; + + if (!PyArg_ParseTuple(args,(char *)"O:NormalizationTransform_norm_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_norm_get" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + result = (float) ((arg1)->norm); + resultobj = SWIG_From_float(static_cast< float >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + float arg2 ; + int val1 ; + int ecode1 = 0 ; + float val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_NormalizationTransform",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_NormalizationTransform" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_float(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_NormalizationTransform" "', argument " "2"" of type '" "float""'"); + } + arg2 = static_cast< float >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(arg1,arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_NormalizationTransform",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_NormalizationTransform" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(arg1); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_NormalizationTransform")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::NormalizationTransform *)new faiss::NormalizationTransform(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_NormalizationTransform(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_NormalizationTransform__SWIG_2(self, args); + } + if (argc == 1) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_NormalizationTransform__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_float(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_NormalizationTransform__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_NormalizationTransform'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::NormalizationTransform::NormalizationTransform(int,float)\n" + " faiss::NormalizationTransform::NormalizationTransform(int)\n" + " faiss::NormalizationTransform::NormalizationTransform()\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_NormalizationTransform_apply_noalloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + faiss::VectorTransform::idx_t arg2 ; + float *arg3 = (float *) 0 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:NormalizationTransform_apply_noalloc",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "1"" of type '" "faiss::NormalizationTransform const *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "2"" of type '" "faiss::VectorTransform::idx_t""'"); + } + arg2 = static_cast< faiss::VectorTransform::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "NormalizationTransform_apply_noalloc" "', argument " "4"" of type '" "float *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::NormalizationTransform const *)arg1)->apply_noalloc(arg2,(float const *)arg3,arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_NormalizationTransform(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::NormalizationTransform *arg1 = (faiss::NormalizationTransform *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_NormalizationTransform",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__NormalizationTransform, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_NormalizationTransform" "', argument " "1"" of type '" "faiss::NormalizationTransform *""'"); + } + arg1 = reinterpret_cast< faiss::NormalizationTransform * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *NormalizationTransform_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__NormalizationTransform, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexPreTransform_chain_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexPreTransform *arg1 = (faiss::IndexPreTransform *) 0 ; @@ -29088,7 +29377,47 @@ fail: } -SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIVF_make_direct_map",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIVF, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIVF_make_direct_map" "', argument " "1"" of type '" "faiss::IndexIVF *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIVF * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIVF_make_direct_map" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->make_direct_map(arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; void *argp1 = 0 ; @@ -29119,6 +29448,50 @@ fail: } +SWIGINTERN PyObject *_wrap_IndexIVF_make_direct_map(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 2) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__IndexIVF, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_IndexIVF_make_direct_map__SWIG_1(self, args); + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__IndexIVF, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_bool(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_IndexIVF_make_direct_map__SWIG_0(self, args); + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IndexIVF_make_direct_map'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexIVF::make_direct_map(bool)\n" + " faiss::IndexIVF::make_direct_map()\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_IndexIVF_imbalance_factor(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVF *arg1 = (faiss::IndexIVF *) 0 ; @@ -30302,6 +30675,64 @@ fail: } +SWIGINTERN PyObject *_wrap_IndexIVFFlat_update_vectors(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIVFFlat *arg1 = (faiss::IndexIVFFlat *) 0 ; + int arg2 ; + faiss::Index::idx_t *arg3 = (faiss::Index::idx_t *) 0 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexIVFFlat_update_vectors",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIVFFlat, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIVFFlat_update_vectors" "', argument " "1"" of type '" "faiss::IndexIVFFlat *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIVFFlat * >(argp1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIVFFlat_update_vectors" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIVFFlat_update_vectors" "', argument " "3"" of type '" "faiss::Index::idx_t *""'"); + } + arg3 = reinterpret_cast< faiss::Index::idx_t * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexIVFFlat_update_vectors" "', argument " "4"" of type '" "float const *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->update_vectors(arg2,arg3,(float const *)arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_IndexIVFFlat_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVFFlat *arg1 = (faiss::IndexIVFFlat *) 0 ; @@ -31459,6 +31890,678 @@ SWIGINTERN PyObject *ScalarQuantizer_swigregister(PyObject *SWIGUNUSEDPARM(self) return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_sq_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::ScalarQuantizer *arg2 = (faiss::ScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_sq_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_sq_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_faiss__ScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexScalarQuantizer_sq_set" "', argument " "2"" of type '" "faiss::ScalarQuantizer *""'"); + } + arg2 = reinterpret_cast< faiss::ScalarQuantizer * >(argp2); + if (arg1) (arg1)->sq = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_sq_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + faiss::ScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_sq_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_sq_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (faiss::ScalarQuantizer *)& ((arg1)->sq); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__ScalarQuantizer, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_codes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + std::vector< uint8_t > *arg2 = (std::vector< uint8_t > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_codes_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_codes_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_uint8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexScalarQuantizer_codes_set" "', argument " "2"" of type '" "std::vector< uint8_t > *""'"); + } + arg2 = reinterpret_cast< std::vector< uint8_t > * >(argp2); + if (arg1) (arg1)->codes = *arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_codes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::vector< uint8_t > *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_codes_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_codes_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (std::vector< uint8_t > *)& ((arg1)->codes); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_uint8_t_t, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_code_size_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexScalarQuantizer_code_size_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_code_size_set" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_size_t(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_code_size_set" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = static_cast< size_t >(val2); + if (arg1) (arg1)->code_size = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_code_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + size_t result; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_code_size_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_code_size_get" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + result = (size_t) ((arg1)->code_size); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + faiss::ScalarQuantizer::QuantizerType arg2 ; + faiss::MetricType arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:new_IndexScalarQuantizer",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IndexScalarQuantizer" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IndexScalarQuantizer" "', argument " "2"" of type '" "faiss::ScalarQuantizer::QuantizerType""'"); + } + arg2 = static_cast< faiss::ScalarQuantizer::QuantizerType >(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_IndexScalarQuantizer" "', argument " "3"" of type '" "faiss::MetricType""'"); + } + arg3 = static_cast< faiss::MetricType >(val3); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(arg1,arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + faiss::ScalarQuantizer::QuantizerType arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:new_IndexScalarQuantizer",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IndexScalarQuantizer" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IndexScalarQuantizer" "', argument " "2"" of type '" "faiss::ScalarQuantizer::QuantizerType""'"); + } + arg2 = static_cast< faiss::ScalarQuantizer::QuantizerType >(val2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(arg1,arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_IndexScalarQuantizer")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexScalarQuantizer *)new faiss::IndexScalarQuantizer(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexScalarQuantizer(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 3) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_IndexScalarQuantizer__SWIG_2(self, args); + } + if (argc == 2) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_IndexScalarQuantizer__SWIG_1(self, args); + } + } + } + if (argc == 3) { + int _v; + { + int res = SWIG_AsVal_int(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_IndexScalarQuantizer__SWIG_0(self, args); + } + } + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_IndexScalarQuantizer'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer(int,faiss::ScalarQuantizer::QuantizerType,faiss::MetricType)\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer(int,faiss::ScalarQuantizer::QuantizerType)\n" + " faiss::IndexScalarQuantizer::IndexScalarQuantizer()\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_train(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_train",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_train" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_train" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_train" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->train(arg2,(float const *)arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_add",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_add" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_add" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_add" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->add(arg2,(float const *)arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + faiss::Index::idx_t arg4 ; + float *arg5 = (float *) 0 ; + faiss::Index::idx_t *arg6 = (faiss::Index::idx_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + long val4 ; + int ecode4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:IndexScalarQuantizer_search",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_search" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_search" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_search" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + ecode4 = SWIG_AsVal_long(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IndexScalarQuantizer_search" "', argument " "4"" of type '" "faiss::Index::idx_t""'"); + } + arg4 = static_cast< faiss::Index::idx_t >(val4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IndexScalarQuantizer_search" "', argument " "5"" of type '" "float *""'"); + } + arg5 = reinterpret_cast< float * >(argp5); + res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IndexScalarQuantizer_search" "', argument " "6"" of type '" "faiss::Index::idx_t *""'"); + } + arg6 = reinterpret_cast< faiss::Index::idx_t * >(argp6); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->search(arg2,(float const *)arg3,arg4,arg5,arg6); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexScalarQuantizer_reset",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reset" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->reset(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reconstruct_n(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + faiss::Index::idx_t arg3 ; + float *arg4 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + long val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexScalarQuantizer_reconstruct_n",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + ecode3 = SWIG_AsVal_long(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "3"" of type '" "faiss::Index::idx_t""'"); + } + arg3 = static_cast< faiss::Index::idx_t >(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexScalarQuantizer_reconstruct_n" "', argument " "4"" of type '" "float *""'"); + } + arg4 = reinterpret_cast< float * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->reconstruct_n(arg2,arg3,arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexScalarQuantizer_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexScalarQuantizer_reconstruct",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexScalarQuantizer_reconstruct" "', argument " "3"" of type '" "float *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexScalarQuantizer const *)arg1)->reconstruct(arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IndexScalarQuantizer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexScalarQuantizer *arg1 = (faiss::IndexScalarQuantizer *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_IndexScalarQuantizer",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IndexScalarQuantizer" "', argument " "1"" of type '" "faiss::IndexScalarQuantizer *""'"); + } + arg1 = reinterpret_cast< faiss::IndexScalarQuantizer * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IndexScalarQuantizer_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__IndexScalarQuantizer, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexIVFScalarQuantizer_sq_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexIVFScalarQuantizer *arg1 = (faiss::IndexIVFScalarQuantizer *) 0 ; @@ -37446,6 +38549,373 @@ SWIGINTERN PyObject *IndexIDMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyO return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_IndexIDMap2_rev_map_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIDMap2_rev_map_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_rev_map_set" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__unordered_mapT_long_long_t, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexIDMap2_rev_map_set" "', argument " "2"" of type '" "std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IndexIDMap2_rev_map_set" "', argument " "2"" of type '" "std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >""'"); + } else { + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > * temp = reinterpret_cast< std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > * >(argp2); + arg2 = *temp; + if (SWIG_IsNewObj(res2)) delete temp; + } + } + if (arg1) (arg1)->rev_map = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_rev_map_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > result; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexIDMap2_rev_map_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_rev_map_get" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + result = ((arg1)->rev_map); + resultobj = SWIG_NewPointerObj((new std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >(static_cast< const std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t >& >(result))), SWIGTYPE_p_std__unordered_mapT_long_long_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::Index *arg1 = (faiss::Index *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + faiss::IndexIDMap2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_IndexIDMap2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__Index, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_IndexIDMap2" "', argument " "1"" of type '" "faiss::Index *""'"); + } + arg1 = reinterpret_cast< faiss::Index * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexIDMap2 *)new faiss::IndexIDMap2(arg1); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_construct_rev_map(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:IndexIDMap2_construct_rev_map",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_construct_rev_map" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->construct_rev_map(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_add_with_ids(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + long *arg4 = (long *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:IndexIDMap2_add_with_ids",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_add_with_ids" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIDMap2_add_with_ids" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIDMap2_add_with_ids" "', argument " "3"" of type '" "float const *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_long, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IndexIDMap2_add_with_ids" "', argument " "4"" of type '" "long const *""'"); + } + arg4 = reinterpret_cast< long * >(argp4); + { + Py_BEGIN_ALLOW_THREADS + try { + (arg1)->add_with_ids(arg2,(float const *)arg3,(long const *)arg4); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_remove_ids(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::IDSelector *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + long result; + + if (!PyArg_ParseTuple(args,(char *)"OO:IndexIDMap2_remove_ids",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_remove_ids" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_faiss__IDSelector, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IndexIDMap2_remove_ids" "', argument " "2"" of type '" "faiss::IDSelector const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IndexIDMap2_remove_ids" "', argument " "2"" of type '" "faiss::IDSelector const &""'"); + } + arg2 = reinterpret_cast< faiss::IDSelector * >(argp2); + { + Py_BEGIN_ALLOW_THREADS + try { + result = (long)(arg1)->remove_ids((faiss::IDSelector const &)*arg2); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_From_long(static_cast< long >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IndexIDMap2_reconstruct(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + faiss::Index::idx_t arg2 ; + float *arg3 = (float *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:IndexIDMap2_reconstruct",&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IndexIDMap2_reconstruct" "', argument " "1"" of type '" "faiss::IndexIDMap2 const *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + ecode2 = SWIG_AsVal_long(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IndexIDMap2_reconstruct" "', argument " "2"" of type '" "faiss::Index::idx_t""'"); + } + arg2 = static_cast< faiss::Index::idx_t >(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_float, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IndexIDMap2_reconstruct" "', argument " "3"" of type '" "float *""'"); + } + arg3 = reinterpret_cast< float * >(argp3); + { + Py_BEGIN_ALLOW_THREADS + try { + ((faiss::IndexIDMap2 const *)arg1)->reconstruct(arg2,arg3); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IndexIDMap2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *arg1 = (faiss::IndexIDMap2 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_IndexIDMap2",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IndexIDMap2" "', argument " "1"" of type '" "faiss::IndexIDMap2 *""'"); + } + arg1 = reinterpret_cast< faiss::IndexIDMap2 * >(argp1); + { + Py_BEGIN_ALLOW_THREADS + try { + delete arg1; + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + faiss::IndexIDMap2 *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_IndexIDMap2")) SWIG_fail; + { + Py_BEGIN_ALLOW_THREADS + try { + result = (faiss::IndexIDMap2 *)new faiss::IndexIDMap2(); + } catch(faiss::FaissException & e) { + PyEval_RestoreThread(_save); + PyErr_SetString(PyExc_RuntimeError, e.what()); + SWIG_fail; + } + Py_END_ALLOW_THREADS + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_faiss__IndexIDMap2, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IndexIDMap2(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[2]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = args ? (int)PyObject_Length(args) : 0; + for (ii = 0; (ii < 1) && (ii < argc); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_IndexIDMap2__SWIG_1(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_faiss__Index, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_IndexIDMap2__SWIG_0(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_IndexIDMap2'.\n" + " Possible C/C++ prototypes are:\n" + " faiss::IndexIDMap2::IndexIDMap2(faiss::Index *)\n" + " faiss::IndexIDMap2::IndexIDMap2()\n"); + return 0; +} + + +SWIGINTERN PyObject *IndexIDMap2_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_faiss__IndexIDMap2, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_IndexShards_shard_indexes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; faiss::IndexShards *arg1 = (faiss::IndexShards *) 0 ; @@ -38977,6 +40447,11 @@ SWIGINTERN PyObject *_wrap_downcast_index(PyObject *SWIGUNUSEDPARM(self), PyObje } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,0); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,0); } else @@ -39073,6 +40548,11 @@ SWIGINTERN PyObject *_wrap_downcast_VectorTransform(PyObject *SWIGUNUSEDPARM(sel } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,0); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,0); } else @@ -39306,6 +40786,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -39427,6 +40912,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -39558,6 +41048,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -39682,6 +41177,11 @@ SWIGINTERN PyObject *_wrap_read_index__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -39892,6 +41392,11 @@ SWIGINTERN PyObject *_wrap_read_VectorTransform(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,SWIG_POINTER_OWN); } else @@ -40066,6 +41571,11 @@ SWIGINTERN PyObject *_wrap_clone_index(PyObject *SWIGUNUSEDPARM(self), PyObject } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -40171,6 +41681,11 @@ SWIGINTERN PyObject *_wrap_Cloner_clone_VectorTransform(PyObject *SWIGUNUSEDPARM } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__NormalizationTransform,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__VectorTransform,SWIG_POINTER_OWN); } else @@ -40274,6 +41789,11 @@ SWIGINTERN PyObject *_wrap_Cloner_clone_Index(PyObject *SWIGUNUSEDPARM(self), Py } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,0); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,0); } else @@ -43413,6 +44933,11 @@ SWIGINTERN PyObject *_wrap_index_factory__SWIG_0(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -43546,6 +45071,11 @@ SWIGINTERN PyObject *_wrap_index_factory__SWIG_1(PyObject *SWIGUNUSEDPARM(self), } else /*@SWIG@*/ /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ + if (dynamic_cast (result)) { + resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexScalarQuantizer,SWIG_POINTER_OWN); + } else + /*@SWIG@*/ + /*@SWIG:swigfaiss.swig,397,DOWNCAST@*/ if (dynamic_cast (result)) { resultobj = SWIG_NewPointerObj(result,SWIGTYPE_p_faiss__IndexLSH,SWIG_POINTER_OWN); } else @@ -50547,6 +52077,12 @@ static PyMethodDef SwigMethods[] = { { (char *)"new_RemapDimensionsTransform", _wrap_new_RemapDimensionsTransform, METH_VARARGS, NULL}, { (char *)"delete_RemapDimensionsTransform", _wrap_delete_RemapDimensionsTransform, METH_VARARGS, NULL}, { (char *)"RemapDimensionsTransform_swigregister", RemapDimensionsTransform_swigregister, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_norm_set", _wrap_NormalizationTransform_norm_set, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_norm_get", _wrap_NormalizationTransform_norm_get, METH_VARARGS, NULL}, + { (char *)"new_NormalizationTransform", _wrap_new_NormalizationTransform, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_apply_noalloc", _wrap_NormalizationTransform_apply_noalloc, METH_VARARGS, NULL}, + { (char *)"delete_NormalizationTransform", _wrap_delete_NormalizationTransform, METH_VARARGS, NULL}, + { (char *)"NormalizationTransform_swigregister", NormalizationTransform_swigregister, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_chain_set", _wrap_IndexPreTransform_chain_set, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_chain_get", _wrap_IndexPreTransform_chain_get, METH_VARARGS, NULL}, { (char *)"IndexPreTransform_index_set", _wrap_IndexPreTransform_index_set, METH_VARARGS, NULL}, @@ -50810,6 +52346,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"IndexIVFFlat_remove_ids", _wrap_IndexIVFFlat_remove_ids, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_search_knn_inner_product", _wrap_IndexIVFFlat_search_knn_inner_product, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_search_knn_L2sqr", _wrap_IndexIVFFlat_search_knn_L2sqr, METH_VARARGS, NULL}, + { (char *)"IndexIVFFlat_update_vectors", _wrap_IndexIVFFlat_update_vectors, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_reconstruct", _wrap_IndexIVFFlat_reconstruct, METH_VARARGS, NULL}, { (char *)"IndexIVFFlat_merge_from_residuals", _wrap_IndexIVFFlat_merge_from_residuals, METH_VARARGS, NULL}, { (char *)"new_IndexIVFFlat", _wrap_new_IndexIVFFlat, METH_VARARGS, NULL}, @@ -50842,6 +52379,21 @@ static PyMethodDef SwigMethods[] = { { (char *)"ScalarQuantizer_decode", _wrap_ScalarQuantizer_decode, METH_VARARGS, NULL}, { (char *)"delete_ScalarQuantizer", _wrap_delete_ScalarQuantizer, METH_VARARGS, NULL}, { (char *)"ScalarQuantizer_swigregister", ScalarQuantizer_swigregister, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_sq_set", _wrap_IndexScalarQuantizer_sq_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_sq_get", _wrap_IndexScalarQuantizer_sq_get, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_codes_set", _wrap_IndexScalarQuantizer_codes_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_codes_get", _wrap_IndexScalarQuantizer_codes_get, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_code_size_set", _wrap_IndexScalarQuantizer_code_size_set, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_code_size_get", _wrap_IndexScalarQuantizer_code_size_get, METH_VARARGS, NULL}, + { (char *)"new_IndexScalarQuantizer", _wrap_new_IndexScalarQuantizer, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_train", _wrap_IndexScalarQuantizer_train, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_add", _wrap_IndexScalarQuantizer_add, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_search", _wrap_IndexScalarQuantizer_search, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reset", _wrap_IndexScalarQuantizer_reset, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reconstruct_n", _wrap_IndexScalarQuantizer_reconstruct_n, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_reconstruct", _wrap_IndexScalarQuantizer_reconstruct, METH_VARARGS, NULL}, + { (char *)"delete_IndexScalarQuantizer", _wrap_delete_IndexScalarQuantizer, METH_VARARGS, NULL}, + { (char *)"IndexScalarQuantizer_swigregister", IndexScalarQuantizer_swigregister, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_sq_set", _wrap_IndexIVFScalarQuantizer_sq_set, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_sq_get", _wrap_IndexIVFScalarQuantizer_sq_get, METH_VARARGS, NULL}, { (char *)"IndexIVFScalarQuantizer_code_size_set", _wrap_IndexIVFScalarQuantizer_code_size_set, METH_VARARGS, NULL}, @@ -50974,6 +52526,15 @@ static PyMethodDef SwigMethods[] = { { (char *)"delete_IndexIDMap", _wrap_delete_IndexIDMap, METH_VARARGS, NULL}, { (char *)"new_IndexIDMap", _wrap_new_IndexIDMap, METH_VARARGS, NULL}, { (char *)"IndexIDMap_swigregister", IndexIDMap_swigregister, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_rev_map_set", _wrap_IndexIDMap2_rev_map_set, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_rev_map_get", _wrap_IndexIDMap2_rev_map_get, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_construct_rev_map", _wrap_IndexIDMap2_construct_rev_map, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_add_with_ids", _wrap_IndexIDMap2_add_with_ids, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_remove_ids", _wrap_IndexIDMap2_remove_ids, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_reconstruct", _wrap_IndexIDMap2_reconstruct, METH_VARARGS, NULL}, + { (char *)"delete_IndexIDMap2", _wrap_delete_IndexIDMap2, METH_VARARGS, NULL}, + { (char *)"new_IndexIDMap2", _wrap_new_IndexIDMap2, METH_VARARGS, NULL}, + { (char *)"IndexIDMap2_swigregister", IndexIDMap2_swigregister, METH_VARARGS, NULL}, { (char *)"IndexShards_shard_indexes_set", _wrap_IndexShards_shard_indexes_set, METH_VARARGS, NULL}, { (char *)"IndexShards_shard_indexes_get", _wrap_IndexShards_shard_indexes_get, METH_VARARGS, NULL}, { (char *)"IndexShards_own_fields_set", _wrap_IndexShards_own_fields_set, METH_VARARGS, NULL}, @@ -51307,6 +52868,9 @@ static void *_p_faiss__LinearTransformTo_p_faiss__VectorTransform(void *x, int * static void *_p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::VectorTransform *) ((faiss::RemapDimensionsTransform *) x)); } +static void *_p_faiss__NormalizationTransformTo_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::VectorTransform *) ((faiss::NormalizationTransform *) x)); +} static void *_p_p_faiss__RandomRotationMatrixTo_p_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::VectorTransform **) (faiss::LinearTransform *) ((faiss::RandomRotationMatrix **) x)); } @@ -51322,6 +52886,9 @@ static void *_p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform(void *x, i static void *_p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::VectorTransform **) ((faiss::RemapDimensionsTransform **) x)); } +static void *_p_p_faiss__NormalizationTransformTo_p_p_faiss__VectorTransform(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::VectorTransform **) ((faiss::NormalizationTransform **) x)); +} static void *_p_faiss__RangeSearchPartialResultTo_p_faiss__BufferList(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::BufferList *) ((faiss::RangeSearchPartialResult *) x)); } @@ -51358,6 +52925,9 @@ static void *_p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index(void *x, int *SWIGU static void *_p_faiss__IndexShardsTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::IndexShards *) x)); } +static void *_p_faiss__IndexIDMap2To_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) (faiss::IndexIDMap *) ((faiss::IndexIDMap2 *) x)); +} static void *_p_faiss__IndexSplitVectorsTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::IndexSplitVectors *) x)); } @@ -51379,21 +52949,24 @@ static void *_p_faiss__IndexIDMapTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM( static void *_p_faiss__IndexIVFPQTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) (faiss::IndexIVF *) ((faiss::IndexIVFPQ *) x)); } -static void *_p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((faiss::Index *) (faiss::IndexIVF *) ((faiss::IndexIVFScalarQuantizer *) x)); +static void *_p_faiss__IndexScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) ((faiss::IndexScalarQuantizer *) x)); } static void *_p_faiss__MultiIndexQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::Index *) ((faiss::MultiIndexQuantizer *) x)); } +static void *_p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::Index *) (faiss::IndexIVF *) ((faiss::IndexIVFScalarQuantizer *) x)); +} +static void *_p_faiss__ClusteringTo_p_faiss__ClusteringParameters(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::ClusteringParameters *) ((faiss::Clustering *) x)); +} static void *_p_faiss__PolysemousTrainingTo_p_faiss__SimulatedAnnealingParameters(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::SimulatedAnnealingParameters *) ((faiss::PolysemousTraining *) x)); } static void *_p_faiss__SimulatedAnnealingOptimizerTo_p_faiss__SimulatedAnnealingParameters(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::SimulatedAnnealingParameters *) ((faiss::SimulatedAnnealingOptimizer *) x)); } -static void *_p_faiss__ClusteringTo_p_faiss__ClusteringParameters(void *x, int *SWIGUNUSEDPARM(newmemory)) { - return (void *)((faiss::ClusteringParameters *) ((faiss::Clustering *) x)); -} static void *_p_faiss__IndexIVFScalarQuantizerTo_p_faiss__IndexIVF(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::IndexIVF *) ((faiss::IndexIVFScalarQuantizer *) x)); } @@ -51418,6 +52991,9 @@ static void *_p_faiss__IDSelectorBatchTo_p_faiss__IDSelector(void *x, int *SWIGU static void *_p_faiss__IDSelectorRangeTo_p_faiss__IDSelector(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((faiss::IDSelector *) ((faiss::IDSelectorRange *) x)); } +static void *_p_faiss__IndexIDMap2To_p_faiss__IndexIDMap(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((faiss::IndexIDMap *) ((faiss::IndexIDMap2 *) x)); +} static swig_type_info _swigt__p_Crev = {"_p_Crev", "Crev *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_T = {"_p_T", "T *", 0, 0, (void*)0, 0}; @@ -51455,6 +53031,7 @@ static swig_type_info _swigt__p_faiss__IndexFlatIP = {"_p_faiss__IndexFlatIP", " static swig_type_info _swigt__p_faiss__IndexFlatL2 = {"_p_faiss__IndexFlatL2", "faiss::IndexFlatL2 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexFlatL2BaseShift = {"_p_faiss__IndexFlatL2BaseShift", "faiss::IndexFlatL2BaseShift *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIDMap = {"_p_faiss__IndexIDMap", "faiss::IndexIDMap *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__IndexIDMap2 = {"_p_faiss__IndexIDMap2", "faiss::IndexIDMap2 *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVF = {"_p_faiss__IndexIVF", "faiss::IndexIVF *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVFFlat = {"_p_faiss__IndexIVFFlat", "faiss::IndexIVFFlat *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexIVFFlatIPBounds = {"_p_faiss__IndexIVFFlatIPBounds", "faiss::IndexIVFFlatIPBounds *", 0, 0, (void*)0, 0}; @@ -51469,11 +53046,13 @@ static swig_type_info _swigt__p_faiss__IndexPQ = {"_p_faiss__IndexPQ", "faiss::I static swig_type_info _swigt__p_faiss__IndexPQStats = {"_p_faiss__IndexPQStats", "faiss::IndexPQStats *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexPreTransform = {"_p_faiss__IndexPreTransform", "faiss::IndexPreTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexRefineFlat = {"_p_faiss__IndexRefineFlat", "faiss::IndexRefineFlat *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__IndexScalarQuantizer = {"_p_faiss__IndexScalarQuantizer", "faiss::IndexScalarQuantizer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexShards = {"_p_faiss__IndexShards", "faiss::IndexShards *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IndexSplitVectors = {"_p_faiss__IndexSplitVectors", "faiss::IndexSplitVectors *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__IntersectionCriterion = {"_p_faiss__IntersectionCriterion", "faiss::IntersectionCriterion *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__LinearTransform = {"_p_faiss__LinearTransform", "faiss::LinearTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__MultiIndexQuantizer = {"_p_faiss__MultiIndexQuantizer", "faiss::MultiIndexQuantizer *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_faiss__NormalizationTransform = {"_p_faiss__NormalizationTransform", "faiss::NormalizationTransform *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OPQMatrix = {"_p_faiss__OPQMatrix", "faiss::OPQMatrix *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OneRecallAtRCriterion = {"_p_faiss__OneRecallAtRCriterion", "faiss::OneRecallAtRCriterion *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_faiss__OperatingPoint = {"_p_faiss__OperatingPoint", "faiss::OperatingPoint *", 0, 0, (void*)0, 0}; @@ -51505,6 +53084,8 @@ static swig_type_info _swigt__p_p_faiss__PCAMatrix = {"_p_p_faiss__PCAMatrix", 0 static swig_type_info _swigt__p_p_faiss__OPQMatrix = {"_p_p_faiss__OPQMatrix", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_faiss__LinearTransform = {"_p_p_faiss__LinearTransform", 0, 0, 0, 0, 0}; static swig_type_info _swigt__p_p_faiss__RemapDimensionsTransform = {"_p_p_faiss__RemapDimensionsTransform", 0, 0, 0, 0, 0}; +static swig_type_info _swigt__p_p_faiss__NormalizationTransform = {"_p_p_faiss__NormalizationTransform", 0, 0, 0, 0, 0}; +static swig_type_info _swigt__p_std__unordered_mapT_long_long_t = {"_p_std__unordered_mapT_long_long_t", "std::unordered_map< long,long > *|std::unordered_map< faiss::Index::idx_t,faiss::Index::idx_t > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_double_t = {"_p_std__vectorT_double_t", "std::vector< double > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_faiss__BufferList__Buffer_t = {"_p_std__vectorT_faiss__BufferList__Buffer_t", "std::vector< faiss::BufferList::Buffer > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_faiss__Index_p_t = {"_p_std__vectorT_faiss__Index_p_t", "std::vector< faiss::Index * > *", 0, 0, (void*)0, 0}; @@ -51565,6 +53146,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_faiss__IndexFlatL2, &_swigt__p_faiss__IndexFlatL2BaseShift, &_swigt__p_faiss__IndexIDMap, + &_swigt__p_faiss__IndexIDMap2, &_swigt__p_faiss__IndexIVF, &_swigt__p_faiss__IndexIVFFlat, &_swigt__p_faiss__IndexIVFFlatIPBounds, @@ -51579,11 +53161,13 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_faiss__IndexPQStats, &_swigt__p_faiss__IndexPreTransform, &_swigt__p_faiss__IndexRefineFlat, + &_swigt__p_faiss__IndexScalarQuantizer, &_swigt__p_faiss__IndexShards, &_swigt__p_faiss__IndexSplitVectors, &_swigt__p_faiss__IntersectionCriterion, &_swigt__p_faiss__LinearTransform, &_swigt__p_faiss__MultiIndexQuantizer, + &_swigt__p_faiss__NormalizationTransform, &_swigt__p_faiss__OPQMatrix, &_swigt__p_faiss__OneRecallAtRCriterion, &_swigt__p_faiss__OperatingPoint, @@ -51610,11 +53194,13 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_int, &_swigt__p_long, &_swigt__p_p_faiss__LinearTransform, + &_swigt__p_p_faiss__NormalizationTransform, &_swigt__p_p_faiss__OPQMatrix, &_swigt__p_p_faiss__PCAMatrix, &_swigt__p_p_faiss__RandomRotationMatrix, &_swigt__p_p_faiss__RemapDimensionsTransform, &_swigt__p_p_faiss__VectorTransform, + &_swigt__p_std__unordered_mapT_long_long_t, &_swigt__p_std__vectorT_double_t, &_swigt__p_std__vectorT_faiss__BufferList__Buffer_t, &_swigt__p_std__vectorT_faiss__Index_p_t, @@ -51668,13 +53254,14 @@ static swig_cast_info _swigc__p_faiss__HeapArrayT_faiss__CMinT_int_long_t_t[] = static swig_cast_info _swigc__p_faiss__IDSelector[] = { {&_swigt__p_faiss__IDSelector, 0, 0, 0}, {&_swigt__p_faiss__IDSelectorBatch, _p_faiss__IDSelectorBatchTo_p_faiss__IDSelector, 0, 0}, {&_swigt__p_faiss__IDSelectorRange, _p_faiss__IDSelectorRangeTo_p_faiss__IDSelector, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IDSelectorBatch[] = { {&_swigt__p_faiss__IDSelectorBatch, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IDSelectorRange[] = { {&_swigt__p_faiss__IDSelectorRange, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__Index[] = { {&_swigt__p_faiss__IndexPreTransform, _p_faiss__IndexPreTransformTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVF, _p_faiss__IndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexLSH, _p_faiss__IndexLSHTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat, _p_faiss__IndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexShards, _p_faiss__IndexShardsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexSplitVectors, _p_faiss__IndexSplitVectorsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__Index, 0, 0, 0}, {&_swigt__p_faiss__IndexRefineFlat, _p_faiss__IndexRefineFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexPQ, _p_faiss__IndexPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap, _p_faiss__IndexIDMapTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__MultiIndexQuantizer, _p_faiss__MultiIndexQuantizerTo_p_faiss__Index, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__Index[] = { {&_swigt__p_faiss__IndexPreTransform, _p_faiss__IndexPreTransformTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVF, _p_faiss__IndexIVFTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexLSH, _p_faiss__IndexLSHTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat, _p_faiss__IndexFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexShards, _p_faiss__IndexShardsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap2, _p_faiss__IndexIDMap2To_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexSplitVectors, _p_faiss__IndexSplitVectorsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__Index, 0, 0, 0}, {&_swigt__p_faiss__IndexRefineFlat, _p_faiss__IndexRefineFlatTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexPQ, _p_faiss__IndexPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIDMap, _p_faiss__IndexIDMapTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__IndexScalarQuantizer, _p_faiss__IndexScalarQuantizerTo_p_faiss__Index, 0, 0}, {&_swigt__p_faiss__MultiIndexQuantizer, _p_faiss__MultiIndexQuantizerTo_p_faiss__Index, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlat[] = { {&_swigt__p_faiss__IndexFlat, 0, 0, 0}, {&_swigt__p_faiss__IndexFlatL2, _p_faiss__IndexFlatL2To_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__IndexFlat, 0, 0}, {&_swigt__p_faiss__IndexFlatIP, _p_faiss__IndexFlatIPTo_p_faiss__IndexFlat, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlat1D[] = { {&_swigt__p_faiss__IndexFlat1D, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatIP[] = { {&_swigt__p_faiss__IndexFlatIP, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatL2[] = { {&_swigt__p_faiss__IndexFlatL2, 0, 0, 0}, {&_swigt__p_faiss__IndexFlat1D, _p_faiss__IndexFlat1DTo_p_faiss__IndexFlatL2, 0, 0}, {&_swigt__p_faiss__IndexFlatL2BaseShift, _p_faiss__IndexFlatL2BaseShiftTo_p_faiss__IndexFlatL2, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexFlatL2BaseShift[] = { {&_swigt__p_faiss__IndexFlatL2BaseShift, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__IndexIDMap[] = { {&_swigt__p_faiss__IndexIDMap, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexIDMap[] = { {&_swigt__p_faiss__IndexIDMap2, _p_faiss__IndexIDMap2To_p_faiss__IndexIDMap, 0, 0}, {&_swigt__p_faiss__IndexIDMap, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexIDMap2[] = { {&_swigt__p_faiss__IndexIDMap2, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVF[] = { {&_swigt__p_faiss__IndexIVF, 0, 0, 0}, {&_swigt__p_faiss__IndexIVFScalarQuantizer, _p_faiss__IndexIVFScalarQuantizerTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQ, _p_faiss__IndexIVFPQTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFFlat, _p_faiss__IndexIVFFlatTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQCompact, _p_faiss__IndexIVFPQCompactTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFPQR, _p_faiss__IndexIVFPQRTo_p_faiss__IndexIVF, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__IndexIVF, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVFFlat[] = { {&_swigt__p_faiss__IndexIVFFlat, 0, 0, 0}, {&_swigt__p_faiss__IndexIVFFlatIPBounds, _p_faiss__IndexIVFFlatIPBoundsTo_p_faiss__IndexIVFFlat, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexIVFFlatIPBounds[] = { {&_swigt__p_faiss__IndexIVFFlatIPBounds, 0, 0, 0},{0, 0, 0, 0}}; @@ -51689,11 +53276,13 @@ static swig_cast_info _swigc__p_faiss__IndexPQ[] = { {&_swigt__p_faiss__IndexPQ static swig_cast_info _swigc__p_faiss__IndexPQStats[] = { {&_swigt__p_faiss__IndexPQStats, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexPreTransform[] = { {&_swigt__p_faiss__IndexPreTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexRefineFlat[] = { {&_swigt__p_faiss__IndexRefineFlat, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__IndexScalarQuantizer[] = { {&_swigt__p_faiss__IndexScalarQuantizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexShards[] = { {&_swigt__p_faiss__IndexShards, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IndexSplitVectors[] = { {&_swigt__p_faiss__IndexSplitVectors, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__IntersectionCriterion[] = { {&_swigt__p_faiss__IntersectionCriterion, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__LinearTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__LinearTransform, 0, 0}, {&_swigt__p_faiss__LinearTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__MultiIndexQuantizer[] = { {&_swigt__p_faiss__MultiIndexQuantizer, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__NormalizationTransform[] = { {&_swigt__p_faiss__NormalizationTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OPQMatrix[] = { {&_swigt__p_faiss__OPQMatrix, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OneRecallAtRCriterion[] = { {&_swigt__p_faiss__OneRecallAtRCriterion, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__OperatingPoint[] = { {&_swigt__p_faiss__OperatingPoint, 0, 0, 0},{0, 0, 0, 0}}; @@ -51714,7 +53303,7 @@ static swig_cast_info _swigc__p_faiss__ReproduceDistancesObjective[] = { {&_swi static swig_cast_info _swigc__p_faiss__ScalarQuantizer[] = { {&_swigt__p_faiss__ScalarQuantizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__SimulatedAnnealingOptimizer[] = { {&_swigt__p_faiss__SimulatedAnnealingOptimizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_faiss__SimulatedAnnealingParameters[] = { {&_swigt__p_faiss__SimulatedAnnealingParameters, 0, 0, 0}, {&_swigt__p_faiss__PolysemousTraining, _p_faiss__PolysemousTrainingTo_p_faiss__SimulatedAnnealingParameters, 0, 0}, {&_swigt__p_faiss__SimulatedAnnealingOptimizer, _p_faiss__SimulatedAnnealingOptimizerTo_p_faiss__SimulatedAnnealingParameters, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_faiss__VectorTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_faiss__LinearTransform, _p_faiss__LinearTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__RemapDimensionsTransform, _p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_faiss__VectorTransform[] = { {&_swigt__p_faiss__RandomRotationMatrix, _p_faiss__RandomRotationMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__PCAMatrix, _p_faiss__PCAMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__OPQMatrix, _p_faiss__OPQMatrixTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_faiss__LinearTransform, _p_faiss__LinearTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__RemapDimensionsTransform, _p_faiss__RemapDimensionsTransformTo_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_faiss__NormalizationTransform, _p_faiss__NormalizationTransformTo_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_idx_t[] = { {&_swigt__p_idx_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; @@ -51724,7 +53313,9 @@ static swig_cast_info _swigc__p_p_faiss__PCAMatrix[] = {{&_swigt__p_p_faiss__PCA static swig_cast_info _swigc__p_p_faiss__OPQMatrix[] = {{&_swigt__p_p_faiss__OPQMatrix, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__LinearTransform[] = {{&_swigt__p_p_faiss__LinearTransform, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_faiss__RemapDimensionsTransform[] = {{&_swigt__p_p_faiss__RemapDimensionsTransform, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_faiss__VectorTransform[] = { {&_swigt__p_p_faiss__RandomRotationMatrix, _p_p_faiss__RandomRotationMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__PCAMatrix, _p_p_faiss__PCAMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__OPQMatrix, _p_p_faiss__OPQMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_p_faiss__LinearTransform, _p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__RemapDimensionsTransform, _p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_faiss__NormalizationTransform[] = {{&_swigt__p_p_faiss__NormalizationTransform, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_faiss__VectorTransform[] = { {&_swigt__p_p_faiss__RandomRotationMatrix, _p_p_faiss__RandomRotationMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__PCAMatrix, _p_p_faiss__PCAMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__OPQMatrix, _p_p_faiss__OPQMatrixTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__VectorTransform, 0, 0, 0}, {&_swigt__p_p_faiss__LinearTransform, _p_p_faiss__LinearTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__RemapDimensionsTransform, _p_p_faiss__RemapDimensionsTransformTo_p_p_faiss__VectorTransform, 0, 0}, {&_swigt__p_p_faiss__NormalizationTransform, _p_p_faiss__NormalizationTransformTo_p_p_faiss__VectorTransform, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__unordered_mapT_long_long_t[] = { {&_swigt__p_std__unordered_mapT_long_long_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_double_t[] = { {&_swigt__p_std__vectorT_double_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_faiss__BufferList__Buffer_t[] = { {&_swigt__p_std__vectorT_faiss__BufferList__Buffer_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_faiss__Index_p_t[] = { {&_swigt__p_std__vectorT_faiss__Index_p_t, 0, 0, 0},{0, 0, 0, 0}}; @@ -51785,6 +53376,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_faiss__IndexFlatL2, _swigc__p_faiss__IndexFlatL2BaseShift, _swigc__p_faiss__IndexIDMap, + _swigc__p_faiss__IndexIDMap2, _swigc__p_faiss__IndexIVF, _swigc__p_faiss__IndexIVFFlat, _swigc__p_faiss__IndexIVFFlatIPBounds, @@ -51799,11 +53391,13 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_faiss__IndexPQStats, _swigc__p_faiss__IndexPreTransform, _swigc__p_faiss__IndexRefineFlat, + _swigc__p_faiss__IndexScalarQuantizer, _swigc__p_faiss__IndexShards, _swigc__p_faiss__IndexSplitVectors, _swigc__p_faiss__IntersectionCriterion, _swigc__p_faiss__LinearTransform, _swigc__p_faiss__MultiIndexQuantizer, + _swigc__p_faiss__NormalizationTransform, _swigc__p_faiss__OPQMatrix, _swigc__p_faiss__OneRecallAtRCriterion, _swigc__p_faiss__OperatingPoint, @@ -51830,11 +53424,13 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_int, _swigc__p_long, _swigc__p_p_faiss__LinearTransform, + _swigc__p_p_faiss__NormalizationTransform, _swigc__p_p_faiss__OPQMatrix, _swigc__p_p_faiss__PCAMatrix, _swigc__p_p_faiss__RandomRotationMatrix, _swigc__p_p_faiss__RemapDimensionsTransform, _swigc__p_p_faiss__VectorTransform, + _swigc__p_std__unordered_mapT_long_long_t, _swigc__p_std__vectorT_double_t, _swigc__p_std__vectorT_faiss__BufferList__Buffer_t, _swigc__p_std__vectorT_faiss__Index_p_t, diff --git a/swigfaiss.swig b/swigfaiss.swig index c40db30ee..41809e267 100644 --- a/swigfaiss.swig +++ b/swigfaiss.swig @@ -74,7 +74,7 @@ extern "C" { #include "IndexPQ.h" #include "IndexIVF.h" #include "IndexIVFPQ.h" -#include "IndexIVFScalarQuantizer.h" +#include "IndexScalarQuantizer.h" #include "MetaIndexes.h" #include "FaissAssert.h" @@ -240,7 +240,7 @@ int get_num_gpus() %include "PolysemousTraining.h" %include "IndexPQ.h" %include "IndexIVF.h" -%include "IndexIVFScalarQuantizer.h" +%include "IndexScalarQuantizer.h" %ignore faiss::IndexIVFPQ::alloc_type; %include "IndexIVFPQ.h" @@ -426,6 +426,7 @@ struct AsyncIndexSearchC { DOWNCAST ( IndexIVF ) DOWNCAST ( IndexFlat ) DOWNCAST ( IndexPQ ) + DOWNCAST ( IndexScalarQuantizer ) DOWNCAST ( IndexLSH ) DOWNCAST ( IndexPreTransform ) DOWNCAST ( MultiIndexQuantizer ) @@ -457,6 +458,7 @@ struct AsyncIndexSearchC { DOWNCAST (PCAMatrix) DOWNCAST (RandomRotationMatrix) DOWNCAST (LinearTransform) + DOWNCAST (NormalizationTransform) DOWNCAST (VectorTransform) { assert(false); diff --git a/tests/test_build_blocks.py b/tests/test_build_blocks.py index ebd45102d..e8589b650 100644 --- a/tests/test_build_blocks.py +++ b/tests/test_build_blocks.py @@ -11,6 +11,7 @@ import numpy as np import faiss import unittest + class TestClustering(unittest.TestCase): def test_clustering(self): @@ -34,6 +35,17 @@ class TestClustering(unittest.TestCase): # check that 64 centroids give a lower quantization error than 32 self.assertGreater(err32, err64) + def test_nasty_clustering(self): + d = 2 + np.random.seed(123) + x = np.zeros((100, d), dtype='float32') + for i in range(5): + x[i * 20:i * 20 + 20] = np.random.random(size=d) + + # we have 5 distinct points but ask for 10 centroids... + km = faiss.Kmeans(d, 10, niter=10, verbose=True) + km.train(x) + class TestPCA(unittest.TestCase): diff --git a/tests/test_index.py b/tests/test_index.py index 2eba9451c..cb14b32fa 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -6,10 +6,8 @@ #! /usr/bin/env python2 -"""this is a basic test script that works with fbmake to check if -some simple indices work""" +"""this is a basic test script for simple indices work""" -import sys import numpy as np import unittest import faiss @@ -75,9 +73,9 @@ class TestMultiIndexQuantizer(unittest.TestCase): self.assertEqual(np.abs(D1[:, :1] - D5[:, :1]).max(), 0) -class TestIVFScalarQuantizer(unittest.TestCase): +class TestScalarQuantizer(unittest.TestCase): - def test_4variants(self): + def test_4variants_ivf(self): d = 32 nt = 1500 nq = 200 @@ -127,19 +125,39 @@ class TestIVFScalarQuantizer(unittest.TestCase): self.assertGreaterEqual(nok['QT_8bit'], nok['QT_8bit_uniform']) self.assertGreaterEqual(nok['QT_4bit'], nok['QT_4bit_uniform']) + def test_4variants(self): + d = 32 + nt = 1500 + nq = 200 + nb = 10000 -class TestRemove(unittest.TestCase): + np.random.seed(123) - def test_remove(self): - # only tests the python interface + xt = np.random.random(size=(nt, d)).astype('float32') + xq = np.random.random(size=(nq, d)).astype('float32') + xb = np.random.random(size=(nb, d)).astype('float32') + + index_gt = faiss.IndexFlatL2(d) + index_gt.add(xb) + D, I_ref = index_gt.search(xq, 10) + + nok = {} + + for qname in "QT_4bit QT_4bit_uniform QT_8bit QT_8bit_uniform".split(): + qtype = getattr(faiss.ScalarQuantizer, qname) + index = faiss.IndexScalarQuantizer(d, qtype, faiss.METRIC_L2) + index.train(xt) + index.add(xb) + D, I = index.search(xq, 10) + + nok[qname] = (I[:, 0] == I_ref[:, 0]).sum() + + print(nok) + + self.assertGreaterEqual(nok['QT_8bit'], nok['QT_4bit']) + self.assertGreaterEqual(nok['QT_8bit'], nok['QT_8bit_uniform']) + self.assertGreaterEqual(nok['QT_4bit'], nok['QT_4bit_uniform']) - index = faiss.IndexFlat(5) - xb = np.zeros((10, 5), dtype='float32') - xb[:, 0] = np.arange(10) + 1000 - index.add(xb) - index.remove_ids(np.arange(5) * 2) - xb2 = faiss.vector_float_to_array(index.xb).reshape(5, 5) - assert np.all(xb2[:, 0] == xb[np.arange(5) * 2 + 1, 0]) if __name__ == '__main__': diff --git a/utils.cpp b/utils.cpp index 512f861dc..fd925ddbe 100644 --- a/utils.cpp +++ b/utils.cpp @@ -1418,7 +1418,7 @@ int km_update_centroids (const float * x, for (size_t ci = 0; ci < k; ci++) { if (hassign[ci] == 0) { /* need to redefine a centroid */ size_t cj; - for (cj = 0; 1; cj = (cj+1) % k) { + for (cj = 0; 1; cj = (cj + 1) % k) { /* probability to pick this cluster for split */ float p = (hassign[cj] - 1.0) / (float) (n - k); float r = rng.rand_float (); @@ -1429,15 +1429,15 @@ int km_update_centroids (const float * x, memcpy (centroids+ci*d, centroids+cj*d, sizeof(*centroids) * d); /* small symmetric pertubation. Much better than */ - for (size_t j = 0; j < d; j++) + for (size_t j = 0; j < d; j++) { if (j % 2 == 0) { centroids[ci * d + j] *= 1 + EPS; centroids[cj * d + j] *= 1 - EPS; + } else { + centroids[ci * d + j] *= 1 - EPS; + centroids[cj * d + j] *= 1 + EPS; } - else { - centroids[ci * d + j] *= 1 + EPS; - centroids[cj * d + j] *= 1 - EPS; - } + } /* assume even split of the cluster */ hassign[ci] = hassign[cj] / 2;