pub fn build_minmax_max_sim<const A_BITS: usize, const B_BITS: usize>(
isa: MaxSimIsa,
query: QueryMatRef<'_, MinMaxMeta<A_BITS>>,
) -> Result<MinMaxMaxSim<B_BITS>, BuildMaxSimError>where
Unsigned: MinMaxKernelFactory<A_BITS, B_BITS>,Expand description
Build a kernel that owns a copy of the MinMax query.
Auto selects a backend at construction. Explicit ISA requests never silently
fall back. Reference uses an independent scalar implementation.
Kernels return negative maximum inner products, matching the MaxSim distance convention.
Supports equal query/document bit widths from 1 through 8, plus 8-bit queries with 1-, 2-, or 4-bit documents. Other combinations fail to compile.
§Errors
Returns BuildMaxSimError for an unavailable ISA, a query dimension exceeding
the bit-width pair’s accumulator limit, or an overflowing storage size.
Dimension and canonical-size checks apply to every backend, including empty queries;
packed-size checks apply only to prepared kernels.
Allocation exhaustion follows the allocator’s normal behavior.
§Example
use diskann_quantization::{
minmax::{MinMaxMeta, build_minmax_max_sim},
multi_vector::{Defaulted, Mat, MaxSimIsa, QueryMatRef},
};
let query = Mat::new(MinMaxMeta::<8>::new(2, 16), Defaulted)?;
let document = Mat::new(MinMaxMeta::<4>::new(3, 16), Defaulted)?;
let query = QueryMatRef::from(query.as_view());
let kernel = build_minmax_max_sim::<8, 4>(MaxSimIsa::Auto, query)?;
let mut scores = vec![0.0; kernel.nrows()];
kernel.compute_max_sim(document.as_view(), &mut scores)?;
assert_eq!(scores, vec![0.0; 2]);