mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
Fix type mismatch bug and remove dead code in IndexRowwiseMinMax::sa_decode_impl (#5051)
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5051 In `sa_decode_impl<StorageMinMaxT>()`, a local variable `std::vector<StorageMinMaxFP16> minmax(...)` was: 1. Using the wrong type: It hardcoded `StorageMinMaxFP16` instead of the template parameter `StorageMinMaxT`. When this function is instantiated with `StorageMinMaxFP32` (via `IndexRowwiseMinMax::sa_decode`), this would create a vector of the wrong type. 2. Dead code: The vector was allocated but never actually used in the function body. The decoding logic reads `StorageMinMaxT` values directly from the input byte buffer, making this allocation unnecessary. This change removes the unused variable, eliminating both the type mismatch and the unnecessary memory allocation. The allocation was O(min(chunk_size, n)) per decode call, so removing it also provides a minor performance benefit. Note: The corresponding `sa_encode_impl` function does NOT have this issue (it correctly uses a local `minmax` that IS used), and the `train_inplace_impl` / `train_impl` functions also correctly use their `minmax` vectors. Only `sa_decode_impl` had this issue. Reviewed By: mnorris11 Differential Revision: D99851973 fbshipit-source-id: a288a4cd355ccc7d9e13d1f7d61bc54fc524675c
This commit is contained in:
committed by
meta-codesync[bot]
parent
364749e886
commit
25296bad4f
@@ -166,11 +166,6 @@ void sa_decode_impl(
|
||||
? chunk_size
|
||||
: static_cast<size_t>(n_input)) *
|
||||
old_code_size);
|
||||
std::vector<StorageMinMaxFP16> minmax(
|
||||
(chunk_size < static_cast<size_t>(n_input)
|
||||
? chunk_size
|
||||
: static_cast<size_t>(n_input)));
|
||||
|
||||
// all the elements to process
|
||||
size_t n_left = n_input;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user