-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement UINT8 vector type - [MOD-8230, MOD-8408] #584
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 97.09% 97.19% +0.10%
==========================================
Files 104 106 +2
Lines 5503 5713 +210
==========================================
+ Hits 5343 5553 +210
Misses 160 160 ☔ View full report in Codecov by Sentry. |
// For uint8 vectors with cosine distance, the extra float for the norm shifts alignment to | ||
// `(dim + sizeof(float)) % 32`. | ||
// Vectors satisfying this have a residual, causing offset loads during calculation. | ||
// To avoid complexity, we skip alignment here, assuming the performance impact is | ||
// negligible. |
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.
I need to better understand the considerations here (I see it follows INT8 as well)
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.
👍🏼. I also thought about it and if we put the norm at the beginning of the vector we will be able to use alignment
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.
As discussed - let's open a (small) spike to try that
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.
cool
// The type should be able to hold `dimension * MAX_VAL(int_elem_t) * MAX_VAL(int_elem_t)`. | ||
// To support dimension up to 2^16, we need the difference between the type and int_elem_t to be at | ||
// least 2 bytes. We assert that in the implementation. | ||
template <typename int_elem_t> | ||
using ret_t = std::conditional_t<sizeof(int_elem_t) == 1, int, long long>; | ||
|
||
template <typename int_elem_t> | ||
static inline ret_t<int_elem_t> | ||
INTEGER_InnerProductImp(const int_elem_t *pVect1, const int_elem_t *pVect2, size_t dimension) { | ||
static_assert(sizeof(ret_t<int_elem_t>) - sizeof(int_elem_t) * 2 >= sizeof(uint16_t)); | ||
ret_t<int_elem_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.
This generic introduced for possible future integer types larger than 1 byte?
Implement support for new type
UINT8
This PR follows the implementation of the
INT8
type and implements all the functionality required for theUINT8
type.Mark if applicable