Skip to content

Commit

Permalink
Make: Put maratyszcza/fp16 in Crates
Browse files Browse the repository at this point in the history
Closes #450

Co-authored-by: Michał Bartoszkiewicz <[email protected]>
  • Loading branch information
ashvardanian and embe-pw committed Aug 15, 2024
1 parent 4653c47 commit e125045
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ include = [
]

[features]
default = ["simsimd"] # SimSIMD is enabled by default
simsimd = [] # No need to do anything to enable SimSIMD by default
openmp = [] # Optional: Users can enable OpenMP
fp16lib = [] # Optional: Users can enable FP16 support
default = ["simsimd", "fp16lib"] # SimSIMD is enabled by default
simsimd = [] # No need to do anything to enable SimSIMD by default
fp16lib = [] # Without this FP16 we lose precision downcasting
openmp = [] # Optional: Users can enable OpenMP

[lib]
name = "usearch"
Expand Down
22 changes: 22 additions & 0 deletions rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,28 @@ mod tests {
}

#[test]
fn test_zero_distances() {
let options = IndexOptions {
dimensions: 8,
metric: MetricKind::L2sq,
quantization: ScalarKind::F16,
..Default::default()
};

let index = new_index(&options).unwrap();
index.reserve(10).unwrap();
index.add(0, &[0.4, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0]).unwrap();
index.add(1, &[0.5, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0]).unwrap();
index.add(2, &[0.6, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0]).unwrap();

// Make sure non of the distances are zeros
let matches = index.search(&[0.05, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0], 2).unwrap();
for distance in matches.distances.iter() {
assert_ne!(*distance, 0.0);
}
}

#[test]
fn test_change_distance_function() {
let mut options = IndexOptions::default();
options.dimensions = 2; // Adjusted for simplicity in creating test vectors
Expand Down

0 comments on commit e125045

Please sign in to comment.