ashvardanian / SimSIMD

Up to 200x Faster Inner Products and Vector Similarity — for Python, JavaScript, Rust, C, and Swift, supporting f64, f32, f16 real & complex, i8, and binary vectors using SIMD for both x86 AVX2 & AVX-512 and Arm NEON & SVE 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
797 stars 42 forks source link

feat: Add Rust binding for SimSIMD library #75

Closed pplanel closed 5 months ago

pplanel commented 5 months ago

This pull request is the beginning of the Rust binding implementation. I would like guidance on reexporting the library's functionalities.

This draft was created based on the header present in the golang binding.

If you have any specific questions or need guidance on a particular aspect of the implementation, feel free to provide more details, and I'll do my best to assist you!

Description

This pull request adds Rust bindings for the simsimd C++ library. The Rust code is generated using the bindgen crate, and the build process includes compiling the C++ source file into a static library. The Rust bindings provide utility functions for cosine, inner product, and squared Euclidean distance based on the Golang Cgo header file.

Changes Made

Checklist

ashvardanian commented 5 months ago

Hi, @pplanel! Thanks a lot for your effort!

There are a couple of things that catch the eye:

  1. Let's not use bindgen and other high-level tools - see this StringZilla PR
  2. Using traits is a better way to pick the right overload, adding a type-specific suffix is a force decision in Go, as it doesn't support overloading function names - see USearch binding

Please let me know if you'd have time to patch those 🤗

pplanel commented 5 months ago

Hey, @ashvardanian. Thanks for your feedback! I have addressed the points you raised, added docs and benchmark.

pplanel commented 5 months ago

Oh, and I updated the crate folder structure based on StringZilla and USearch crates.

ashvardanian commented 5 months ago

:tada: This PR is included in version 3.7.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: