Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/simd/distances_sve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ fvec_L2sqr_sve(const float* x, const float* y, size_t d) {
return svaddv_f32(svptrue_b32(), sum);
}

float
fvec_inner_product_sve(const float* x, const float* y, size_t d) {
svfloat32_t sum = svdup_f32(0.0f);
size_t i = 0;

svbool_t pg = svptrue_b32();

while (i < d) {
if (d - i < svcntw())
pg = svwhilelt_b32(i, d);

svfloat32_t a = svld1_f32(pg, x + i);
svfloat32_t b = svld1_f32(pg, y + i);
sum = svmla_f32_m(pg, sum, a, b);
i += svcntw();
}

float result = svaddv_f32(svptrue_b32(), sum);

return result;
}

float
fp16_vec_L2sqr_sve(const knowhere::fp16* x, const knowhere::fp16* y, size_t d) {
svfloat32_t sum1 = svdup_f32(0.0f);
Expand Down
3 changes: 3 additions & 0 deletions src/simd/distances_sve.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace faiss {
float
fvec_L2sqr_sve(const float* x, const float* y, size_t d);

float
fvec_inner_product_sve(const float* x, const float* y, size_t d);

float
fp16_vec_L2sqr_sve(const knowhere::fp16* x, const knowhere::fp16* y, size_t d);

Expand Down
2 changes: 1 addition & 1 deletion src/simd/hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fvec_hook(std::string& simd_type) {
fvec_madd = fvec_madd_sve;
fvec_madd_and_argmin = fvec_madd_and_argmin_sve;

fvec_inner_product = fvec_inner_product_neon;
fvec_inner_product = fvec_inner_product_sve;
fvec_L2sqr_ny = fvec_L2sqr_ny_sve;
fvec_inner_products_ny = fvec_inner_products_ny_neon;

Expand Down
Loading