Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion diskann-quantization/src/minmax/multi/max_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod tests {
where
Unsigned: Representation<NBITS>,
{
let input_mat = MatRef::new(Standard::<f32>::new(n, dim), input).unwrap();
let input_mat = MatRef::new(Standard::<f32>::new(n, dim).unwrap(), input).unwrap();
let mut output: Mat<MinMaxMeta<NBITS>> =
Mat::new(MinMaxMeta::new(n, dim), Defaulted).unwrap();
quantizer
Expand Down
18 changes: 11 additions & 7 deletions diskann-quantization/src/minmax/multi/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,9 @@ mod tests {
let input_data = generate_test_data(num_vectors, dim);

// Multi-vector compression
let input_view = MatRef::new(Standard::new(num_vectors, dim), &input_data)
.expect("input view creation");
let input_view =
MatRef::new(Standard::new(num_vectors, dim).unwrap(), &input_data)
.expect("input view creation");

let mut multi_mat: Mat<MinMaxMeta<NBITS>> =
Mat::new(MinMaxMeta::new(num_vectors, dim), Defaulted)
Expand Down Expand Up @@ -584,8 +585,8 @@ mod tests {
let quantizer = make_quantizer(dim);
let input_data = generate_test_data(num_vectors, dim);

let input_view =
MatRef::new(Standard::new(num_vectors, dim), &input_data).expect("input view");
let input_view = MatRef::new(Standard::new(num_vectors, dim).unwrap(), &input_data)
.expect("input view");

let mut mat: Mat<MinMaxMeta<NBITS>> =
Mat::new(MinMaxMeta::new(num_vectors, dim), Defaulted).expect("mat creation");
Expand Down Expand Up @@ -623,7 +624,8 @@ mod tests {

// Input has 3 vectors
let input_data = generate_test_data(3, dim);
let input_view = MatRef::new(Standard::new(3, dim), &input_data).expect("input view");
let input_view =
MatRef::new(Standard::new(3, dim).unwrap(), &input_data).expect("input view");

// Output has 2 vectors (mismatch)
let mut mat: Mat<MinMaxMeta<NBITS>> =
Expand All @@ -640,7 +642,8 @@ mod tests {

// Input has dim=8 (mismatch)
let input_data = generate_test_data(2, 8);
let input_view = MatRef::new(Standard::new(2, 8), &input_data).expect("input view");
let input_view =
MatRef::new(Standard::new(2, 8).unwrap(), &input_data).expect("input view");

// Output correctly has dim=4
let mut mat: Mat<MinMaxMeta<NBITS>> =
Expand All @@ -659,7 +662,8 @@ mod tests {

// Input correctly has dim=4
let input_data = generate_test_data(2, 4);
let input_view = MatRef::new(Standard::new(2, 4), &input_data).expect("input view");
let input_view =
MatRef::new(Standard::new(2, 4).unwrap(), &input_data).expect("input view");

// Output has intrinsic_dim=8 (mismatch)
let row_bytes = Data::<NBITS>::canonical_bytes(8);
Expand Down
4 changes: 2 additions & 2 deletions diskann-quantization/src/minmax/multi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
//! 0.0, 1.0, 0.0, 0.0, // query vector 1
//! ];
//! let query_input = MatRef::new(
//! Standard::new(num_query_vectors, dim), &query_data
//! Standard::new(num_query_vectors, dim).unwrap(), &query_data
//! ).unwrap();
//!
//! // Full-precision document multi-vector (3 vectors × 4 dimensions)
Expand All @@ -55,7 +55,7 @@
//! 0.0, 0.0, 1.0, 0.0, // doc vector 2
//! ];
//! let doc_input = MatRef::new(
//! Standard::new(num_doc_vectors, dim), &doc_data
//! Standard::new(num_doc_vectors, dim).unwrap(), &doc_data
//! ).unwrap();
//!
//! // Create owned matrices for quantized output using Mat::new
Expand Down
4 changes: 2 additions & 2 deletions diskann-quantization/src/multi_vector/distance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
//! // Query: 2 vectors of dim 3 (wrapped as QueryMatRef)
//! let query_data = [1.0f32, 0.0, 0.0, 0.0, 1.0, 0.0];
//! let query: QueryMatRef<_> = MatRef::new(
//! Standard::new(2, 3),
//! Standard::new(2, 3).unwrap(),
//! &query_data,
//! ).unwrap().into();
//!
//! // Doc: 2 vectors of dim 3
//! let doc_data = [1.0f32, 0.0, 0.0, 0.0, 0.0, 1.0];
//! let doc = MatRef::new(
//! Standard::new(2, 3),
//! Standard::new(2, 3).unwrap(),
//! &doc_data,
//! ).unwrap();
//!
Expand Down
8 changes: 4 additions & 4 deletions diskann-quantization/src/multi_vector/distance/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::multi_vector::{MatRef, MaxSimError, Repr, Standard};
/// use diskann_quantization::multi_vector::distance::QueryMatRef;
///
/// let data = [1.0f32, 2.0, 3.0, 4.0];
/// let view = MatRef::new(Standard::new(2, 2), &data).unwrap();
/// let view = MatRef::new(Standard::new(2, 2).unwrap(), &data).unwrap();
/// let query: QueryMatRef<_> = view.into();
/// ```
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -165,14 +165,14 @@ mod tests {

/// Helper to create a QueryMatRef from raw data
fn make_query(data: &[f32], nrows: usize, ncols: usize) -> QueryMatRef<'_, Standard<f32>> {
MatRef::new(Standard::new(nrows, ncols), data)
MatRef::new(Standard::new(nrows, ncols).unwrap(), data)
.unwrap()
.into()
}

/// Helper to create a MatRef from raw data
fn make_doc(data: &[f32], nrows: usize, ncols: usize) -> MatRef<'_, Standard<f32>> {
MatRef::new(Standard::new(nrows, ncols), data).unwrap()
MatRef::new(Standard::new(nrows, ncols).unwrap(), data).unwrap()
}

/// Naive implementation of max-sim for a single query vector against all doc vectors.
Expand All @@ -196,7 +196,7 @@ mod tests {
#[test]
fn from_mat_ref_and_deref() {
let data = [1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0];
let view = MatRef::new(Standard::new(2, 3), &data).unwrap();
let view = MatRef::new(Standard::new(2, 3).unwrap(), &data).unwrap();
let query: QueryMatRef<_> = view.into();

// Deref access works
Expand Down
Loading