usearch 2.15.3 → 2.16.1
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.
- package/README.md +1 -1
- package/cpp/test.cpp +16 -0
- package/include/usearch/index.hpp +21 -5
- package/include/usearch/index_dense.hpp +6 -1
- package/include/usearch/index_plugins.hpp +345 -8
- package/javascript/lib.cpp +17 -5
- package/javascript/usearch.test.js +190 -21
- package/package.json +1 -1
- package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
- package/prebuilds/linux-arm64/usearch.node +0 -0
- package/prebuilds/linux-x64/usearch.node +0 -0
- package/simsimd/.git-blame-ignore-revs +2 -0
- package/simsimd/CONTRIBUTING.md +71 -23
- package/simsimd/Cargo.lock +1 -1
- package/simsimd/Cargo.toml +4 -4
- package/simsimd/MANIFEST.in +2 -1
- package/simsimd/Package.swift +15 -3
- package/simsimd/README.md +104 -35
- package/simsimd/binding.gyp +6 -2
- package/simsimd/build.rs +2 -0
- package/simsimd/c/lib.c +180 -99
- package/simsimd/include/simsimd/binary.h +311 -102
- package/simsimd/include/simsimd/curved.h +134 -135
- package/simsimd/include/simsimd/dot.h +448 -274
- package/simsimd/include/simsimd/elementwise.h +1437 -0
- package/simsimd/include/simsimd/geospatial.h +2 -2
- package/simsimd/include/simsimd/mesh.h +2 -2
- package/simsimd/include/simsimd/probability.h +88 -88
- package/simsimd/include/simsimd/simsimd.h +1157 -772
- package/simsimd/include/simsimd/sparse.h +768 -147
- package/simsimd/include/simsimd/spatial.h +955 -376
- package/simsimd/include/simsimd/types.h +145 -71
- package/simsimd/javascript/lib.c +1 -2
- package/simsimd/package.json +4 -4
- package/simsimd/rust/lib.rs +14 -1
- package/simsimd/scripts/bench.cxx +1070 -0
- package/simsimd/scripts/bench.ipynb +187 -0
- package/simsimd/{javascript → scripts}/bench.js +1 -1
- package/simsimd/{rust/benches/sqeuclidean.rs → scripts/bench_sqeuclidean.rs} +6 -6
- package/simsimd/scripts/bench_vectors.py +700 -0
- package/simsimd/scripts/bench_vectors_live.py +213 -0
- package/simsimd/scripts/test.c +155 -0
- package/simsimd/{javascript → scripts}/test.mjs +2 -2
- package/simsimd/scripts/test.py +1410 -0
- package/simsimd/swift/{source/SimSIMD.swift → SimSIMD.swift} +6 -2
- package/simsimd/swift/{tests/SimSIMDTests.swift → Test.swift} +1 -1
- /package/simsimd/{rust/benches/cosine.rs → scripts/bench_cosine.rs} +0 -0
- /package/simsimd/{rust/benches/native.rs → scripts/bench_native.rs} +0 -0
package/simsimd/README.md
CHANGED
|
@@ -42,8 +42,8 @@ SimSIMD provides an alternative.
|
|
|
42
42
|
|
|
43
43
|
## Features
|
|
44
44
|
|
|
45
|
-
__SimSIMD__ (Arabic: "سيمسيم دي") is a library of __over 200 SIMD-optimized kernels__
|
|
46
|
-
Named after the iconic ["Open Sesame"](https://en.wikipedia.org/wiki/Open_sesame) command
|
|
45
|
+
__SimSIMD__ (Arabic: "سيمسيم دي") is a mixed-precision math library of __over 200 SIMD-optimized kernels__ extensively used in AI, Search, and DBMS workloads.
|
|
46
|
+
Named after the iconic ["Open Sesame"](https://en.wikipedia.org/wiki/Open_sesame) command that opened doors to treasure in _Ali Baba and the Forty Thieves_, SimSimd can help you 10x the cost-efficiency of your computational pipelines.
|
|
47
47
|
Implemented distance functions include:
|
|
48
48
|
|
|
49
49
|
- Euclidean (L2) and Cosine (Angular) spatial distances for Vector Search. _[docs][docs-spatial]_
|
|
@@ -52,6 +52,7 @@ Implemented distance functions include:
|
|
|
52
52
|
- Set Intersections for Sparse Vectors and Text Analysis. _[docs][docs-sparse]_
|
|
53
53
|
- Mahalanobis distance and Quadratic forms for Scientific Computing. _[docs][docs-curved]_
|
|
54
54
|
- Kullback-Leibler and Jensen–Shannon divergences for probability distributions. _[docs][docs-probability]_
|
|
55
|
+
- Fused-Multiply-Add (FMA) and Weighted Sums to replace BLAS level 1 functions. _[docs][docs-fma]_
|
|
55
56
|
- For Levenshtein, Needleman–Wunsch, and Smith-Waterman, check [StringZilla][stringzilla].
|
|
56
57
|
- 🔜 Haversine and Vincenty's formulae for Geospatial Analysis.
|
|
57
58
|
|
|
@@ -61,6 +62,7 @@ Implemented distance functions include:
|
|
|
61
62
|
[docs-binary]: https://github.com/ashvardanian/SimSIMD/pull/138
|
|
62
63
|
[docs-dot]: #complex-dot-products-conjugate-dot-products-and-complex-numbers
|
|
63
64
|
[docs-probability]: #logarithms-in-kullback-leibler--jensenshannon-divergences
|
|
65
|
+
[docs-fma]: #mixed-precision-in-fused-multiply-add-and-weighted-sums
|
|
64
66
|
[scipy]: https://docs.scipy.org/doc/scipy/reference/spatial.distance.html#module-scipy.spatial.distance
|
|
65
67
|
[numpy]: https://numpy.org/doc/stable/reference/generated/numpy.inner.html
|
|
66
68
|
[stringzilla]: https://github.com/ashvardanian/stringzilla
|
|
@@ -68,9 +70,10 @@ Implemented distance functions include:
|
|
|
68
70
|
Moreover, SimSIMD...
|
|
69
71
|
|
|
70
72
|
- handles `f64`, `f32`, `f16`, and `bf16` real & complex vectors.
|
|
71
|
-
- handles `i8` integral and `b8`
|
|
73
|
+
- handles `i8` integral, `i4` sub-byte, and `b8` binary vectors.
|
|
74
|
+
- handles sparse `u32` and `u16` sets, and weighted sparse vectors.
|
|
72
75
|
- is a zero-dependency [header-only C 99](#using-simsimd-in-c) library.
|
|
73
|
-
- has
|
|
76
|
+
- has [Python](#using-simsimd-in-python), [Rust](#using-simsimd-in-rust), [JS](#using-simsimd-in-javascript), and [Swift](#using-simsimd-in-swift) bindings.
|
|
74
77
|
- has Arm backends for NEON, Scalable Vector Extensions (SVE), and SVE2.
|
|
75
78
|
- has x86 backends for Haswell, Skylake, Ice Lake, Genoa, and Sapphire Rapids.
|
|
76
79
|
- with both compile-time and runtime CPU feature detection easily integrates anywhere!
|
|
@@ -89,40 +92,30 @@ You can learn more about the technical implementation details in the following b
|
|
|
89
92
|
|
|
90
93
|
## Benchmarks
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
For reference, we use 1536-dimensional vectors, like the embeddings produced by the OpenAI Ada API.
|
|
96
|
+
Comparing the serial code throughput produced by GCC 12 to hand-optimized kernels in SimSIMD, we see the following single-core improvements for the two most common vector-vector similarity metrics - the Cosine similarity and the Euclidean distance:
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
| Type | Apple M2 Pro | Intel Sapphire Rapids | AWS Graviton 4 |
|
|
99
|
+
| :----- | ----------------------------: | -------------------------------: | ------------------------------: |
|
|
100
|
+
| `f64` | 18.5 → 28.8 GB/s <br/> + 56 % | 21.9 → 41.4 GB/s <br/> + 89 % | 20.7 → 41.3 GB/s <br/> + 99 % |
|
|
101
|
+
| `f32` | 9.2 → 29.6 GB/s <br/> + 221 % | 10.9 → 95.8 GB/s <br/> + 779 % | 4.9 → 41.9 GB/s <br/> + 755 % |
|
|
102
|
+
| `f16` | 4.6 → 14.6 GB/s <br/> + 217 % | 3.1 → 108.4 GB/s <br/> + 3,397 % | 5.4 → 39.3 GB/s <br/> + 627 % |
|
|
103
|
+
| `bf16` | 4.6 → 26.3 GB/s <br/> + 472 % | 0.8 → 59.5 GB/s <br/> +7,437 % | 2.5 → 29.9 GB/s <br/> + 1,096 % |
|
|
104
|
+
| `i8` | 25.8 → 47.1 GB/s <br/> + 83 % | 33.1 → 65.3 GB/s <br/> + 97 % | 35.2 → 43.5 GB/s <br/> + 24 % |
|
|
105
|
+
| `u8` | | 32.5 → 66.5 GB/s <br/> + 105 % | |
|
|
95
106
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
| Inner (Dot) Product | __2 x__ | __9 x__ | __18 x__ | `numpy.inner` | `inner` |
|
|
99
|
-
| Cosine Distance | __32 x__ | __79 x__ | __133 x__ | `scipy.*.*.cosine` | `cosine` |
|
|
100
|
-
| Euclidean Distance ² | __5 x__ | __26 x__ | __17 x__ | `scipy.*.*.sqeuclidean` | `sqeuclidean` |
|
|
101
|
-
| Jensen-Shannon Divergence | __31 x__ | __53 x__ | | `scipy.*.*.jensenshannon` | `jensenshannon` |
|
|
102
|
-
|
|
103
|
-
### Against GCC Auto-Vectorization
|
|
104
|
-
|
|
105
|
-
On the Intel Sapphire Rapids platform, SimSIMD was benchmarked against auto-vectorized code using GCC 12.
|
|
106
|
-
GCC handles single-precision `float` but might not be the best choice for `int8` and `_Float16` arrays, which have been part of the C language since 2011.
|
|
107
|
-
|
|
108
|
-
| Kind | GCC 12 `f32` | GCC 12 `f16` | SimSIMD `f16` | `f16` improvement |
|
|
109
|
-
| :------------------------ | -----------: | -----------: | ------------: | ----------------: |
|
|
110
|
-
| Inner Product | 3,810 K/s | 192 K/s | 5,990 K/s | __31 x__ |
|
|
111
|
-
| Cosine Distance | 3,280 K/s | 336 K/s | 6,880 K/s | __20 x__ |
|
|
112
|
-
| Euclidean Distance ² | 4,620 K/s | 147 K/s | 5,320 K/s | __36 x__ |
|
|
113
|
-
| Jensen-Shannon Divergence | 1,180 K/s | 18 K/s | 2,140 K/s | __118 x__ |
|
|
114
|
-
|
|
115
|
-
__Broader Benchmarking Results__:
|
|
107
|
+
Similar speedups are often observed even when compared to BLAS and LAPACK libraries underlying most numerical computing libraries, including NumPy and SciPy in Python.
|
|
108
|
+
Broader benchmarking results:
|
|
116
109
|
|
|
117
110
|
- [Apple M2 Pro](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-1-performance-on-apple-m2-pro).
|
|
118
|
-
- [
|
|
111
|
+
- [Intel Sapphire Rapids](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-2-performance-on-4th-gen-intel-xeon-platinum-8480).
|
|
119
112
|
- [AWS Graviton 3](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-3-performance-on-aws-graviton-3).
|
|
120
113
|
|
|
121
114
|
## Using SimSIMD in Python
|
|
122
115
|
|
|
123
116
|
The package is intended to replace the usage of `numpy.inner`, `numpy.dot`, and `scipy.spatial.distance`.
|
|
124
117
|
Aside from drastic performance improvements, SimSIMD significantly improves accuracy in mixed precision setups.
|
|
125
|
-
NumPy and SciPy, processing `i8` or `f16` vectors, will use the same types for accumulators, while SimSIMD can combine `i8` enumeration, `i16` multiplication, and `i32` accumulation to avoid overflows entirely.
|
|
118
|
+
NumPy and SciPy, processing `i8`, `u8` or `f16` vectors, will use the same types for accumulators, while SimSIMD can combine `i8` enumeration, `i16` multiplication, and `i32` accumulation to avoid overflows entirely.
|
|
126
119
|
The same applies to processing `f16` and `bf16` values with `f32` precision.
|
|
127
120
|
|
|
128
121
|
### Installation
|
|
@@ -131,7 +124,8 @@ Use the following snippet to install SimSIMD and list available hardware acceler
|
|
|
131
124
|
|
|
132
125
|
```sh
|
|
133
126
|
pip install simsimd
|
|
134
|
-
python -c "import simsimd; print(simsimd.get_capabilities())"
|
|
127
|
+
python -c "import simsimd; print(simsimd.get_capabilities())" # for hardware introspection
|
|
128
|
+
python -c "import simsimd; help(simsimd)" # for documentation
|
|
135
129
|
```
|
|
136
130
|
|
|
137
131
|
With precompiled binaries, SimSIMD ships `.pyi` interface files for type hinting and static analysis.
|
|
@@ -272,7 +266,7 @@ A common case may be avoiding AVX-512 on older AMD CPUs and [Intel Ice Lake](htt
|
|
|
272
266
|
|
|
273
267
|
```py
|
|
274
268
|
$ simsimd.get_capabilities()
|
|
275
|
-
> {'serial': True, 'neon': False, 'sve': False, 'neon_f16': False, 'sve_f16': False, 'neon_bf16': False, 'sve_bf16': False, 'neon_i8': False, 'sve_i8': False, 'haswell': True, 'skylake': True, 'ice': True, 'genoa': True, 'sapphire': True}
|
|
269
|
+
> {'serial': True, 'neon': False, 'sve': False, 'neon_f16': False, 'sve_f16': False, 'neon_bf16': False, 'sve_bf16': False, 'neon_i8': False, 'sve_i8': False, 'haswell': True, 'skylake': True, 'ice': True, 'genoa': True, 'sapphire': True, 'turin': True}
|
|
276
270
|
$ simsimd.disable_capability("sapphire")
|
|
277
271
|
$ simsimd.enable_capability("sapphire")
|
|
278
272
|
```
|
|
@@ -480,6 +474,7 @@ println!("uses skylake: {}", capabilities::uses_skylake());
|
|
|
480
474
|
println!("uses ice: {}", capabilities::uses_ice());
|
|
481
475
|
println!("uses genoa: {}", capabilities::uses_genoa());
|
|
482
476
|
println!("uses sapphire: {}", capabilities::uses_sapphire());
|
|
477
|
+
println!("uses turin: {}", capabilities::uses_turin());
|
|
483
478
|
```
|
|
484
479
|
|
|
485
480
|
## Using SimSIMD in JavaScript
|
|
@@ -535,6 +530,29 @@ const binaryVectorB = toBinary(vectorB);
|
|
|
535
530
|
const distance = hamming(binaryVectorA, binaryVectorB);
|
|
536
531
|
```
|
|
537
532
|
|
|
533
|
+
## Using SimSIMD in Sift
|
|
534
|
+
|
|
535
|
+
To install, simply add the following dependency to you `Package.swift`:
|
|
536
|
+
|
|
537
|
+
```swift
|
|
538
|
+
dependencies: [
|
|
539
|
+
.package(url: "https://github.com/ashvardanian/simsimd")
|
|
540
|
+
]
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
The package provides the most common spatial metrics for `Int8`, `Float16`, `Float32`, and `Float64` vectors.
|
|
544
|
+
|
|
545
|
+
```swift
|
|
546
|
+
import SimSIMD
|
|
547
|
+
|
|
548
|
+
let vectorA: [Int8] = [1, 2, 3]
|
|
549
|
+
let vectorB: [Int8] = [4, 5, 6]
|
|
550
|
+
|
|
551
|
+
let cosineSimilarity = vectorA.cosine(vectorB) // Computes the cosine similarity
|
|
552
|
+
let dotProduct = vectorA.dot(vectorB) // Computes the dot product
|
|
553
|
+
let sqEuclidean = vectorA.sqeuclidean(vectorB) // Computes the squared Euclidean distance
|
|
554
|
+
```
|
|
555
|
+
|
|
538
556
|
## Using SimSIMD in C
|
|
539
557
|
|
|
540
558
|
For integration within a CMake-based project, add the following segment to your `CMakeLists.txt`:
|
|
@@ -714,7 +732,8 @@ To explicitly disable half-precision support, define the following macro before
|
|
|
714
732
|
> But if you are running on different generations of devices, it makes sense to pre-compile the library for all supported generations at once, and dispatch at runtime.
|
|
715
733
|
> This flag does just that and is used to produce the `simsimd.so` shared library, as well as the Python and other bindings.
|
|
716
734
|
|
|
717
|
-
|
|
735
|
+
For Arm: `SIMSIMD_TARGET_NEON`, `SIMSIMD_TARGET_SVE`, `SIMSIMD_TARGET_SVE2`, `SIMSIMD_TARGET_NEON_F16`, `SIMSIMD_TARGET_SVE_F16`, `SIMSIMD_TARGET_NEON_BF16`, `SIMSIMD_TARGET_SVE_BF16`.
|
|
736
|
+
For x86: (`SIMSIMD_TARGET_HASWELL`, `SIMSIMD_TARGET_SKYLAKE`, `SIMSIMD_TARGET_ICE`, `SIMSIMD_TARGET_GENOA`, `SIMSIMD_TARGET_SAPPHIRE`, `SIMSIMD_TARGET_TURIN`, `SIMSIMD_TARGET_SIERRA`.
|
|
718
737
|
|
|
719
738
|
> By default, SimSIMD automatically infers the target architecture and pre-compiles as many kernels as possible.
|
|
720
739
|
> In some cases, you may want to explicitly disable some of the kernels.
|
|
@@ -738,6 +757,12 @@ In general there are a few principles that SimSIMD follows:
|
|
|
738
757
|
- Avoid returning from public interfaces, use out-arguments instead.
|
|
739
758
|
- Don't over-optimize for old CPUs and single- and double-precision floating-point numbers.
|
|
740
759
|
- Prioritize mixed-precision and integer operations, and new ISA extensions.
|
|
760
|
+
- Prefer saturated arithmetic and avoid overflows.
|
|
761
|
+
|
|
762
|
+
Possibly, in the future:
|
|
763
|
+
|
|
764
|
+
- Best effort computation silencing `NaN` components in low-precision inputs.
|
|
765
|
+
- Detect overflows and report the distance with a "signaling" `NaN`.
|
|
741
766
|
|
|
742
767
|
Last, but not the least - don't build unless there is a demand for it.
|
|
743
768
|
So if you have a specific use-case, please open an issue or a pull request, and ideally, bring in more users with similar needs.
|
|
@@ -775,9 +800,11 @@ It's not only less efficient, but also less accurate, given how the reciprocal s
|
|
|
775
800
|
The C standard library provides the `sqrt` function, which is generally very accurate, but slow.
|
|
776
801
|
The `rsqrt` in-hardware implementations are faster, but have different accuracy characteristics.
|
|
777
802
|
|
|
778
|
-
- SSE `rsqrtps` and AVX `vrsqrtps`: $1.5 \times 2^{-12}$ maximal error.
|
|
779
|
-
- AVX-512 `vrsqrt14pd` instruction: $2^{-14}$ maximal error.
|
|
780
|
-
- NEON `frsqrte` instruction has no
|
|
803
|
+
- SSE `rsqrtps` and AVX `vrsqrtps`: $1.5 \times 2^{-12}$ maximal relative error.
|
|
804
|
+
- AVX-512 `vrsqrt14pd` instruction: $2^{-14}$ maximal relative error.
|
|
805
|
+
- NEON `frsqrte` instruction has no documented error bounds, but [can be][arm-rsqrt] $2^{-3}$.
|
|
806
|
+
|
|
807
|
+
[arm-rsqrt]: https://gist.github.com/ashvardanian/5e5cf585d63f8ab6d240932313c75411
|
|
781
808
|
|
|
782
809
|
To overcome the limitations of the `rsqrt` instruction, SimSIMD uses the Newton-Raphson iteration to refine the initial estimate for high-precision floating-point numbers.
|
|
783
810
|
It can be defined as:
|
|
@@ -905,6 +932,48 @@ Jensen-Shannon divergence is a symmetrized and smoothed version of the Kullback-
|
|
|
905
932
|
|
|
906
933
|
Both functions are defined for non-negative numbers, and the logarithm is a key part of their computation.
|
|
907
934
|
|
|
935
|
+
### Mixed Precision in Fused-Multiply-Add and Weighted Sums
|
|
936
|
+
|
|
937
|
+
The Fused-Multiply-Add (FMA) operation is a single operation that combines element-wise multiplication and addition with different scaling factors.
|
|
938
|
+
The Weighted Sum is it's simplified variant without element-wise multiplication.
|
|
939
|
+
|
|
940
|
+
```math
|
|
941
|
+
\text{FMA}_i(A, B, C, \alpha, \beta) = \alpha \cdot A_i \cdot B_i + \beta \cdot C_i
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
```math
|
|
945
|
+
\text{WSum}_i(A, B, \alpha, \beta) = \alpha \cdot A_i + \beta \cdot B_i
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
In NumPy terms, the implementation may look like:
|
|
949
|
+
|
|
950
|
+
```py
|
|
951
|
+
import numpy as np
|
|
952
|
+
def wsum(A: np.ndarray, B: np.ndarray, Alpha: float, Beta: float) -> np.ndarray:
|
|
953
|
+
assert A.dtype == B.dtype, "Input types must match and affect the output style"
|
|
954
|
+
return (Alpha * A + Beta * B).astype(A.dtype)
|
|
955
|
+
def fma(A: np.ndarray, B: np.ndarray, C: np.ndarray, Alpha: float, Beta: float) -> np.ndarray:
|
|
956
|
+
assert A.dtype == B.dtype and A.dtype == C.dtype, "Input types must match and affect the output style"
|
|
957
|
+
return (Alpha * A * B + Beta * C).astype(A.dtype)
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
The tricky part is implementing those operations in mixed precision, where the scaling factors are of different precision than the input and output vectors.
|
|
961
|
+
SimSIMD uses double-precision floating-point scaling factors for any input and output precision, including `i8` and `u8` integers and `f16` and `bf16` floats.
|
|
962
|
+
Depending on the generation of the CPU, given native support for `f16` addition and multiplication, the `f16` temporaries are used for `i8` and `u8` multiplication, scaling, and addition.
|
|
963
|
+
For `bf16`, native support is generally limited to dot-products with subsequent partial accumulation, which is not enough for the FMA and WSum operations, so `f32` is used as a temporary.
|
|
964
|
+
|
|
965
|
+
### Auto-Vectorization & Loop Unrolling
|
|
966
|
+
|
|
967
|
+
On the Intel Sapphire Rapids platform, SimSIMD was benchmarked against auto-vectorized code using GCC 12.
|
|
968
|
+
GCC handles single-precision `float` but might not be the best choice for `int8` and `_Float16` arrays, which have been part of the C language since 2011.
|
|
969
|
+
|
|
970
|
+
| Kind | GCC 12 `f32` | GCC 12 `f16` | SimSIMD `f16` | `f16` improvement |
|
|
971
|
+
| :------------------------ | -----------: | -----------: | ------------: | ----------------: |
|
|
972
|
+
| Inner Product | 3,810 K/s | 192 K/s | 5,990 K/s | __31 x__ |
|
|
973
|
+
| Cosine Distance | 3,280 K/s | 336 K/s | 6,880 K/s | __20 x__ |
|
|
974
|
+
| Euclidean Distance ² | 4,620 K/s | 147 K/s | 5,320 K/s | __36 x__ |
|
|
975
|
+
| Jensen-Shannon Divergence | 1,180 K/s | 18 K/s | 2,140 K/s | __118 x__ |
|
|
976
|
+
|
|
908
977
|
### Dynamic Dispatch
|
|
909
978
|
|
|
910
979
|
Most popular software is precompiled and distributed with fairly conservative CPU optimizations, to ensure compatibility with older hardware.
|
|
@@ -1022,7 +1091,7 @@ SimSIMD exposes all kernels for all backends, and you can select the most advanc
|
|
|
1022
1091
|
That's handy for testing and benchmarking, but also in case you want to dispatch a very specific kernel for a very specific CPU, bypassing SimSIMD assignment logic.
|
|
1023
1092
|
All of the function names follow the same pattern: `simsimd_{function}_{type}_{backend}`.
|
|
1024
1093
|
|
|
1025
|
-
- The backend can be `serial`, `haswell`, `skylake`, `ice`, `genoa`, `sapphire`, `neon`, or `sve`.
|
|
1094
|
+
- The backend can be `serial`, `haswell`, `skylake`, `ice`, `genoa`, `sapphire`, `turin`, `neon`, or `sve`.
|
|
1026
1095
|
- The type can be `f64`, `f32`, `f16`, `bf16`, `f64c`, `f32c`, `f16c`, `bf16c`, `i8`, or `b8`.
|
|
1027
1096
|
- The function can be `dot`, `vdot`, `cos`, `l2sq`, `hamming`, `jaccard`, `kl`, `js`, or `intersect`.
|
|
1028
1097
|
|
package/simsimd/binding.gyp
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
"targets": [
|
|
4
4
|
{
|
|
5
5
|
"target_name": "simsimd",
|
|
6
|
-
"sources": ["javascript/lib.c"],
|
|
6
|
+
"sources": ["javascript/lib.c", "c/lib.c"],
|
|
7
7
|
"include_dirs": ["include"],
|
|
8
|
-
"defines": [
|
|
8
|
+
"defines": [
|
|
9
|
+
"SIMSIMD_NATIVE_F16=0",
|
|
10
|
+
"SIMSIMD_NATIVE_BF16=0",
|
|
11
|
+
"SIMSIMD_DYNAMIC_DISPATCH=1",
|
|
12
|
+
],
|
|
9
13
|
"cflags": [
|
|
10
14
|
"-std=c11",
|
|
11
15
|
"-ffast-math",
|