hnswlib 0.5.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 885313b6fa45e5affa85d537d015b8276d92f361530c9bff8bbf9673990b3665
4
- data.tar.gz: 5eb711a3a8be4fee6142a1f18fc74fd0044bacb381e8acef4ccf839df2ee005a
3
+ metadata.gz: f313f103d9a4a6e6ae92f21cc92a4aaaecd3121e3a2c5be533f87954afb5ac7d
4
+ data.tar.gz: 3b7ec61621c905759f466df1ac76c18a76186a5ef5c84517ada5c1493524ec5c
5
5
  SHA512:
6
- metadata.gz: 552a7b1f43bc0743d059c97e5c57ca3abfcee3d3795619cb40599e4363da24ec832151ed3084d2134c969727d3e41f36b8e3d94c2b2fcb9e6b15752c04ece4d0
7
- data.tar.gz: 8d3f95354ee12f6e75c2258f90c929777a3dac375a09e996c7d772cb8179c75ba816a0ab87a6c7e82250b628e0276d9da4dedc058238d8f4fd390a80b5929e33
6
+ metadata.gz: 12717a35c16fb2ef3f8884fb541559349410e43c9ba35c98de4fbf4a5faa6cd58ffba2cd26ac049ffaea855cf2c4e33f77ffefea023b901cbd8605ada3b63d5c
7
+ data.tar.gz: c134905c5c268313a8a6bfff69567a66ca62e3d2e1a9d133cd87592262994eaf3731ac3b59e1eaed212a9dfa514f2c91b9eceb11f420e6f988d15f9250dbe863
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.5.2] - 2022-02-19
2
+
3
+ - Update bundled hnswlib version to 0.6.2.
4
+
1
5
  ## [0.5.1] - 2022-02-11
2
6
 
3
7
  - Update bundled hnswlib version to 0.6.1.
@@ -10,10 +10,15 @@ namespace hnswlib {
10
10
  for (unsigned i = 0; i < qty; i++) {
11
11
  res += ((float *) pVect1)[i] * ((float *) pVect2)[i];
12
12
  }
13
- return (1.0f - res);
13
+ return res;
14
14
 
15
15
  }
16
16
 
17
+ static float
18
+ InnerProductDistance(const void *pVect1, const void *pVect2, const void *qty_ptr) {
19
+ return 1.0f - InnerProduct(pVect1, pVect2, qty_ptr);
20
+ }
21
+
17
22
  #if defined(USE_AVX)
18
23
 
19
24
  // Favor using AVX if available.
@@ -61,8 +66,13 @@ namespace hnswlib {
61
66
 
62
67
  _mm_store_ps(TmpRes, sum_prod);
63
68
  float sum = TmpRes[0] + TmpRes[1] + TmpRes[2] + TmpRes[3];;
64
- return 1.0f - sum;
65
- }
69
+ return sum;
70
+ }
71
+
72
+ static float
73
+ InnerProductDistanceSIMD4ExtAVX(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
74
+ return 1.0f - InnerProductSIMD4ExtAVX(pVect1v, pVect2v, qty_ptr);
75
+ }
66
76
 
67
77
  #endif
68
78
 
@@ -121,7 +131,12 @@ namespace hnswlib {
121
131
  _mm_store_ps(TmpRes, sum_prod);
122
132
  float sum = TmpRes[0] + TmpRes[1] + TmpRes[2] + TmpRes[3];
123
133
 
124
- return 1.0f - sum;
134
+ return sum;
135
+ }
136
+
137
+ static float
138
+ InnerProductDistanceSIMD4ExtSSE(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
139
+ return 1.0f - InnerProductSIMD4ExtSSE(pVect1v, pVect2v, qty_ptr);
125
140
  }
126
141
 
127
142
  #endif
@@ -156,7 +171,12 @@ namespace hnswlib {
156
171
  _mm512_store_ps(TmpRes, sum512);
157
172
  float sum = TmpRes[0] + TmpRes[1] + TmpRes[2] + TmpRes[3] + TmpRes[4] + TmpRes[5] + TmpRes[6] + TmpRes[7] + TmpRes[8] + TmpRes[9] + TmpRes[10] + TmpRes[11] + TmpRes[12] + TmpRes[13] + TmpRes[14] + TmpRes[15];
158
173
 
159
- return 1.0f - sum;
174
+ return sum;
175
+ }
176
+
177
+ static float
178
+ InnerProductDistanceSIMD16ExtAVX512(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
179
+ return 1.0f - InnerProductSIMD16ExtAVX512(pVect1v, pVect2v, qty_ptr);
160
180
  }
161
181
 
162
182
  #endif
@@ -196,15 +216,20 @@ namespace hnswlib {
196
216
  _mm256_store_ps(TmpRes, sum256);
197
217
  float sum = TmpRes[0] + TmpRes[1] + TmpRes[2] + TmpRes[3] + TmpRes[4] + TmpRes[5] + TmpRes[6] + TmpRes[7];
198
218
 
199
- return 1.0f - sum;
219
+ return sum;
220
+ }
221
+
222
+ static float
223
+ InnerProductDistanceSIMD16ExtAVX(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
224
+ return 1.0f - InnerProductSIMD16ExtAVX(pVect1v, pVect2v, qty_ptr);
200
225
  }
201
226
 
202
227
  #endif
203
228
 
204
229
  #if defined(USE_SSE)
205
230
 
206
- static float
207
- InnerProductSIMD16ExtSSE(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
231
+ static float
232
+ InnerProductSIMD16ExtSSE(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
208
233
  float PORTABLE_ALIGN32 TmpRes[8];
209
234
  float *pVect1 = (float *) pVect1v;
210
235
  float *pVect2 = (float *) pVect2v;
@@ -245,7 +270,12 @@ namespace hnswlib {
245
270
  _mm_store_ps(TmpRes, sum_prod);
246
271
  float sum = TmpRes[0] + TmpRes[1] + TmpRes[2] + TmpRes[3];
247
272
 
248
- return 1.0f - sum;
273
+ return sum;
274
+ }
275
+
276
+ static float
277
+ InnerProductDistanceSIMD16ExtSSE(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
278
+ return 1.0f - InnerProductSIMD16ExtSSE(pVect1v, pVect2v, qty_ptr);
249
279
  }
250
280
 
251
281
  #endif
@@ -253,9 +283,11 @@ namespace hnswlib {
253
283
  #if defined(USE_SSE) || defined(USE_AVX) || defined(USE_AVX512)
254
284
  DISTFUNC<float> InnerProductSIMD16Ext = InnerProductSIMD16ExtSSE;
255
285
  DISTFUNC<float> InnerProductSIMD4Ext = InnerProductSIMD4ExtSSE;
286
+ DISTFUNC<float> InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtSSE;
287
+ DISTFUNC<float> InnerProductDistanceSIMD4Ext = InnerProductDistanceSIMD4ExtSSE;
256
288
 
257
289
  static float
258
- InnerProductSIMD16ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
290
+ InnerProductDistanceSIMD16ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
259
291
  size_t qty = *((size_t *) qty_ptr);
260
292
  size_t qty16 = qty >> 4 << 4;
261
293
  float res = InnerProductSIMD16Ext(pVect1v, pVect2v, &qty16);
@@ -264,11 +296,11 @@ namespace hnswlib {
264
296
 
265
297
  size_t qty_left = qty - qty16;
266
298
  float res_tail = InnerProduct(pVect1, pVect2, &qty_left);
267
- return res + res_tail - 1.0f;
299
+ return 1.0f - (res + res_tail);
268
300
  }
269
301
 
270
302
  static float
271
- InnerProductSIMD4ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
303
+ InnerProductDistanceSIMD4ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
272
304
  size_t qty = *((size_t *) qty_ptr);
273
305
  size_t qty4 = qty >> 2 << 2;
274
306
 
@@ -279,7 +311,7 @@ namespace hnswlib {
279
311
  float *pVect2 = (float *) pVect2v + qty4;
280
312
  float res_tail = InnerProduct(pVect1, pVect2, &qty_left);
281
313
 
282
- return res + res_tail - 1.0f;
314
+ return 1.0f - (res + res_tail);
283
315
  }
284
316
  #endif
285
317
 
@@ -291,30 +323,37 @@ namespace hnswlib {
291
323
  public:
292
324
  InnerProductSpace() : data_size_(0), dim_(0) { }
293
325
  InnerProductSpace(size_t dim) {
294
- fstdistfunc_ = InnerProduct;
326
+ fstdistfunc_ = InnerProductDistance;
295
327
  #if defined(USE_AVX) || defined(USE_SSE) || defined(USE_AVX512)
296
328
  #if defined(USE_AVX512)
297
- if (AVX512Capable())
329
+ if (AVX512Capable()) {
298
330
  InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX512;
299
- else if (AVXCapable())
331
+ InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtAVX512;
332
+ } else if (AVXCapable()) {
300
333
  InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX;
334
+ InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtAVX;
335
+ }
301
336
  #elif defined(USE_AVX)
302
- if (AVXCapable())
337
+ if (AVXCapable()) {
303
338
  InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX;
339
+ InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtAVX;
340
+ }
304
341
  #endif
305
342
  #if defined(USE_AVX)
306
- if (AVXCapable())
343
+ if (AVXCapable()) {
307
344
  InnerProductSIMD4Ext = InnerProductSIMD4ExtAVX;
345
+ InnerProductDistanceSIMD4Ext = InnerProductDistanceSIMD4ExtAVX;
346
+ }
308
347
  #endif
309
348
 
310
349
  if (dim % 16 == 0)
311
- fstdistfunc_ = InnerProductSIMD16Ext;
350
+ fstdistfunc_ = InnerProductDistanceSIMD16Ext;
312
351
  else if (dim % 4 == 0)
313
- fstdistfunc_ = InnerProductSIMD4Ext;
352
+ fstdistfunc_ = InnerProductDistanceSIMD4Ext;
314
353
  else if (dim > 16)
315
- fstdistfunc_ = InnerProductSIMD16ExtResiduals;
354
+ fstdistfunc_ = InnerProductDistanceSIMD16ExtResiduals;
316
355
  else if (dim > 4)
317
- fstdistfunc_ = InnerProductSIMD4ExtResiduals;
356
+ fstdistfunc_ = InnerProductDistanceSIMD4ExtResiduals;
318
357
  #endif
319
358
  dim_ = dim;
320
359
  data_size_ = dim * sizeof(float);
@@ -335,5 +374,4 @@ namespace hnswlib {
335
374
  ~InnerProductSpace() {}
336
375
  };
337
376
 
338
-
339
377
  }
@@ -3,8 +3,8 @@
3
3
  # Hnswlib.rb provides Ruby bindings for the Hnswlib.
4
4
  module Hnswlib
5
5
  # The version of Hnswlib.rb you install.
6
- VERSION = '0.5.1'
6
+ VERSION = '0.5.2'
7
7
 
8
8
  # The version of Hnswlib included with gem.
9
- HSWLIB_VERSION = '0.6.1'
9
+ HSWLIB_VERSION = '0.6.2'
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hnswlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-02-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Hnswlib.rb provides Ruby bindings for the Hnswlib.
14
14
  email:
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.3.3
59
+ rubygems_version: 3.3.7
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Ruby bindings for the Hnswlib.