Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5032
Convert supported metric type assert to throw in `to_svs_metric()` to
better support tests that expect exceptions when processing invalid input.
There are two vectors that reach `to_svs_metric()` with an unsupported
metric:
1. **Deserialization** (`deserialize_impl()`):
A invalid binary index with fourcc `"IBFf"`
(IndexBinaryFromFloat) wrapping an SVS float index (`"ISVF"`,
`"ILVQ"`, etc.) can carry any valid `MetricType` in the
serialized stream. When the metric is not L2 or INNER_PRODUCT,
`to_svs_metric()` is called with the unsupported value during
`deserialize_impl()`.
2. **Programmatic construction** (`create_impl()`):
Creating an SVS index (e.g., `IndexSVSFlat`) with an unsupported
metric and calling `add()` triggers `create_impl()` which calls
`to_svs_metric()`. This is a user-error path.
Reviewed By: mnorris11
Differential Revision: D99336458
fbshipit-source-id: ee5449b72e957a5e7eb77f651471f84c34e5c122