usearch 2.7.3 → 2.7.6

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.
Files changed (55) hide show
  1. package/.github/workflows/Dockerfile.libs +4 -6
  2. package/.github/workflows/prerelease.yml +4 -1
  3. package/.github/workflows/release.yml +8 -28
  4. package/.github/workflows/update_version.sh +1 -0
  5. package/CITATION.cff +2 -2
  6. package/CMakeLists.txt +1 -1
  7. package/Cargo.toml +1 -1
  8. package/README.md +4 -4
  9. package/binding.gyp +1 -1
  10. package/build.gradle +20 -5
  11. package/conanfile.py +1 -1
  12. package/csharp/nuget/nuget-package.props +1 -1
  13. package/docs/compilation.md +0 -2
  14. package/golang/README.md +0 -1
  15. package/include/usearch/index.hpp +1 -1
  16. package/include/usearch/index_plugins.hpp +119 -243
  17. package/package.json +1 -1
  18. package/simsimd/.github/workflows/prerelease.yml +33 -58
  19. package/simsimd/.github/workflows/release.yml +22 -9
  20. package/simsimd/.github/workflows/update_version.sh +3 -1
  21. package/simsimd/.releaserc +9 -1
  22. package/simsimd/.vscode/launch.json +3 -0
  23. package/simsimd/.vscode/settings.json +15 -2
  24. package/simsimd/.vscode/tasks.json +2 -2
  25. package/simsimd/CMakeLists.txt +36 -55
  26. package/simsimd/README.md +163 -109
  27. package/simsimd/binding.gyp +18 -0
  28. package/simsimd/cpp/bench.cxx +187 -0
  29. package/simsimd/go.mod +3 -0
  30. package/simsimd/golang/bench_test.go +40 -0
  31. package/simsimd/golang/simsimd.go +47 -0
  32. package/simsimd/golang/unit_test.go +40 -0
  33. package/simsimd/include/simsimd/binary.h +186 -0
  34. package/simsimd/include/simsimd/probability.h +645 -0
  35. package/simsimd/include/simsimd/simsimd.h +335 -575
  36. package/simsimd/include/simsimd/spatial.h +924 -0
  37. package/simsimd/include/simsimd/types.h +196 -0
  38. package/simsimd/javascript/bench.js +117 -0
  39. package/simsimd/javascript/lib.c +102 -0
  40. package/simsimd/javascript/simsimd.js +45 -0
  41. package/simsimd/javascript/test.js +29 -0
  42. package/simsimd/package.json +31 -2
  43. package/simsimd/pyproject.toml +5 -6
  44. package/simsimd/python/bench.ipynb +187 -0
  45. package/simsimd/python/bench.py +268 -0
  46. package/simsimd/python/lib.c +453 -72
  47. package/simsimd/python/test.py +167 -35
  48. package/simsimd/setup.py +51 -8
  49. package/wasmer.toml +1 -1
  50. package/simsimd/bench.cxx +0 -137
  51. package/simsimd/include/simsimd/simsimd_bio.h +0 -54
  52. package/simsimd/include/simsimd/simsimd_chem.h +0 -167
  53. package/simsimd/include/simsimd/simsimd_text.h +0 -92
  54. package/simsimd/python/run.sh +0 -1
  55. package/simsimd/python/test.c +0 -109
@@ -1,92 +0,0 @@
1
- /**
2
- * @brief Collection of Biology-oriented Similarity Measures, SIMD-accelerated with SSE, AVX, NEON, SVE.
3
- *
4
- * @author Ash Vardanian
5
- * @date August 8, 2023
6
- */
7
-
8
- #pragma once
9
-
10
- #include <simsimd/simsimd_chem.h>
11
-
12
- #ifdef _MSC_VER
13
- #define hash32
14
- #define hash64
15
- #else
16
- #define hash32
17
- #define hash64
18
- #endif
19
-
20
- #ifdef __cplusplus
21
- extern "C" {
22
- #endif
23
-
24
- inline static void simsimd_4gram_hash_string( //
25
- char const* chars, size_t chars_length, //
26
- uint8_t* hash, size_t hash_length) {
27
-
28
- // Skip misaligned addresses in a naive fashion
29
- char const* const chars_end = chars + chars_length;
30
- for (; uintptr_t(chars) % 4 && chars != chars_end; ++chars) {
31
- uint32_t word;
32
- memcpy(&word, chars, 4);
33
- hash;
34
- }
35
-
36
- uint32_t last_word = *a_chars;
37
-
38
- for (size_t i = 0; i + 8 <= a_length; i += 8) {
39
- uint32_t new_word = *a_chars;
40
-
41
- size_t hash_first = hash(last_word);
42
- size_t hash_second = hash((last_word << 8) | (new_word >> 24));
43
- size_t hash_third = hash((last_word << 16) | (new_word >> 16));
44
- size_t hash_fourth = hash((last_word << 16) | (new_word >> 16));
45
-
46
- uint64_t a_word;
47
- memcpy(&a_word, a_chars, 8);
48
- }
49
- }
50
-
51
- /**
52
- * @brief Similarity measure for different length strings, that compares them
53
- * by hashing the N-grams first and computing the Tenimoto distance of
54
- * hashes.
55
- *
56
- * By design uses a separate bit-set for every string. Those have to be of identical
57
- * length derived from `l = max(a_length, b_length)`, as `(l + N - 1) * 2` for any
58
- * N-gram, to have less than half of bits populated.
59
- *
60
- * Inspired by Rabin-Karp algorithm, and continues the approaches implemented in Stringzilla.
61
- */
62
- inline static simsimd_f32_t simsimd_4gram_hashes_naive( //
63
- uint8_t const* a_chars, uint8_t const* b_chars, //
64
- size_t a_length, size_t b_length, //
65
- uint8_t* a_hash, uint8_t* b_hash, size_t length_hash) {
66
-
67
- // Skip thrrough misaligned part
68
-
69
- uint32_t last_word = *a_chars;
70
-
71
- for (size_t i = 0; i + 8 <= a_length; i += 8) {
72
- uint32_t new_word = *a_chars;
73
-
74
- size_t hash_first = hash(last_word);
75
- size_t hash_second = hash((last_word << 8) | (new_word >> 24));
76
- size_t hash_third = hash((last_word << 16) | (new_word >> 16));
77
- size_t hash_fourth = hash((last_word << 16) | (new_word >> 16));
78
-
79
- uint64_t a_word;
80
- memcpy(&a_word, a_chars, 8);
81
- }
82
-
83
- size_t b_words = (b_length + 7) / 8;
84
-
85
- return simsimd_tanimoto_b1x8_naive(a_hash, b_hash, length_hash);
86
- }
87
-
88
- #undef popcount64
89
-
90
- #ifdef __cplusplus
91
- }
92
- #endif
@@ -1 +0,0 @@
1
- pip install --upgrade --force-reinstall . && pytest --capture=no python/tests/
@@ -1,109 +0,0 @@
1
- #include <stdio.h>
2
-
3
- #define PY_SSIZE_T_CLEAN
4
- #include <Python.h>
5
-
6
- #include "simsimd/simsimd.h"
7
-
8
- #define stringify_value_m(a) stringify_m(a)
9
- #define stringify_m(a) #a
10
- #define concat_m(A, B) A##B
11
- #define macro_concat_m(A, B) concat_m(A, B)
12
- #define pyinit_f_m macro_concat_m(PyInit_, SIMDSIMD_PYTHON_MODULE_NAME)
13
-
14
- char const* names[14] = {
15
- "dot_f32_sve", "cos_f32_sve", "l2sq_f32_sve", "cos_f32x4_avx2", "cos_f32x4_neon",
16
- "dot_f32x4_neon", "cos_f16x4_neon", "cos_f16x16_avx512", "l2sq_f16_sve", "cos_i8x16_neon",
17
- "dot_i8x16_avx2", "hamming_b1x8_sve", "hamming_b1x128_sve", "hamming_b1x128_avx512",
18
- };
19
- void* callables[14] = {NULL};
20
-
21
- void assign(size_t idx, void* function) { callables[idx] = function; }
22
-
23
- typedef simsimd_f32_t (*function_f32_t)(simsimd_f32_t*, simsimd_f32_t*, size_t);
24
- typedef simsimd_f32_t (*function_f32x16_t)(simsimd_f16_t*, simsimd_f16_t*, size_t);
25
- typedef simsimd_f16_t (*function_f16_t)(simsimd_f16_t*, simsimd_f16_t*, size_t);
26
- typedef simsimd_f32_t (*function_fi8_t)(int8_t*, int8_t*, size_t);
27
- typedef int32_t (*function_i8_t)(int8_t*, int8_t*, size_t);
28
- typedef size_t (*function_ui8_t)(uint8_t*, uint8_t*, size_t);
29
-
30
- int main(int argc, char* argv[]) {
31
- Py_Initialize();
32
- PyObject* module = PyImport_ImportModule("simsimd");
33
- PyErr_Print();
34
- if (module == NULL)
35
- return -1;
36
-
37
- PyObject* dictionary = PyModule_GetDict(module);
38
- PyObject *key, *value;
39
- Py_ssize_t pos = 0;
40
-
41
- size_t idx = 0;
42
- while (PyDict_Next(dictionary, &pos, &key, &value)) {
43
- if (PyCapsule_CheckExact(value)) {
44
- char const* name = PyCapsule_GetName(value);
45
- void* pointer = PyCapsule_GetPointer(value, NULL);
46
- assign(idx, pointer);
47
- ++idx;
48
- }
49
- }
50
-
51
- size_t d = 3;
52
- {
53
- simsimd_f32_t a[] = {1, 2, 3};
54
- simsimd_f32_t b[] = {4, 5, 6};
55
- for (idx = 0; idx < 6; ++idx) {
56
- function_f32_t function = (function_f32_t)callables[idx];
57
- simsimd_f32_t result = function(a, b, d);
58
- printf("%f\n", result);
59
- }
60
- }
61
-
62
- {
63
- simsimd_f16_t a[] = {1, 2, 3};
64
- simsimd_f16_t b[] = {4, 5, 6};
65
- function_f32x16_t function = (function_f32x16_t)callables[6];
66
- simsimd_f32_t result = function(a, b, d);
67
- printf("%f\n", result);
68
- function = (function_f32x16_t)callables[7];
69
- result = function(a, b, d);
70
- printf("%f\n", result);
71
- }
72
-
73
- {
74
- simsimd_f16_t a[] = {1, 2, 3};
75
- simsimd_f16_t b[] = {4, 5, 6};
76
- function_f16_t function = (function_f16_t)callables[8];
77
- simsimd_f16_t result = function(a, b, d);
78
- printf("%i\n", result);
79
- }
80
-
81
- {
82
- int8_t a[] = {1, 2, 3};
83
- int8_t b[] = {4, 5, 6};
84
- function_fi8_t function = (function_fi8_t)callables[9];
85
- simsimd_f32_t result = function(a, b, d);
86
- printf("%f\n", result);
87
- }
88
-
89
- {
90
- int8_t a[] = {1, 2, 3};
91
- int8_t b[] = {4, 5, 6};
92
- function_i8_t function = (function_i8_t)callables[10];
93
- int32_t result = function(a, b, d);
94
- printf("%i\n", result);
95
- }
96
-
97
- {
98
- uint8_t a[] = {1, 2, 3};
99
- uint8_t b[] = {4, 5, 6};
100
- for (idx = 11; idx < 14; ++idx) {
101
- function_ui8_t function = (function_ui8_t)callables[idx];
102
- size_t result = function(a, b, d);
103
- printf("%zu\n", result);
104
- }
105
- }
106
-
107
- Py_DECREF(module);
108
- return 0;
109
- }