-
Notifications
You must be signed in to change notification settings - Fork 83
fix(quantization): add missing constexpr and static_assert in INT8Quantizer::ComputeImpl #1719
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
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "2026-03-18-\u4FEE\u590D-int8-quantizer-computeimpl-\u7F3A\u5C11-return"
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -106,6 +106,10 @@ INT8Quantizer<metric>::DecodeBatchImpl(const uint8_t* codes, DataType* data, uin | |||||
| template <MetricType metric> | ||||||
| float | ||||||
| INT8Quantizer<metric>::ComputeImpl(const uint8_t* codes1, const uint8_t* codes2) { | ||||||
| static_assert(metric == MetricType::METRIC_TYPE_IP || | ||||||
| metric == MetricType::METRIC_TYPE_COSINE || | ||||||
| metric == MetricType::METRIC_TYPE_L2SQR, | ||||||
| "Unsupported metric type for INT8Quantizer"); | ||||||
| if constexpr (metric == MetricType::METRIC_TYPE_IP) { | ||||||
| return 1.0F - INT8ComputeIP(reinterpret_cast<const int8_t*>(codes1), | ||||||
| reinterpret_cast<const int8_t*>(codes2), | ||||||
|
|
@@ -122,7 +126,7 @@ INT8Quantizer<metric>::ComputeImpl(const uint8_t* codes1, const uint8_t* codes2) | |||||
| this->dim_); | ||||||
| similarity /= mold1[0] * mold2[0]; | ||||||
| return 1.0F - std::max(-1.0F, std::min(1.0F, similarity)); | ||||||
| } else if (metric == MetricType::METRIC_TYPE_L2SQR) { | ||||||
| } else { | ||||||
|
||||||
| } else { | |
| } else if constexpr (metric == MetricType::METRIC_TYPE_L2SQR) { |
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.
The PR description says the code was changed to
else if constexpr (metric == MetricType::METRIC_TYPE_L2SQR), but the diff shows the L2SQR path is now handled via a plainelse. Either update the PR description to match the implementation, or change the code to useelse if constexpras described.