usearch 2.10.3 → 2.11.0
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 +28 -8
- package/binding.gyp +101 -0
- package/c/CMakeLists.txt +27 -0
- package/c/README.md +244 -0
- package/c/lib.cpp +459 -0
- package/c/test.c +386 -0
- package/c/usearch.h +451 -0
- package/cmake/clipp.cmake +7 -0
- package/cmake/config.cmake.in +15 -0
- package/cmake/emscripten.cmake +8 -0
- package/cmake/jemalloc.cmake +62 -0
- package/cmake/pkg-config.pc.in +4 -0
- package/cmake/usearchConfigVersion.cmake.in +20 -0
- package/cpp/CMakeLists.txt +14 -0
- package/cpp/README.md +161 -0
- package/cpp/bench.cpp +616 -0
- package/cpp/test.cpp +335 -0
- package/fp16/CMakeLists.txt +176 -0
- package/fp16/LICENSE +11 -0
- package/fp16/README.md +20 -0
- package/fp16/bench/alt-element.cc +89 -0
- package/fp16/bench/from-alt-array.cc +175 -0
- package/fp16/bench/from-ieee-array.cc +399 -0
- package/fp16/bench/ieee-element.cc +272 -0
- package/fp16/bench/to-alt-array.cc +91 -0
- package/fp16/bench/to-ieee-array.cc +303 -0
- package/fp16/cmake/DownloadGoogleBenchmark.cmake +15 -0
- package/fp16/cmake/DownloadGoogleTest.cmake +15 -0
- package/fp16/cmake/DownloadPSimd.cmake +15 -0
- package/fp16/configure.py +65 -0
- package/fp16/confu.yaml +8 -0
- package/fp16/include/fp16/__init__.py +0 -0
- package/fp16/include/fp16/avx.py +50 -0
- package/fp16/include/fp16/avx2.py +53 -0
- package/fp16/include/fp16/bitcasts.h +92 -0
- package/fp16/include/fp16/fp16.h +451 -0
- package/fp16/include/fp16/psimd.h +131 -0
- package/fp16/include/fp16.h +11 -0
- package/fp16/jni/Android.mk +6 -0
- package/fp16/jni/Application.mk +4 -0
- package/fp16/test/alt-from-fp32-value.cc +498 -0
- package/fp16/test/alt-to-fp32-bits.cc +263 -0
- package/fp16/test/alt-to-fp32-psimd.cc +145 -0
- package/fp16/test/alt-to-fp32-value.cc +348 -0
- package/fp16/test/alt-to-fp32x2-psimd.cc +245 -0
- package/fp16/test/bitcasts.cc +56 -0
- package/fp16/test/ieee-from-fp32-value.cc +523 -0
- package/fp16/test/ieee-to-fp32-bits.cc +333 -0
- package/fp16/test/ieee-to-fp32-psimd.cc +312 -0
- package/fp16/test/ieee-to-fp32-value.cc +420 -0
- package/fp16/test/ieee-to-fp32x2-psimd.cc +541 -0
- package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +96 -0
- package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +96 -0
- package/fp16/test/peachpy/stubs.py +38 -0
- package/fp16/test/tables.cc +530 -0
- package/fp16/test/tables.h +13 -0
- package/fp16/third-party/THHalf.h +92 -0
- package/fp16/third-party/eigen-half.h +170 -0
- package/fp16/third-party/float16-compressor.h +80 -0
- package/fp16/third-party/half.hpp +2916 -0
- package/fp16/third-party/npy-halffloat.h +328 -0
- package/include/usearch/index.hpp +3838 -0
- package/include/usearch/index_dense.hpp +2022 -0
- package/include/usearch/index_plugins.hpp +2317 -0
- package/javascript/dist/cjs/usearch.js +5 -5
- package/javascript/dist/esm/usearch.js +2 -2
- package/javascript/dist-package-cjs.json +3 -0
- package/javascript/dist-package-esm.json +3 -0
- package/javascript/lib.cpp +350 -0
- package/javascript/node-gyp-build.d.ts +1 -0
- package/javascript/tsconfig-base.json +25 -0
- package/javascript/tsconfig-cjs.json +8 -0
- package/javascript/tsconfig-esm.json +8 -0
- package/javascript/usearch.test.js +84 -0
- package/javascript/usearch.ts +640 -0
- package/package.json +14 -7
- 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/prebuilds/win32-ia32/usearch.node +0 -0
- package/prebuilds/win32-x64/usearch.node +0 -0
- package/simsimd/.releaserc +87 -0
- package/simsimd/CONTRIBUTING.md +114 -0
- package/simsimd/Cargo.lock +709 -0
- package/simsimd/Cargo.toml +44 -0
- package/simsimd/LICENSE +201 -0
- package/simsimd/README.md +708 -0
- package/simsimd/binding.gyp +36 -0
- package/simsimd/build.rs +51 -0
- package/simsimd/c/lib.c +110 -0
- package/simsimd/include/simsimd/binary.h +258 -0
- package/simsimd/include/simsimd/dot.h +1237 -0
- package/simsimd/include/simsimd/geospatial.h +37 -0
- package/simsimd/include/simsimd/probability.h +563 -0
- package/simsimd/include/simsimd/simsimd.h +1129 -0
- package/simsimd/include/simsimd/spatial.h +1019 -0
- package/simsimd/include/simsimd/types.h +309 -0
- package/simsimd/javascript/bench.js +127 -0
- package/simsimd/javascript/dist-package-cjs.json +3 -0
- package/simsimd/javascript/dist-package-esm.json +3 -0
- package/simsimd/javascript/fallback.ts +203 -0
- package/simsimd/javascript/lib.c +107 -0
- package/simsimd/javascript/node-gyp-build.d.ts +1 -0
- package/simsimd/javascript/simsimd.ts +135 -0
- package/simsimd/javascript/test.mjs +179 -0
- package/simsimd/javascript/tsconfig-base.json +37 -0
- package/simsimd/javascript/tsconfig-cjs.json +8 -0
- package/simsimd/javascript/tsconfig-esm.json +8 -0
- package/simsimd/package-lock.json +1709 -0
- package/simsimd/package.json +61 -0
- package/simsimd/rust/benches/cosine.rs +27 -0
- package/simsimd/rust/benches/native.rs +30 -0
- package/simsimd/rust/benches/sqeuclidean.rs +27 -0
- package/simsimd/rust/lib.rs +778 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simsimd",
|
|
3
|
+
"version": "4.2.2",
|
|
4
|
+
"description": "Fastest SIMD-Accelerated Vector Similarity Functions for x86 and Arm",
|
|
5
|
+
"homepage": "https://github.com/ashvardanian/simsimd",
|
|
6
|
+
"author": "Ash Vardanian",
|
|
7
|
+
"license": "Apache 2.0",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"vector",
|
|
10
|
+
"distance",
|
|
11
|
+
"similarity",
|
|
12
|
+
"search",
|
|
13
|
+
"ai",
|
|
14
|
+
"math",
|
|
15
|
+
"avx2",
|
|
16
|
+
"avx512",
|
|
17
|
+
"neon",
|
|
18
|
+
"sve",
|
|
19
|
+
"arm",
|
|
20
|
+
"x86",
|
|
21
|
+
"simd",
|
|
22
|
+
"f16"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"install": "node-gyp-build",
|
|
26
|
+
"prebuild-single": "prebuildify --napi --strip --target=10.4.0",
|
|
27
|
+
"prebuild-arm64": "prebuildify --arch arm64 --napi --strip --target=10.4.0",
|
|
28
|
+
"prebuild-darwin-x64+arm64": "prebuildify --arch arm64+x64 --napi --strip --target=10.4.0",
|
|
29
|
+
"build-js": "rm -fr javascript/dist/* && tsc -p javascript/tsconfig-esm.json && tsc -p javascript/tsconfig-cjs.json && cp javascript/dist-package-esm.json javascript/dist/esm/package.json && cp javascript/dist-package-cjs.json javascript/dist/cjs/package.json",
|
|
30
|
+
"test": "node --test ./javascript/test.mjs",
|
|
31
|
+
"bench": "node ./javascript/bench.js"
|
|
32
|
+
},
|
|
33
|
+
"main": "javascript/dist/cjs/simsimd.js",
|
|
34
|
+
"module": "javascript/dist/esm/simsimd.js",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"import": "./javascript/dist/esm/simsimd.js",
|
|
38
|
+
"require": "./javascript/dist/cjs/simsimd.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": "~10 >=10.20 || >=12.17"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"bindings": "^1.5.0",
|
|
46
|
+
"node-addon-api": "^3.2.1",
|
|
47
|
+
"node-gyp-build": "^4.8.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/bindings": "^1.5.5",
|
|
51
|
+
"@types/node": "^20.12.2",
|
|
52
|
+
"node-gyp": "^10.0.1",
|
|
53
|
+
"prebuildify": "^6.0.0",
|
|
54
|
+
"typescript": "^5.3.3"
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"benchmark": "^2.1.4",
|
|
58
|
+
"mathjs": "^11.11.2",
|
|
59
|
+
"usearch": "^2.8.15"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
2
|
+
use simsimd::SpatialSimilarity as SimSIMD;
|
|
3
|
+
|
|
4
|
+
mod native;
|
|
5
|
+
|
|
6
|
+
const DIMENSIONS: usize = 1536;
|
|
7
|
+
|
|
8
|
+
pub fn cos_benchmark(c: &mut Criterion) {
|
|
9
|
+
let inputs: (Vec<f32>, Vec<f32>) = (
|
|
10
|
+
native::generate_random_vector(DIMENSIONS),
|
|
11
|
+
native::generate_random_vector(DIMENSIONS),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
let mut group = c.benchmark_group("SIMD Cosine");
|
|
15
|
+
|
|
16
|
+
for i in 0..=5 {
|
|
17
|
+
group.bench_with_input(BenchmarkId::new("SimSIMD", i), &i, |b, _| {
|
|
18
|
+
b.iter(|| SimSIMD::cosine(&inputs.0, &inputs.1))
|
|
19
|
+
});
|
|
20
|
+
group.bench_with_input(BenchmarkId::new("Rust Native", i), &i, |b, _| {
|
|
21
|
+
b.iter(|| native::cos_similarity_cpu(&inputs.0, &inputs.1))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
criterion_group!(benches, cos_benchmark);
|
|
27
|
+
criterion_main!(benches);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#![allow(unused)]
|
|
2
|
+
use rand::Rng;
|
|
3
|
+
|
|
4
|
+
pub(crate) fn generate_random_vector(dim: usize) -> Vec<f32> {
|
|
5
|
+
(0..dim).map(|_| rand::thread_rng().gen()).collect()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
pub(crate) fn cos_similarity_cpu(a: &[f32], b: &[f32]) -> Option<f32> {
|
|
9
|
+
if a.len() != b.len() {
|
|
10
|
+
return None;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let (dot_product, norm_a, norm_b) = a
|
|
14
|
+
.iter()
|
|
15
|
+
.zip(b)
|
|
16
|
+
.map(|(a, b)| (a * b, a * a, b * b))
|
|
17
|
+
.fold((0.0, 0.0, 0.0), |acc, x| {
|
|
18
|
+
(acc.0 + x.0, acc.1 + x.1, acc.2 + x.2)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
Some(1.0 - (dot_product / (norm_a.sqrt() * norm_b.sqrt())))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub(crate) fn squared_euclidean_cpu(a: &[f32], b: &[f32]) -> Option<f32> {
|
|
25
|
+
if a.len() != b.len() {
|
|
26
|
+
return None;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Some(a.iter().zip(b).map(|(x, y)| (x - y).powi(2)).sum())
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
2
|
+
use simsimd::SpatialSimilarity as SimSIMD;
|
|
3
|
+
|
|
4
|
+
mod native;
|
|
5
|
+
|
|
6
|
+
const DIMENSIONS: usize = 1536;
|
|
7
|
+
|
|
8
|
+
pub fn l2sq_benchmark(c: &mut Criterion) {
|
|
9
|
+
let inputs: (Vec<f32>, Vec<f32>) = (
|
|
10
|
+
native::generate_random_vector(DIMENSIONS),
|
|
11
|
+
native::generate_random_vector(DIMENSIONS),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
let mut group = c.benchmark_group("SIMD SqEuclidean");
|
|
15
|
+
|
|
16
|
+
for i in 0..=5 {
|
|
17
|
+
group.bench_with_input(BenchmarkId::new("SimSIMD", i), &i, |b, _| {
|
|
18
|
+
b.iter(|| SimSIMD::sqeuclidean(&inputs.0, &inputs.1))
|
|
19
|
+
});
|
|
20
|
+
group.bench_with_input(BenchmarkId::new("Rust Native", i), &i, |b, _| {
|
|
21
|
+
b.iter(|| native::squared_euclidean_cpu(&inputs.0, &inputs.1))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
criterion_group!(benches, l2sq_benchmark);
|
|
27
|
+
criterion_main!(benches);
|