Commit Graph

32 Commits (cff072b78ef019998990c6ba02df83dd7d3c8d38)

Author SHA1 Message Date
Alexander Andreev a87930111e Classes inherited from VectorTransform for c_api (#1869)
Summary:
inherite from  LinearTransform doesn't work here.

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

Reviewed By: beauby

Differential Revision: D28345866

Pulled By: mdouze

fbshipit-source-id: 277dd421213a91c07ed41d7b23002840cc5cfa1f
2021-05-12 07:34:39 -07:00
Patrick Weizhi Xu 1ea134eb83 Remove redundant c_api headers while installing (#1841)
Summary:
This diff is related to
https://github.com/facebookresearch/faiss/issues/1722

File structure with `-DFAISS_ENABLE_GPU=OFF`
```
/usr/local/include/faiss/c_api
├── AutoTune_c.h
├── clone_index_c.h
├── Clustering_c.h
├── error_c.h
├── error_impl.h
├── faiss_c.h
├── impl
│   └── AuxIndexStructures_c.h
├── Index_c.h
├── index_factory_c.h
├── IndexFlat_c.h
├── index_io_c.h
├── IndexIVF_c.h
├── IndexIVFFlat_c.h
├── IndexLSH_c.h
├── IndexPreTransform_c.h
├── IndexScalarQuantizer_c.h
├── IndexShards_c.h
├── macros_impl.h
├── MetaIndexes_c.h
└── VectorTransform_c.h
```

File structure with `-DFAISS_ENABLE_GPU=ON`
```
/usr/local/include/faiss/c_api
├── AutoTune_c.h
├── clone_index_c.h
├── Clustering_c.h
├── error_c.h
├── error_impl.h
├── faiss_c.h
├── gpu
│   ├── DeviceUtils_c.h
│   ├── GpuAutoTune_c.h
│   ├── GpuClonerOptions_c.h
│   ├── GpuIndex_c.h
│   ├── GpuIndicesOptions_c.h
│   ├── GpuResources_c.h
│   ├── macros_impl.h
│   └── StandardGpuResources_c.h
├── impl
│   └── AuxIndexStructures_c.h
├── Index_c.h
├── index_factory_c.h
├── IndexFlat_c.h
├── index_io_c.h
├── IndexIVF_c.h
├── IndexIVFFlat_c.h
├── IndexLSH_c.h
├── IndexPreTransform_c.h
├── IndexScalarQuantizer_c.h
├── IndexShards_c.h
├── macros_impl.h
├── MetaIndexes_c.h
└── VectorTransform_c.h
```

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

Reviewed By: mdouze

Differential Revision: D27992822

Pulled By: beauby

fbshipit-source-id: 63fa9a39c77502d138453cb4b04c50652e732196
2021-04-26 02:20:23 -07:00
Alexander Andreev d640c6fcda Impl IndexPreTransform for c_api (#1816)
Summary:
This PR extends c_api for IndexPreTransform

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

Reviewed By: beauby

Differential Revision: D27904597

Pulled By: mdouze

fbshipit-source-id: b54dfffcc97879fdf66f9a8a26e9b7840a2e97f2
2021-04-22 05:27:36 -07:00
Alexander Andreev b209361f7b Add setters for IndexIVF* indexes (#1827)
Summary:
This PR gives users control over resources

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

Reviewed By: beauby

Differential Revision: D27904561

Pulled By: mdouze

fbshipit-source-id: 61352f776971d9f488917e39f8746d43614386d9
2021-04-22 05:22:40 -07:00
Alexander Andreev f15f639b64 Improve impl IndexRefineFlat for c_api (#1821)
Summary:
This PR extends c_api for IndexRefineFlat

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

Reviewed By: beauby

Differential Revision: D27904607

Pulled By: mdouze

fbshipit-source-id: 1a4592ab7d61bf722df1bbaf0aaee4e982a56a74
2021-04-22 05:22:40 -07:00
Alexander Andreev d9764d8aff Add IndexIVFScalarQuantizer for c_api (#1829)
Summary:
This PR add impl IndexIVFScalarQuantizer in c_api interface

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

Reviewed By: beauby

Differential Revision: D27904571

Pulled By: mdouze

fbshipit-source-id: 2cdbbd356f7520cea897f69c90486837c569ed19
2021-04-22 05:19:42 -07:00
Alexander Andreev 513f895b7c Add get,set verbose for Index in c_api (#1790)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1790

Reviewed By: beauby

Differential Revision: D27904738

Pulled By: mdouze

fbshipit-source-id: 31e8881996ee558c42206b9bf7ce1f9057595133
2021-04-22 05:16:55 -07:00
Alexander Andreev 1ddb517bbd Add IndexScalarQuantizer for c_api (#1802)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1802

Reviewed By: beauby

Differential Revision: D27706399

Pulled By: mdouze

fbshipit-source-id: 61ac99f61e9e44b2fca8e3de45357ee4c0a0b9d7
2021-04-15 23:04:49 -07:00
Alexander Andreev d77169173e Add getters for c_api IndexIVFFlat (#1787)
Summary:
ref https://github.com/facebookresearch/faiss/issues/1756

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

Reviewed By: beauby

Differential Revision: D27619587

Pulled By: mdouze

fbshipit-source-id: 0a9bb12f27b48c1b21025957e26c7453ab64a78d
2021-04-08 03:01:53 -07:00
Alexander Andreev fe7b06197e IndexIVFFlat inherited from Index for c_api (#1764)
Summary:
ref https://github.com/facebookresearch/faiss/issues/1756

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

Reviewed By: beauby

Differential Revision: D27152915

Pulled By: mdouze

fbshipit-source-id: 5e4ed9e861ff63fc95f92644f58ee8c7f98ca052
2021-03-18 02:36:51 -07:00
Prabhat Roy f2f014de50 Added C API(GPU) to CMake and CircleCI (#1700)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1700

Reviewed By: mdouze

Differential Revision: D26814446

Pulled By: beauby

fbshipit-source-id: 654e0297be929afd42bcfbaf790c5d87f04f5193
2021-03-04 05:04:00 -08:00
Lucas Hosseini e86bf8cae1 Enable clang-format + autofix.
Summary: Format whole codebase with clang-format.

Reviewed By: mdouze

Differential Revision: D22891341

fbshipit-source-id: 673032b2444d61026d1e2c3fa2c5659f178cf58b
2021-02-25 04:46:10 -08:00
Prabhat Roy 7a289d5418 Added C API to CMake and CircleCI (#1678)
Summary:
This supersedes https://github.com/facebookresearch/faiss/issues/1390 and https://github.com/facebookresearch/faiss/issues/1141.

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

Reviewed By: mdouze

Differential Revision: D26428986

Pulled By: beauby

fbshipit-source-id: 1e2718f457c1aca18c19edc2436d6baf9b627a60
2021-02-15 12:41:31 -08:00
Eduardo Pinho 9503cf0d6a Add GPU device utility functions (#1613)
Summary:
This adds some more functions to the C API, under a new DeviceUtils_c.h module. Resolves https://github.com/facebookresearch/faiss/issues/1414.

- `faiss_get_num_gpus`
- `faiss_gpu_profiler_start`
- `faiss_gpu_profiler_stop`
- `faiss_gpu_sync_all_devices`

The only minor issue right now is that building this requires basing it against an older version of Faiss until the building system is updated to use CMake (https://github.com/facebookresearch/faiss/issues/1390). I have provided a separate branch with the same contribution which is based against a version that works and builds OK: [`imp/c_api/add_gpu_device_utils`](https://github.com/Enet4/faiss/tree/imp/c_api/add_gpu_device_utils)

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

Reviewed By: wickedfoo

Differential Revision: D25942933

Pulled By: mdouze

fbshipit-source-id: 5b73a86b0c1702dfb7b9e56bd741f72495aac2fd
2021-01-19 17:23:12 -08:00
Matthijs Douze e1adde0d84 Faster brute force search (#1502)
Summary:
This diff streamlines the code that collects results for brute force distance computations for the L2 / IP and range search / knn search combinations.

It introduces a `ResultHandler` template class that abstracts what happens with the computed distances and ids. In addition to the heap result handler and the range search result handler, it introduces a reservoir result handler that improves the search speed for  large k (>=100).

Benchmark results (https://fb.quip.com/y0g1ACLEqJXx#OCaACA2Gm45) show that on small datasets (10k) search is 10-50% faster (improvements are larger for small k). There is room for improvement in the reservoir implementation, whose implementation is quite naive currently, but the diff is already useful in its current form.

Experiments on precomputed db vector norms for L2 distance computations were not very concluding performance-wise, so the implementation is removed from IndexFlatL2.

This diff also removes IndexL2BaseShift, which was never used.

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

Test Plan:
```
buck test //faiss/tests/:test_product_quantizer
buck test //faiss/tests/:test_index -- TestIndexFlat
```

Reviewed By: wickedfoo

Differential Revision: D24705464

Pulled By: mdouze

fbshipit-source-id: 270e10b19f3c89ed7b607ec30549aca0ac5027fe
2020-11-04 22:16:23 -08:00
Lucas Hosseini 70eaa9b1a3 Add missing copyright headers. (#1460)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1460

Reviewed By: wickedfoo

Differential Revision: D24278804

Pulled By: beauby

fbshipit-source-id: 5ea96ceb63be76a34f1eb4da03972159342cd5b6
2020-10-13 11:15:59 -07:00
Jeff Johnson ef6e53f8ba Cleanup flag/data propagation for IndexShards and IndexReplicas
Summary:
This diff fixes https://github.com/facebookresearch/faiss/issues/1412

There were various inconsistencies in how the shard and replica wrappers updated their internal state as the sub-indices were updated. This makes the two container classes work in the same way with similar synchronization functionality.

Reviewed By: beauby

Differential Revision: D23974186

fbshipit-source-id: c688c0c9124f823e4239aa2ff617b007b4564859
2020-09-29 10:25:46 -07:00
Eduardo Pinho bf593c0fae
[c_api] Fix GPU library build (#1296)
- depend on libfaiss.so instead of libgpufaiss.so
- update include directives in gpu C wrapper impl
- fix implicit call warning in C examples
2020-07-27 17:26:17 +02:00
glutamatt 9e5d5b722e
fix free parameterspace (#1243) 2020-07-09 09:32:03 +02:00
glutamatt ddd9c52f31
C API : ClusteringIterationStats integration (#1140)
Thanks for the fix @glutamatt and thanks for the review @Enet4 !

* C API : ClusteringIterationStats integration

* Update c_api/Clustering_c.h

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

* Update c_api/Clustering_c.cpp

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

* Update c_api/Clustering_c.cpp

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

* Update c_api/Clustering_c.cpp

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

* Add getter implementation

Co-authored-by: Eduardo Pinho <enet4mikeenet@gmail.com>
2020-03-12 23:22:39 +01:00
glutamatt 5a187120a5
[ C api ] Indexpretransform get underlying index (#1100)
Approved by @Enet4 so good by me.
2020-02-10 15:00:59 +01:00
Danil Guskov 7e08db7cb7
c_api: faiss_IndexIVF_invlists_get_ids function (#1094)
If @Enet4 approves it's fine with me.

* c_api: faiss_IndexIVF_invlists_get_ids function

* Update c_api/IndexIVF_c.h

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

Co-authored-by: Eduardo Pinho <enet4mikeenet@gmail.com>
2020-01-31 13:40:28 +01:00
glutamatt d278355b9c Fix typo in Clustering_c.h (#1084) 2020-01-14 15:41:07 +01:00
Jose Truyol c47da8a948 [C_API] Pass compilation in current state (#989)
* Pass compilation in current state

* Fix formatting and add missing parts

* Define DistanceComputer

* Add documentation to name changed on DistanceComputer::operator()()

* Apply suggestions from code review

Changes in docs

Co-Authored-By: Eduardo Pinho <enet4mikeenet@gmail.com>

* Updated MetricType
2019-11-19 11:36:44 +01:00
Eduardo Pinho 828dcea400 [C API] June 2019 update (#869)
* [c_api] use all relevant flags in compilation

* [c_api] Remove redundant IndexIVFFlat declarations

- From IndexIVF_c.h, already declared in IndexIVFFlat_c.h

* [c_api] type changes

- replace `long` with a more suitable type
- provide definitions for `faiss_component_t` and `faiss_distance_t`

* [c_api] Define CFLAGS and CUDACFLAGS
2019-06-24 13:29:38 +02:00
Eduardo Pinho 2bfbead8f1 [C API] Update for compatibility with v1.5 (#858)
* [c_api] Update impl and interface for v1.5

- move IndexShards to dedicated module IndexShards_c.{h|cpp}
- remove getter/setters to unreachable fields
- reimplement faiss_IndexIVF_imbalance_factor (to use invlists)
- minor IndexIVF documentation tweaks
- Remove QueryResult, provide RangeQueryResult

* [c_api] Document FaissErrorCode

* [c_api] Update GPU impl and interface for v1.5

- Remove unavailable method setTempMemoryFraction

* [c_api] Relicense to MIT

In accordance to the rest of the project
2019-06-12 15:46:08 +02:00
Eduardo Pinho 27a4ba0d93 [C API] Multi-GPU functions (#628)
* [c_api] minor tweak on Index_c header imports

* [c_api] Multi GPU constructs

- Add constructor & destructor for `FaissGpuMultipleClonerOptions`
- Add function `faiss_index_cpu_to_gpu_multiple`
- Add function `faiss_index_cpu_to_gpu_multiple_with_options`

* [c_api] fix doc comments in GpuClonerOptions

* [c_api] Improve cpu_to_gpu_multiple prototype

* [c_api] Improve cpu_to_gpu_multiple prototype

* [c_api] Add dtor definition for GpuMultipleClonerOptions
2018-12-23 18:46:07 +01:00
Eduardo Pinho dd6c9ebf2d [c_api] Rearrange lib linking in Makefiles (#490) 2018-06-13 13:40:04 +02:00
Eduardo Pinho fd63f06e97 Make c_api compatible with configure'd makefile (#477) 2018-06-04 11:58:23 +02:00
Eduardo Pinho 433f5c0fa5 [C API] Fix libgpufaiss_c with extended API (#448)
- change libfaiss_c.a libgpufaiss_c.a targets to only include wrapper
impl
- include libfaiss_c.a on c_api `make all`
- build libgpufaiss_c.so with libfaiss_c.a instead of faiss_c .o file list
2018-05-15 10:26:40 +02:00
Eduardo Pinho 9efdd8d427 [C API] Additional API coverage: IndexLSH, I/O, meta-indexes (#425)
* [c_api] leverage index downcast

- make index downcast declaration+definition possible with macros
- use macros on existing index types

* [c_api] Add IndexLSH to C API

* [c_api] Add Index IO interface

- new header index_io_c.h for access to the index_io.h API
- function`faiss_write_index` and overloads for dumping index to a file
- function`faiss_read_index` and overloads for reading index from a file
- function`faiss_clone_index` for cloning an index
- update C example to save index to a file

* [c_api] Add IndexIDMap and IndexShards API
2018-05-02 13:39:59 +02:00
Eduardo Pinho de0541c365 Add C API (#317)
* Add C API

* Add installation instructions for the C API
2018-02-26 11:23:17 +01:00