Add ANN search support for vec0 virtual table

Add approximate nearest neighbor infrastructure to vec0: shared distance
dispatch (vec0_distance_full), flat index type with parser, NEON-optimized
cosine/Hamming for float32/int8, amalgamation script, and benchmark suite
(benchmarks-ann/) with ground-truth generation and profiling tools. Remove
unused vec_npy_each/vec_static_blobs code, fix missing stdint.h include.
This commit is contained in:
Alex Garcia 2026-03-29 19:44:44 -07:00
parent dfd8dc5290
commit bf2455f2ba
27 changed files with 2177 additions and 2116 deletions

View file

@ -42,6 +42,11 @@ ifndef OMIT_SIMD
ifeq ($(shell uname -sm),Darwin arm64)
CFLAGS += -mcpu=apple-m1 -DSQLITE_VEC_ENABLE_NEON
endif
ifeq ($(shell uname -s),Linux)
ifneq ($(filter avx,$(shell grep -o 'avx[^ ]*' /proc/cpuinfo 2>/dev/null | head -1)),)
CFLAGS += -mavx -DSQLITE_VEC_ENABLE_AVX
endif
endif
endif
ifdef USE_BREW_SQLITE
@ -155,6 +160,13 @@ clean:
rm -rf dist
TARGET_AMALGAMATION=$(prefix)/sqlite-vec.c
amalgamation: $(TARGET_AMALGAMATION)
$(TARGET_AMALGAMATION): sqlite-vec.c $(wildcard sqlite-vec-*.c) scripts/amalgamate.py $(prefix)
python3 scripts/amalgamate.py sqlite-vec.c > $@
FORMAT_FILES=sqlite-vec.h sqlite-vec.c
format: $(FORMAT_FILES)
clang-format -i $(FORMAT_FILES)
@ -174,7 +186,7 @@ evidence-of:
test:
sqlite3 :memory: '.read test.sql'
.PHONY: version loadable static test clean gh-release evidence-of install uninstall
.PHONY: version loadable static test clean gh-release evidence-of install uninstall amalgamation
publish-release:
./scripts/publish-release.sh