Expand description
§SIMD-Accelerated Distance Functions
Optimized distance calculations using SIMD instructions. Falls back to scalar implementations when SIMD is not available.
§Supported Architectures
- x86_64: AVX2, SSE4.1 (auto-detected at runtime)
- aarch64: NEON (always available on Apple Silicon)
- Fallback: Portable scalar implementation
§Performance
SIMD acceleration provides 2-8x speedup for distance calculations:
- L2 (Euclidean): Process 8 floats per iteration (AVX) or 4 (SSE/NEON)
- Dot product: Same vectorization approach
- Cosine: Computed as 1 - dot(a,b) / (||a|| * ||b||)
Structs§
- Simd
Cosine - SIMD-accelerated cosine distance
- SimdDot
- SIMD-accelerated dot product distance (for normalized vectors)
- Simd
Info - Information about available SIMD features
- SimdL2
- SIMD-accelerated L2 (Euclidean squared) distance
Functions§
- cosine_
distance - Compute cosine distance with best available SIMD Returns 1 - cosine_similarity, so 0 = identical, 2 = opposite
- dot_
product - Compute dot product with best available SIMD
- l2_
squared - Compute L2 squared distance with best available SIMD
- norm_
squared - Compute squared norm with best available SIMD
- simd_
info - Returns information about SIMD capabilities