faiss 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.h +1 -1
- data/vendor/faiss/faiss/Clustering.cpp +35 -4
- data/vendor/faiss/faiss/Clustering.h +10 -1
- data/vendor/faiss/faiss/IVFlib.cpp +4 -1
- data/vendor/faiss/faiss/Index.h +21 -6
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +1 -1
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +1 -1
- data/vendor/faiss/faiss/IndexFastScan.cpp +22 -4
- data/vendor/faiss/faiss/IndexFlat.cpp +11 -7
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +159 -5
- data/vendor/faiss/faiss/IndexFlatCodes.h +20 -3
- data/vendor/faiss/faiss/IndexHNSW.cpp +143 -90
- data/vendor/faiss/faiss/IndexHNSW.h +52 -3
- data/vendor/faiss/faiss/IndexIVF.cpp +3 -3
- data/vendor/faiss/faiss/IndexIVF.h +9 -1
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +15 -0
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +3 -0
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +130 -57
- data/vendor/faiss/faiss/IndexIVFFastScan.h +14 -7
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +1 -3
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +21 -2
- data/vendor/faiss/faiss/IndexLattice.cpp +1 -19
- data/vendor/faiss/faiss/IndexLattice.h +3 -22
- data/vendor/faiss/faiss/IndexNNDescent.cpp +0 -29
- data/vendor/faiss/faiss/IndexNNDescent.h +1 -1
- data/vendor/faiss/faiss/IndexNSG.h +1 -1
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +56 -0
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +49 -0
- data/vendor/faiss/faiss/IndexPreTransform.h +1 -1
- data/vendor/faiss/faiss/IndexRefine.cpp +5 -5
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +3 -1
- data/vendor/faiss/faiss/MetricType.h +7 -2
- data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +95 -17
- data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +152 -0
- data/vendor/faiss/faiss/cppcontrib/factory_tools.h +24 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +83 -30
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +36 -4
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +6 -0
- data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +1 -1
- data/vendor/faiss/faiss/gpu/GpuIndex.h +2 -8
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +282 -0
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +6 -0
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +2 -0
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +25 -0
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +26 -21
- data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +6 -0
- data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +8 -5
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +65 -0
- data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +1 -1
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +6 -0
- data/vendor/faiss/faiss/gpu/utils/Timer.cpp +4 -1
- data/vendor/faiss/faiss/gpu/utils/Timer.h +1 -1
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +25 -0
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +9 -1
- data/vendor/faiss/faiss/impl/DistanceComputer.h +46 -0
- data/vendor/faiss/faiss/impl/FaissAssert.h +4 -2
- data/vendor/faiss/faiss/impl/HNSW.cpp +358 -190
- data/vendor/faiss/faiss/impl/HNSW.h +43 -22
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +8 -8
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +34 -0
- data/vendor/faiss/faiss/impl/NNDescent.cpp +13 -8
- data/vendor/faiss/faiss/impl/NSG.cpp +0 -29
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +1 -0
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +5 -1
- data/vendor/faiss/faiss/impl/ResultHandler.h +151 -32
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +719 -102
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +3 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +5 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +248 -0
- data/vendor/faiss/faiss/impl/index_read.cpp +29 -15
- data/vendor/faiss/faiss/impl/index_read_utils.h +37 -0
- data/vendor/faiss/faiss/impl/index_write.cpp +28 -10
- data/vendor/faiss/faiss/impl/io.cpp +13 -5
- data/vendor/faiss/faiss/impl/io.h +4 -4
- data/vendor/faiss/faiss/impl/io_macros.h +6 -0
- data/vendor/faiss/faiss/impl/platform_macros.h +22 -0
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +11 -0
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +1 -1
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +448 -1
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +5 -5
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +1 -1
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +143 -59
- data/vendor/faiss/faiss/index_factory.cpp +31 -13
- data/vendor/faiss/faiss/index_io.h +12 -5
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +28 -8
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +3 -0
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +9 -1
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +55 -17
- data/vendor/faiss/faiss/invlists/InvertedLists.h +18 -9
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +21 -6
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -1
- data/vendor/faiss/faiss/python/python_callbacks.cpp +3 -3
- data/vendor/faiss/faiss/utils/Heap.h +105 -0
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +342 -0
- data/vendor/faiss/faiss/utils/NeuralNet.h +147 -0
- data/vendor/faiss/faiss/utils/bf16.h +36 -0
- data/vendor/faiss/faiss/utils/distances.cpp +58 -88
- data/vendor/faiss/faiss/utils/distances.h +5 -5
- data/vendor/faiss/faiss/utils/distances_simd.cpp +997 -9
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +70 -0
- data/vendor/faiss/faiss/utils/extra_distances.cpp +85 -137
- data/vendor/faiss/faiss/utils/extra_distances.h +3 -2
- data/vendor/faiss/faiss/utils/hamming.cpp +1 -1
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +4 -1
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +2 -1
- data/vendor/faiss/faiss/utils/random.cpp +43 -0
- data/vendor/faiss/faiss/utils/random.h +25 -0
- data/vendor/faiss/faiss/utils/simdlib.h +10 -1
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +296 -0
- data/vendor/faiss/faiss/utils/simdlib_neon.h +5 -2
- data/vendor/faiss/faiss/utils/simdlib_ppc64.h +1084 -0
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +176 -0
- data/vendor/faiss/faiss/utils/utils.cpp +10 -3
- data/vendor/faiss/faiss/utils/utils.h +3 -0
- metadata +16 -4
- data/vendor/faiss/faiss/impl/code_distance/code_distance_avx512.h +0 -102
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// This file contains transposing kernels for AVX512 for // tiny float/int32
|
|
11
|
+
// matrices, such as 16x2.
|
|
12
|
+
|
|
13
|
+
#ifdef __AVX512F__
|
|
14
|
+
|
|
15
|
+
#include <immintrin.h>
|
|
16
|
+
|
|
17
|
+
namespace faiss {
|
|
18
|
+
|
|
19
|
+
// 16x2 -> 2x16
|
|
20
|
+
inline void transpose_16x2(
|
|
21
|
+
const __m512 i0,
|
|
22
|
+
const __m512 i1,
|
|
23
|
+
__m512& o0,
|
|
24
|
+
__m512& o1) {
|
|
25
|
+
// assume we have the following input:
|
|
26
|
+
// i0: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
27
|
+
// i1: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
28
|
+
|
|
29
|
+
// 0 1 2 3 8 9 10 11 16 17 18 19 24 25 26 27
|
|
30
|
+
const __m512 r0 = _mm512_shuffle_f32x4(i0, i1, _MM_SHUFFLE(2, 0, 2, 0));
|
|
31
|
+
// 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31
|
|
32
|
+
const __m512 r1 = _mm512_shuffle_f32x4(i0, i1, _MM_SHUFFLE(3, 1, 3, 1));
|
|
33
|
+
|
|
34
|
+
// 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
|
|
35
|
+
o0 = _mm512_shuffle_ps(r0, r1, _MM_SHUFFLE(2, 0, 2, 0));
|
|
36
|
+
// 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
|
|
37
|
+
o1 = _mm512_shuffle_ps(r0, r1, _MM_SHUFFLE(3, 1, 3, 1));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 16x4 -> 4x16
|
|
41
|
+
inline void transpose_16x4(
|
|
42
|
+
const __m512 i0,
|
|
43
|
+
const __m512 i1,
|
|
44
|
+
const __m512 i2,
|
|
45
|
+
const __m512 i3,
|
|
46
|
+
__m512& o0,
|
|
47
|
+
__m512& o1,
|
|
48
|
+
__m512& o2,
|
|
49
|
+
__m512& o3) {
|
|
50
|
+
// assume that we have the following input:
|
|
51
|
+
// i0: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
52
|
+
// i1: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
53
|
+
// i2: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
54
|
+
// i3: 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
55
|
+
|
|
56
|
+
// 0 1 2 3 8 9 10 11 16 17 18 19 24 25 26 27
|
|
57
|
+
const __m512 r0 = _mm512_shuffle_f32x4(i0, i1, _MM_SHUFFLE(2, 0, 2, 0));
|
|
58
|
+
// 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31
|
|
59
|
+
const __m512 r1 = _mm512_shuffle_f32x4(i0, i1, _MM_SHUFFLE(3, 1, 3, 1));
|
|
60
|
+
// 32 33 34 35 40 41 42 43 48 49 50 51 56 57 58 59
|
|
61
|
+
const __m512 r2 = _mm512_shuffle_f32x4(i2, i3, _MM_SHUFFLE(2, 0, 2, 0));
|
|
62
|
+
// 52 53 54 55 60 61 62 63 52 53 54 55 60 61 62 63
|
|
63
|
+
const __m512 r3 = _mm512_shuffle_f32x4(i2, i3, _MM_SHUFFLE(3, 1, 3, 1));
|
|
64
|
+
|
|
65
|
+
// 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
|
|
66
|
+
const __m512 t0 = _mm512_shuffle_ps(r0, r1, _MM_SHUFFLE(2, 0, 2, 0));
|
|
67
|
+
// 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
|
|
68
|
+
const __m512 t1 = _mm512_shuffle_ps(r0, r1, _MM_SHUFFLE(3, 1, 3, 1));
|
|
69
|
+
// 32 34 52 54 40 42 60 62 48 50 52 54 56 58 60 62
|
|
70
|
+
const __m512 t2 = _mm512_shuffle_ps(r2, r3, _MM_SHUFFLE(2, 0, 2, 0));
|
|
71
|
+
// 33 35 53 55 41 43 61 63 49 51 53 55 57 59 61 63
|
|
72
|
+
const __m512 t3 = _mm512_shuffle_ps(r2, r3, _MM_SHUFFLE(3, 1, 3, 1));
|
|
73
|
+
|
|
74
|
+
const __m512i idx0 = _mm512_set_epi32(
|
|
75
|
+
30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0);
|
|
76
|
+
const __m512i idx1 = _mm512_set_epi32(
|
|
77
|
+
31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1);
|
|
78
|
+
|
|
79
|
+
// 0 4 8 12 16 20 24 28 32 52 40 60 48 52 56 60
|
|
80
|
+
o0 = _mm512_permutex2var_ps(t0, idx0, t2);
|
|
81
|
+
// 1 5 9 13 17 21 25 29 33 53 41 61 49 53 57 61
|
|
82
|
+
o1 = _mm512_permutex2var_ps(t1, idx0, t3);
|
|
83
|
+
// 2 6 10 14 18 22 26 30 34 54 42 62 50 54 58 62
|
|
84
|
+
o2 = _mm512_permutex2var_ps(t0, idx1, t2);
|
|
85
|
+
// 3 7 11 15 19 23 27 31 35 55 43 63 51 55 59 63
|
|
86
|
+
o3 = _mm512_permutex2var_ps(t1, idx1, t3);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 16x8 -> 8x16 transpose
|
|
90
|
+
inline void transpose_16x8(
|
|
91
|
+
const __m512 i0,
|
|
92
|
+
const __m512 i1,
|
|
93
|
+
const __m512 i2,
|
|
94
|
+
const __m512 i3,
|
|
95
|
+
const __m512 i4,
|
|
96
|
+
const __m512 i5,
|
|
97
|
+
const __m512 i6,
|
|
98
|
+
const __m512 i7,
|
|
99
|
+
__m512& o0,
|
|
100
|
+
__m512& o1,
|
|
101
|
+
__m512& o2,
|
|
102
|
+
__m512& o3,
|
|
103
|
+
__m512& o4,
|
|
104
|
+
__m512& o5,
|
|
105
|
+
__m512& o6,
|
|
106
|
+
__m512& o7) {
|
|
107
|
+
// assume that we have the following input:
|
|
108
|
+
// i0: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
109
|
+
// i1: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
110
|
+
// i2: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
111
|
+
// i3: 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
112
|
+
// i4: 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
113
|
+
// i5: 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
114
|
+
// i6: 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
115
|
+
// i7: 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
116
|
+
|
|
117
|
+
// 0 16 1 17 4 20 5 21 8 24 9 25 12 28 13 29
|
|
118
|
+
const __m512 r0 = _mm512_unpacklo_ps(i0, i1);
|
|
119
|
+
// 2 18 3 19 6 22 7 23 10 26 11 27 14 30 15 31
|
|
120
|
+
const __m512 r1 = _mm512_unpackhi_ps(i0, i1);
|
|
121
|
+
// 32 48 33 49 36 52 37 53 40 56 41 57 44 60 45 61
|
|
122
|
+
const __m512 r2 = _mm512_unpacklo_ps(i2, i3);
|
|
123
|
+
// 34 50 35 51 38 54 39 55 42 58 43 59 46 62 47 63
|
|
124
|
+
const __m512 r3 = _mm512_unpackhi_ps(i2, i3);
|
|
125
|
+
// 64 80 65 81 68 84 69 85 72 88 73 89 76 92 77 93
|
|
126
|
+
const __m512 r4 = _mm512_unpacklo_ps(i4, i5);
|
|
127
|
+
// 66 82 67 83 70 86 71 87 74 90 75 91 78 94 79 95
|
|
128
|
+
const __m512 r5 = _mm512_unpackhi_ps(i4, i5);
|
|
129
|
+
// 96 112 97 113 100 116 101 117 104 120 105 121 108 124 109 125
|
|
130
|
+
const __m512 r6 = _mm512_unpacklo_ps(i6, i7);
|
|
131
|
+
// 98 114 99 115 102 118 103 119 106 122 107 123 110 126 111 127
|
|
132
|
+
const __m512 r7 = _mm512_unpackhi_ps(i6, i7);
|
|
133
|
+
|
|
134
|
+
// 0 16 32 48 4 20 36 52 8 24 40 56 12 28 44 60
|
|
135
|
+
const __m512 t0 = _mm512_shuffle_ps(r0, r2, _MM_SHUFFLE(1, 0, 1, 0));
|
|
136
|
+
// 1 17 33 49 5 21 37 53 9 25 41 57 13 29 45 61
|
|
137
|
+
const __m512 t1 = _mm512_shuffle_ps(r0, r2, _MM_SHUFFLE(3, 2, 3, 2));
|
|
138
|
+
// 2 18 34 50 6 22 38 54 10 26 42 58 14 30 46 62
|
|
139
|
+
const __m512 t2 = _mm512_shuffle_ps(r1, r3, _MM_SHUFFLE(1, 0, 1, 0));
|
|
140
|
+
// 3 19 35 51 7 23 39 55 11 27 43 59 15 31 47 63
|
|
141
|
+
const __m512 t3 = _mm512_shuffle_ps(r1, r3, _MM_SHUFFLE(3, 2, 3, 2));
|
|
142
|
+
// 64 80 96 112 68 84 100 116 72 88 104 120 76 92 108 124
|
|
143
|
+
const __m512 t4 = _mm512_shuffle_ps(r4, r6, _MM_SHUFFLE(1, 0, 1, 0));
|
|
144
|
+
// 65 81 97 113 69 85 101 117 73 89 105 121 77 93 109 125
|
|
145
|
+
const __m512 t5 = _mm512_shuffle_ps(r4, r6, _MM_SHUFFLE(3, 2, 3, 2));
|
|
146
|
+
// 66 82 98 114 70 86 102 118 74 90 106 122 78 94 110 126
|
|
147
|
+
const __m512 t6 = _mm512_shuffle_ps(r5, r7, _MM_SHUFFLE(1, 0, 1, 0));
|
|
148
|
+
// 67 83 99 115 71 87 103 119 75 91 107 123 79 95 111 127
|
|
149
|
+
const __m512 t7 = _mm512_shuffle_ps(r5, r7, _MM_SHUFFLE(3, 2, 3, 2));
|
|
150
|
+
|
|
151
|
+
const __m512i idx0 = _mm512_set_epi32(
|
|
152
|
+
27, 19, 26, 18, 25, 17, 24, 16, 11, 3, 10, 2, 9, 1, 8, 0);
|
|
153
|
+
const __m512i idx1 = _mm512_set_epi32(
|
|
154
|
+
31, 23, 30, 22, 29, 21, 28, 20, 15, 7, 14, 6, 13, 5, 12, 4);
|
|
155
|
+
|
|
156
|
+
// 0 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120
|
|
157
|
+
o0 = _mm512_permutex2var_ps(t0, idx0, t4);
|
|
158
|
+
// 1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121
|
|
159
|
+
o1 = _mm512_permutex2var_ps(t1, idx0, t5);
|
|
160
|
+
// 2 10 18 26 34 42 50 58 66 74 82 90 98 106 114 122
|
|
161
|
+
o2 = _mm512_permutex2var_ps(t2, idx0, t6);
|
|
162
|
+
// 3 11 19 27 35 43 51 59 67 75 83 91 99 107 115 123
|
|
163
|
+
o3 = _mm512_permutex2var_ps(t3, idx0, t7);
|
|
164
|
+
// 4 12 20 28 36 44 52 60 68 76 84 92 100 108 116 124
|
|
165
|
+
o4 = _mm512_permutex2var_ps(t0, idx1, t4);
|
|
166
|
+
// 5 13 21 29 37 45 53 61 69 77 85 93 101 109 117 125
|
|
167
|
+
o5 = _mm512_permutex2var_ps(t1, idx1, t5);
|
|
168
|
+
// 6 14 22 30 38 46 54 62 70 78 86 94 102 110 118 126
|
|
169
|
+
o6 = _mm512_permutex2var_ps(t2, idx1, t6);
|
|
170
|
+
// 7 15 23 31 39 47 55 63 71 79 87 95 103 111 119 127
|
|
171
|
+
o7 = _mm512_permutex2var_ps(t3, idx1, t7);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
} // namespace faiss
|
|
175
|
+
|
|
176
|
+
#endif
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// -*- c++ -*-
|
|
9
9
|
|
|
10
|
+
#include <faiss/Index.h>
|
|
10
11
|
#include <faiss/utils/utils.h>
|
|
11
12
|
|
|
12
13
|
#include <cassert>
|
|
@@ -114,10 +115,12 @@ std::string get_compile_options() {
|
|
|
114
115
|
options += "OPTIMIZE ";
|
|
115
116
|
#endif
|
|
116
117
|
|
|
117
|
-
#ifdef
|
|
118
|
-
options += "AVX2 ";
|
|
119
|
-
#elif __AVX512F__
|
|
118
|
+
#ifdef __AVX512F__
|
|
120
119
|
options += "AVX512 ";
|
|
120
|
+
#elif defined(__AVX2__)
|
|
121
|
+
options += "AVX2 ";
|
|
122
|
+
#elif defined(__ARM_FEATURE_SVE)
|
|
123
|
+
options += "SVE NEON ";
|
|
121
124
|
#elif defined(__aarch64__)
|
|
122
125
|
options += "NEON ";
|
|
123
126
|
#else
|
|
@@ -129,6 +132,10 @@ std::string get_compile_options() {
|
|
|
129
132
|
return options;
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
std::string get_version() {
|
|
136
|
+
return VERSION_STRING;
|
|
137
|
+
}
|
|
138
|
+
|
|
132
139
|
#ifdef _MSC_VER
|
|
133
140
|
double getmillisecs() {
|
|
134
141
|
LARGE_INTEGER ts;
|
|
@@ -37,6 +37,9 @@ std::string get_compile_options();
|
|
|
37
37
|
* Get some stats about the system
|
|
38
38
|
**************************************************/
|
|
39
39
|
|
|
40
|
+
// Expose FAISS version as a string
|
|
41
|
+
std::string get_version();
|
|
42
|
+
|
|
40
43
|
/// ms elapsed since some arbitrary epoch
|
|
41
44
|
double getmillisecs();
|
|
42
45
|
|
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.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rice
|
|
@@ -125,6 +125,8 @@ files:
|
|
|
125
125
|
- vendor/faiss/faiss/IndexNNDescent.h
|
|
126
126
|
- vendor/faiss/faiss/IndexNSG.cpp
|
|
127
127
|
- vendor/faiss/faiss/IndexNSG.h
|
|
128
|
+
- vendor/faiss/faiss/IndexNeuralNetCodec.cpp
|
|
129
|
+
- vendor/faiss/faiss/IndexNeuralNetCodec.h
|
|
128
130
|
- vendor/faiss/faiss/IndexPQ.cpp
|
|
129
131
|
- vendor/faiss/faiss/IndexPQ.h
|
|
130
132
|
- vendor/faiss/faiss/IndexPQFastScan.cpp
|
|
@@ -155,6 +157,8 @@ files:
|
|
|
155
157
|
- vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h
|
|
156
158
|
- vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h
|
|
157
159
|
- vendor/faiss/faiss/cppcontrib/detail/UintReader.h
|
|
160
|
+
- vendor/faiss/faiss/cppcontrib/factory_tools.cpp
|
|
161
|
+
- vendor/faiss/faiss/cppcontrib/factory_tools.h
|
|
158
162
|
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h
|
|
159
163
|
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h
|
|
160
164
|
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h
|
|
@@ -173,6 +177,7 @@ files:
|
|
|
173
177
|
- vendor/faiss/faiss/gpu/GpuIcmEncoder.h
|
|
174
178
|
- vendor/faiss/faiss/gpu/GpuIndex.h
|
|
175
179
|
- vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h
|
|
180
|
+
- vendor/faiss/faiss/gpu/GpuIndexCagra.h
|
|
176
181
|
- vendor/faiss/faiss/gpu/GpuIndexFlat.h
|
|
177
182
|
- vendor/faiss/faiss/gpu/GpuIndexIVF.h
|
|
178
183
|
- vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h
|
|
@@ -247,10 +252,11 @@ files:
|
|
|
247
252
|
- vendor/faiss/faiss/impl/ThreadedIndex-inl.h
|
|
248
253
|
- vendor/faiss/faiss/impl/ThreadedIndex.h
|
|
249
254
|
- vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h
|
|
255
|
+
- vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h
|
|
250
256
|
- vendor/faiss/faiss/impl/code_distance/code_distance-generic.h
|
|
251
257
|
- vendor/faiss/faiss/impl/code_distance/code_distance.h
|
|
252
|
-
- vendor/faiss/faiss/impl/code_distance/code_distance_avx512.h
|
|
253
258
|
- vendor/faiss/faiss/impl/index_read.cpp
|
|
259
|
+
- vendor/faiss/faiss/impl/index_read_utils.h
|
|
254
260
|
- vendor/faiss/faiss/impl/index_write.cpp
|
|
255
261
|
- vendor/faiss/faiss/impl/io.cpp
|
|
256
262
|
- vendor/faiss/faiss/impl/io.h
|
|
@@ -285,6 +291,8 @@ files:
|
|
|
285
291
|
- vendor/faiss/faiss/utils/AlignedTable.h
|
|
286
292
|
- vendor/faiss/faiss/utils/Heap.cpp
|
|
287
293
|
- vendor/faiss/faiss/utils/Heap.h
|
|
294
|
+
- vendor/faiss/faiss/utils/NeuralNet.cpp
|
|
295
|
+
- vendor/faiss/faiss/utils/NeuralNet.h
|
|
288
296
|
- vendor/faiss/faiss/utils/WorkerThread.cpp
|
|
289
297
|
- vendor/faiss/faiss/utils/WorkerThread.h
|
|
290
298
|
- vendor/faiss/faiss/utils/approx_topk/approx_topk.h
|
|
@@ -292,6 +300,7 @@ files:
|
|
|
292
300
|
- vendor/faiss/faiss/utils/approx_topk/generic.h
|
|
293
301
|
- vendor/faiss/faiss/utils/approx_topk/mode.h
|
|
294
302
|
- vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h
|
|
303
|
+
- vendor/faiss/faiss/utils/bf16.h
|
|
295
304
|
- vendor/faiss/faiss/utils/distances.cpp
|
|
296
305
|
- vendor/faiss/faiss/utils/distances.h
|
|
297
306
|
- vendor/faiss/faiss/utils/distances_fused/avx512.cpp
|
|
@@ -326,11 +335,14 @@ files:
|
|
|
326
335
|
- vendor/faiss/faiss/utils/random.h
|
|
327
336
|
- vendor/faiss/faiss/utils/simdlib.h
|
|
328
337
|
- vendor/faiss/faiss/utils/simdlib_avx2.h
|
|
338
|
+
- vendor/faiss/faiss/utils/simdlib_avx512.h
|
|
329
339
|
- vendor/faiss/faiss/utils/simdlib_emulated.h
|
|
330
340
|
- vendor/faiss/faiss/utils/simdlib_neon.h
|
|
341
|
+
- vendor/faiss/faiss/utils/simdlib_ppc64.h
|
|
331
342
|
- vendor/faiss/faiss/utils/sorting.cpp
|
|
332
343
|
- vendor/faiss/faiss/utils/sorting.h
|
|
333
344
|
- vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h
|
|
345
|
+
- vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h
|
|
334
346
|
- vendor/faiss/faiss/utils/utils.cpp
|
|
335
347
|
- vendor/faiss/faiss/utils/utils.h
|
|
336
348
|
homepage: https://github.com/ankane/faiss-ruby
|
|
@@ -352,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
352
364
|
- !ruby/object:Gem::Version
|
|
353
365
|
version: '0'
|
|
354
366
|
requirements: []
|
|
355
|
-
rubygems_version: 3.5.
|
|
367
|
+
rubygems_version: 3.5.16
|
|
356
368
|
signing_key:
|
|
357
369
|
specification_version: 4
|
|
358
370
|
summary: Efficient similarity search and clustering for Ruby
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// // // AVX-512 version. It is not used, but let it be for the future
|
|
9
|
-
// // // needs.
|
|
10
|
-
// // template <class SearchResultType, typename T = PQDecoder>
|
|
11
|
-
// // typename std::enable_if<(std::is_same<T, PQDecoder8>::value), void>::
|
|
12
|
-
// // type distance_four_codes(
|
|
13
|
-
// // const uint8_t* __restrict code0,
|
|
14
|
-
// // const uint8_t* __restrict code1,
|
|
15
|
-
// // const uint8_t* __restrict code2,
|
|
16
|
-
// // const uint8_t* __restrict code3,
|
|
17
|
-
// // float& result0,
|
|
18
|
-
// // float& result1,
|
|
19
|
-
// // float& result2,
|
|
20
|
-
// // float& result3
|
|
21
|
-
// // ) const {
|
|
22
|
-
// // result0 = 0;
|
|
23
|
-
// // result1 = 0;
|
|
24
|
-
// // result2 = 0;
|
|
25
|
-
// // result3 = 0;
|
|
26
|
-
|
|
27
|
-
// // size_t m = 0;
|
|
28
|
-
// // const size_t pqM16 = pq.M / 16;
|
|
29
|
-
|
|
30
|
-
// // constexpr intptr_t N = 4;
|
|
31
|
-
|
|
32
|
-
// // const float* tab = sim_table;
|
|
33
|
-
|
|
34
|
-
// // if (pqM16 > 0) {
|
|
35
|
-
// // // process 16 values per loop
|
|
36
|
-
// // const __m512i ksub = _mm512_set1_epi32(pq.ksub);
|
|
37
|
-
// // __m512i offsets_0 = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7,
|
|
38
|
-
// // 8, 9, 10, 11, 12, 13, 14, 15);
|
|
39
|
-
// // offsets_0 = _mm512_mullo_epi32(offsets_0, ksub);
|
|
40
|
-
|
|
41
|
-
// // // accumulators of partial sums
|
|
42
|
-
// // __m512 partialSums[N];
|
|
43
|
-
// // for (intptr_t j = 0; j < N; j++) {
|
|
44
|
-
// // partialSums[j] = _mm512_setzero_ps();
|
|
45
|
-
// // }
|
|
46
|
-
|
|
47
|
-
// // // loop
|
|
48
|
-
// // for (m = 0; m < pqM16 * 16; m += 16) {
|
|
49
|
-
// // // load 16 uint8 values
|
|
50
|
-
// // __m128i mm1[N];
|
|
51
|
-
// // mm1[0] = _mm_loadu_si128((const __m128i_u*)(code0 + m));
|
|
52
|
-
// // mm1[1] = _mm_loadu_si128((const __m128i_u*)(code1 + m));
|
|
53
|
-
// // mm1[2] = _mm_loadu_si128((const __m128i_u*)(code2 + m));
|
|
54
|
-
// // mm1[3] = _mm_loadu_si128((const __m128i_u*)(code3 + m));
|
|
55
|
-
|
|
56
|
-
// // // process first 8 codes
|
|
57
|
-
// // for (intptr_t j = 0; j < N; j++) {
|
|
58
|
-
// // // convert uint8 values (low part of __m128i) to int32
|
|
59
|
-
// // // values
|
|
60
|
-
// // const __m512i idx1 = _mm512_cvtepu8_epi32(mm1[j]);
|
|
61
|
-
|
|
62
|
-
// // // add offsets
|
|
63
|
-
// // const __m512i indices_to_read_from =
|
|
64
|
-
// // _mm512_add_epi32(idx1, offsets_0);
|
|
65
|
-
|
|
66
|
-
// // // gather 8 values, similar to 8 operations of
|
|
67
|
-
// // // tab[idx]
|
|
68
|
-
// // __m512 collected =
|
|
69
|
-
// // _mm512_i32gather_ps(
|
|
70
|
-
// // indices_to_read_from, tab, sizeof(float));
|
|
71
|
-
|
|
72
|
-
// // // collect partial sums
|
|
73
|
-
// // partialSums[j] = _mm512_add_ps(partialSums[j],
|
|
74
|
-
// // collected);
|
|
75
|
-
// // }
|
|
76
|
-
// // tab += pq.ksub * 16;
|
|
77
|
-
|
|
78
|
-
// // }
|
|
79
|
-
|
|
80
|
-
// // // horizontal sum for partialSum
|
|
81
|
-
// // result0 += _mm512_reduce_add_ps(partialSums[0]);
|
|
82
|
-
// // result1 += _mm512_reduce_add_ps(partialSums[1]);
|
|
83
|
-
// // result2 += _mm512_reduce_add_ps(partialSums[2]);
|
|
84
|
-
// // result3 += _mm512_reduce_add_ps(partialSums[3]);
|
|
85
|
-
// // }
|
|
86
|
-
|
|
87
|
-
// // //
|
|
88
|
-
// // if (m < pq.M) {
|
|
89
|
-
// // // process leftovers
|
|
90
|
-
// // PQDecoder decoder0(code0 + m, pq.nbits);
|
|
91
|
-
// // PQDecoder decoder1(code1 + m, pq.nbits);
|
|
92
|
-
// // PQDecoder decoder2(code2 + m, pq.nbits);
|
|
93
|
-
// // PQDecoder decoder3(code3 + m, pq.nbits);
|
|
94
|
-
// // for (; m < pq.M; m++) {
|
|
95
|
-
// // result0 += tab[decoder0.decode()];
|
|
96
|
-
// // result1 += tab[decoder1.decode()];
|
|
97
|
-
// // result2 += tab[decoder2.decode()];
|
|
98
|
-
// // result3 += tab[decoder3.decode()];
|
|
99
|
-
// // tab += pq.ksub;
|
|
100
|
-
// // }
|
|
101
|
-
// // }
|
|
102
|
-
// // }
|