-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L2 distance #439
L2 distance #439
Conversation
|
||
/// Euclidean Distance (L2) from a point to a list of points. | ||
pub fn l2_distance(from: &Float32Array, to: &FixedSizeListArray) -> Result<Arc<Float32Array>> { | ||
assert_eq!(from.len(), to.value_length() as usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these stay in production? These panic right? Should these return Err in stead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not error, but bugs. Err
is catchable & recoverable by the users, this is not the case?
rust/src/utils/distance.rs
Outdated
pub fn l2_distance(from: &Float32Array, to: &FixedSizeListArray) -> Result<Arc<Float32Array>> { | ||
assert_eq!(from.len(), to.value_length() as usize); | ||
assert_eq!(to.value_type(), DataType::Float32); | ||
assert_eq!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an odd constraint no? shouldn't there be a non-optimized case that can deal with non-multiples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, added a fallback to non SIMD route for odd length vectors.
Use
std::arch
provided by the stable Rust. We could usestd::simd
when it is ready for stable rust.Note that, I did not hand write simd for M1 / Aarch64 yet,
std::arch::aarch64
seems not stable at the moment. Also, no BLAS-based performance is tested so that there is no extra dependency for Lance.