simd

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvgAbsDiff512

func AvgAbsDiff512(a, b *Vec512) float32

AvgAbsDiff512 returns the average absolute difference across 512 dims as float32

func ClearF32

func ClearF32(buf []float32)

ClearF32 zeros 512 float32 values using AVX2

func Cosine512

func Cosine512(a, b *Vec512, scaleA, scaleB float32) float32

Cosine computes cosine similarity between normalized int8 vectors Assumes vectors are pre-normalized and quantized

func Dot512

func Dot512(a, b *Vec512) int32

Dot512 returns the dot product of two 512-d int8 vectors with cached dispatch

func Dot512Batch

func Dot512Batch(query *Vec512, vectors []Vec512, scores []int32) []int32

Dot512Batch computes dot products between a query vector and a slice of vectors. The scores slice is reused when capacity allows to avoid allocations.

func DotN

func DotN(a, b []int8) int32

DotN computes dot product for arbitrary length int8 vectors

func EmbedAccum

func EmbedAccum(embedding []int8, scale float32, result []float32)

EmbedAccum accumulates embedding * scale into result using AVX2

func EmbedAccumBatch

func EmbedAccumBatch(embeddings [][]int8, scales []float32, result []float32)

EmbedAccumBatch accumulates multiple embeddings into result using AVX2

func EmbedTokensIntoSIMD

func EmbedTokensIntoSIMD(embeddings [][]int8, scales []float32, tokens []int16, result []float32) int

EmbedTokensIntoSIMD is the optimized embedding function using SIMD Returns number of valid tokens processed (zero allocation hot path)

func L2Squared512

func L2Squared512(a, b *Vec512) int32

L2Squared512 computes squared L2 distance between int8 vectors (optimized)

func ScaleF32

func ScaleF32(buf []float32, scale float32)

ScaleF32 multiplies 512 float32 values by scale using AVX2

func SumAbsDiff512

func SumAbsDiff512(a, b *Vec512) int32

SumAbsDiff512 computes sum of absolute differences (L1) between two int8 vectors (512-d) Returns the total L1 distance as int32. Uses AVX2 when available.

Types

type Vec512

type Vec512 [512]int8

Vec512 represents a 512-dimensional int8 vector

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL