usearch 2.3.2 → 2.4.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/.github/workflows/prerelease.yml +3 -3
- package/.github/workflows/release.yml +96 -5
- package/CITATION.cff +1 -1
- package/CMakeLists.txt +2 -2
- package/Cargo.toml +1 -1
- package/README.md +2 -2
- package/c/CMakeLists.txt +1 -1
- package/c/README.md +1 -1
- package/conanfile.py +14 -7
- package/cpp/test.cpp +7 -0
- package/csharp/nuget/nuget-package.props +1 -1
- package/csharp/src/Cloud.Unum.USearch.Tests/USearchIndexTests.cs +1013 -0
- package/docs/format.md +40 -17
- package/include/usearch/index.hpp +2 -2
- package/include/usearch/index_dense.hpp +47 -27
- package/include/usearch/index_plugins.hpp +516 -7
- package/package.json +2 -2
- package/python/lib.cpp +8 -5
- package/python/scripts/cluster.ipynb +0 -7
- package/python/usearch/index.py +25 -13
- package/rust/lib.rs +24 -2
- package/wasmer.toml +1 -1
- package/csharp/src/Cloud.Unum.USearch.Tests/InitTests.cs +0 -306
|
@@ -34,7 +34,7 @@ jobs:
|
|
|
34
34
|
cmake -B ./build_release \
|
|
35
35
|
-DCMAKE_CXX_COMPILER="g++-12" \
|
|
36
36
|
-DCMAKE_BUILD_TYPE=Release \
|
|
37
|
-
-
|
|
37
|
+
-DUSEARCH_BUILD_CTEST=1 \
|
|
38
38
|
-DUSEARCH_USE_OPENMP=1 \
|
|
39
39
|
-DUSEARCH_USE_SIMSIMD=1 \
|
|
40
40
|
-DUSEARCH_USE_JEMALLOC=1 \
|
|
@@ -101,7 +101,7 @@ jobs:
|
|
|
101
101
|
run: python -m pip install .
|
|
102
102
|
if: ${{ matrix.os != 'ubuntu-22.04' }}
|
|
103
103
|
- name: Test with PyTest
|
|
104
|
-
run: pytest python/scripts/
|
|
104
|
+
run: pytest python/scripts/ -s -x
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
test_python_37:
|
|
@@ -136,7 +136,7 @@ jobs:
|
|
|
136
136
|
if: ${{ matrix.os == 'ubuntu-22.04' }}
|
|
137
137
|
|
|
138
138
|
- name: Test with PyTest
|
|
139
|
-
run: pytest python/scripts/
|
|
139
|
+
run: pytest python/scripts/ -s -x
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
test_javascript:
|
|
@@ -216,10 +216,95 @@ jobs:
|
|
|
216
216
|
update_latest_release: true
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
name:
|
|
219
|
+
wasm_c_library:
|
|
220
|
+
name: WASM builds for C libraries on ${{ matrix.os }}
|
|
221
|
+
runs-on: ${{ matrix.os }}
|
|
222
|
+
needs: versioning
|
|
223
|
+
strategy:
|
|
224
|
+
matrix:
|
|
225
|
+
os: [ubuntu-22.04, macOS-11, windows-2022]
|
|
226
|
+
steps:
|
|
227
|
+
- uses: actions/checkout@v3
|
|
228
|
+
with:
|
|
229
|
+
persist-credentials: false
|
|
230
|
+
ref: 'main'
|
|
231
|
+
- run: git submodule update --init --recursive
|
|
232
|
+
|
|
233
|
+
- name: Get version
|
|
234
|
+
id: version
|
|
235
|
+
run: |
|
|
236
|
+
version=$(cat VERSION)
|
|
237
|
+
echo "version=$version" >> $GITHUB_OUTPUT
|
|
238
|
+
shell: bash
|
|
239
|
+
|
|
240
|
+
- name: Build library on Ubuntu
|
|
241
|
+
run: |
|
|
242
|
+
export WASI_VERSION=20
|
|
243
|
+
export WASI_VERSION_FULL=${WASI_VERSION}.0
|
|
244
|
+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
|
|
245
|
+
tar xf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
|
|
246
|
+
rm -rf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
|
|
247
|
+
export WASI_SDK_PATH=/home/runner/work/usearch/usearch/wasi-sdk-${WASI_VERSION_FULL}
|
|
248
|
+
archs=("x86_64" "arm64")
|
|
249
|
+
cd ./c
|
|
250
|
+
for arch in "${archs[@]}"
|
|
251
|
+
do
|
|
252
|
+
../wasi-sdk-20.0/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -o libusearch.so -O3 lib.cpp -I. -I ../include/ -I ../fp16/include/ -shared --target=wasm32-wasi-threads -Wl,--no-entry -nostdlib -D_WASI_EMULATED_MMAN -march="$arch"
|
|
253
|
+
tar -czvf usearch_wasm_linux_"$arch"_${{ steps.version.outputs.version }}.tar.gz libusearch.so
|
|
254
|
+
mv usearch_wasm_linux_"$arch"_${{ steps.version.outputs.version }}.tar.gz ../ && rm -rf libusearch.so
|
|
255
|
+
done
|
|
256
|
+
if: matrix.os == 'ubuntu-22.04'
|
|
257
|
+
|
|
258
|
+
- name: Build library on MacOS
|
|
259
|
+
run: |
|
|
260
|
+
export WASI_VERSION=20
|
|
261
|
+
export WASI_VERSION_FULL=${WASI_VERSION}.0
|
|
262
|
+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
|
|
263
|
+
tar xf wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
|
|
264
|
+
rm -rf wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
|
|
265
|
+
export WASI_SDK_PATH=/Users/runner/work/usearch/usearch/wasi-sdk-${WASI_VERSION_FULL}
|
|
266
|
+
archs=("x86_64" "arm64")
|
|
267
|
+
cd ./c
|
|
268
|
+
for arch in "${archs[@]}"
|
|
269
|
+
do
|
|
270
|
+
../wasi-sdk-20.0/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -o libusearch.so -O3 lib.cpp -I. -I ../include/ -I ../fp16/include/ -shared --target=wasm32-wasi-threads -Wl,--no-entry -nostdlib -D_WASI_EMULATED_MMAN -march="$arch"
|
|
271
|
+
zip -r usearch_wasm_macos_"$arch"_${{ steps.version.outputs.version }}.zip libusearch.so
|
|
272
|
+
mv usearch_wasm_macos_"$arch"_${{ steps.version.outputs.version }}.zip ../ && rm -rf libusearch.so
|
|
273
|
+
done
|
|
274
|
+
if: matrix.os == 'macOS-11'
|
|
275
|
+
|
|
276
|
+
- name: Build library on Windows
|
|
277
|
+
run: |
|
|
278
|
+
export WASI_VERSION=20
|
|
279
|
+
export WASI_VERSION_FULL=${WASI_VERSION}.0
|
|
280
|
+
curl -LOJ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}.m-mingw.tar.gz
|
|
281
|
+
tar xf wasi-sdk-${WASI_VERSION_FULL}.m-mingw.tar.gz
|
|
282
|
+
rm -rf wasi-sdk-${WASI_VERSION_FULL}.m-mingw.tar.gz
|
|
283
|
+
export WASI_SDK_PATH=/d/a/usearch/usearch/wasi-sdk-${WASI_VERSION_FULL}+m
|
|
284
|
+
archs=("x64" "x86")
|
|
285
|
+
cd ./c
|
|
286
|
+
for arch in "${archs[@]}"
|
|
287
|
+
do
|
|
288
|
+
../wasi-sdk-20.0+m/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -o libusearch.so -O3 lib.cpp -I. -I ../include/ -I ../fp16/include/ -shared --target=wasm32-wasi-threads -Wl,--no-entry -nostdlib -D_WASI_EMULATED_MMAN -march="$arch"
|
|
289
|
+
tar -cvf usearch_wasm_windows_"$arch"_${{ steps.version.outputs.version }}.tar.gz libusearch.so
|
|
290
|
+
mv usearch_wasm_windows_"$arch"_${{ steps.version.outputs.version }}.tar.gz ../ && rm -rf libusearch.so
|
|
291
|
+
done
|
|
292
|
+
shell: bash
|
|
293
|
+
if: matrix.os == 'windows-2022'
|
|
294
|
+
|
|
295
|
+
- name: Upload archive
|
|
296
|
+
uses: xresloader/upload-to-github-release@v1
|
|
297
|
+
env:
|
|
298
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
299
|
+
with:
|
|
300
|
+
file: "*.zip;*.tar.gz"
|
|
301
|
+
update_latest_release: true
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
publish_checksums:
|
|
305
|
+
name: Compute Assets Checksums
|
|
221
306
|
runs-on: ubuntu-latest
|
|
222
|
-
needs: [versioning, create_linux_deb_package, create_windows_dll_library, create_macos_library, deploy_docs_pages]
|
|
307
|
+
needs: [versioning, create_linux_deb_package, create_windows_dll_library, create_macos_library, deploy_docs_pages, wasm_c_library]
|
|
223
308
|
steps:
|
|
224
309
|
- name: Get last release ID
|
|
225
310
|
id: last_release
|
|
@@ -267,10 +352,16 @@ jobs:
|
|
|
267
352
|
* ${{ steps.hashes.outputs.asset_name_7 }} : `${{ steps.hashes.outputs.asset_hash_7 }}`
|
|
268
353
|
* ${{ steps.hashes.outputs.asset_name_8 }} : `${{ steps.hashes.outputs.asset_hash_8 }}`
|
|
269
354
|
* ${{ steps.hashes.outputs.asset_name_9 }} : `${{ steps.hashes.outputs.asset_hash_9 }}`
|
|
355
|
+
* ${{ steps.hashes.outputs.asset_name_10 }} : `${{ steps.hashes.outputs.asset_hash_10 }}`
|
|
356
|
+
* ${{ steps.hashes.outputs.asset_name_11 }} : `${{ steps.hashes.outputs.asset_hash_11 }}`
|
|
357
|
+
* ${{ steps.hashes.outputs.asset_name_12 }} : `${{ steps.hashes.outputs.asset_hash_12 }}`
|
|
358
|
+
* ${{ steps.hashes.outputs.asset_name_13 }} : `${{ steps.hashes.outputs.asset_hash_13 }}`
|
|
359
|
+
* ${{ steps.hashes.outputs.asset_name_14 }} : `${{ steps.hashes.outputs.asset_hash_14 }}`
|
|
360
|
+
* ${{ steps.hashes.outputs.asset_name_15 }} : `${{ steps.hashes.outputs.asset_hash_15 }}`
|
|
270
361
|
|
|
271
362
|
|
|
272
363
|
build_wheels:
|
|
273
|
-
name: Build
|
|
364
|
+
name: Build Python
|
|
274
365
|
needs: versioning
|
|
275
366
|
runs-on: ${{ matrix.os }}
|
|
276
367
|
strategy:
|
|
@@ -445,7 +536,7 @@ jobs:
|
|
|
445
536
|
labels: ${{ steps.meta.outputs.labels }}
|
|
446
537
|
|
|
447
538
|
build_csharp:
|
|
448
|
-
name: Build
|
|
539
|
+
name: Build C#
|
|
449
540
|
needs: versioning
|
|
450
541
|
strategy:
|
|
451
542
|
matrix:
|
package/CITATION.cff
CHANGED
package/CMakeLists.txt
CHANGED
|
@@ -15,6 +15,7 @@ option(USEARCH_BUILD_TEST "Compile a native unit test in C++" ${USEARCH_IS_MAIN_
|
|
|
15
15
|
option(USEARCH_BUILD_BENCHMARK "Compile a native benchmark in C++" ${USEARCH_IS_MAIN_PROJECT})
|
|
16
16
|
option(USEARCH_BUILD_WOLFRAM "Compile Wolfram Language bindings" OFF)
|
|
17
17
|
option(USEARCH_BUILD_CLIB "Compile a native library for the C 99 interface" OFF)
|
|
18
|
+
option(USEARCH_BUILD_CTEST "Compile a test for the C 99 interface" OFF)
|
|
18
19
|
|
|
19
20
|
# Includes
|
|
20
21
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
|
@@ -128,7 +129,6 @@ if(USEARCH_INSTALL)
|
|
|
128
129
|
endif()
|
|
129
130
|
|
|
130
131
|
if(${USEARCH_BUILD_TEST} OR ${USEARCH_BUILD_BENCHMARK})
|
|
131
|
-
add_subdirectory(c)
|
|
132
132
|
add_subdirectory(cpp)
|
|
133
133
|
endif()
|
|
134
134
|
|
|
@@ -140,6 +140,6 @@ if(${USEARCH_BUILD_WASM})
|
|
|
140
140
|
add_subdirectory(wasm)
|
|
141
141
|
endif()
|
|
142
142
|
|
|
143
|
-
if (${USEARCH_BUILD_CLIB})
|
|
143
|
+
if (${USEARCH_BUILD_CLIB} OR ${USEARCH_BUILD_CTEST})
|
|
144
144
|
add_subdirectory(c)
|
|
145
145
|
endif()
|
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ index = Index(
|
|
|
99
99
|
|
|
100
100
|
vector = np.array([0.2, 0.6, 0.4])
|
|
101
101
|
index.add(42, vector)
|
|
102
|
-
matches
|
|
102
|
+
matches = index.search(vector, 10)
|
|
103
103
|
|
|
104
104
|
assert len(index) == 1
|
|
105
105
|
assert len(matches) == 1
|
|
@@ -392,7 +392,7 @@ doi = {10.5281/zenodo.7949416},
|
|
|
392
392
|
author = {Vardanian, Ash},
|
|
393
393
|
title = {{USearch by Unum Cloud}},
|
|
394
394
|
url = {https://github.com/unum-cloud/usearch},
|
|
395
|
-
version = {2.
|
|
395
|
+
version = {2.4.1},
|
|
396
396
|
year = {2022},
|
|
397
397
|
month = jun,
|
|
398
398
|
}
|
package/c/CMakeLists.txt
CHANGED
|
@@ -45,7 +45,7 @@ if (${USEARCH_LOOKUP_LABEL})
|
|
|
45
45
|
target_compile_definitions(usearch_c PRIVATE USEARCH_LOOKUP_LABEL=1)
|
|
46
46
|
endif()
|
|
47
47
|
|
|
48
|
-
if(${
|
|
48
|
+
if(${USEARCH_BUILD_CTEST})
|
|
49
49
|
add_executable(test_c "${CMAKE_CURRENT_SOURCE_DIR}/test.c")
|
|
50
50
|
target_link_libraries(test_c usearch_c)
|
|
51
51
|
set_target_properties(test_c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
package/c/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The simplest form to integrate is to copy the contents of `usearch/c/` into your
|
|
|
6
6
|
To build the library `libusearch_c`, pass enable the `USEARCH_BUILD_CLIB` CMake option:
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
cmake -DUSEARCH_BUILD_CLIB=1 -DUSEARCH_BUILD_STATIC=0 -DUSEARCH_BUILD_TEST=0 -DUSEARCH_BUILD_BENCHMARK=0 ..
|
|
9
|
+
cmake -DUSEARCH_BUILD_CLIB=1 -DUSEARCH_BUILD_CTEST=1 -DUSEARCH_BUILD_STATIC=0 -DUSEARCH_BUILD_TEST=0 -DUSEARCH_BUILD_BENCHMARK=0 ..
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
You can choose between a static and dynamic library by setting `USEARCH_BUILD_STATIC`.
|
package/conanfile.py
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
from conans import ConanFile
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
required_conan_version = ">=1.53.0"
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
class USearchConan(ConanFile):
|
|
5
8
|
|
|
6
|
-
name =
|
|
7
|
-
version = '2.
|
|
8
|
-
license =
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
name = "usearch"
|
|
10
|
+
version = '2.4.1'
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
description = "Smaller & Faster Single-File Vector Search Engine from Unum"
|
|
13
|
+
homepage = "https://github.com/unum-cloud/usearch"
|
|
14
|
+
topics = ("search", "vector", "simd")
|
|
15
|
+
settings = "os", "arch", "compiler", "build_type"
|
|
16
|
+
url = "https://github.com/conan-io/conan-center-index"
|
|
17
|
+
package_type = "header-library"
|
|
11
18
|
|
|
12
19
|
# No settings/options are necessary, this is header only
|
|
13
20
|
# Potentially add unit-tests in the future:
|
|
14
21
|
# https://docs.conan.io/1/howtos/header_only.html#with-unit-tests
|
|
15
|
-
exports_sources =
|
|
22
|
+
exports_sources = "include/*"
|
|
16
23
|
no_copy_source = True
|
|
17
24
|
|
|
18
25
|
def package(self):
|
|
19
|
-
self.copy(
|
|
26
|
+
self.copy("*.h")
|
package/cpp/test.cpp
CHANGED
|
@@ -36,6 +36,13 @@ void test_cosine(index_at& index, std::vector<std::vector<scalar_at>> const& vec
|
|
|
36
36
|
scalar_t const* vector_third = vectors[2].data();
|
|
37
37
|
std::size_t dimensions = vectors[0].size();
|
|
38
38
|
|
|
39
|
+
// Try checking the empty state
|
|
40
|
+
if constexpr (punned_ak) {
|
|
41
|
+
expect(!index.contains(key_first));
|
|
42
|
+
expect(!index.get(key_first, (f32_t*)nullptr, 1));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Add data
|
|
39
46
|
index.reserve(10);
|
|
40
47
|
index.add(key_first, vector_first, args...);
|
|
41
48
|
|