注意

RAFT 中的向量搜索和聚类算法正在迁移到名为 cuVS 的新向量搜索专用库。在迁移过程中,我们将继续支持 RAFT 中的向量搜索算法,但在 RAPIDS 24.06(六月)发布后将不再更新它们。我们计划在 RAPIDS 24.10(十月)发布时完成迁移,并在 24.12(十二月)发布中将它们完全从 RAFT 中移除。

BLAS 例程#

axpy#

#include <raft/linalg/axpy.cuh>

namespace raft::linalg

template<typename ElementType, typename IndexType, typename InLayoutPolicy, typename OutLayoutPolicy, typename ScalarIdxType>
void axpy(raft::resources const &handle, raft::device_scalar_view<const ElementType, ScalarIdxType> alpha, raft::device_vector_view<const ElementType, IndexType, InLayoutPolicy> x, raft::device_vector_view<ElementType, IndexType, OutLayoutPolicy> y)#

axpy 函数。它计算以下方程: y = alpha * x + y

参数:
  • handle[in] raft::resources

  • alpha[in] raft::device_scalar_view

  • x[in] 输入向量

  • y[inout] 输出向量

template<typename ElementType, typename IndexType, typename InLayoutPolicy, typename OutLayoutPolicy, typename ScalarIdxType>
void axpy(raft::resources const &handle, raft::host_scalar_view<const ElementType, ScalarIdxType> alpha, raft::device_vector_view<const ElementType, IndexType, InLayoutPolicy> x, raft::device_vector_view<ElementType, IndexType, OutLayoutPolicy> y)#

axpy 函数。它计算以下方程: y = alpha * x + y

参数:
  • handle[in] raft::resources

  • alpha[in] raft::device_scalar_view

  • x[in] 输入向量

  • y[inout] 输出向量

dot#

#include <raft/linalg/dot.cuh>

namespace raft::linalg

template<typename ElementType, typename IndexType, typename ScalarIndexType, typename LayoutPolicy1, typename LayoutPolicy2>
void dot(raft::resources const &handle, raft::device_vector_view<const ElementType, IndexType, LayoutPolicy1> x, raft::device_vector_view<const ElementType, IndexType, LayoutPolicy2> y, raft::device_scalar_view<ElementType, ScalarIndexType> out)#

计算两个向量的点积。

参数:
  • handle[in] raft::resources

  • x[in] 第一个输入向量

  • y[in] 第二个输入向量

  • out[out] x 和 y 向量的点积输出。

template<typename ElementType, typename IndexType, typename ScalarIndexType, typename LayoutPolicy1, typename LayoutPolicy2>
void dot(raft::resources const &handle, raft::device_vector_view<const ElementType, IndexType, LayoutPolicy1> x, raft::device_vector_view<const ElementType, IndexType, LayoutPolicy2> y, raft::host_scalar_view<ElementType, ScalarIndexType> out)#

计算两个向量的点积。

参数:
  • handle[in] raft::resources

  • x[in] 第一个输入向量

  • y[in] 第二个输入向量

  • out[out] x 和 y 向量的点积输出。

gemm#

#include <raft/linalg/gemm.hpp>

namespace raft::linalg

template<typename ValueType, typename IndexType, typename LayoutPolicyX, typename LayoutPolicyY, typename LayoutPolicyZ, typename ScalarIdxType = std::uint32_t, typename ScalarViewType = raft::host_scalar_view<ValueType, ScalarIdxType>, typename = std::enable_if_t<std::disjunction_v<std::is_same<ScalarViewType, raft::host_scalar_view<ValueType, ScalarIdxType>>, std::is_same<ScalarViewType, raft::device_scalar_view<ValueType, ScalarIdxType>>>>>
void gemm(raft::resources const &res, raft::device_matrix_view<ValueType, IndexType, LayoutPolicyX> x, raft::device_matrix_view<ValueType, IndexType, LayoutPolicyY> y, raft::device_matrix_view<ValueType, IndexType, LayoutPolicyZ> z, std::optional<ScalarViewType> alpha = std::nullopt, std::optional<ScalarViewType> beta = std::nullopt)#

GEMM 函数旨在处理所有可能的运算对象布局组合(raft::row_majorraft::col_major),支持在主机或设备上使用标量 alpha 和 beta。它计算以下方程:Z = alpha . X * Y + beta . Z 如果未提供 alpha,则假定为 1.0 如果未提供 beta,则假定为 0.0。

模板参数:
  • ValueType – 输入/输出矩阵的数据类型 (float/double)

  • IndexType – 索引类型

  • LayoutPolicyX – X 的布局

  • LayoutPolicyY – Y 的布局

  • LayoutPolicyZ – Z 的布局

参数:

gemv#

#include <raft/linalg/gemv.cuh>

namespace raft::linalg

template<typename ValueType, typename IndexType, typename LayoutPolicy, typename ScalarIdxType = std::uint32_t, typename ScalarViewType = raft::host_scalar_view<ValueType, ScalarIdxType>, typename = std::enable_if_t<std::disjunction_v<std::is_same<ScalarViewType, raft::host_scalar_view<ValueType, ScalarIdxType>>, std::is_same<ScalarViewType, raft::device_scalar_view<ValueType, ScalarIdxType>>>>>
void gemv(raft::resources const &handle, raft::device_matrix_view<const ValueType, IndexType, LayoutPolicy> A, raft::device_vector_view<const ValueType, IndexType> x, raft::device_vector_view<ValueType, IndexType> y, std::optional<ScalarViewType> alpha = std::nullopt, std::optional<ScalarViewType> beta = std::nullopt)#

GEMV 函数专为 A 的 raft::col_major 布局设计。它计算 y = alpha * op(A) * x + beta * y,其中 y 的长度是 A 的行数,x 的长度是 A 的列数。如果 A 的布局提供为 raft::row_major,则计算中使用 A 的转置,其中 y 的长度是 A 的列数,x 的长度是 A 的行数。如果未提供 alpha,则假定为 1.0 如果未提供 beta,则假定为 0.0。

模板参数:
  • ValueType – 输入/输出矩阵的数据类型 (float/double)

  • IndexType – 索引类型

  • LayoutPolicyX – X 的布局

  • LayoutPolicyY – Y 的布局

  • LayoutPolicyZ – Z 的布局

参数: