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.08 (August) release.
Arithmetic#
Addition#
#include <raft/linalg/add.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void add(raft::resources const &handle, InType in1, InType in2, OutType out)# Elementwise add operation.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] raft::resources
in1 – [in] First Input
in2 – [in] Second Input
out – [out] Output
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void add_scalar(raft::resources const &handle, InType in, OutType out, raft::device_scalar_view<const typename InType::value_type, ScalarIdxType> scalar)# Elementwise addition of device scalar to input.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
scalar – [in] raft::device_scalar_view
out – [in] Output
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void add_scalar(raft::resources const &handle, const InType in, OutType out, raft::host_scalar_view<const typename InType::value_type, ScalarIdxType> scalar)# Elementwise addition of host scalar to input.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
scalar – [in] raft::host_scalar_view
out – [in] Output
Binary Op#
#include <raft/linalg/binary_op.cuh>
namespace raft::linalg
-
template<typename InType, typename Lambda, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void binary_op(raft::resources const &handle, InType in1, InType in2, OutType out, Lambda op)# perform element-wise binary operation on the input arrays
Note
Lambda must be a functor with the following signature:
OutType func(const InType& val1, const InType& val2);
- Template Parameters:
InType – Input Type raft::device_mdspan
Lambda – the device-lambda performing the actual operation
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] raft::resources
in1 – [in] First input
in2 – [in] Second input
out – [out] Output
op – [in] the device-lambda
Division#
#include <raft/linalg/divide.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void divide_scalar(raft::resources const &handle, InType in, OutType out, raft::host_scalar_view<const typename InType::value_type, ScalarIdxType> scalar)# Elementwise division of input by host scalar.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
scalar – [in] raft::host_scalar_view
out – [out] Output
Multiplication#
#include <raft/linalg/multiply.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void multiply_scalar(raft::resources const &handle, InType in, OutType out, raft::host_scalar_view<const typename InType::value_type, ScalarIdxType> scalar)# Element-wise multiplication of host scalar.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] the input buffer
out – [out] the output buffer
scalar – [in] the scalar used in the operations
Power#
#include <raft/linalg/power.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void power(raft::resources const &handle, InType in1, InType in2, OutType out)# Elementwise power operation on the input buffers.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] raft::resources
in1 – [in] First Input
in2 – [in] Second Input
out – [out] Output
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void power_scalar(raft::resources const &handle, InType in, OutType out, const raft::host_scalar_view<const typename InType::value_type, ScalarIdxType> scalar)# Elementwise power of host scalar to input.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
out – [out] Output
scalar – [in] raft::host_scalar_view
Square Root#
#include <raft/linalg/sqrt.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void sqrt(raft::resources const &handle, InType in, OutType out)# Elementwise sqrt operation.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] raft::resources
in – [in] Input
out – [out] Output
Subtraction#
#include <raft/linalg/subtract.cuh>
namespace raft::linalg
-
template<typename InType, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void subtract(raft::resources const &handle, InType in1, InType in2, OutType out)# Elementwise subtraction operation on the input buffers.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
- Parameters:
handle – raft::resources
in1 – [in] First Input
in2 – [in] Second Input
out – [out] Output
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void subtract_scalar(raft::resources const &handle, InType in, OutType out, raft::device_scalar_view<const typename InType::element_type, ScalarIdxType> scalar)# Elementwise subtraction of device scalar to input.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
out – [out] Output
scalar – [in] raft::device_scalar_view
-
template<typename InType, typename OutType, typename ScalarIdxType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void subtract_scalar(raft::resources const &handle, InType in, OutType out, raft::host_scalar_view<const typename InType::element_type, ScalarIdxType> scalar)# Elementwise subtraction of host scalar to input.
- Template Parameters:
InType – Input Type raft::device_mdspan
OutType – Output Type raft::device_mdspan
ScalarIdxType – Index Type of scalar
- Parameters:
handle – [in] raft::resources
in – [in] Input
out – [out] Output
scalar – [in] raft::host_scalar_view
Ternary Op#
#include <raft/linalg/ternary_op.cuh>
namespace raft::linalg
-
template<typename InType, typename Lambda, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void ternary_op(raft::resources const &handle, InType in1, InType in2, InType in3, OutType out, Lambda op)# perform element-wise ternary operation on the input arrays
Note
Lambda must be a functor with the following signature:
OutType func(const InType& val1, const InType& val2, const InType& val3);
- Template Parameters:
InType – Input Type raft::device_mdspan
Lambda – the device-lambda performing the actual operation
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] raft::resources
in1 – [in] First input
in2 – [in] Second input
in3 – [in] Third input
out – [out] Output
op – [in] the device-lambda
Unary Op#
#include <raft/linalg/unary_op.cuh>
namespace raft::linalg
-
template<typename InType, typename Lambda, typename OutType, typename = raft::enable_if_input_device_mdspan<InType>, typename = raft::enable_if_output_device_mdspan<OutType>>
void unary_op(raft::resources const &handle, InType in, OutType out, Lambda op)# Perform an element-wise unary operation into the output array.
- Template Parameters:
InType – Input Type raft::device_mdspan
Lambda – Device lambda performing the actual operation, with the signature
out_value_t func(const in_value_t& val);
OutType – Output Type raft::device_mdspan
- Parameters:
handle – [in] The raft handle
in – [in] Input
out – [out] Output
op – [in] Device lambda
-
template<typename OutType, typename Lambda, typename = raft::enable_if_output_device_mdspan<OutType>>
void write_only_unary_op(const raft::resources &handle, OutType out, Lambda op)# Perform an element-wise unary operation on the input index into the output array.
Note
This operation is deprecated. Please use map_offset in
raft/linalg/map.cuh
instead.- Template Parameters:
OutType – Output Type raft::device_mdspan
Lambda – Device lambda performing the actual operation, with the signature
void func(out_value_t* out_location, index_t idx);
- Parameters:
handle – [in] The raft handle
out – [out] Output
op – [in] Device lambda