Bruteforce#

The bruteforce method is running the KNN algorithm. It performs an extensive search, and in contrast to ANN methods produces an exact result.

#include <raft/neighbors/bruteforce.h>

Index#

typedef cuvsBruteForceIndex *cuvsBruteForceIndex_t#
cuvsError_t cuvsBruteForceIndexCreate(cuvsBruteForceIndex_t *index)#

Allocate BRUTEFORCE index.

Parameters:

index[in] cuvsBruteForceIndex_t to allocate

Returns:

cuvsError_t

cuvsError_t cuvsBruteForceIndexDestroy(cuvsBruteForceIndex_t index)#

De-allocate BRUTEFORCE index.

Parameters:

index[in] cuvsBruteForceIndex_t to de-allocate

struct cuvsBruteForceIndex#
#include <brute_force.h>

Struct to hold address of cuvs::neighbors::brute_force::index and its active trained dtype.

Index build#

cuvsError_t cuvsBruteForceBuild(cuvsResources_t res, DLManagedTensor *dataset, cuvsDistanceType metric, float metric_arg, cuvsBruteForceIndex_t index)#

Build a BRUTEFORCE index with a DLManagedTensor which has underlying DLDeviceType equal to kDLCUDA, kDLCUDAHost, kDLCUDAManaged, or kDLCPU. Also, acceptable underlying types are:

  1. kDLDataType.code == kDLFloat and kDLDataType.bits = 32

  2. kDLDataType.code == kDLInt and kDLDataType.bits = 8

  3. kDLDataType.code == kDLUInt and kDLDataType.bits = 8

#include <cuvs/core/c_api.h>
#include <cuvs/neighbors/brute_force.h>

// Create cuvsResources_t
cuvsResources_t res;
cuvsError_t res_create_status = cuvsResourcesCreate(&res);

// Assume a populated `DLManagedTensor` type here
DLManagedTensor dataset;

// Create BRUTEFORCE index
cuvsBruteForceIndex_t index;
cuvsError_t index_create_status = cuvsBruteForceIndexCreate(&index);

// Build the BRUTEFORCE Index
cuvsError_t build_status = cuvsBruteForceBuild(res, &dataset_tensor, L2Expanded, 0.f, index);

// de-allocate `index` and `res`
cuvsError_t index_destroy_status = cuvsBruteForceIndexDestroy(index);
cuvsError_t res_destroy_status = cuvsResourcesDestroy(res);
Parameters:
  • res[in] cuvsResources_t opaque C handle

  • dataset[in] DLManagedTensor* training dataset

  • metric[in] metric

  • metric_arg[in] metric_arg

  • index[out] cuvsBruteForceIndex_t Newly built BRUTEFORCE index

Returns:

cuvsError_t

Index serialize#

Warning

doxygengroup: Cannot find group “bruteforce_c_index_serialize” in doxygen xml output for project “cuvs” from directory: ../../cpp/doxygen/_xml/