-
Notifications
You must be signed in to change notification settings - Fork 20
Fix SVS factory issue on non-SVS and non-LVQ platforms [MOD-9413] #664
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
Changes from 5 commits
88b1481
fb75a0c
cd7cd57
74d23d9
1eb1cbf
6d567ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "VecSim/index_factories/svs_factory.h" | ||
|
||
#if HAVE_SVS | ||
#include "VecSim/memory/vecsim_malloc.h" | ||
#include "VecSim/vec_sim_index.h" | ||
#include "VecSim/algorithms/svs/svs.h" | ||
|
@@ -35,7 +37,12 @@ VecSimIndex *NewIndexImpl(const VecSimParams *params, bool is_normalized) { | |
|
||
template <typename MetricType, typename DataType> | ||
VecSimIndex *NewIndexImpl(const VecSimParams *params, bool is_normalized) { | ||
switch (params->algoParams.svsParams.quantBits) { | ||
// Ignore the 'supported' flag because we always fallback at least to the non-quantized mode | ||
// elsewhere we got code coverage failure for the `supported==false` case | ||
auto quantBits = | ||
std::get<0>(svs_details::isSVSQuantBitsSupported(params->algoParams.svsParams.quantBits)); | ||
|
||
switch (quantBits) { | ||
case VecSimSvsQuant_NONE: | ||
return NewIndexImpl<MetricType, DataType, 0>(params, is_normalized); | ||
case VecSimSvsQuant_8: | ||
|
@@ -91,7 +98,11 @@ constexpr size_t QuantizedVectorSize(size_t dims, size_t alignment = 0) { | |
|
||
template <typename DataType> | ||
size_t QuantizedVectorSize(VecSimSvsQuantBits quant_bits, size_t dims, size_t alignment = 0) { | ||
switch (quant_bits) { | ||
// Ignore the 'supported' flag because we always fallback at least to the non-quantized mode | ||
// elsewhere we got code coverage failure for the `supported==false` case | ||
auto quantBits = std::get<0>(svs_details::isSVSQuantBitsSupported(quant_bits)); | ||
|
||
switch (quantBits) { | ||
case VecSimSvsQuant_NONE: | ||
return QuantizedVectorSize<DataType, 0>(dims, alignment); | ||
case VecSimSvsQuant_8: | ||
|
@@ -169,3 +180,11 @@ size_t EstimateInitialSize(const SVSParams *params, bool is_normalized) { | |
} | ||
|
||
} // namespace SVSFactory | ||
|
||
#else // HAVE_SVS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please comment that this is temporary, and we should never get here - once svs public repo will allow building for all platforms and we address platforms with GCC < 11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comment |
||
namespace SVSFactory { | ||
VecSimIndex *NewIndex(const VecSimParams *params, bool is_normalized) { return NULL; } | ||
size_t EstimateInitialSize(const SVSParams *params, bool is_normalized) { return -1; } | ||
size_t EstimateElementSize(const SVSParams *params) { return -1; } | ||
}; // namespace SVSFactory | ||
#endif // HAVE_SVS |
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 comment that this is temporary, and mark in TODO that the actual fallback should be the basic quantisation if
check_cpuid() == false && quant_bits != VecSimSvsQuant_NONE
once it is available in svsThere 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.
Added comments