Skip to content
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

Add Rust bindings for CAGRA #34

Merged
merged 41 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a4ec121
Rust bindings for cuvs
benfred Feb 6, 2024
cae7cd3
share common workspace metadata
benfred Feb 6, 2024
160b363
support for building cagra index
benfred Feb 7, 2024
4e277e5
working search unittest
benfred Feb 12, 2024
0027115
cudaFree
benfred Feb 12, 2024
e11e4e0
functioning unittest
benfred Feb 13, 2024
15aceda
add cagra example program
benfred Feb 20, 2024
2e4b477
Add resources to to_host/to_device functions
benfred Feb 20, 2024
83e202e
add From trait for converting ndarray to ManagedTensor
benfred Feb 21, 2024
1990d02
basic CI
benfred Feb 21, 2024
5c7aafa
.
benfred Feb 21, 2024
b44b81c
.
benfred Feb 26, 2024
13b1848
.
benfred Feb 26, 2024
bd8c432
.
benfred Feb 26, 2024
d411803
.
benfred Feb 26, 2024
a2e8009
remove export
benfred Feb 26, 2024
b4dc043
.
benfred Feb 26, 2024
af4b0ba
.
benfred Feb 26, 2024
e7a47de
.
benfred Feb 26, 2024
a757060
one more time
benfred Feb 27, 2024
6c54aa4
don't download python artifacts
benfred Feb 27, 2024
79560c3
one more time
benfred Feb 27, 2024
023795d
.
benfred Feb 27, 2024
d3ceacf
add libclang
benfred Feb 27, 2024
a60edc8
add clang
benfred Feb 27, 2024
db00e6f
set LIBCLANG_PATH
benfred Feb 27, 2024
82ccb25
correct libclang_path
benfred Feb 27, 2024
1ffdfd7
check in cuvs_bindings.rs
benfred Feb 27, 2024
c091196
Revert "check in cuvs_bindings.rs"
benfred Feb 28, 2024
0005294
try harder with libclang
benfred Feb 28, 2024
fc413fb
.
benfred Feb 28, 2024
8397651
.
benfred Feb 28, 2024
4c26cd7
:facepalm:
benfred Feb 29, 2024
eddab35
Merge branch 'branch-24.04' into rust_bindings
benfred Feb 29, 2024
0433e07
.
benfred Mar 4, 2024
b3a9624
Merge branch 'branch-24.04' into rust_bindings
benfred Mar 4, 2024
3eec2c3
update to latest 24.04 cagra api
benfred Mar 4, 2024
6cd44b1
Merge branch 'rust_bindings' of https://github.com/benfred/cuvs into …
benfred Mar 4, 2024
2dd4ea0
add example to README
benfred Mar 4, 2024
a781042
.
benfred Mar 4, 2024
e836117
update dependencies.yaml
benfred Mar 4, 2024
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
Prev Previous commit
Next Next commit
update to latest 24.04 cagra api
  • Loading branch information
benfred committed Mar 4, 2024
commit 3eec2c3ac33a36f68011d26e3208633dd1fcabe3
2 changes: 1 addition & 1 deletion rust/cuvs-sys/cuvs_c_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
// wrapper file containing all the C-API's we should automatically be creating rust
// bindings for
#include <cuvs/core/c_api.h>
#include <cuvs/neighbors/cagra_c.h>
#include <cuvs/neighbors/cagra.h>
6 changes: 3 additions & 3 deletions rust/cuvs-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ mod tests {
#[test]
fn test_create_cagra_index() {
unsafe {
let mut index = core::mem::MaybeUninit::<cagraIndex_t>::uninit();
let mut index = core::mem::MaybeUninit::<cuvsCagraIndex_t>::uninit();
assert_eq!(
cagraIndexCreate(index.as_mut_ptr()),
cuvsCagraIndexCreate(index.as_mut_ptr()),
cuvsError_t::CUVS_SUCCESS
);
let index = index.assume_init();
assert_eq!(cagraIndexDestroy(index), cuvsError_t::CUVS_SUCCESS);
assert_eq!(cuvsCagraIndexDestroy(index), cuvsError_t::CUVS_SUCCESS);
}
}

Expand Down
12 changes: 6 additions & 6 deletions rust/cuvs/src/cagra/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::error::{check_cuvs, Result};
use crate::resources::Resources;

#[derive(Debug)]
pub struct Index(ffi::cagraIndex_t);
pub struct Index(ffi::cuvsCagraIndex_t);

impl Index {
/// Builds a new index
Expand All @@ -34,16 +34,16 @@ impl Index {
let dataset: ManagedTensor = dataset.into();
let index = Index::new()?;
unsafe {
check_cuvs(ffi::cagraBuild(res.0, params.0, dataset.as_ptr(), index.0))?;
check_cuvs(ffi::cuvsCagraBuild(res.0, params.0, dataset.as_ptr(), index.0))?;
}
Ok(index)
}

/// Creates a new empty index
pub fn new() -> Result<Index> {
unsafe {
let mut index = core::mem::MaybeUninit::<ffi::cagraIndex_t>::uninit();
check_cuvs(ffi::cagraIndexCreate(index.as_mut_ptr()))?;
let mut index = core::mem::MaybeUninit::<ffi::cuvsCagraIndex_t>::uninit();
check_cuvs(ffi::cuvsCagraIndexCreate(index.as_mut_ptr()))?;
Ok(Index(index.assume_init()))
}
}
Expand All @@ -57,7 +57,7 @@ impl Index {
distances: &ManagedTensor,
) -> Result<()> {
unsafe {
check_cuvs(ffi::cagraSearch(
check_cuvs(ffi::cuvsCagraSearch(
res.0,
params.0,
self.0,
Expand All @@ -71,7 +71,7 @@ impl Index {

impl Drop for Index {
fn drop(&mut self) {
if let Err(e) = check_cuvs(unsafe { ffi::cagraIndexDestroy(self.0) }) {
if let Err(e) = check_cuvs(unsafe { ffi::cuvsCagraIndexDestroy(self.0) }) {
write!(stderr(), "failed to call cagraIndexDestroy {:?}", e)
.expect("failed to write to stderr");
}
Expand Down
2 changes: 1 addition & 1 deletion rust/cuvs/src/cagra/index_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::error::{check_cuvs, Result};
use std::fmt;
use std::io::{stderr, Write};

pub type BuildAlgo = ffi::cagraGraphBuildAlgo;
pub type BuildAlgo = ffi::cuvsCagraGraphBuildAlgo;

/// Supplemental parameters to build CAGRA Index
pub struct IndexParams(pub ffi::cuvsCagraIndexParams_t);
Expand Down
4 changes: 2 additions & 2 deletions rust/cuvs/src/cagra/search_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::error::{check_cuvs, Result};
use std::fmt;
use std::io::{stderr, Write};

pub type SearchAlgo = ffi::cagraSearchAlgo;
pub type HashMode = ffi::cagraHashMode;
pub type SearchAlgo = ffi::cuvsCagraSearchAlgo;
pub type HashMode = ffi::cuvsCagraHashMode;

/// Supplemental parameters to search CAGRA index
pub struct SearchParams(pub ffi::cuvsCagraSearchParams_t);
Expand Down