forked from rapidsai/raft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More docs updates for 24.04 (rapidsai#54)
Authors: - Corey J. Nolet (https://github.com/cjnolet) Approvers: - Divye Gala (https://github.com/divyegala) URL: rapidsai/cuvs#54
- Loading branch information
Showing
6 changed files
with
162 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,11 @@ | ||
Working with ANN Indexes | ||
======================== | ||
|
||
- `Building an index`_ | ||
- `Searching an index`_ | ||
- `CPU/GPU Interoperability`_ | ||
- `Serializing an index`_ | ||
|
||
Building an index | ||
----------------- | ||
|
||
C | ||
^ | ||
|
||
.. code-block:: c | ||
#include <cuvs/neighbors/cagra.h> | ||
cuvsResources_t res; | ||
cuvsCagraIndexParams_t index_params; | ||
cuvsCagraIndex_t index; | ||
DLManagedTensor *dataset; | ||
load_dataset(dataset); | ||
cuvsResourcesCreate(&res); | ||
cuvsCagraIndexParamsCreate(&index_params); | ||
cuvsCagraIndexCreate(&index); | ||
cuvsCagraBuild(res, index_params, dataset, index); | ||
cuvsCagraIndexDestroy(index); | ||
cuvsCagraIndexParamsDestroy(index_params); | ||
cuvsResourcesDestroy(res); | ||
C++ | ||
^^^ | ||
|
||
.. code-block:: c++ | ||
|
||
#include <cuvs/neighbors/cagra.hpp> | ||
|
||
using namespace cuvs::neighbors; | ||
|
||
raft::device_matrix_view<float> dataset = load_dataset(); | ||
raft::device_resources res; | ||
|
||
cagra::index_params index_params; | ||
|
||
auto index = cagra::build(res, index_params, dataset); | ||
|
||
|
||
Python | ||
^^^^^^ | ||
|
||
.. code-block:: python | ||
from cuvs.neighbors import cagra | ||
dataset = load_data() | ||
index_params = cagra.IndexParams() | ||
index = cagra.build_index(build_params, dataset) | ||
Rust | ||
^^^^ | ||
|
||
.. code-block:: rust | ||
use cuvs::cagra::{Index, IndexParams}; | ||
use cuvs::{Resources, Result}; | ||
use ndarray_rand::rand_distr::Uniform; | ||
use ndarray_rand::RandomExt; | ||
/// Example showing how to index and search data with CAGRA | ||
fn cagra_example() -> Result<()> { | ||
let res = Resources::new()?; | ||
// Create a new random dataset to index | ||
let n_datapoints = 65536; | ||
let n_features = 512; | ||
let dataset = | ||
ndarray::Array::<f32, _>::random((n_datapoints, n_features), Uniform::new(0., 1.0)); | ||
// build the cagra index | ||
let build_params = IndexParams::new()?; | ||
let index = Index::build(&res, &build_params, &dataset)?; | ||
Ok(()) | ||
} | ||
Searching an index | ||
------------------ | ||
|
||
|
||
CPU/GPU interoperability | ||
------------------------ | ||
|
||
Serializing an index | ||
-------------------- | ||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
working_with_ann_indexes_c.rst | ||
working_with_ann_indexes_cpp.rst | ||
working_with_ann_indexes_python.rst | ||
working_with_ann_indexes_rust.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Working with ANN Indexes in C | ||
============================= | ||
|
||
- `Building an index`_ | ||
- `Searching an index`_ | ||
- `CPU/GPU Interoperability`_ | ||
- `Serializing an index`_ | ||
|
||
Building an index | ||
----------------- | ||
|
||
.. code-block:: c | ||
#include <cuvs/neighbors/cagra.h> | ||
cuvsResources_t res; | ||
cuvsCagraIndexParams_t index_params; | ||
cuvsCagraIndex_t index; | ||
DLManagedTensor *dataset; | ||
load_dataset(dataset); | ||
cuvsResourcesCreate(&res); | ||
cuvsCagraIndexParamsCreate(&index_params); | ||
cuvsCagraIndexCreate(&index); | ||
cuvsCagraBuild(res, index_params, dataset, index); | ||
cuvsCagraIndexDestroy(index); | ||
cuvsCagraIndexParamsDestroy(index_params); | ||
cuvsResourcesDestroy(res); | ||
Searching an index | ||
------------------ | ||
|
||
|
||
Serializing an index | ||
-------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Working with ANN Indexes in C++ | ||
=============================== | ||
|
||
- `Building an index`_ | ||
- `Searching an index`_ | ||
- `CPU/GPU Interoperability`_ | ||
- `Serializing an index`_ | ||
|
||
Building an index | ||
----------------- | ||
|
||
.. code-block:: c++ | ||
|
||
#include <cuvs/neighbors/cagra.hpp> | ||
|
||
using namespace cuvs::neighbors; | ||
|
||
raft::device_matrix_view<float> dataset = load_dataset(); | ||
raft::device_resources res; | ||
|
||
cagra::index_params index_params; | ||
|
||
auto index = cagra::build(res, index_params, dataset); | ||
|
||
|
||
|
||
Searching an index | ||
------------------ | ||
|
||
|
||
CPU/GPU interoperability | ||
------------------------ | ||
|
||
Serializing an index | ||
-------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Working with ANN Indexes in Python | ||
================================== | ||
|
||
- `Building an index`_ | ||
- `Searching an index`_ | ||
- `CPU/GPU Interoperability`_ | ||
- `Serializing an index`_ | ||
|
||
Building an index | ||
----------------- | ||
|
||
.. code-block:: python | ||
from cuvs.neighbors import cagra | ||
dataset = load_data() | ||
index_params = cagra.IndexParams() | ||
index = cagra.build_index(build_params, dataset) | ||
Searching an index | ||
------------------ | ||
|
||
|
||
CPU/GPU interoperability | ||
------------------------ | ||
|
||
Serializing an index | ||
-------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Working with ANN Indexes in Rust | ||
================================ | ||
|
||
- `Building an index`_ | ||
- `Searching an index`_ | ||
- `CPU/GPU Interoperability`_ | ||
- `Serializing an index`_ | ||
|
||
Building an index | ||
----------------- | ||
|
||
.. code-block:: rust | ||
use cuvs::cagra::{Index, IndexParams}; | ||
use cuvs::{Resources, Result}; | ||
use ndarray_rand::rand_distr::Uniform; | ||
use ndarray_rand::RandomExt; | ||
/// Example showing how to index and search data with CAGRA | ||
fn cagra_example() -> Result<()> { | ||
let res = Resources::new()?; | ||
// Create a new random dataset to index | ||
let n_datapoints = 65536; | ||
let n_features = 512; | ||
let dataset = | ||
ndarray::Array::<f32, _>::random((n_datapoints, n_features), Uniform::new(0., 1.0)); | ||
// build the cagra index | ||
let build_params = IndexParams::new()?; | ||
let index = Index::build(&res, &build_params, &dataset)?; | ||
Ok(()) | ||
} | ||
Searching an index | ||
------------------ | ||
|
||
|
||
Serializing an index | ||
-------------------- |