faiss 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/ext/faiss/extconf.rb +1 -1
  4. data/lib/faiss/version.rb +1 -1
  5. data/vendor/faiss/benchs/bench_6bit_codec.cpp +80 -0
  6. data/vendor/faiss/c_api/AutoTune_c.h +2 -0
  7. data/vendor/faiss/c_api/IndexShards_c.cpp +0 -6
  8. data/vendor/faiss/c_api/IndexShards_c.h +1 -4
  9. data/vendor/faiss/c_api/gpu/GpuAutoTune_c.cpp +4 -2
  10. data/vendor/faiss/c_api/gpu/GpuClonerOptions_c.cpp +1 -1
  11. data/vendor/faiss/c_api/gpu/GpuIndex_c.cpp +1 -1
  12. data/vendor/faiss/c_api/gpu/GpuResources_c.cpp +1 -1
  13. data/vendor/faiss/c_api/gpu/StandardGpuResources_c.cpp +1 -1
  14. data/vendor/faiss/demos/demo_imi_flat.cpp +5 -2
  15. data/vendor/faiss/demos/demo_imi_pq.cpp +6 -2
  16. data/vendor/faiss/demos/demo_ivfpq_indexing.cpp +7 -2
  17. data/vendor/faiss/{AutoTune.cpp → faiss/AutoTune.cpp} +9 -9
  18. data/vendor/faiss/{AutoTune.h → faiss/AutoTune.h} +0 -0
  19. data/vendor/faiss/{Clustering.cpp → faiss/Clustering.cpp} +13 -12
  20. data/vendor/faiss/{Clustering.h → faiss/Clustering.h} +0 -0
  21. data/vendor/faiss/{DirectMap.cpp → faiss/DirectMap.cpp} +0 -0
  22. data/vendor/faiss/{DirectMap.h → faiss/DirectMap.h} +0 -0
  23. data/vendor/faiss/{IVFlib.cpp → faiss/IVFlib.cpp} +86 -11
  24. data/vendor/faiss/{IVFlib.h → faiss/IVFlib.h} +26 -8
  25. data/vendor/faiss/{Index.cpp → faiss/Index.cpp} +0 -0
  26. data/vendor/faiss/{Index.h → faiss/Index.h} +1 -1
  27. data/vendor/faiss/{Index2Layer.cpp → faiss/Index2Layer.cpp} +12 -11
  28. data/vendor/faiss/{Index2Layer.h → faiss/Index2Layer.h} +0 -0
  29. data/vendor/faiss/{IndexBinary.cpp → faiss/IndexBinary.cpp} +2 -1
  30. data/vendor/faiss/{IndexBinary.h → faiss/IndexBinary.h} +0 -0
  31. data/vendor/faiss/{IndexBinaryFlat.cpp → faiss/IndexBinaryFlat.cpp} +0 -0
  32. data/vendor/faiss/{IndexBinaryFlat.h → faiss/IndexBinaryFlat.h} +0 -0
  33. data/vendor/faiss/{IndexBinaryFromFloat.cpp → faiss/IndexBinaryFromFloat.cpp} +1 -0
  34. data/vendor/faiss/{IndexBinaryFromFloat.h → faiss/IndexBinaryFromFloat.h} +0 -0
  35. data/vendor/faiss/{IndexBinaryHNSW.cpp → faiss/IndexBinaryHNSW.cpp} +1 -2
  36. data/vendor/faiss/{IndexBinaryHNSW.h → faiss/IndexBinaryHNSW.h} +0 -0
  37. data/vendor/faiss/{IndexBinaryHash.cpp → faiss/IndexBinaryHash.cpp} +16 -7
  38. data/vendor/faiss/{IndexBinaryHash.h → faiss/IndexBinaryHash.h} +2 -1
  39. data/vendor/faiss/{IndexBinaryIVF.cpp → faiss/IndexBinaryIVF.cpp} +10 -16
  40. data/vendor/faiss/{IndexBinaryIVF.h → faiss/IndexBinaryIVF.h} +1 -1
  41. data/vendor/faiss/{IndexFlat.cpp → faiss/IndexFlat.cpp} +0 -0
  42. data/vendor/faiss/{IndexFlat.h → faiss/IndexFlat.h} +0 -0
  43. data/vendor/faiss/{IndexHNSW.cpp → faiss/IndexHNSW.cpp} +63 -32
  44. data/vendor/faiss/{IndexHNSW.h → faiss/IndexHNSW.h} +0 -0
  45. data/vendor/faiss/{IndexIVF.cpp → faiss/IndexIVF.cpp} +129 -46
  46. data/vendor/faiss/{IndexIVF.h → faiss/IndexIVF.h} +7 -3
  47. data/vendor/faiss/{IndexIVFFlat.cpp → faiss/IndexIVFFlat.cpp} +6 -5
  48. data/vendor/faiss/{IndexIVFFlat.h → faiss/IndexIVFFlat.h} +0 -0
  49. data/vendor/faiss/{IndexIVFPQ.cpp → faiss/IndexIVFPQ.cpp} +9 -8
  50. data/vendor/faiss/{IndexIVFPQ.h → faiss/IndexIVFPQ.h} +4 -2
  51. data/vendor/faiss/{IndexIVFPQR.cpp → faiss/IndexIVFPQR.cpp} +3 -1
  52. data/vendor/faiss/{IndexIVFPQR.h → faiss/IndexIVFPQR.h} +0 -0
  53. data/vendor/faiss/{IndexIVFSpectralHash.cpp → faiss/IndexIVFSpectralHash.cpp} +1 -1
  54. data/vendor/faiss/{IndexIVFSpectralHash.h → faiss/IndexIVFSpectralHash.h} +0 -0
  55. data/vendor/faiss/{IndexLSH.cpp → faiss/IndexLSH.cpp} +0 -0
  56. data/vendor/faiss/{IndexLSH.h → faiss/IndexLSH.h} +0 -0
  57. data/vendor/faiss/{IndexLattice.cpp → faiss/IndexLattice.cpp} +0 -0
  58. data/vendor/faiss/{IndexLattice.h → faiss/IndexLattice.h} +0 -0
  59. data/vendor/faiss/{IndexPQ.cpp → faiss/IndexPQ.cpp} +6 -6
  60. data/vendor/faiss/{IndexPQ.h → faiss/IndexPQ.h} +3 -1
  61. data/vendor/faiss/{IndexPreTransform.cpp → faiss/IndexPreTransform.cpp} +0 -0
  62. data/vendor/faiss/{IndexPreTransform.h → faiss/IndexPreTransform.h} +0 -0
  63. data/vendor/faiss/{IndexReplicas.cpp → faiss/IndexReplicas.cpp} +102 -10
  64. data/vendor/faiss/{IndexReplicas.h → faiss/IndexReplicas.h} +6 -0
  65. data/vendor/faiss/{IndexScalarQuantizer.cpp → faiss/IndexScalarQuantizer.cpp} +3 -3
  66. data/vendor/faiss/{IndexScalarQuantizer.h → faiss/IndexScalarQuantizer.h} +0 -0
  67. data/vendor/faiss/{IndexShards.cpp → faiss/IndexShards.cpp} +37 -12
  68. data/vendor/faiss/{IndexShards.h → faiss/IndexShards.h} +3 -4
  69. data/vendor/faiss/{InvertedLists.cpp → faiss/InvertedLists.cpp} +2 -2
  70. data/vendor/faiss/{InvertedLists.h → faiss/InvertedLists.h} +1 -0
  71. data/vendor/faiss/{MatrixStats.cpp → faiss/MatrixStats.cpp} +0 -0
  72. data/vendor/faiss/{MatrixStats.h → faiss/MatrixStats.h} +0 -0
  73. data/vendor/faiss/{MetaIndexes.cpp → faiss/MetaIndexes.cpp} +5 -3
  74. data/vendor/faiss/{MetaIndexes.h → faiss/MetaIndexes.h} +0 -0
  75. data/vendor/faiss/{MetricType.h → faiss/MetricType.h} +0 -0
  76. data/vendor/faiss/{OnDiskInvertedLists.cpp → faiss/OnDiskInvertedLists.cpp} +141 -3
  77. data/vendor/faiss/{OnDiskInvertedLists.h → faiss/OnDiskInvertedLists.h} +27 -7
  78. data/vendor/faiss/{VectorTransform.cpp → faiss/VectorTransform.cpp} +4 -3
  79. data/vendor/faiss/{VectorTransform.h → faiss/VectorTransform.h} +0 -0
  80. data/vendor/faiss/{clone_index.cpp → faiss/clone_index.cpp} +0 -0
  81. data/vendor/faiss/{clone_index.h → faiss/clone_index.h} +0 -0
  82. data/vendor/faiss/{gpu → faiss/gpu}/GpuAutoTune.cpp +0 -0
  83. data/vendor/faiss/{gpu → faiss/gpu}/GpuAutoTune.h +0 -0
  84. data/vendor/faiss/{gpu → faiss/gpu}/GpuCloner.cpp +14 -14
  85. data/vendor/faiss/{gpu → faiss/gpu}/GpuCloner.h +6 -7
  86. data/vendor/faiss/{gpu → faiss/gpu}/GpuClonerOptions.cpp +0 -0
  87. data/vendor/faiss/{gpu → faiss/gpu}/GpuClonerOptions.h +0 -0
  88. data/vendor/faiss/{gpu → faiss/gpu}/GpuDistance.h +12 -4
  89. data/vendor/faiss/{gpu → faiss/gpu}/GpuFaissAssert.h +0 -0
  90. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndex.h +3 -9
  91. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexBinaryFlat.h +7 -7
  92. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexFlat.h +35 -10
  93. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexIVF.h +1 -2
  94. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexIVFFlat.h +4 -3
  95. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexIVFPQ.h +21 -4
  96. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndexIVFScalarQuantizer.h +4 -3
  97. data/vendor/faiss/{gpu → faiss/gpu}/GpuIndicesOptions.h +0 -0
  98. data/vendor/faiss/faiss/gpu/GpuResources.cpp +200 -0
  99. data/vendor/faiss/faiss/gpu/GpuResources.h +264 -0
  100. data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +572 -0
  101. data/vendor/faiss/{gpu → faiss/gpu}/StandardGpuResources.h +83 -15
  102. data/vendor/faiss/{gpu → faiss/gpu}/impl/RemapIndices.cpp +0 -0
  103. data/vendor/faiss/{gpu → faiss/gpu}/impl/RemapIndices.h +0 -0
  104. data/vendor/faiss/{gpu → faiss/gpu}/perf/IndexWrapper-inl.h +1 -1
  105. data/vendor/faiss/{gpu → faiss/gpu}/perf/IndexWrapper.h +1 -1
  106. data/vendor/faiss/{gpu → faiss/gpu}/perf/PerfClustering.cpp +1 -1
  107. data/vendor/faiss/{gpu → faiss/gpu}/perf/PerfIVFPQAdd.cpp +0 -0
  108. data/vendor/faiss/{gpu → faiss/gpu}/perf/WriteIndex.cpp +0 -0
  109. data/vendor/faiss/{gpu → faiss/gpu}/test/TestGpuIndexBinaryFlat.cpp +0 -0
  110. data/vendor/faiss/{gpu → faiss/gpu}/test/TestGpuIndexFlat.cpp +1 -1
  111. data/vendor/faiss/{gpu → faiss/gpu}/test/TestGpuIndexIVFFlat.cpp +0 -0
  112. data/vendor/faiss/{gpu → faiss/gpu}/test/TestGpuIndexIVFPQ.cpp +141 -52
  113. data/vendor/faiss/{gpu → faiss/gpu}/test/TestGpuMemoryException.cpp +0 -0
  114. data/vendor/faiss/{gpu → faiss/gpu}/test/TestUtils.cpp +4 -2
  115. data/vendor/faiss/{gpu → faiss/gpu}/test/TestUtils.h +0 -0
  116. data/vendor/faiss/{gpu → faiss/gpu}/test/demo_ivfpq_indexing_gpu.cpp +7 -5
  117. data/vendor/faiss/{gpu → faiss/gpu}/utils/DeviceUtils.h +1 -1
  118. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +213 -0
  119. data/vendor/faiss/{gpu → faiss/gpu}/utils/StackDeviceMemory.h +25 -40
  120. data/vendor/faiss/{gpu → faiss/gpu}/utils/StaticUtils.h +0 -0
  121. data/vendor/faiss/{gpu → faiss/gpu}/utils/Timer.cpp +0 -0
  122. data/vendor/faiss/{gpu → faiss/gpu}/utils/Timer.h +0 -0
  123. data/vendor/faiss/{impl → faiss/impl}/AuxIndexStructures.cpp +1 -0
  124. data/vendor/faiss/{impl → faiss/impl}/AuxIndexStructures.h +3 -1
  125. data/vendor/faiss/{impl → faiss/impl}/FaissAssert.h +1 -0
  126. data/vendor/faiss/{impl → faiss/impl}/FaissException.cpp +26 -0
  127. data/vendor/faiss/{impl → faiss/impl}/FaissException.h +4 -0
  128. data/vendor/faiss/{impl → faiss/impl}/HNSW.cpp +26 -26
  129. data/vendor/faiss/{impl → faiss/impl}/HNSW.h +19 -11
  130. data/vendor/faiss/{impl → faiss/impl}/PolysemousTraining.cpp +1 -1
  131. data/vendor/faiss/{impl → faiss/impl}/PolysemousTraining.h +1 -1
  132. data/vendor/faiss/{impl → faiss/impl}/ProductQuantizer-inl.h +0 -1
  133. data/vendor/faiss/{impl → faiss/impl}/ProductQuantizer.cpp +9 -9
  134. data/vendor/faiss/{impl → faiss/impl}/ProductQuantizer.h +0 -0
  135. data/vendor/faiss/{impl → faiss/impl}/ScalarQuantizer.cpp +63 -39
  136. data/vendor/faiss/{impl → faiss/impl}/ScalarQuantizer.h +1 -1
  137. data/vendor/faiss/{impl → faiss/impl}/ThreadedIndex-inl.h +0 -0
  138. data/vendor/faiss/{impl → faiss/impl}/ThreadedIndex.h +0 -0
  139. data/vendor/faiss/{impl → faiss/impl}/index_read.cpp +99 -116
  140. data/vendor/faiss/{impl → faiss/impl}/index_write.cpp +15 -50
  141. data/vendor/faiss/{impl → faiss/impl}/io.cpp +15 -10
  142. data/vendor/faiss/{impl → faiss/impl}/io.h +22 -8
  143. data/vendor/faiss/faiss/impl/io_macros.h +57 -0
  144. data/vendor/faiss/{impl → faiss/impl}/lattice_Zn.cpp +52 -36
  145. data/vendor/faiss/{impl → faiss/impl}/lattice_Zn.h +3 -3
  146. data/vendor/faiss/faiss/impl/platform_macros.h +24 -0
  147. data/vendor/faiss/{index_factory.cpp → faiss/index_factory.cpp} +33 -12
  148. data/vendor/faiss/{index_factory.h → faiss/index_factory.h} +0 -0
  149. data/vendor/faiss/{index_io.h → faiss/index_io.h} +55 -1
  150. data/vendor/faiss/faiss/python/python_callbacks.cpp +112 -0
  151. data/vendor/faiss/faiss/python/python_callbacks.h +45 -0
  152. data/vendor/faiss/{utils → faiss/utils}/Heap.cpp +5 -5
  153. data/vendor/faiss/{utils → faiss/utils}/Heap.h +1 -3
  154. data/vendor/faiss/{utils → faiss/utils}/WorkerThread.cpp +0 -0
  155. data/vendor/faiss/{utils → faiss/utils}/WorkerThread.h +0 -0
  156. data/vendor/faiss/{utils → faiss/utils}/distances.cpp +28 -13
  157. data/vendor/faiss/{utils → faiss/utils}/distances.h +2 -1
  158. data/vendor/faiss/{utils → faiss/utils}/distances_simd.cpp +5 -5
  159. data/vendor/faiss/{utils → faiss/utils}/extra_distances.cpp +8 -7
  160. data/vendor/faiss/{utils → faiss/utils}/extra_distances.h +0 -0
  161. data/vendor/faiss/{utils → faiss/utils}/hamming-inl.h +1 -3
  162. data/vendor/faiss/{utils → faiss/utils}/hamming.cpp +8 -7
  163. data/vendor/faiss/{utils → faiss/utils}/hamming.h +7 -1
  164. data/vendor/faiss/{utils → faiss/utils}/random.cpp +5 -5
  165. data/vendor/faiss/{utils → faiss/utils}/random.h +0 -0
  166. data/vendor/faiss/{utils → faiss/utils}/utils.cpp +27 -28
  167. data/vendor/faiss/{utils → faiss/utils}/utils.h +4 -0
  168. data/vendor/faiss/misc/test_blas.cpp +4 -1
  169. data/vendor/faiss/tests/test_binary_flat.cpp +0 -2
  170. data/vendor/faiss/tests/test_dealloc_invlists.cpp +6 -1
  171. data/vendor/faiss/tests/test_ivfpq_codec.cpp +4 -1
  172. data/vendor/faiss/tests/test_ivfpq_indexing.cpp +6 -4
  173. data/vendor/faiss/tests/test_lowlevel_ivf.cpp +12 -5
  174. data/vendor/faiss/tests/test_merge.cpp +6 -3
  175. data/vendor/faiss/tests/test_ondisk_ivf.cpp +7 -2
  176. data/vendor/faiss/tests/test_pairs_decoding.cpp +5 -1
  177. data/vendor/faiss/tests/test_params_override.cpp +7 -2
  178. data/vendor/faiss/tests/test_sliding_ivf.cpp +10 -4
  179. data/vendor/faiss/tutorial/cpp/1-Flat.cpp +14 -8
  180. data/vendor/faiss/tutorial/cpp/2-IVFFlat.cpp +11 -7
  181. data/vendor/faiss/tutorial/cpp/3-IVFPQ.cpp +12 -7
  182. data/vendor/faiss/tutorial/cpp/4-GPU.cpp +6 -3
  183. data/vendor/faiss/tutorial/cpp/5-Multiple-GPUs.cpp +7 -3
  184. metadata +154 -153
  185. data/vendor/faiss/gpu/GpuResources.cpp +0 -52
  186. data/vendor/faiss/gpu/GpuResources.h +0 -73
  187. data/vendor/faiss/gpu/StandardGpuResources.cpp +0 -303
  188. data/vendor/faiss/gpu/utils/DeviceMemory.cpp +0 -77
  189. data/vendor/faiss/gpu/utils/DeviceMemory.h +0 -71
  190. data/vendor/faiss/gpu/utils/MemorySpace.cpp +0 -89
  191. data/vendor/faiss/gpu/utils/MemorySpace.h +0 -44
  192. data/vendor/faiss/gpu/utils/StackDeviceMemory.cpp +0 -239
@@ -7,28 +7,33 @@
7
7
 
8
8
  #include <cstdio>
9
9
  #include <cstdlib>
10
+ #include <random>
10
11
 
11
12
  #include <faiss/IndexFlat.h>
12
13
  #include <faiss/IndexIVFPQ.h>
13
14
 
15
+ using idx_t = faiss::Index::idx_t;
14
16
 
15
17
  int main() {
16
18
  int d = 64; // dimension
17
19
  int nb = 100000; // database size
18
20
  int nq = 10000; // nb of queries
19
21
 
22
+ std::mt19937 rng;
23
+ std::uniform_real_distribution<> distrib;
24
+
20
25
  float *xb = new float[d * nb];
21
26
  float *xq = new float[d * nq];
22
27
 
23
28
  for(int i = 0; i < nb; i++) {
24
29
  for(int j = 0; j < d; j++)
25
- xb[d * i + j] = drand48();
30
+ xb[d * i + j] = distrib(rng);
26
31
  xb[d * i] += i / 1000.;
27
32
  }
28
33
 
29
34
  for(int i = 0; i < nq; i++) {
30
35
  for(int j = 0; j < d; j++)
31
- xq[d * i + j] = drand48();
36
+ xq[d * i + j] = distrib(rng);
32
37
  xq[d * i] += i / 1000.;
33
38
  }
34
39
 
@@ -38,12 +43,12 @@ int main() {
38
43
  int m = 8; // bytes per vector
39
44
  faiss::IndexFlatL2 quantizer(d); // the other index
40
45
  faiss::IndexIVFPQ index(&quantizer, d, nlist, m, 8);
41
- // here we specify METRIC_L2, by default it performs inner-product search
46
+
42
47
  index.train(nb, xb);
43
48
  index.add(nb, xb);
44
49
 
45
50
  { // sanity check
46
- long *I = new long[k * 5];
51
+ idx_t *I = new idx_t[k * 5];
47
52
  float *D = new float[k * 5];
48
53
 
49
54
  index.search(5, xb, k, D, I);
@@ -51,7 +56,7 @@ int main() {
51
56
  printf("I=\n");
52
57
  for(int i = 0; i < 5; i++) {
53
58
  for(int j = 0; j < k; j++)
54
- printf("%5ld ", I[i * k + j]);
59
+ printf("%5zd ", I[i * k + j]);
55
60
  printf("\n");
56
61
  }
57
62
 
@@ -67,7 +72,7 @@ int main() {
67
72
  }
68
73
 
69
74
  { // search xq
70
- long *I = new long[k * nq];
75
+ idx_t *I = new idx_t[k * nq];
71
76
  float *D = new float[k * nq];
72
77
 
73
78
  index.nprobe = 10;
@@ -76,7 +81,7 @@ int main() {
76
81
  printf("I=\n");
77
82
  for(int i = nq - 5; i < nq; i++) {
78
83
  for(int j = 0; j < k; j++)
79
- printf("%5ld ", I[i * k + j]);
84
+ printf("%5zd ", I[i * k + j]);
80
85
  printf("\n");
81
86
  }
82
87
 
@@ -8,6 +8,7 @@
8
8
  #include <cstdio>
9
9
  #include <cstdlib>
10
10
  #include <cassert>
11
+ #include <random>
11
12
 
12
13
  #include <faiss/IndexFlat.h>
13
14
  #include <faiss/gpu/GpuIndexFlat.h>
@@ -20,18 +21,21 @@ int main() {
20
21
  int nb = 100000; // database size
21
22
  int nq = 10000; // nb of queries
22
23
 
24
+ std::mt19937 rng;
25
+ std::uniform_real_distribution<> distrib;
26
+
23
27
  float *xb = new float[d * nb];
24
28
  float *xq = new float[d * nq];
25
29
 
26
30
  for(int i = 0; i < nb; i++) {
27
31
  for(int j = 0; j < d; j++)
28
- xb[d * i + j] = drand48();
32
+ xb[d * i + j] = distrib(rng);
29
33
  xb[d * i] += i / 1000.;
30
34
  }
31
35
 
32
36
  for(int i = 0; i < nq; i++) {
33
37
  for(int j = 0; j < d; j++)
34
- xq[d * i + j] = drand48();
38
+ xq[d * i + j] = distrib(rng);
35
39
  xq[d * i] += i / 1000.;
36
40
  }
37
41
 
@@ -76,7 +80,6 @@ int main() {
76
80
 
77
81
  int nlist = 100;
78
82
  faiss::gpu::GpuIndexIVFFlat index_ivf(&res, d, nlist, faiss::METRIC_L2);
79
- // here we specify METRIC_L2, by default it performs inner-product search
80
83
 
81
84
  assert(!index_ivf.is_trained);
82
85
  index_ivf.train(nb, xb);
@@ -7,6 +7,7 @@
7
7
 
8
8
  #include <cstdio>
9
9
  #include <cstdlib>
10
+ #include <random>
10
11
 
11
12
  #include <faiss/IndexFlat.h>
12
13
  #include <faiss/gpu/GpuAutoTune.h>
@@ -21,18 +22,21 @@ int main() {
21
22
  int nb = 100000; // database size
22
23
  int nq = 10000; // nb of queries
23
24
 
25
+ std::mt19937 rng;
26
+ std::uniform_real_distribution<> distrib;
27
+
24
28
  float *xb = new float[d * nb];
25
29
  float *xq = new float[d * nq];
26
30
 
27
31
  for(int i = 0; i < nb; i++) {
28
32
  for(int j = 0; j < d; j++)
29
- xb[d * i + j] = drand48();
33
+ xb[d * i + j] = distrib(rng);
30
34
  xb[d * i] += i / 1000.;
31
35
  }
32
36
 
33
37
  for(int i = 0; i < nq; i++) {
34
38
  for(int j = 0; j < d; j++)
35
- xq[d * i + j] = drand48();
39
+ xq[d * i + j] = distrib(rng);
36
40
  xq[d * i] += i / 1000.;
37
41
  }
38
42
 
@@ -40,7 +44,7 @@ int main() {
40
44
 
41
45
  printf("Number of GPUs: %d\n", ngpus);
42
46
 
43
- std::vector<faiss::gpu::GpuResources*> res;
47
+ std::vector<faiss::gpu::GpuResourcesProvider*> res;
44
48
  std::vector<int> devs;
45
49
  for(int i = 0; i < ngpus; i++) {
46
50
  res.push_back(new faiss::gpu::StandardGpuResources);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice
@@ -113,70 +113,8 @@ files:
113
113
  - lib/faiss/pca_matrix.rb
114
114
  - lib/faiss/product_quantizer.rb
115
115
  - lib/faiss/version.rb
116
- - vendor/faiss/AutoTune.cpp
117
- - vendor/faiss/AutoTune.h
118
- - vendor/faiss/Clustering.cpp
119
- - vendor/faiss/Clustering.h
120
- - vendor/faiss/DirectMap.cpp
121
- - vendor/faiss/DirectMap.h
122
- - vendor/faiss/IVFlib.cpp
123
- - vendor/faiss/IVFlib.h
124
- - vendor/faiss/Index.cpp
125
- - vendor/faiss/Index.h
126
- - vendor/faiss/Index2Layer.cpp
127
- - vendor/faiss/Index2Layer.h
128
- - vendor/faiss/IndexBinary.cpp
129
- - vendor/faiss/IndexBinary.h
130
- - vendor/faiss/IndexBinaryFlat.cpp
131
- - vendor/faiss/IndexBinaryFlat.h
132
- - vendor/faiss/IndexBinaryFromFloat.cpp
133
- - vendor/faiss/IndexBinaryFromFloat.h
134
- - vendor/faiss/IndexBinaryHNSW.cpp
135
- - vendor/faiss/IndexBinaryHNSW.h
136
- - vendor/faiss/IndexBinaryHash.cpp
137
- - vendor/faiss/IndexBinaryHash.h
138
- - vendor/faiss/IndexBinaryIVF.cpp
139
- - vendor/faiss/IndexBinaryIVF.h
140
- - vendor/faiss/IndexFlat.cpp
141
- - vendor/faiss/IndexFlat.h
142
- - vendor/faiss/IndexHNSW.cpp
143
- - vendor/faiss/IndexHNSW.h
144
- - vendor/faiss/IndexIVF.cpp
145
- - vendor/faiss/IndexIVF.h
146
- - vendor/faiss/IndexIVFFlat.cpp
147
- - vendor/faiss/IndexIVFFlat.h
148
- - vendor/faiss/IndexIVFPQ.cpp
149
- - vendor/faiss/IndexIVFPQ.h
150
- - vendor/faiss/IndexIVFPQR.cpp
151
- - vendor/faiss/IndexIVFPQR.h
152
- - vendor/faiss/IndexIVFSpectralHash.cpp
153
- - vendor/faiss/IndexIVFSpectralHash.h
154
- - vendor/faiss/IndexLSH.cpp
155
- - vendor/faiss/IndexLSH.h
156
- - vendor/faiss/IndexLattice.cpp
157
- - vendor/faiss/IndexLattice.h
158
- - vendor/faiss/IndexPQ.cpp
159
- - vendor/faiss/IndexPQ.h
160
- - vendor/faiss/IndexPreTransform.cpp
161
- - vendor/faiss/IndexPreTransform.h
162
- - vendor/faiss/IndexReplicas.cpp
163
- - vendor/faiss/IndexReplicas.h
164
- - vendor/faiss/IndexScalarQuantizer.cpp
165
- - vendor/faiss/IndexScalarQuantizer.h
166
- - vendor/faiss/IndexShards.cpp
167
- - vendor/faiss/IndexShards.h
168
- - vendor/faiss/InvertedLists.cpp
169
- - vendor/faiss/InvertedLists.h
170
116
  - vendor/faiss/LICENSE
171
- - vendor/faiss/MatrixStats.cpp
172
- - vendor/faiss/MatrixStats.h
173
- - vendor/faiss/MetaIndexes.cpp
174
- - vendor/faiss/MetaIndexes.h
175
- - vendor/faiss/MetricType.h
176
- - vendor/faiss/OnDiskInvertedLists.cpp
177
- - vendor/faiss/OnDiskInvertedLists.h
178
- - vendor/faiss/VectorTransform.cpp
179
- - vendor/faiss/VectorTransform.h
117
+ - vendor/faiss/benchs/bench_6bit_codec.cpp
180
118
  - vendor/faiss/c_api/AutoTune_c.cpp
181
119
  - vendor/faiss/c_api/AutoTune_c.h
182
120
  - vendor/faiss/c_api/Clustering_c.cpp
@@ -222,83 +160,162 @@ files:
222
160
  - vendor/faiss/c_api/index_io_c.cpp
223
161
  - vendor/faiss/c_api/index_io_c.h
224
162
  - vendor/faiss/c_api/macros_impl.h
225
- - vendor/faiss/clone_index.cpp
226
- - vendor/faiss/clone_index.h
227
163
  - vendor/faiss/demos/demo_imi_flat.cpp
228
164
  - vendor/faiss/demos/demo_imi_pq.cpp
229
165
  - vendor/faiss/demos/demo_ivfpq_indexing.cpp
230
166
  - vendor/faiss/demos/demo_sift1M.cpp
231
167
  - vendor/faiss/demos/demo_weighted_kmeans.cpp
232
- - vendor/faiss/gpu/GpuAutoTune.cpp
233
- - vendor/faiss/gpu/GpuAutoTune.h
234
- - vendor/faiss/gpu/GpuCloner.cpp
235
- - vendor/faiss/gpu/GpuCloner.h
236
- - vendor/faiss/gpu/GpuClonerOptions.cpp
237
- - vendor/faiss/gpu/GpuClonerOptions.h
238
- - vendor/faiss/gpu/GpuDistance.h
239
- - vendor/faiss/gpu/GpuFaissAssert.h
240
- - vendor/faiss/gpu/GpuIndex.h
241
- - vendor/faiss/gpu/GpuIndexBinaryFlat.h
242
- - vendor/faiss/gpu/GpuIndexFlat.h
243
- - vendor/faiss/gpu/GpuIndexIVF.h
244
- - vendor/faiss/gpu/GpuIndexIVFFlat.h
245
- - vendor/faiss/gpu/GpuIndexIVFPQ.h
246
- - vendor/faiss/gpu/GpuIndexIVFScalarQuantizer.h
247
- - vendor/faiss/gpu/GpuIndicesOptions.h
248
- - vendor/faiss/gpu/GpuResources.cpp
249
- - vendor/faiss/gpu/GpuResources.h
250
- - vendor/faiss/gpu/StandardGpuResources.cpp
251
- - vendor/faiss/gpu/StandardGpuResources.h
252
- - vendor/faiss/gpu/impl/RemapIndices.cpp
253
- - vendor/faiss/gpu/impl/RemapIndices.h
254
- - vendor/faiss/gpu/perf/IndexWrapper-inl.h
255
- - vendor/faiss/gpu/perf/IndexWrapper.h
256
- - vendor/faiss/gpu/perf/PerfClustering.cpp
257
- - vendor/faiss/gpu/perf/PerfIVFPQAdd.cpp
258
- - vendor/faiss/gpu/perf/WriteIndex.cpp
259
- - vendor/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp
260
- - vendor/faiss/gpu/test/TestGpuIndexFlat.cpp
261
- - vendor/faiss/gpu/test/TestGpuIndexIVFFlat.cpp
262
- - vendor/faiss/gpu/test/TestGpuIndexIVFPQ.cpp
263
- - vendor/faiss/gpu/test/TestGpuMemoryException.cpp
264
- - vendor/faiss/gpu/test/TestUtils.cpp
265
- - vendor/faiss/gpu/test/TestUtils.h
266
- - vendor/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp
267
- - vendor/faiss/gpu/utils/DeviceMemory.cpp
268
- - vendor/faiss/gpu/utils/DeviceMemory.h
269
- - vendor/faiss/gpu/utils/DeviceUtils.h
270
- - vendor/faiss/gpu/utils/MemorySpace.cpp
271
- - vendor/faiss/gpu/utils/MemorySpace.h
272
- - vendor/faiss/gpu/utils/StackDeviceMemory.cpp
273
- - vendor/faiss/gpu/utils/StackDeviceMemory.h
274
- - vendor/faiss/gpu/utils/StaticUtils.h
275
- - vendor/faiss/gpu/utils/Timer.cpp
276
- - vendor/faiss/gpu/utils/Timer.h
277
- - vendor/faiss/impl/AuxIndexStructures.cpp
278
- - vendor/faiss/impl/AuxIndexStructures.h
279
- - vendor/faiss/impl/FaissAssert.h
280
- - vendor/faiss/impl/FaissException.cpp
281
- - vendor/faiss/impl/FaissException.h
282
- - vendor/faiss/impl/HNSW.cpp
283
- - vendor/faiss/impl/HNSW.h
284
- - vendor/faiss/impl/PolysemousTraining.cpp
285
- - vendor/faiss/impl/PolysemousTraining.h
286
- - vendor/faiss/impl/ProductQuantizer-inl.h
287
- - vendor/faiss/impl/ProductQuantizer.cpp
288
- - vendor/faiss/impl/ProductQuantizer.h
289
- - vendor/faiss/impl/ScalarQuantizer.cpp
290
- - vendor/faiss/impl/ScalarQuantizer.h
291
- - vendor/faiss/impl/ThreadedIndex-inl.h
292
- - vendor/faiss/impl/ThreadedIndex.h
293
- - vendor/faiss/impl/index_read.cpp
294
- - vendor/faiss/impl/index_write.cpp
295
- - vendor/faiss/impl/io.cpp
296
- - vendor/faiss/impl/io.h
297
- - vendor/faiss/impl/lattice_Zn.cpp
298
- - vendor/faiss/impl/lattice_Zn.h
299
- - vendor/faiss/index_factory.cpp
300
- - vendor/faiss/index_factory.h
301
- - vendor/faiss/index_io.h
168
+ - vendor/faiss/faiss/AutoTune.cpp
169
+ - vendor/faiss/faiss/AutoTune.h
170
+ - vendor/faiss/faiss/Clustering.cpp
171
+ - vendor/faiss/faiss/Clustering.h
172
+ - vendor/faiss/faiss/DirectMap.cpp
173
+ - vendor/faiss/faiss/DirectMap.h
174
+ - vendor/faiss/faiss/IVFlib.cpp
175
+ - vendor/faiss/faiss/IVFlib.h
176
+ - vendor/faiss/faiss/Index.cpp
177
+ - vendor/faiss/faiss/Index.h
178
+ - vendor/faiss/faiss/Index2Layer.cpp
179
+ - vendor/faiss/faiss/Index2Layer.h
180
+ - vendor/faiss/faiss/IndexBinary.cpp
181
+ - vendor/faiss/faiss/IndexBinary.h
182
+ - vendor/faiss/faiss/IndexBinaryFlat.cpp
183
+ - vendor/faiss/faiss/IndexBinaryFlat.h
184
+ - vendor/faiss/faiss/IndexBinaryFromFloat.cpp
185
+ - vendor/faiss/faiss/IndexBinaryFromFloat.h
186
+ - vendor/faiss/faiss/IndexBinaryHNSW.cpp
187
+ - vendor/faiss/faiss/IndexBinaryHNSW.h
188
+ - vendor/faiss/faiss/IndexBinaryHash.cpp
189
+ - vendor/faiss/faiss/IndexBinaryHash.h
190
+ - vendor/faiss/faiss/IndexBinaryIVF.cpp
191
+ - vendor/faiss/faiss/IndexBinaryIVF.h
192
+ - vendor/faiss/faiss/IndexFlat.cpp
193
+ - vendor/faiss/faiss/IndexFlat.h
194
+ - vendor/faiss/faiss/IndexHNSW.cpp
195
+ - vendor/faiss/faiss/IndexHNSW.h
196
+ - vendor/faiss/faiss/IndexIVF.cpp
197
+ - vendor/faiss/faiss/IndexIVF.h
198
+ - vendor/faiss/faiss/IndexIVFFlat.cpp
199
+ - vendor/faiss/faiss/IndexIVFFlat.h
200
+ - vendor/faiss/faiss/IndexIVFPQ.cpp
201
+ - vendor/faiss/faiss/IndexIVFPQ.h
202
+ - vendor/faiss/faiss/IndexIVFPQR.cpp
203
+ - vendor/faiss/faiss/IndexIVFPQR.h
204
+ - vendor/faiss/faiss/IndexIVFSpectralHash.cpp
205
+ - vendor/faiss/faiss/IndexIVFSpectralHash.h
206
+ - vendor/faiss/faiss/IndexLSH.cpp
207
+ - vendor/faiss/faiss/IndexLSH.h
208
+ - vendor/faiss/faiss/IndexLattice.cpp
209
+ - vendor/faiss/faiss/IndexLattice.h
210
+ - vendor/faiss/faiss/IndexPQ.cpp
211
+ - vendor/faiss/faiss/IndexPQ.h
212
+ - vendor/faiss/faiss/IndexPreTransform.cpp
213
+ - vendor/faiss/faiss/IndexPreTransform.h
214
+ - vendor/faiss/faiss/IndexReplicas.cpp
215
+ - vendor/faiss/faiss/IndexReplicas.h
216
+ - vendor/faiss/faiss/IndexScalarQuantizer.cpp
217
+ - vendor/faiss/faiss/IndexScalarQuantizer.h
218
+ - vendor/faiss/faiss/IndexShards.cpp
219
+ - vendor/faiss/faiss/IndexShards.h
220
+ - vendor/faiss/faiss/InvertedLists.cpp
221
+ - vendor/faiss/faiss/InvertedLists.h
222
+ - vendor/faiss/faiss/MatrixStats.cpp
223
+ - vendor/faiss/faiss/MatrixStats.h
224
+ - vendor/faiss/faiss/MetaIndexes.cpp
225
+ - vendor/faiss/faiss/MetaIndexes.h
226
+ - vendor/faiss/faiss/MetricType.h
227
+ - vendor/faiss/faiss/OnDiskInvertedLists.cpp
228
+ - vendor/faiss/faiss/OnDiskInvertedLists.h
229
+ - vendor/faiss/faiss/VectorTransform.cpp
230
+ - vendor/faiss/faiss/VectorTransform.h
231
+ - vendor/faiss/faiss/clone_index.cpp
232
+ - vendor/faiss/faiss/clone_index.h
233
+ - vendor/faiss/faiss/gpu/GpuAutoTune.cpp
234
+ - vendor/faiss/faiss/gpu/GpuAutoTune.h
235
+ - vendor/faiss/faiss/gpu/GpuCloner.cpp
236
+ - vendor/faiss/faiss/gpu/GpuCloner.h
237
+ - vendor/faiss/faiss/gpu/GpuClonerOptions.cpp
238
+ - vendor/faiss/faiss/gpu/GpuClonerOptions.h
239
+ - vendor/faiss/faiss/gpu/GpuDistance.h
240
+ - vendor/faiss/faiss/gpu/GpuFaissAssert.h
241
+ - vendor/faiss/faiss/gpu/GpuIndex.h
242
+ - vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h
243
+ - vendor/faiss/faiss/gpu/GpuIndexFlat.h
244
+ - vendor/faiss/faiss/gpu/GpuIndexIVF.h
245
+ - vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h
246
+ - vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h
247
+ - vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h
248
+ - vendor/faiss/faiss/gpu/GpuIndicesOptions.h
249
+ - vendor/faiss/faiss/gpu/GpuResources.cpp
250
+ - vendor/faiss/faiss/gpu/GpuResources.h
251
+ - vendor/faiss/faiss/gpu/StandardGpuResources.cpp
252
+ - vendor/faiss/faiss/gpu/StandardGpuResources.h
253
+ - vendor/faiss/faiss/gpu/impl/RemapIndices.cpp
254
+ - vendor/faiss/faiss/gpu/impl/RemapIndices.h
255
+ - vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h
256
+ - vendor/faiss/faiss/gpu/perf/IndexWrapper.h
257
+ - vendor/faiss/faiss/gpu/perf/PerfClustering.cpp
258
+ - vendor/faiss/faiss/gpu/perf/PerfIVFPQAdd.cpp
259
+ - vendor/faiss/faiss/gpu/perf/WriteIndex.cpp
260
+ - vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp
261
+ - vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp
262
+ - vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp
263
+ - vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp
264
+ - vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp
265
+ - vendor/faiss/faiss/gpu/test/TestUtils.cpp
266
+ - vendor/faiss/faiss/gpu/test/TestUtils.h
267
+ - vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp
268
+ - vendor/faiss/faiss/gpu/utils/DeviceUtils.h
269
+ - vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp
270
+ - vendor/faiss/faiss/gpu/utils/StackDeviceMemory.h
271
+ - vendor/faiss/faiss/gpu/utils/StaticUtils.h
272
+ - vendor/faiss/faiss/gpu/utils/Timer.cpp
273
+ - vendor/faiss/faiss/gpu/utils/Timer.h
274
+ - vendor/faiss/faiss/impl/AuxIndexStructures.cpp
275
+ - vendor/faiss/faiss/impl/AuxIndexStructures.h
276
+ - vendor/faiss/faiss/impl/FaissAssert.h
277
+ - vendor/faiss/faiss/impl/FaissException.cpp
278
+ - vendor/faiss/faiss/impl/FaissException.h
279
+ - vendor/faiss/faiss/impl/HNSW.cpp
280
+ - vendor/faiss/faiss/impl/HNSW.h
281
+ - vendor/faiss/faiss/impl/PolysemousTraining.cpp
282
+ - vendor/faiss/faiss/impl/PolysemousTraining.h
283
+ - vendor/faiss/faiss/impl/ProductQuantizer-inl.h
284
+ - vendor/faiss/faiss/impl/ProductQuantizer.cpp
285
+ - vendor/faiss/faiss/impl/ProductQuantizer.h
286
+ - vendor/faiss/faiss/impl/ScalarQuantizer.cpp
287
+ - vendor/faiss/faiss/impl/ScalarQuantizer.h
288
+ - vendor/faiss/faiss/impl/ThreadedIndex-inl.h
289
+ - vendor/faiss/faiss/impl/ThreadedIndex.h
290
+ - vendor/faiss/faiss/impl/index_read.cpp
291
+ - vendor/faiss/faiss/impl/index_write.cpp
292
+ - vendor/faiss/faiss/impl/io.cpp
293
+ - vendor/faiss/faiss/impl/io.h
294
+ - vendor/faiss/faiss/impl/io_macros.h
295
+ - vendor/faiss/faiss/impl/lattice_Zn.cpp
296
+ - vendor/faiss/faiss/impl/lattice_Zn.h
297
+ - vendor/faiss/faiss/impl/platform_macros.h
298
+ - vendor/faiss/faiss/index_factory.cpp
299
+ - vendor/faiss/faiss/index_factory.h
300
+ - vendor/faiss/faiss/index_io.h
301
+ - vendor/faiss/faiss/python/python_callbacks.cpp
302
+ - vendor/faiss/faiss/python/python_callbacks.h
303
+ - vendor/faiss/faiss/utils/Heap.cpp
304
+ - vendor/faiss/faiss/utils/Heap.h
305
+ - vendor/faiss/faiss/utils/WorkerThread.cpp
306
+ - vendor/faiss/faiss/utils/WorkerThread.h
307
+ - vendor/faiss/faiss/utils/distances.cpp
308
+ - vendor/faiss/faiss/utils/distances.h
309
+ - vendor/faiss/faiss/utils/distances_simd.cpp
310
+ - vendor/faiss/faiss/utils/extra_distances.cpp
311
+ - vendor/faiss/faiss/utils/extra_distances.h
312
+ - vendor/faiss/faiss/utils/hamming-inl.h
313
+ - vendor/faiss/faiss/utils/hamming.cpp
314
+ - vendor/faiss/faiss/utils/hamming.h
315
+ - vendor/faiss/faiss/utils/random.cpp
316
+ - vendor/faiss/faiss/utils/random.h
317
+ - vendor/faiss/faiss/utils/utils.cpp
318
+ - vendor/faiss/faiss/utils/utils.h
302
319
  - vendor/faiss/misc/test_blas.cpp
303
320
  - vendor/faiss/tests/test_binary_flat.cpp
304
321
  - vendor/faiss/tests/test_dealloc_invlists.cpp
@@ -319,22 +336,6 @@ files:
319
336
  - vendor/faiss/tutorial/cpp/3-IVFPQ.cpp
320
337
  - vendor/faiss/tutorial/cpp/4-GPU.cpp
321
338
  - vendor/faiss/tutorial/cpp/5-Multiple-GPUs.cpp
322
- - vendor/faiss/utils/Heap.cpp
323
- - vendor/faiss/utils/Heap.h
324
- - vendor/faiss/utils/WorkerThread.cpp
325
- - vendor/faiss/utils/WorkerThread.h
326
- - vendor/faiss/utils/distances.cpp
327
- - vendor/faiss/utils/distances.h
328
- - vendor/faiss/utils/distances_simd.cpp
329
- - vendor/faiss/utils/extra_distances.cpp
330
- - vendor/faiss/utils/extra_distances.h
331
- - vendor/faiss/utils/hamming-inl.h
332
- - vendor/faiss/utils/hamming.cpp
333
- - vendor/faiss/utils/hamming.h
334
- - vendor/faiss/utils/random.cpp
335
- - vendor/faiss/utils/random.h
336
- - vendor/faiss/utils/utils.cpp
337
- - vendor/faiss/utils/utils.h
338
339
  homepage: https://github.com/ankane/faiss
339
340
  licenses:
340
341
  - MIT