Attention

The vector search and clustering algorithms in RAFT are being migrated to a new library dedicated to vector search called cuVS. We will continue to support the vector search algorithms in RAFT during this move, but will no longer update them after the RAPIDS 24.06 (June) release. We plan to complete the migration by RAPIDS 24.10 (October) release and they will be removed from RAFT altogether in the 24.12 (December) release.

Operators and Functors#

#include <raft/core/operators.hpp>

namespace raft::core

template<typename Type>
using add_const_op = plug_const_op<Type, add_op>#
template<typename Type>
using sub_const_op = plug_const_op<Type, sub_op>#
template<typename Type>
using mul_const_op = plug_const_op<Type, mul_op>#
template<typename Type>
using div_const_op = plug_const_op<Type, div_op>#
template<typename Type>
using div_checkzero_const_op = plug_const_op<Type, div_checkzero_op>#
template<typename Type>
using pow_const_op = plug_const_op<Type, pow_op>#
template<typename Type>
using mod_const_op = plug_const_op<Type, mod_op>#
template<typename Type>
using equal_const_op = plug_const_op<Type, equal_op>#
using absdiff_op = compose_op<abs_op, sub_op>#
using sqdiff_op = compose_op<sq_op, sub_op>#
struct identity_op#
#include <operators.hpp>

Subclassed by raft::neighbors::experimental::nn_descent::DistEpilogue< value_idx, value_t >

struct void_op#
#include <operators.hpp>
template<typename OutT>
struct cast_op#
#include <operators.hpp>
struct key_op#
#include <operators.hpp>
struct value_op#
#include <operators.hpp>
struct sqrt_op#
#include <operators.hpp>
struct nz_op#
#include <operators.hpp>
struct abs_op#
#include <operators.hpp>
struct sq_op#
#include <operators.hpp>
struct add_op#
#include <operators.hpp>
struct sub_op#
#include <operators.hpp>
struct mul_op#
#include <operators.hpp>
struct div_op#
#include <operators.hpp>
struct div_checkzero_op#
#include <operators.hpp>
struct pow_op#
#include <operators.hpp>
struct mod_op#
#include <operators.hpp>
struct min_op#
#include <operators.hpp>
struct max_op#
#include <operators.hpp>
struct argmin_op#
#include <operators.hpp>
struct argmax_op#
#include <operators.hpp>
struct greater_op#
#include <operators.hpp>
struct less_op#
#include <operators.hpp>
struct greater_or_equal_op#
#include <operators.hpp>
struct less_or_equal_op#
#include <operators.hpp>
struct equal_op#
#include <operators.hpp>
struct notequal_op#
#include <operators.hpp>
template<typename ScalarT>
struct const_op#
#include <operators.hpp>
template<typename ConstT, typename BinaryOpT>
struct plug_const_op#
#include <operators.hpp>

Wraps around a binary operator, passing a constant on the right-hand side.

Usage example:

#include <raft/core/operators.hpp>

raft::plug_const_op<float, raft::mul_op> op(2.0f);
std::cout << op(2.1f) << std::endl;  // 4.2

Template Parameters:
  • ConstT

  • BinaryOpT

template<typename ...OpsT>
struct compose_op#
#include <operators.hpp>

Constructs an operator by composing a chain of operators.

Note that all arguments are passed to the innermost operator.

Usage example:

#include <raft/core/operators.hpp>

auto op = raft::compose_op(raft::sqrt_op(), raft::abs_op(), raft::cast_op<float>(),
                           raft::add_const_op<int>(8));
std::cout << op(-50) << std::endl;  // 6.48074

Template Parameters:

OpsT – Any number of operation types.

template<typename OuterOpT, typename ...ArgOpsT>
struct map_args_op#
#include <operators.hpp>

Constructs an operator by composing an outer op with one inner op for each of its inputs.

Usage example:

#include <raft/core/operators.hpp>

raft::map_args_op<raft::add_op, raft::sqrt_op, raft::cast_op<float>> op;
std::cout << op(42.0f, 10) << std::endl;  // 16.4807

Template Parameters:
  • OuterOpT – Outer operation type

  • ArgOpsT – Operation types for each input of the outer operation