-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Int8Vector SIMD APIs for avx512/avx2/sse/ref #1098
Add Int8Vector SIMD APIs for avx512/avx2/sse/ref #1098
Conversation
/kind improvement |
18afefb
to
8d8daa8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1098 +/- ##
=========================================
+ Coverage 0 72.87% +72.87%
=========================================
Files 0 85 +85
Lines 0 8381 +8381
=========================================
+ Hits 0 6108 +6108
- Misses 0 2273 +2273 |
src/simd/distances_avx.cc
Outdated
for (size_t i = 0; i < d; i++) { | ||
res += (float)x[i] * (float)y[i]; | ||
} | ||
return res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the following pattern here and it all the further functions that were added: compute in ints and convert the final result into float. This is faster in terms of CPU ops / cycles.
FAISS_PRAGMA_IMPRECISE_FUNCTION_BEGIN
float
int8_vec_inner_product_avx(const int8_t* x, const int8_t* y, size_t d) {
int32_t res = 0;
FAISS_PRAGMA_IMPRECISE_LOOP
for (size_t i = 0; i < d; i++) {
res += (int32_t)x[i] * (int32_t)y[i];
}
return (float)res;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thx
/hold |
8d8daa8
to
76b7f89
Compare
int8_vec_inner_product_neon(const int8_t* x, const int8_t* y, size_t d) { | ||
// TODO caiyd: use ref implementation temporarily | ||
int32_t res = 0; | ||
for (size_t i = 0; i < d; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated code here
{
return int8_vec_inner_product_ref(x, y, d);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the duplicated code is correct, bcz it will be compiled with different compiler options
float | ||
int8_vec_L2sqr_neon(const int8_t* x, const int8_t* y, size_t d) { | ||
// TODO caiyd: use ref implementation temporarily | ||
int32_t res = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
/lgtm |
/unhold |
for (size_t i = 0; i < d; i++) { | ||
res += (int32_t)x[i] * (int32_t)x[i]; | ||
} | ||
return (float)res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement a neon version.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexanderguzhva, cydrain The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Signed-off-by: CaiYudong <[email protected]>
76b7f89
to
94eea31
Compare
/lgtm |
Issue: #977