1065 Commits

Author SHA1 Message Date
Richard Barnes
6d00c416f4 Remove unused variables in faiss/utils/hamming_distance/neon-inl.h
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779537

fbshipit-source-id: 698cdc6720c10d219e56ecd2aad8f4cbe636c639
2024-02-15 00:14:53 -08:00
Richard Barnes
c0624d2346 Remove unused variables in faiss/invlists/OnDiskInvertedLists.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779541

fbshipit-source-id: 7184c46a38d126debaebbda40aedcb4e9a048040
2024-02-15 00:02:37 -08:00
Richard Barnes
a87b4320eb Remove unused variables in faiss/IndexIVFPQ.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779571

fbshipit-source-id: 008ce210aee7eb8668587cb40154563ada0172db
2024-02-14 23:58:45 -08:00
Richard Barnes
1338e0de58 Remove unused variables in faiss/IndexBinaryIVF.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779472

fbshipit-source-id: 0efad740e4741950ee023ac77c4ca8c2f0d03c61
2024-02-14 23:21:12 -08:00
Richard Barnes
1b0d274f4e Remove unused variables in faiss/IndexIVF.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779599

fbshipit-source-id: 7f872cecdff078681748d18dfdea78e361a9a72f
2024-02-14 23:14:00 -08:00
Richard Barnes
53fc6171a6 Remove unused variables in faiss/tests/test_threaded_index.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: palmje

Differential Revision: D53779512

fbshipit-source-id: 038967a05306d921cc09f48ae71b4e6d4eda6664
2024-02-14 15:59:23 -08:00
Richard Barnes
aaca1c2471 Remove semicolon(s) from 3 files inc facer/engine/utils/UDPServer.h
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt` found an extra semi

If the code compiles, this is safe to land.

Reviewed By: palmje, dmm-fb

Differential Revision: D53776211

fbshipit-source-id: c256f5197537251bbe0f583869089b3035a8ee77
2024-02-14 14:37:40 -08:00
Gergely Szilvasy
a187394a8a libraft 24.02 is released, switching channel
Summary:
libraft 24.02 is now in the main channel of rapidsai (and no longer in the nightly), switching channel we build against to prepare for the release of faiss-gpu-raft

cmake build will continue to use the nightly, but the conda packages will be built against the release

Reviewed By: mlomeli1

Differential Revision: D53712646

fbshipit-source-id: de60c3336e6a199b496fc3829d71a778e5ea8cbd
2024-02-14 04:38:45 -08:00
Gergely Szilvasy
f2620119f0 fix omp parallelism in fast scan range search
Summary: Fix omp n^2 parallelism

Reviewed By: mdouze

Differential Revision: D53705601

fbshipit-source-id: 3fcc2368c436185119f6e988ee2867dfd7d8eb07
2024-02-13 12:21:00 -08:00
yuhaijun999
8898eabe9f Add feature in IndexIDMap.cpp range_search with Parameters. (#3213)
Summary:
for example:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <random>

#include <faiss/IndexFlat.h>
#include <faiss/IndexIDMap.h>
#include <faiss/impl/AuxIndexStructures.h>
#include <faiss/impl/IDSelector.h>

// 64-bit int
using idx_t = faiss::idx_t;

int main() {
    int d = 64;     // dimension
    int nb = 10000; // database size
    int nq = 5;     // nb of queries

    std::mt19937 rng;
    std::uniform_real_distribution<> distrib;

    float* xb = new float[d * nb];
    float* xq = new float[d * nq];

    for (int i = 0; i < nb; i++) {
        for (int j = 0; j < d; j++)
            xb[d * i + j] = distrib(rng);
        xb[d * i] += i / 1000.;
    }

    for (int i = 0; i < nq; i++) {
        for (int j = 0; j < d; j++)
            xq[d * i + j] = distrib(rng);
        xq[d * i] += i / 1000.;
    }

    faiss::IndexFlatL2 index(d);
    faiss::IndexIDMap2 index_id_map2(&index);

    idx_t* xids = new idx_t[nb]();
    for (int i = 0; i < nb; i++) {
        xids[i] = i + nb;           // add ids
    }

    index_id_map2.add_with_ids(nb, xb, xids);

    faiss::SearchParameters params;

    std::vector<faiss::idx_t> ids;
    ids.reserve(nb / 2);
    for (faiss::idx_t i = 0; i < nb / 2; i++) {
        ids.push_back(i + nb);   // search ids
    }

    faiss::IDSelectorArray id_selector_array(ids.size(), ids.data());

    params.sel = &id_selector_array;

    // range search with param
    {
        float radius = 7.0f;
        faiss::RangeSearchResult* result = new faiss::RangeSearchResult(nq);

        index_id_map2.range_search(nq, xb, radius, result, &params);

        size_t off = 0;
        for (size_t i = 0; i < result->nq; i++) {
            size_t n = (result->lims[i + 1] - result->lims[i]);
            std::cout << "i : " << i << std::endl;
            for (size_t j = 0; j < n; j++) {
                std::cout << "\t label : " << result->labels[off + j]
                          << " distance : " << result->distances[off + j]
                          << std::endl;
            }
            off += n;
        }

        delete result;
    }

    delete[] xb;
    delete[] xq;
    delete[] xids;

    return 0;
}

outputs:
server@dingo11 cpp [main] $ ./6-Range-Search
i : 0
         label : 10000 distance : 0
i : 1
         label : 10001 distance : 0
         label : 10136 distance : 6.72638
         label : 10183 distance : 6.73293
         label : 10223 distance : 6.76569
         label : 10555 distance : 6.93339
         label : 10995 distance : 5.78548
i : 2
         label : 10002 distance : 0
         label : 10253 distance : 6.84876
         label : 10312 distance : 5.07469
i : 3
         label : 10003 distance : 0
         label : 10983 distance : 6.77275
i : 4
         label : 10004 distance : 0
         label : 10112 distance : 6.89793
         label : 10403 distance : 6.84196

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3213

Reviewed By: mdouze

Differential Revision: D53704072

Pulled By: algoriddle

fbshipit-source-id: ca7f03f5a474a59089ebdf9685fb83e54ae198b0
2024-02-13 11:36:36 -08:00
Xiaozhong Pan
ebb5f8401b add a context parameter to InvertedLists and InvertedListsIterator (#3247)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3247

add a context parameter to be passed to InvertedLists and InvertedListsIterator.
- add a context field in `SearchParametersIVF`, the context will be passed to `InvertedLists::get_iterator`. The user can create `InvertedListsIterator` with the context object
- add a context parameter in `IndexIVF::add_core` method. the context will be passed to `InvertedLists::add_entry`.

The user can use the context object to pass storage handlers, store error codes from storage layer, logging information, etc.

Reviewed By: mdouze

Differential Revision: D53113911

fbshipit-source-id: ff31d247d3dc949d0bb50bcaffc3142efd027089
2024-02-09 09:14:38 -08:00
Gergely Szilvasy
bfa46a3a59 pin circleci windows image (#3248)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3248

Build scripts can't find conda in the 'stable' image, trying to pin to a specific version.

Reviewed By: mlomeli1

Differential Revision: D53608347

fbshipit-source-id: 3f7c350608afc9c253cf0153e37ceeb4fceca92c
2024-02-09 03:26:44 -08:00
Gergely Szilvasy
ed3f6e5fdf faiss-gpu to use 11.4.4 and be the only one supporting P100 (#3237)
Summary:
Considering that only GPU classic works on Pascal and only if compiled with cuda 11.4, this sets up the conda builds as follows.

tl;dr: Pascal will only be supported by faiss-gpu on cuda 11.

## faiss-gpu
1. build on cuda 11.4.4, supports Pascal, works with pytorch-cuda=11 (including hosts with cuda 12 drivers)
2. build on cuda 12.1.1, does NOT support Pascal, works with pytorch-cuda=12

## faiss-gpu-raft
1. build on cuda 11.8.0, does NOT support Pascal, works with pytorch-cuda=11.8
2. build on cuda 12.1.1, does NOT support Pascal, works with pytorch-cuda=12

The reason faiss-gpu-raft is built with and supports only 11.8 is due to the risk of clobbering otherwise between libraft and pytorch-cuda dependencies.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3237

Reviewed By: mdouze

Differential Revision: D53354121

Pulled By: algoriddle

fbshipit-source-id: 86108e975168759572f84922bf0ccef55ae75ef8
2024-02-02 09:01:10 -08:00
xinhuitian
31a29d0378 HNSW search use efSearch from params if provided (#3233)
Summary:
I found that HNSW search method uses its own efSearch to create candidates, which should be got from params if provided I think?

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3233

Reviewed By: algoriddle

Differential Revision: D53342879

Pulled By: mdouze

fbshipit-source-id: 4f47f19d3673d1bb8d7e8e82745f9e5c1b9afb42
2024-02-02 02:31:57 -08:00
Gergely Szilvasy
c1822a81b2 cuda dependencies (#3230)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3230

Reviewed By: mlomeli1

Differential Revision: D53271742

Pulled By: algoriddle

fbshipit-source-id: b0f09e26ab0b4cfcbdb10528b2f57e15c10f4265
2024-01-31 14:25:13 -08:00
Gergely Szilvasy
1d0e8d489f index optimizer (#3154)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3154

Using the benchmark to find Pareto optimal indices, in this case on BigANN as an example.

Separately optimize the coarse quantizer and the vector codec and use Pareto optimal configurations to construct IVF indices, which are then retested at various scales. See `optimize()` in `optimize.py` as the main function driving the process.

The results can be interpreted with `bench_fw_notebook.ipynb`, which allows:
* filtering by maximum code size
* maximum time
* minimum accuracy
* space or time Pareto optimal options
* and visualize the results and output them as a table.

This version is intentionally limited to IVF(Flat|HNSW),PQ|SQ indices...

Reviewed By: mdouze

Differential Revision: D51781670

fbshipit-source-id: 2c0f800d374ea845255934f519cc28095c00a51f
2024-01-30 10:58:13 -08:00
Richard Barnes
75ae0bfb7f Remove unused variables in faiss/IndexScalarQuantizer.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52981077

fbshipit-source-id: ad164f9fbe267c6f594f9298132578f0a3805a2c
2024-01-30 09:48:48 -08:00
Maria Lomeli
420d25f51c Index pretransform support in search_preassigned (#3225)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3225

This diff fixes issue [#3113](https://github.com/facebookresearch/faiss/issues/3113), e.g. introduces support for index pretransform in `search_preassigned`.

Reviewed By: mdouze

Differential Revision: D53188584

fbshipit-source-id: 8189c0a59f957a2606391f22cf3fdc8874110a6e
2024-01-30 09:20:07 -08:00
Gergely Szilvasy
31bddeb0cf add faiss_gpu lib (#3222)
Summary:
1. Split the GPU code into a separate static library to reduce build times.
2. faiss-gpu now depends on pytorch-cuda to stop clobbering of CUDA libraries when Faiss and Pytorch installed in the same environment
3. Add CUDA 12 (we support both 11.8 and 12.1)
4. Add Python 3.12

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3222

Reviewed By: mlomeli1

Differential Revision: D53215033

Pulled By: algoriddle

fbshipit-source-id: d48c5707af20b7e5ff72c3aa27b0e677259f22f8
2024-01-30 01:44:50 -08:00
Gergely Szilvasy
2817344f6f fix ACCESS VIOLATION error when searching using IDSelectorArray
Summary:
Fixes #3156

Metamate says: "This diff fixes an ACCESS VIOLATION error that occurs when searching using IDSelectorArray. The code changes include adding a new parameter to the knn_inner_products_by_idx and knn_L2sqr_by_idx functions in the distances.cpp file, as well as modifying the test_search_params.py file to test the bounds of the IDSelectorArray."

Reviewed By: mdouze

Differential Revision: D53185461

fbshipit-source-id: c7ec4783f77455684c078bba3aace160078f6c27
2024-01-29 23:08:45 -08:00
Richard Barnes
67c6a191b7 Remove extra semi colon from faiss/impl/ProductAdditiveQuantizer.h
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969139

fbshipit-source-id: 563843d43c64fb988ff0d08ccdb0408cd0eba454
2024-01-27 10:28:14 -08:00
Richard Barnes
898ce35a8a Remove unused function from faiss/utils/distances_simd.cpp
Summary: `-Wunused-function` has identified an unused function. This diff removes it. In many cases these functions have existed for years in an unused state.

Reviewed By: algoriddle

Differential Revision: D53049745

fbshipit-source-id: aa6d9fa5b3ac93c777dd9a5ca239312d1a188a1c
2024-01-25 08:03:31 -08:00
Kota Yamaguchi
1dcb5d314d Add missing header files (#3218)
Summary:
The current CMakeList.txt misses a few header files. This PR adds these missing files.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3218

Reviewed By: mlomeli1

Differential Revision: D53081725

Pulled By: algoriddle

fbshipit-source-id: 94531b39350f6d5b9f8c1bedbb1286f265e99a09
2024-01-25 07:39:57 -08:00
Gergely Szilvasy
51b6083187 faiss on rocksdb demo (#3216)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3216

Reviewed By: mdouze

Differential Revision: D53051090

Pulled By: algoriddle

fbshipit-source-id: 13a027db36207af9be11a2f181116994b2aff2cb
2024-01-25 07:39:53 -08:00
Gergely Szilvasy
c4b91a54d1 Replace pickle serialization to address security vulnerability
Summary: This diff replaces the use of pickle serialization with json to address a security vulnerability. Adding a warning message that this code is for demonstration purposes only.

Reviewed By: mdouze

Differential Revision: D52777650

fbshipit-source-id: d9d6a00fd341b29ac854adcbf675d2cd303d2f29
2024-01-25 07:24:04 -08:00
Richard Barnes
a30fd74333 Remove unused function from faiss/clone_index.cpp
Summary: `-Wunused-function` has identified an unused function. This diff removes it. In many cases these functions have existed for years in an unused state.

Reviewed By: palmje

Differential Revision: D53049728

fbshipit-source-id: b3d6b98e4ef035f257e9120369b0e70b3200bec0
2024-01-24 13:19:29 -08:00
Richard Barnes
fc4dbd513c Remove extra semi colon from faiss/IndexIVFSpectralHash.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52968923

fbshipit-source-id: 5754c0b17b46bc90d0f05d66bbfacb24fee5caae
2024-01-24 12:40:15 -08:00
Richard Barnes
6b2c79c0e3 Remove extra semi colon from faiss/index_factory.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969102

fbshipit-source-id: f6e4992783a2a1ab0598bf96c664da950e5bba5d
2024-01-24 12:39:15 -08:00
Richard Barnes
a7b76a7d52 Fix shadowed variable in faiss/IndexAdditiveQuantizerFastScan.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52959038

fbshipit-source-id: 2b688a08710ff60aea0fea9d8be34f3c1f524f85
2024-01-24 12:28:21 -08:00
Richard Barnes
ae25b1bef1 Fix shadowed variable in faiss/impl/residual_quantizer_encode_steps.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52959180

fbshipit-source-id: 90f735f65f1306c817d80c99c8a2108aee7c599a
2024-01-24 11:28:16 -08:00
Richard Barnes
7c4fb6dfe7 Fix shadowed variable in faiss/impl/ResultHandler.h
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52958916

fbshipit-source-id: 408f0cc2c4687ef812b62631d708f2633754df69
2024-01-24 11:27:22 -08:00
Richard Barnes
12637a2b12 Fix shadowed variable in faiss/utils/utils.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52959071

fbshipit-source-id: c71b331f9a1ee214cfef8143fdd41c336284d8a2
2024-01-24 11:26:51 -08:00
Kota Yamaguchi
63edc32435 Fix AVX512 build targets in CMakeLists.txt (#3214)
Summary:
When `FAISS_OPT_LEVEL=avx512`, the current default target omits the `avx2` build, which conflicts with the install targets that specify both `avx2` and `avx512` builds. This PR fixes the default build targets for AVX512.

Install targets:

e19de27d72/faiss/CMakeLists.txt (L332)

With this PR, cmake can build and install without any error.

```bash
cmake -B build -DFAISS_OPT_LEVEL=avx512 .
cmake --build build --config Release -j
cmake --install build
```

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3214

Reviewed By: mlomeli1

Differential Revision: D52996716

Pulled By: algoriddle

fbshipit-source-id: b8a46eee6cc15c2043a1a74c5e15d7a606e94acc
2024-01-24 09:36:53 -08:00
Richard Barnes
99c0e2bd59 Remove unused variables in faiss/utils/sorting.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: bunnypak, dmm-fb

Differential Revision: D53011673

fbshipit-source-id: 011204944fdc48627a34e1358833fc525dcc2c28
2024-01-24 09:00:55 -08:00
Richard Barnes
e8494f62d9 Remove unused variables in faiss/IndexBinaryHash.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: bunnypak, dmm-fb

Differential Revision: D53011679

fbshipit-source-id: 90cdfb645d66e155b3de853dfab7586a8c720465
2024-01-24 08:50:57 -08:00
Richard Barnes
bbb6ec7e1d Remove unused variables in faiss/IndexShardsIVF.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: bunnypak, dmm-fb

Differential Revision: D53011658

fbshipit-source-id: a8ba9102751def7a584167c3f50e4d02e9e6442c
2024-01-23 13:06:41 -08:00
Richard Barnes
0716bde250 Fix shadowed variable in faiss/IndexNSG.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: dmm-fb

Differential Revision: D52959118

fbshipit-source-id: f3b44eb294ae534ebebfcb7d2da4cd70e259eaa3
2024-01-23 08:40:54 -08:00
Richard Barnes
bffedda903 Fix shadowed variable in faiss/IndexIDMap.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: dmm-fb

Differential Revision: D52959009

fbshipit-source-id: 4842fdae7c20105746660304b3c04d20066c70ae
2024-01-23 08:38:30 -08:00
Richard Barnes
a70a8a5e1d Remove unused variables in faiss/impl/HNSW.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52981042

fbshipit-source-id: 6748dc957a26a6b5dec3922505c18a1996e3a002
2024-01-23 06:26:35 -08:00
Richard Barnes
b274cb4f4f Remove unused variables in faiss/IndexIVFFastScan.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52981034

fbshipit-source-id: 0315bb594a2dfaa059132b5f4e41855a4e15034b
2024-01-23 06:15:33 -08:00
Richard Barnes
e55a0ac5b5 Remove unused variables in faiss/impl/index_write.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52981052

fbshipit-source-id: 203e7ead56c69ffd77ee4a61eed1d0a502a14866
2024-01-23 04:40:52 -08:00
Richard Barnes
a651069a37 Remove unused variables in faiss/impl/index_read.cpp
Summary:
LLVM-15 has a warning `-Wunused-but-set-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code, or (b) qualifies the variable with `[[maybe_unused]]`, mostly in cases where the variable _is_ used, but, eg, in an `assert` statement that isn't present in production code.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: algoriddle

Differential Revision: D52981028

fbshipit-source-id: dbdf5c56e1d594e534183483c236ed2f08f98857
2024-01-23 04:40:47 -08:00
Richard Barnes
e19de27d72 Remove extra semi colon from faiss/IndexIVFFastScan.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969081

fbshipit-source-id: d728a4887ac1415ae88dae643055380a183c6990
2024-01-22 20:32:04 -08:00
Richard Barnes
b10eb35569 Remove extra semi colon from faiss/Clustering.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969138

fbshipit-source-id: bdde568b9bc6f4cc650e131a471a41f6bc2f3f95
2024-01-22 20:15:40 -08:00
Richard Barnes
683eadf1a0 Remove extra semi colon from faiss/utils/distances_simd.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52965948

fbshipit-source-id: e24e38ecbb7e0c957b024a1ae7b2ec94d2fa0adf
2024-01-22 19:43:11 -08:00
Richard Barnes
522452f7d3 Remove extra semi colon from faiss/python/python_callbacks.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969076

fbshipit-source-id: 97692db6dd7a2d6ffef12ebcdaadd99abf089ca1
2024-01-22 19:06:17 -08:00
Richard Barnes
3e666aea8b Remove extra semi colon from faiss/invlists/InvertedLists.cpp
Summary:
`-Wextra-semi` or `-Wextra-semi-stmt`

If the code compiles, this is safe to land.

Reviewed By: algoriddle

Differential Revision: D52969085

fbshipit-source-id: f532f9000abd580e53159f660f6703dacb02796f
2024-01-22 19:01:12 -08:00
Gergely Szilvasy
7e01b47a1c fix raft build
Summary:
Raft conda packages are built with conda-forge, which ships a newer version of swig, which broke the build. I'm pinning the version as a zero-effort attempt to fix this.

```
[ 80%] Building CXX object CMakeFiles/swigfaiss.dir/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx.o
/home/circleci/miniconda/conda-bld/faiss-pkg_1705881814815/work/_build_python_3.9/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx: In function 'PyObject* swig_ptr(PyObject*)':
/home/circleci/miniconda/conda-bld/faiss-pkg_1705881814815/work/_build_python_3.9/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx:6573:41: error: 'SWIGTYPE_p_unsigned_long_long' was not declared in this scope; did you mean 'SWIGTYPE_p_unsigned_long'?
 6573 |         return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/circleci/miniconda/conda-bld/faiss-pkg_1705881814815/work/_build_python_3.9/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx:1136:94: note: in definition of macro 'SWIG_NewPointerObj'
 1136 | #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
      |                                                                                              ^~~~
/home/circleci/miniconda/conda-bld/faiss-pkg_1705881814815/work/_build_python_3.9/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx:6580:41: error: 'SWIGTYPE_p_long_long' was not declared in this scope; did you mean 'SWIGTYPE_p_MapLong2Long'?
 6580 |         return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0);
      |                                         ^~~~~~~~~~~~~~~~~~~~
/home/circleci/miniconda/conda-bld/faiss-pkg_1705881814815/work/_build_python_3.9/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx:1136:94: note: in definition of macro 'SWIG_NewPointerObj'
 1136 | #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
      |                                                                                              ^~~~
make[3]: *** [CMakeFiles/swigfaiss.dir/build.make:76: CMakeFiles/swigfaiss.dir/CMakeFiles/swigfaiss.dir/swigfaissPYTHON_wrap.cxx.o] Error 1
```

Reviewed By: mlomeli1

Differential Revision: D52962236

fbshipit-source-id: e1a6b4c6ba03c9a0a320b5dbb54a8d618b8f8e74
2024-01-22 09:51:35 -08:00
Richard Barnes
7f3e0a349f Mismatch tags take 2 (#3211)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3211

X-link: https://github.com/facebookincubator/velox/pull/8461

Reviewed By: luciang

Differential Revision: D52931746

fbshipit-source-id: 0aa40ff310ec48ace13927faaa47e0ebfa8b921e
2024-01-21 12:14:46 -08:00
Richard Barnes
aff812ed4c Fix shadowed variable in faiss/clone_index.cpp
Summary:
Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: dmm-fb

Differential Revision: D52582793

fbshipit-source-id: 2941630671d99de39c19cfc5d24b2e27e495c171
2024-01-19 03:54:36 -08:00