diff --git a/README.md b/README.md index 4f34bbc6b0..f73d474efc 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ While not exhaustive, the following general categories help summarize the accele | **Spatial** | pairwise distances, nearest neighbors, neighborhood graph construction | | **Sparse Operations** | linear algebra, eigenvalue problems, slicing, symmetrization, labeling | | **Basic Clustering** | spectral clustering, hierarchical clustering, k-means | -| **Optimization** | combinatorial optimization, iterative solvers | +| **Solvers** | combinatorial optimization, iterative solvers | | **Statistics** | sampling, moments and summary statistics, metrics | | **Distributed Tools** | multi-node multi-gpu infrastructure | diff --git a/cpp/doxygen/Doxyfile.in b/cpp/doxygen/Doxyfile.in index c83224050e..2ca265c454 100644 --- a/cpp/doxygen/Doxyfile.in +++ b/cpp/doxygen/Doxyfile.in @@ -798,7 +798,7 @@ INPUT_ENCODING = UTF-8 # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, # *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. -FILE_PATTERNS = *.hpp +FILE_PATTERNS = *.hpp *.cuh # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -814,8 +814,7 @@ RECURSIVE = YES # run. EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/include/raft/sparse/linalg/symmetrize.hpp \ # Contains device code - @CMAKE_CURRENT_SOURCE_DIR@/include/raft/sparse/csr.hpp \ # Contains device code - @CMAKE_CURRENT_SOURCE_DIR@/include/raft/sparse/detail/cusparse_wrappers.h + @CMAKE_CURRENT_SOURCE_DIR@/include/raft/sparse/csr.hpp # Contains device code # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -832,8 +831,7 @@ EXCLUDE_SYMLINKS = NO # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = */detail/* \ - */specializations/* \ - */spectral/* + */specializations/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/cpp/doxygen/main_page.md b/cpp/doxygen/main_page.md index 070a8f1f1d..ff0c7820c7 100644 --- a/cpp/doxygen/main_page.md +++ b/cpp/doxygen/main_page.md @@ -1,14 +1,22 @@ # libraft -RAFT (RAPIDS Analytics Framework Toolkit) is a library containing building-blocks for rapid composition of RAPIDS Analytics. These building-blocks include shared representations, mathematical computational primitives, and utilities that accelerate building analytics and data science algorithms in the RAPIDS ecosystem. Both the C++ and Python components can be included in consuming libraries, providing building-blocks for both dense and sparse matrix formats in the following general categories: +RAFT contains fundamental widely-used algorithms and primitives for data science, graph and machine learning. The algorithms are CUDA-accelerated and form building-blocks for rapidly composing analytics. + +By taking a primitives-based approach to algorithm development, RAFT +- accelerates algorithm construction time, +- reduces the maintenance burden by maximizing reuse across projects, and +- centralizes core reusable computations, allowing future optimizations to benefit all algorithms that use them. + +While not exhaustive, the following general categories help summarize the accelerated functions in RAFT: ##### -| Category | Description / Examples | +| Category | Examples | | --- | --- | -| **Data Formats** | tensor representations and conversions for both sparse and dense formats | -| **Data Generation** | graph, spatial, and machine learning dataset generation | -| **Dense Operations** | linear algebra, statistics | -| **Spatial** | pairwise distances, nearest neighbors, neighborhood / proximity graph construction | -| **Sparse/Graph Operations** | linear algebra, statistics, slicing, msf, spectral embedding/clustering, slhc, vertex degree | -| **Solvers** | eigenvalue decomposition, least squares, lanczos | -| **Tools** | multi-node multi-gpu communicator, utilities | +| **Data Formats** | sparse & dense, conversions, data generation | +| **Dense Linear Algebra** | matrix arithmetic, norms, factorization, least squares, svd & eigenvalue problems | +| **Spatial** | pairwise distances, nearest neighbors, neighborhood graph construction | +| **Sparse Operations** | linear algebra, eigenvalue problems, slicing, symmetrization, labeling | +| **Basic Clustering** | spectral clustering, hierarchical clustering, k-means | +| **Solvers** | combinatorial optimization, iterative solvers | +| **Statistics** | sampling, moments and summary statistics, metrics | +| **Distributed Tools** | multi-node multi-gpu infrastructure | diff --git a/cpp/include/raft.hpp b/cpp/include/raft.hpp index fff4d09ffe..b1b8255b7e 100644 --- a/cpp/include/raft.hpp +++ b/cpp/include/raft.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. */ #include "raft/handle.hpp" #include "raft/mdarray.hpp" diff --git a/cpp/include/raft/cache/cache_util.cuh b/cpp/include/raft/cache/cache_util.cuh index dc9327bb94..3e2222eff1 100644 --- a/cpp/include/raft/cache/cache_util.cuh +++ b/cpp/include/raft/cache/cache_util.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ __global__ void store_vecs(const math_t* tile, * @brief Map a key to a cache set. * * @param key key to be hashed - * @param n_cache_set number of cache sets + * @param n_cache_sets number of cache sets * @return index of the cache set [0..n_cache_set) */ int DI hash(int key, int n_cache_sets) { return key % n_cache_sets; } diff --git a/cpp/include/raft/comms/comms.hpp b/cpp/include/raft/comms/comms.hpp index b30a4648a6..9fb2b5a2c6 100644 --- a/cpp/include/raft/comms/comms.hpp +++ b/cpp/include/raft/comms/comms.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use raft_runtime/comms.hpp instead. */ diff --git a/cpp/include/raft/cudart_utils.h b/cpp/include/raft/cudart_utils.h index 3a18d7e420..4ba1e18768 100644 --- a/cpp/include/raft/cudart_utils.h +++ b/cpp/include/raft/cudart_utils.h @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use raft_runtime/cudart_utils.hpp instead. */ diff --git a/cpp/include/raft/device_atomics.cuh b/cpp/include/raft/device_atomics.cuh index e3b324d030..d1ca239170 100644 --- a/cpp/include/raft/device_atomics.cuh +++ b/cpp/include/raft/device_atomics.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -462,7 +462,7 @@ struct typesAtomicCASImpl { * int8_t, int16_t, int32_t, int64_t, float, double * * @param[in] address The address of old value in global or shared memory - * @param[in] val The value to be computed + * @param[in] update_value The value to be computed * @param[in] op The binary operator used for compute * * @returns The old value at `address` diff --git a/cpp/include/raft/distance/distance.cuh b/cpp/include/raft/distance/distance.cuh index e13cfd94f8..d8e60550ca 100644 --- a/cpp/include/raft/distance/distance.cuh +++ b/cpp/include/raft/distance/distance.cuh @@ -25,6 +25,11 @@ #include +/** + * @defgroup pairwise_distance pairwise distance prims + * @{ + */ + namespace raft { namespace distance { @@ -267,12 +272,11 @@ void distance(raft::handle_t const& handle, } /** - * @defgroup pairwise_distance pairwise distance prims - * @{ * @brief Convenience wrapper around 'distance' prim to convert runtime metric * into compile time for the purpose of dispatch * @tparam Type input/accumulation/output data-type * @tparam Index_ indexing type + * @param handle raft handle for managing expensive resources * @param x first set of points * @param y second set of points * @param dist output distance matrix @@ -282,8 +286,8 @@ void distance(raft::handle_t const& handle, * @param workspace temporary workspace buffer which can get resized as per the * needed workspace size * @param metric distance metric - * @param stream cuda stream * @param isRowMajor whether the matrices are row-major or col-major + * @param metric_arg metric argument (used for Minkowski distance) */ template void pairwise_distance(const raft::handle_t& handle, @@ -363,15 +367,13 @@ void pairwise_distance(const raft::handle_t& handle, default: THROW("Unknown or unsupported distance metric '%d'!", (int)metric); }; } -/** @} */ /** - * @defgroup pairwise_distance pairwise distance prims - * @{ * @brief Convenience wrapper around 'distance' prim to convert runtime metric * into compile time for the purpose of dispatch * @tparam Type input/accumulation/output data-type * @tparam Index_ indexing type + * @param handle raft handle for managing expensive resources * @param x first set of points * @param y second set of points * @param dist output distance matrix @@ -379,8 +381,8 @@ void pairwise_distance(const raft::handle_t& handle, * @param n number of points in y * @param k dimensionality * @param metric distance metric - * @param stream cuda stream * @param isRowMajor whether the matrices are row-major or col-major + * @param metric_arg metric argument (used for Minkowski distance) */ template void pairwise_distance(const raft::handle_t& handle, @@ -400,20 +402,16 @@ void pairwise_distance(const raft::handle_t& handle, } /** - * @defgroup pairwise_distance pairwise distance prims - * @{ * @brief Convenience wrapper around 'distance' prim to convert runtime metric * into compile time for the purpose of dispatch * @tparam Type input/accumulation/output data-type * @tparam Index_ indexing type + * @param handle raft handle for managing expensive resources * @param x first matrix of points (size mxk) * @param y second matrix of points (size nxk) * @param dist output distance matrix (size mxn) - * @param workspace temporary workspace buffer which can get resized as per the - * needed workspace size * @param metric distance metric - * @param stream cuda stream - * @param isRowMajor whether the matrices are row-major or col-major + * @param metric_arg metric argument (used for Minkowski distance) */ template void pairwise_distance(raft::handle_t const& handle, @@ -454,4 +452,6 @@ void pairwise_distance(raft::handle_t const& handle, }; // namespace distance }; // namespace raft +/** @} */ + #endif \ No newline at end of file diff --git a/cpp/include/raft/distance/distance.hpp b/cpp/include/raft/distance/distance.hpp index 66b4efcede..e5d39be86b 100644 --- a/cpp/include/raft/distance/distance.hpp +++ b/cpp/include/raft/distance/distance.hpp @@ -14,454 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __DISTANCE_H -#define __DISTANCE_H - #pragma once -#include -#include -#include -#include - -#include - -namespace raft { -namespace distance { - -/** - * @brief Evaluate pairwise distances with the user epilogue lamba allowed - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam FinalLambda user-defined epilogue lamba - * @tparam Index_ Index type - * @param x first set of points - * @param y second set of points - * @param dist output distance matrix - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * @param workspace temporary workspace needed for computations - * @param worksize number of bytes of the workspace - * @param fin_op the final gemm epilogue lambda - * @param stream cuda stream - * @param isRowMajor whether the matrices are row-major or col-major - * @param metric_arg metric argument (used for Minkowski distance) - * - * @note fin_op: This is a device lambda which is supposed to operate upon the - * input which is AccType and returns the output in OutType. It's signature is - * as follows:
OutType fin_op(AccType in, int g_idx);
. If one needs - * any other parameters, feel free to pass them via closure. - */ -template -void distance(const InType* x, - const InType* y, - OutType* dist, - Index_ m, - Index_ n, - Index_ k, - void* workspace, - size_t worksize, - FinalLambda fin_op, - cudaStream_t stream, - bool isRowMajor = true, - InType metric_arg = 2.0f) -{ - detail::distance( - x, y, dist, m, n, k, workspace, worksize, fin_op, stream, isRowMajor, metric_arg); -} - -/** - * @brief Evaluate pairwise distances for the simple use case - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam Index_ Index type - * @param x first set of points - * @param y second set of points - * @param dist output distance matrix - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * @param workspace temporary workspace needed for computations - * @param worksize number of bytes of the workspace - * @param stream cuda stream - * @param isRowMajor whether the matrices are row-major or col-major - * @param metric_arg metric argument (used for Minkowski distance) - * - * @note if workspace is passed as nullptr, this will return in - * worksize, the number of bytes of workspace required - */ -template -void distance(const InType* x, - const InType* y, - OutType* dist, - Index_ m, - Index_ n, - Index_ k, - void* workspace, - size_t worksize, - cudaStream_t stream, - bool isRowMajor = true, - InType metric_arg = 2.0f) -{ - detail::distance( - x, y, dist, m, n, k, workspace, worksize, stream, isRowMajor, metric_arg); -} - -/** - * @brief Return the exact workspace size to compute the distance - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam Index_ Index type - * @param x first set of points - * @param y second set of points - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * - * @note If the specified distanceType doesn't need the workspace at all, it - * returns 0. - */ -template -size_t getWorkspaceSize(const InType* x, const InType* y, Index_ m, Index_ n, Index_ k) -{ - return detail::getWorkspaceSize(x, y, m, n, k); -} - -/** - * @brief Return the exact workspace size to compute the distance - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam Index_ Index type - * @param x first set of points (size m*k) - * @param y second set of points (size n*k) - * @return number of bytes needed in workspace - * - * @note If the specified distanceType doesn't need the workspace at all, it - * returns 0. - */ -template -size_t getWorkspaceSize(const raft::device_matrix_view& x, - const raft::device_matrix_view& y) -{ - RAFT_EXPECTS(x.extent(1) == y.extent(1), "Number of columns must be equal."); - - return getWorkspaceSize( - x.data(), y.data(), x.extent(0), y.extent(0), x.extent(1)); -} - -/** - * @brief Evaluate pairwise distances for the simple use case - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam Index_ Index type - * @param x first set of points - * @param y second set of points - * @param dist output distance matrix - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * @param stream cuda stream - * @param isRowMajor whether the matrices are row-major or col-major - * @param metric_arg metric argument (used for Minkowski distance) - */ -template -void distance(const InType* x, - const InType* y, - OutType* dist, - Index_ m, - Index_ n, - Index_ k, - cudaStream_t stream, - bool isRowMajor = true, - InType metric_arg = 2.0f) -{ - rmm::device_uvector workspace(0, stream); - auto worksize = getWorkspaceSize(x, y, m, n, k); - workspace.resize(worksize, stream); - detail::distance( - x, y, dist, m, n, k, workspace.data(), worksize, stream, isRowMajor, metric_arg); -} - -/** - * @brief Evaluate pairwise distances for the simple use case. - * - * Note: Only contiguous row- or column-major layouts supported currently. - * - * @tparam DistanceType which distance to evaluate - * @tparam InType input argument type - * @tparam AccType accumulation type - * @tparam OutType output type - * @tparam Index_ Index type - * @param handle raft handle for managing expensive resources - * @param x first set of points (size n*k) - * @param y second set of points (size m*k) - * @param dist output distance matrix (size n*m) - * @param metric_arg metric argument (used for Minkowski distance) - */ - -template -void distance(raft::handle_t const handle, - raft::device_matrix_view const x, - raft::device_matrix_view const y, - raft::device_matrix_view dist, - InType metric_arg = 2.0f) -{ - RAFT_EXPECTS(x.extent(1) == y.extent(1), "Number of columns must be equal."); - RAFT_EXPECTS(dist.extent(0) == x.extent(0), - "Number of rows in output must be equal to " - "number of rows in X"); - RAFT_EXPECTS(dist.extent(1) == y.extent(0), - "Number of columns in output must be equal to " - "number of rows in Y"); - - RAFT_EXPECTS(x.is_contiguous(), "Input x must be contiguous."); - RAFT_EXPECTS(y.is_contiguous(), "Input y must be contiguous."); - - if (x.stride(0) == 0 && y.stride(0) == 0) { - distance(x.data(), - y.data(), - dist.data(), - x.extent(0), - y.extent(0), - x.extent(1), - handle.get_stream(), - true, - metric_arg); - } else if (x.stride(0) > 0 && y.stride(0) > 0) { - distance(x.data(), - y.data(), - dist.data(), - x.extent(0), - y.extent(0), - x.extent(1), - handle.get_stream(), - false, - metric_arg); - } else { - RAFT_FAIL("x and y must both have the same layout: row-major or column-major."); - } -} - -/** - * @brief Convenience wrapper around 'distance' prim to convert runtime metric - * into compile time for the purpose of dispatch - * @tparam Type input/accumulation/output data-type - * @tparam Index_ indexing type - * @param handle raft handle for managing expensive resources - * @param x first set of points - * @param y second set of points - * @param dist output distance matrix - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * @param workspace temporary workspace buffer which can get resized as per the - * needed workspace size - * @param metric distance metric - * @param isRowMajor whether the matrices are row-major or col-major - * @param metric_arg metric argument - */ -template -void pairwise_distance(const raft::handle_t& handle, - const Type* x, - const Type* y, - Type* dist, - Index_ m, - Index_ n, - Index_ k, - rmm::device_uvector& workspace, - raft::distance::DistanceType metric, - bool isRowMajor = true, - Type metric_arg = 2.0f) -{ - switch (metric) { - case raft::distance::DistanceType::L2Expanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::L2SqrtExpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::CosineExpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::L1: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::L2Unexpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::L2SqrtUnexpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::Linf: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::HellingerExpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::LpUnexpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor, metric_arg); - break; - case raft::distance::DistanceType::Canberra: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::HammingUnexpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::JensenShannon: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::RusselRaoExpanded: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::KLDivergence: - detail::pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - case raft::distance::DistanceType::CorrelationExpanded: - detail:: - pairwise_distance_impl( - x, y, dist, m, n, k, workspace, handle.get_stream(), isRowMajor); - break; - default: THROW("Unknown or unsupported distance metric '%d'!", (int)metric); - }; -} - -/** - * @brief Convenience wrapper around 'distance' prim to convert runtime metric - * into compile time for the purpose of dispatch - * @tparam Type input/accumulation/output data-type - * @tparam Index_ indexing type - * @param handle raft handle for managing expensive resources - * @param x first set of points - * @param y second set of points - * @param dist output distance matrix - * @param m number of points in x - * @param n number of points in y - * @param k dimensionality - * @param metric distance metric - * @param isRowMajor whether the matrices are row-major or col-major - * @param metric_arg metric argument - */ -template -void pairwise_distance(const raft::handle_t& handle, - const Type* x, - const Type* y, - Type* dist, - Index_ m, - Index_ n, - Index_ k, - raft::distance::DistanceType metric, - bool isRowMajor = true, - Type metric_arg = 2.0f) -{ - rmm::device_uvector workspace(0, handle.get_stream()); - pairwise_distance( - handle, x, y, dist, m, n, k, workspace, metric, isRowMajor, metric_arg); -} - -/** - * @brief Convenience wrapper around 'distance' prim to convert runtime metric - * into compile time for the purpose of dispatch - * @tparam Type input/accumulation/output data-type - * @tparam Index_ indexing type - * @param handle raft handle for managing expensive resources - * @param x first matrix of points (size mxk) - * @param y second matrix of points (size nxk) - * @param dist output distance matrix (size mxn) - * @param metric distance metric - * @param metric_arg metric argument - */ -template -void pairwise_distance(raft::handle_t const& handle, - device_matrix_view const& x, - device_matrix_view const& y, - device_matrix_view& dist, - raft::distance::DistanceType metric, - Type metric_arg = 2.0f) -{ - RAFT_EXPECTS(x.extent(1) == y.extent(1), "Number of columns must be equal."); - RAFT_EXPECTS(dist.extent(0) == x.extent(0), - "Number of rows in output must be equal to " - "number of rows in X"); - RAFT_EXPECTS(dist.extent(1) == y.extent(0), - "Number of columns in output must be equal to " - "number of rows in Y"); - - RAFT_EXPECTS(x.is_contiguous(), "Input x must be contiguous."); - RAFT_EXPECTS(y.is_contiguous(), "Input y must be contiguous."); - RAFT_EXPECTS(dist.is_contiguous(), "Output must be contiguous."); - - bool rowmajor = x.stride(0) == 0; - - rmm::device_uvector workspace(0, handle.get_stream()); - - pairwise_distance(handle, - x.data(), - y.data(), - dist.data(), - x.extent(0), - y.extent(0), - x.extent(1), - metric, - rowmajor, - metric_arg); -} - -}; // namespace distance -}; // namespace raft - -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/cpp/include/raft/distance/fused_l2_nn.hpp b/cpp/include/raft/distance/fused_l2_nn.hpp index 1cb3ee39eb..768e33b3a7 100644 --- a/cpp/include/raft/distance/fused_l2_nn.hpp +++ b/cpp/include/raft/distance/fused_l2_nn.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/distance/specializations.hpp b/cpp/include/raft/distance/specializations.hpp index db426c30d2..641968d9f1 100644 --- a/cpp/include/raft/distance/specializations.hpp +++ b/cpp/include/raft/distance/specializations.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/error.hpp b/cpp/include/raft/error.hpp index 5e1aa3af28..0927142829 100644 --- a/cpp/include/raft/error.hpp +++ b/cpp/include/raft/error.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the include/raft_runtime/error.hpp instead. */ @@ -178,4 +178,4 @@ struct logic_error : public raft::exception { throw raft::logic_error(msg); \ } while (0) -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/handle.hpp b/cpp/include/raft/handle.hpp index 158816f762..6f049503c8 100644 --- a/cpp/include/raft/handle.hpp +++ b/cpp/include/raft/handle.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the include/raft_runtime/handle.hpp instead. */ @@ -341,4 +341,4 @@ class stream_syncer { } // namespace raft -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/interruptible.hpp b/cpp/include/raft/interruptible.hpp index 6764065363..603f19ff35 100644 --- a/cpp/include/raft/interruptible.hpp +++ b/cpp/include/raft/interruptible.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the include/raft_runtime/interruptible.hpp instead. */ @@ -273,4 +273,4 @@ class interruptible { } // namespace raft -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/lap/lap.hpp b/cpp/include/raft/lap/lap.hpp index 238af9545d..2a4f10f000 100644 --- a/cpp/include/raft/lap/lap.hpp +++ b/cpp/include/raft/lap/lap.hpp @@ -12,7 +12,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License.+ * * CUDA Implementation of O(n^3) alternating tree Hungarian Algorithm * Authors: Ketan Date and Rakesh Nagi @@ -24,7 +24,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/add.cuh b/cpp/include/raft/linalg/add.cuh index 92152a8c03..e25c9df9ef 100644 --- a/cpp/include/raft/linalg/add.cuh +++ b/cpp/include/raft/linalg/add.cuh @@ -16,6 +16,11 @@ #ifndef __ADD_H #define __ADD_H +/** + * @defgroup arithmetic Dense matrix arithmetic + * @{ + */ + #pragma once #include "detail/add.cuh" @@ -26,6 +31,7 @@ namespace linalg { using detail::adds_scalar; /** + * @ingroup arithmetic * @brief Elementwise scalar add operation on the input buffer * * @tparam InT input data-type. Also the data-type upon which the math ops @@ -87,4 +93,6 @@ void addDevScalar(math_t* outDev, }; // end namespace linalg }; // end namespace raft +/** @} */ + #endif \ No newline at end of file diff --git a/cpp/include/raft/linalg/add.hpp b/cpp/include/raft/linalg/add.hpp index 32c7f68459..a80398fcad 100644 --- a/cpp/include/raft/linalg/add.hpp +++ b/cpp/include/raft/linalg/add.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/axpy.hpp b/cpp/include/raft/linalg/axpy.hpp index 921ed3f89b..c227ba66c8 100644 --- a/cpp/include/raft/linalg/axpy.hpp +++ b/cpp/include/raft/linalg/axpy.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/binary_op.hpp b/cpp/include/raft/linalg/binary_op.hpp index 468c278909..9983e8ab50 100644 --- a/cpp/include/raft/linalg/binary_op.hpp +++ b/cpp/include/raft/linalg/binary_op.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/cholesky_r1_update.cuh b/cpp/include/raft/linalg/cholesky_r1_update.cuh index 7d22d6bcf7..d8e838a634 100644 --- a/cpp/include/raft/linalg/cholesky_r1_update.cuh +++ b/cpp/include/raft/linalg/cholesky_r1_update.cuh @@ -62,7 +62,7 @@ namespace linalg { * // Initialize arrays * int ld_L = n_rows; * rmm::device_uvector L(ld_L * n_rows, stream); - * MLCommon::LinAlg::choleskyRank1Update(handle, L, n_rows, ld_L, nullptr, + * raft::linalg::choleskyRank1Update(handle, L, n_rows, ld_L, nullptr, * &n_bytes, CUBLAS_FILL_MODE_LOWER, * stream); * rmm::device_uvector workspace(n_bytes, stream); @@ -74,7 +74,7 @@ namespace linalg { * RAFT_CUBLAS_TRY(cublasCopy(handle.get_cublas_handle(), n - 1, A_new, 1, * L + n - 1, ld_L, stream)); * // Update Cholesky factorization - * MLCommon::LinAlg::choleskyRank1Update( + * raft::linalg::choleskyRank1Update( * handle, L, rank, ld_L, workspace, &n_bytes, CUBLAS_FILL_MODE_LOWER, * stream); * } @@ -86,7 +86,7 @@ namespace linalg { * // Initialize arrays * int ld_U = n_rows; * rmm::device_uvector U(ld_U * n_rows, stream); - * MLCommon::LinAlg::choleskyRank1Update(handle, L, n_rows, ld_U, nullptr, + * raft::linalg::choleskyRank1Update(handle, L, n_rows, ld_U, nullptr, * &n_bytes, CUBLAS_FILL_MODE_UPPER, * stream); * rmm::device_uvector workspace(stream, n_bytes, stream); @@ -98,7 +98,7 @@ namespace linalg { * raft::copy(U + ld_U * (n-1), A_new, n-1, stream); * // * // Update Cholesky factorization - * MLCommon::LinAlg::choleskyRank1Update( + * raft::linalg::choleskyRank1Update( * handle, U, n, ld_U, workspace, &n_bytes, CUBLAS_FILL_MODE_UPPER, * stream); * } diff --git a/cpp/include/raft/linalg/cholesky_r1_update.hpp b/cpp/include/raft/linalg/cholesky_r1_update.hpp index b55f5d06da..1158ad3aa4 100644 --- a/cpp/include/raft/linalg/cholesky_r1_update.hpp +++ b/cpp/include/raft/linalg/cholesky_r1_update.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ @@ -67,7 +67,7 @@ namespace linalg { * // Initialize arrays * int ld_L = n_rows; * rmm::device_uvector L(ld_L * n_rows, stream); - * MLCommon::LinAlg::choleskyRank1Update(handle, L, n_rows, ld_L, nullptr, + * raft::linalg::choleskyRank1Update(handle, L, n_rows, ld_L, nullptr, * &n_bytes, CUBLAS_FILL_MODE_LOWER, * stream); * rmm::device_uvector workspace(n_bytes, stream); @@ -79,7 +79,7 @@ namespace linalg { * RAFT_CUBLAS_TRY(cublasCopy(handle.get_cublas_handle(), n - 1, A_new, 1, * L + n - 1, ld_L, stream)); * // Update Cholesky factorization - * MLCommon::LinAlg::choleskyRank1Update( + * raft::linalg::choleskyRank1Update( * handle, L, rank, ld_L, workspace, &n_bytes, CUBLAS_FILL_MODE_LOWER, * stream); * } @@ -91,7 +91,7 @@ namespace linalg { * // Initialize arrays * int ld_U = n_rows; * rmm::device_uvector U(ld_U * n_rows, stream); - * MLCommon::LinAlg::choleskyRank1Update(handle, L, n_rows, ld_U, nullptr, + * raft::linalg::choleskyRank1Update(handle, L, n_rows, ld_U, nullptr, * &n_bytes, CUBLAS_FILL_MODE_UPPER, * stream); * rmm::device_uvector workspace(stream, n_bytes, stream); @@ -103,7 +103,7 @@ namespace linalg { * raft::copy(U + ld_U * (n-1), A_new, n-1, stream); * // * // Update Cholesky factorization - * MLCommon::LinAlg::choleskyRank1Update( + * raft::linalg::choleskyRank1Update( * handle, U, n, ld_U, workspace, &n_bytes, CUBLAS_FILL_MODE_UPPER, * stream); * } diff --git a/cpp/include/raft/linalg/coalesced_reduction.hpp b/cpp/include/raft/linalg/coalesced_reduction.hpp index 4b9e5d262f..48f8798a03 100644 --- a/cpp/include/raft/linalg/coalesced_reduction.hpp +++ b/cpp/include/raft/linalg/coalesced_reduction.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/contractions.hpp b/cpp/include/raft/linalg/contractions.hpp index 84c86b93a4..256593d9ae 100644 --- a/cpp/include/raft/linalg/contractions.hpp +++ b/cpp/include/raft/linalg/contractions.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/cublas_macros.h b/cpp/include/raft/linalg/cublas_macros.h index 0281c5c667..a321a080c8 100644 --- a/cpp/include/raft/linalg/cublas_macros.h +++ b/cpp/include/raft/linalg/cublas_macros.h @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use raft_runtime/cublas_macros.hpp instead. */ @@ -123,4 +123,4 @@ inline const char* cublas_error_to_string(cublasStatus_t err) #define CUBLAS_CHECK_NO_THROW(call) RAFT_CUBLAS_TRY_NO_THROW(call) #endif -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/linalg/cusolver_macros.h b/cpp/include/raft/linalg/cusolver_macros.h index df27f7ce26..fa1cd3d4c7 100644 --- a/cpp/include/raft/linalg/cusolver_macros.h +++ b/cpp/include/raft/linalg/cusolver_macros.h @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use raft_runtime/cusolver_macros.hpp instead. */ @@ -119,4 +119,4 @@ inline const char* cusolver_error_to_string(cusolverStatus_t err) #define CUSOLVER_CHECK_NO_THROW(call) CUSOLVER_TRY_NO_THROW(call) #endif -#endif \ No newline at end of file +#endif diff --git a/cpp/include/raft/linalg/divide.hpp b/cpp/include/raft/linalg/divide.hpp index 88b919b92a..8d1bd37186 100644 --- a/cpp/include/raft/linalg/divide.hpp +++ b/cpp/include/raft/linalg/divide.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/eig.hpp b/cpp/include/raft/linalg/eig.hpp index 9417b6fb3f..032c4e97f9 100644 --- a/cpp/include/raft/linalg/eig.hpp +++ b/cpp/include/raft/linalg/eig.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/eltwise.hpp b/cpp/include/raft/linalg/eltwise.hpp index 0ebefc7c25..62624f6eeb 100644 --- a/cpp/include/raft/linalg/eltwise.hpp +++ b/cpp/include/raft/linalg/eltwise.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/gemm.hpp b/cpp/include/raft/linalg/gemm.hpp index 736590938b..56621e4f8b 100644 --- a/cpp/include/raft/linalg/gemm.hpp +++ b/cpp/include/raft/linalg/gemm.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/gemv.hpp b/cpp/include/raft/linalg/gemv.hpp index d6e0e0326b..3b6b60263b 100644 --- a/cpp/include/raft/linalg/gemv.hpp +++ b/cpp/include/raft/linalg/gemv.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/init.hpp b/cpp/include/raft/linalg/init.hpp index af3486f278..db7b0f9cfe 100644 --- a/cpp/include/raft/linalg/init.hpp +++ b/cpp/include/raft/linalg/init.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/lanczos.hpp b/cpp/include/raft/linalg/lanczos.hpp index 7663af3cb2..75e3d11444 100644 --- a/cpp/include/raft/linalg/lanczos.hpp +++ b/cpp/include/raft/linalg/lanczos.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/lstsq.hpp b/cpp/include/raft/linalg/lstsq.hpp index 008fcab653..f90cd00ea3 100644 --- a/cpp/include/raft/linalg/lstsq.hpp +++ b/cpp/include/raft/linalg/lstsq.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/map.hpp b/cpp/include/raft/linalg/map.hpp index d4ee231eb1..8321dcebe4 100644 --- a/cpp/include/raft/linalg/map.hpp +++ b/cpp/include/raft/linalg/map.hpp @@ -14,46 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __MAP_H -#define __MAP_H - #pragma once -#include "detail/map.cuh" - -namespace raft { -namespace linalg { - -/** - * @brief CUDA version of map - * @tparam InType data-type upon which the math operation will be performed - * @tparam MapOp the device-lambda performing the actual operation - * @tparam TPB threads-per-block in the final kernel launched - * @tparam Args additional parameters - * @tparam OutType data-type in which the result will be stored - * @param out the output of the map operation (assumed to be a device pointer) - * @param len number of elements in the input array - * @param map the device-lambda - * @param stream cuda-stream where to launch this kernel - * @param in the input array - * @param args additional input arrays - */ - -template -void map(OutType* out, size_t len, MapOp map, cudaStream_t stream, const InType* in, Args... args) -{ - detail::mapImpl(out, len, map, stream, in, args...); -} - -} // namespace linalg -}; // namespace raft - -#endif \ No newline at end of file +#include "map.cuh" diff --git a/cpp/include/raft/linalg/map_then_reduce.hpp b/cpp/include/raft/linalg/map_then_reduce.hpp index c4b136d1b8..235485926b 100644 --- a/cpp/include/raft/linalg/map_then_reduce.hpp +++ b/cpp/include/raft/linalg/map_then_reduce.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/matrix_vector_op.hpp b/cpp/include/raft/linalg/matrix_vector_op.hpp index c041d4c263..574d4aee63 100644 --- a/cpp/include/raft/linalg/matrix_vector_op.hpp +++ b/cpp/include/raft/linalg/matrix_vector_op.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/mean_squared_error.hpp b/cpp/include/raft/linalg/mean_squared_error.hpp index 95428d47e0..7a7f03ee18 100644 --- a/cpp/include/raft/linalg/mean_squared_error.hpp +++ b/cpp/include/raft/linalg/mean_squared_error.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/multiply.hpp b/cpp/include/raft/linalg/multiply.hpp index 260fb25018..eb933cd607 100644 --- a/cpp/include/raft/linalg/multiply.hpp +++ b/cpp/include/raft/linalg/multiply.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/norm.hpp b/cpp/include/raft/linalg/norm.hpp index 7be524f6de..958784d67e 100644 --- a/cpp/include/raft/linalg/norm.hpp +++ b/cpp/include/raft/linalg/norm.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/power.hpp b/cpp/include/raft/linalg/power.hpp index 124ee8513a..d1506ff7a9 100644 --- a/cpp/include/raft/linalg/power.hpp +++ b/cpp/include/raft/linalg/power.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/qr.hpp b/cpp/include/raft/linalg/qr.hpp index da8736b46f..f0194ddbf9 100644 --- a/cpp/include/raft/linalg/qr.hpp +++ b/cpp/include/raft/linalg/qr.hpp @@ -14,70 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __QR_H -#define __QR_H - #pragma once -#include "detail/qr.cuh" - -namespace raft { -namespace linalg { - -/** - * @defgroup QRdecomp QR decomposition - * @{ - */ - -/** - * @brief compute QR decomp and return only Q matrix - * @param handle: raft handle - * @param M: input matrix - * @param Q: Q matrix to be returned (on GPU) - * @param n_rows: number rows of input matrix - * @param n_cols: number columns of input matrix - * @param stream cuda stream - * @{ - */ -template -void qrGetQ(const raft::handle_t& handle, - const math_t* M, - math_t* Q, - int n_rows, - int n_cols, - cudaStream_t stream) -{ - detail::qrGetQ(handle, M, Q, n_rows, n_cols, stream); -} - -/** - * @brief compute QR decomp and return both Q and R matrices - * @param handle: raft handle - * @param M: input matrix - * @param Q: Q matrix to be returned (on GPU) - * @param R: R matrix to be returned (on GPU) - * @param n_rows: number rows of input matrix - * @param n_cols: number columns of input matrix - * @param stream cuda stream - */ -template -void qrGetQR(const raft::handle_t& handle, - math_t* M, - math_t* Q, - math_t* R, - int n_rows, - int n_cols, - cudaStream_t stream) -{ - detail::qrGetQR(handle, M, Q, R, n_rows, n_cols, stream); -} -/** @} */ - -}; // namespace linalg -}; // namespace raft - -#endif \ No newline at end of file +#include "qr.cuh" \ No newline at end of file diff --git a/cpp/include/raft/linalg/reduce.hpp b/cpp/include/raft/linalg/reduce.hpp index b9f057771a..b9cc2c6e9d 100644 --- a/cpp/include/raft/linalg/reduce.hpp +++ b/cpp/include/raft/linalg/reduce.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/reduce_cols_by_key.hpp b/cpp/include/raft/linalg/reduce_cols_by_key.hpp index a338d8572b..c24baa60de 100644 --- a/cpp/include/raft/linalg/reduce_cols_by_key.hpp +++ b/cpp/include/raft/linalg/reduce_cols_by_key.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/reduce_rows_by_key.hpp b/cpp/include/raft/linalg/reduce_rows_by_key.hpp index 70ce9eaa4f..d18a00aa1d 100644 --- a/cpp/include/raft/linalg/reduce_rows_by_key.hpp +++ b/cpp/include/raft/linalg/reduce_rows_by_key.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/rsvd.hpp b/cpp/include/raft/linalg/rsvd.hpp index 2dd5faa332..ac6e13b555 100644 --- a/cpp/include/raft/linalg/rsvd.hpp +++ b/cpp/include/raft/linalg/rsvd.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/sqrt.hpp b/cpp/include/raft/linalg/sqrt.hpp index 9856173248..9c66ee2d14 100644 --- a/cpp/include/raft/linalg/sqrt.hpp +++ b/cpp/include/raft/linalg/sqrt.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/strided_reduction.hpp b/cpp/include/raft/linalg/strided_reduction.hpp index 534f8edcf7..3b1597dfc3 100644 --- a/cpp/include/raft/linalg/strided_reduction.hpp +++ b/cpp/include/raft/linalg/strided_reduction.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/subtract.hpp b/cpp/include/raft/linalg/subtract.hpp index 2420ce69e2..accf57a939 100644 --- a/cpp/include/raft/linalg/subtract.hpp +++ b/cpp/include/raft/linalg/subtract.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/svd.hpp b/cpp/include/raft/linalg/svd.hpp index 765f364d5b..01788a4188 100644 --- a/cpp/include/raft/linalg/svd.hpp +++ b/cpp/include/raft/linalg/svd.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/ternary_op.hpp b/cpp/include/raft/linalg/ternary_op.hpp index 1e8892211c..bce9eacb11 100644 --- a/cpp/include/raft/linalg/ternary_op.hpp +++ b/cpp/include/raft/linalg/ternary_op.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/transpose.hpp b/cpp/include/raft/linalg/transpose.hpp index 765d523b16..caa6bafedf 100644 --- a/cpp/include/raft/linalg/transpose.hpp +++ b/cpp/include/raft/linalg/transpose.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/linalg/unary_op.hpp b/cpp/include/raft/linalg/unary_op.hpp index 12d841340b..ca1e3f9875 100644 --- a/cpp/include/raft/linalg/unary_op.hpp +++ b/cpp/include/raft/linalg/unary_op.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/matrix/col_wise_sort.hpp b/cpp/include/raft/matrix/col_wise_sort.hpp index f259bc71a8..83a8738219 100644 --- a/cpp/include/raft/matrix/col_wise_sort.hpp +++ b/cpp/include/raft/matrix/col_wise_sort.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/matrix/math.hpp b/cpp/include/raft/matrix/math.hpp index ab02c8a85f..6ed9a0d358 100644 --- a/cpp/include/raft/matrix/math.hpp +++ b/cpp/include/raft/matrix/math.hpp @@ -14,459 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __MATH_H -#define __MATH_H - #pragma once -#include "detail/math.cuh" - -namespace raft { -namespace matrix { - -/** - * @defgroup MatrixMathOp math operation on the input matrix - * @{ - */ - -/** - * @brief Power of every element in the input matrix - * @param in: input matrix - * @param out: output matrix. The result is stored in the out matrix - * @param scalar: every element is multiplied with scalar. - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void power(math_t* in, math_t* out, math_t scalar, int len, cudaStream_t stream) -{ - detail::power(in, out, scalar, len, stream); -} - -/** - * @brief Power of every element in the input matrix - * @param inout: input matrix and also the result is stored - * @param scalar: every element is multiplied with scalar. - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void power(math_t* inout, math_t scalar, int len, cudaStream_t stream) -{ - detail::power(inout, scalar, len, stream); -} - -/** - * @brief Power of every element in the input matrix - * @param inout: input matrix and also the result is stored - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void power(math_t* inout, int len, cudaStream_t stream) -{ - detail::power(inout, len, stream); -} - -/** - * @brief Power of every element in the input matrix - * @param in: input matrix - * @param out: output matrix. The result is stored in the out matrix - * @param len: number elements of input matrix - * @param stream cuda stream - * @{ - */ -template -void power(math_t* in, math_t* out, int len, cudaStream_t stream) -{ - detail::power(in, out, len, stream); -} - -/** - * @brief Square root of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param in: input matrix and also the result is stored - * @param out: output matrix. The result is stored in the out matrix - * @param scalar: every element is multiplied with scalar - * @param len: number elements of input matrix - * @param stream cuda stream - * @param set_neg_zero whether to set negative numbers to zero - */ -template -void seqRoot(math_t* in, - math_t* out, - math_t scalar, - IdxType len, - cudaStream_t stream, - bool set_neg_zero = false) -{ - detail::seqRoot(in, out, scalar, len, stream, set_neg_zero); -} - -/** - * @brief Square root of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param inout: input matrix and also the result is stored - * @param scalar: every element is multiplied with scalar - * @param len: number elements of input matrix - * @param stream cuda stream - * @param set_neg_zero whether to set negative numbers to zero - */ -template -void seqRoot( - math_t* inout, math_t scalar, IdxType len, cudaStream_t stream, bool set_neg_zero = false) -{ - detail::seqRoot(inout, scalar, len, stream, set_neg_zero); -} - -/** - * @brief Square root of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param in: input matrix and also the result is stored - * @param out: output matrix. The result is stored in the out matrix - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void seqRoot(math_t* in, math_t* out, IdxType len, cudaStream_t stream) -{ - detail::seqRoot(in, out, len, stream); -} - -/** - * @brief Square root of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param inout: input matrix with in-place results - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void seqRoot(math_t* inout, IdxType len, cudaStream_t stream) -{ - detail::seqRoot(inout, len, stream); -} - -/** - * @brief sets the small values to zero based on a defined threshold - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param out: output matrix. The result is stored in the out matrix - * @param in: input matrix - * @param len: number elements of input matrix - * @param stream cuda stream - * @param thres threshold to set values to zero - */ -template -void setSmallValuesZero( - math_t* out, const math_t* in, IdxType len, cudaStream_t stream, math_t thres = 1e-15) -{ - detail::setSmallValuesZero(out, in, len, stream, thres); -} - -/** - * @brief sets the small values to zero based on a defined threshold - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param inout: input matrix and also the result is stored - * @param len: number elements of input matrix - * @param stream cuda stream - * @param thres: threshold - */ -template -void setSmallValuesZero(math_t* inout, IdxType len, cudaStream_t stream, math_t thres = 1e-15) -{ - detail::setSmallValuesZero(inout, len, stream, thres); -} - -/** - * @brief Reciprocal of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param in: input matrix and also the result is stored - * @param out: output matrix. The result is stored in the out matrix - * @param scalar: every element is multiplied with scalar - * @param len: number elements of input matrix - * @param stream cuda stream - * @param setzero round down to zero if the input is less the threshold - * @param thres the threshold used to forcibly set inputs to zero - * @{ - */ -template -void reciprocal(math_t* in, - math_t* out, - math_t scalar, - int len, - cudaStream_t stream, - bool setzero = false, - math_t thres = 1e-15) -{ - detail::reciprocal(in, out, scalar, len, stream, setzero, thres); -} - -/** - * @brief Reciprocal of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param inout: input matrix with in-place results - * @param scalar: every element is multiplied with scalar - * @param len: number elements of input matrix - * @param stream cuda stream - * @param setzero round down to zero if the input is less the threshold - * @param thres the threshold used to forcibly set inputs to zero - * @{ - */ -template -void reciprocal(math_t* inout, - math_t scalar, - IdxType len, - cudaStream_t stream, - bool setzero = false, - math_t thres = 1e-15) -{ - detail::reciprocal(inout, scalar, len, stream, setzero, thres); -} - -/** - * @brief Reciprocal of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param inout: input matrix and also the result is stored - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void reciprocal(math_t* inout, IdxType len, cudaStream_t stream) -{ - detail::reciprocal(inout, len, stream); -} - -/** - * @brief Reciprocal of every element in the input matrix - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param in: input matrix and also the result is stored - * @param out: output matrix. The result is stored in the out matrix - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void reciprocal(math_t* in, math_t* out, IdxType len, cudaStream_t stream) -{ - detail::reciprocal(in, out, len, stream); -} - -/** - * @brief set values to scalar in matrix - * @tparam math_t data-type upon which the math operation will be performed - * @param out output matrix. The result is stored in the out matrix - * @param in input matrix - * @param scalar svalar value - * @param len number elements of input matrix - * @param stream cuda stream - */ -template -void setValue(math_t* out, const math_t* in, math_t scalar, int len, cudaStream_t stream = 0) -{ - detail::setValue(out, in, scalar, len, stream); -} - -/** - * @brief ratio of every element over sum of input vector is calculated - * @tparam math_t data-type upon which the math operation will be performed - * @tparam IdxType Integer type used to for addressing - * @param handle - * @param src: input matrix - * @param dest: output matrix. The result is stored in the dest matrix - * @param len: number elements of input matrix - * @param stream cuda stream - */ -template -void ratio( - const raft::handle_t& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) -{ - detail::ratio(handle, src, dest, len, stream); -} - -/** @} */ - -/** - * @brief Argmax: find the row idx with maximum value for each column - * @param in: input matrix - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param out: output vector of size n_cols - * @param stream: cuda stream - */ -template -void argmax(const math_t* in, int n_rows, int n_cols, math_t* out, cudaStream_t stream) -{ - detail::argmax(in, n_rows, n_cols, out, stream); -} - -/** - * @brief sign flip for PCA. This is used to stabilize the sign of column - * major eigen vectors. Flips the sign if the column has negative |max|. - * @param inout: input matrix. Result also stored in this parameter - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param stream cuda stream - */ -template -void signFlip(math_t* inout, int n_rows, int n_cols, cudaStream_t stream) -{ - detail::signFlip(inout, n_rows, n_cols, stream); -} - -/** - * @brief multiply each row or column of matrix with vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - */ -template -void matrixVectorBinaryMult(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream) -{ - detail::matrixVectorBinaryMult( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream); -} - -/** - * @brief multiply each row or column of matrix with vector, skipping zeros in vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - */ -template -void matrixVectorBinaryMultSkipZero(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream) -{ - detail::matrixVectorBinaryMultSkipZero( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream); -} - -/** - * @brief divide each row or column of matrix with vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - */ -template -void matrixVectorBinaryDiv(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream) -{ - detail::matrixVectorBinaryDiv( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream); -} - -/** - * @brief divide each row or column of matrix with vector, skipping zeros in vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - * @param return_zero result is zero if true and vector value is below threshold, original value if - * false - */ -template -void matrixVectorBinaryDivSkipZero(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream, - bool return_zero = false) -{ - detail::matrixVectorBinaryDivSkipZero( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream, return_zero); -} - -/** - * @brief add each row or column of matrix with vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - */ -template -void matrixVectorBinaryAdd(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream) -{ - detail::matrixVectorBinaryAdd( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream); -} - -/** - * @brief subtract each row or column of matrix with vector - * @param data input matrix, results are in-place - * @param vec input vector - * @param n_row number of rows of input matrix - * @param n_col number of columns of input matrix - * @param rowMajor whether matrix is row major - * @param bcastAlongRows whether to broadcast vector along rows of matrix or columns - * @param stream cuda stream - */ -template -void matrixVectorBinarySub(Type* data, - const Type* vec, - IdxType n_row, - IdxType n_col, - bool rowMajor, - bool bcastAlongRows, - cudaStream_t stream) -{ - detail::matrixVectorBinarySub( - data, vec, n_row, n_col, rowMajor, bcastAlongRows, stream); -} - -}; // end namespace matrix -}; // end namespace raft - -#endif \ No newline at end of file +#include "math.cuh" \ No newline at end of file diff --git a/cpp/include/raft/matrix/matrix.hpp b/cpp/include/raft/matrix/matrix.hpp index cf5f5d1f25..7409140d7c 100644 --- a/cpp/include/raft/matrix/matrix.hpp +++ b/cpp/include/raft/matrix/matrix.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/random/make_blobs.cuh b/cpp/include/raft/random/make_blobs.cuh index 088690529a..5da960fc1a 100644 --- a/cpp/include/raft/random/make_blobs.cuh +++ b/cpp/include/raft/random/make_blobs.cuh @@ -99,17 +99,12 @@ void make_blobs(DataT* out, * @tparam DataT output data type * @tparam IdxT indexing arithmetic type * + * @param[in] handle raft handle for managing expensive resources * @param[out] out generated data [on device] * [dim = n_rows x n_cols] * @param[out] labels labels for the generated data [on device] * [len = n_rows] - * @param[in] n_rows number of rows in the generated data - * @param[in] n_cols number of columns in the generated data * @param[in] n_clusters number of clusters (or classes) to generate - * @param[in] stream cuda stream to schedule the work on - * @param[in] row_major whether input `centers` and output `out` - * buffers are to be stored in row or column - * major layout * @param[in] centers centers of each of the cluster, pass a nullptr * if you need this also to be generated randomly * [on device] [dim = n_clusters x n_cols] diff --git a/cpp/include/raft/random/make_blobs.hpp b/cpp/include/raft/random/make_blobs.hpp index 02aef809e7..372839b500 100644 --- a/cpp/include/raft/random/make_blobs.hpp +++ b/cpp/include/raft/random/make_blobs.hpp @@ -15,168 +15,10 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __MAKE_BLOBS_H -#define __MAKE_BLOBS_H - #pragma once -#include "detail/make_blobs.cuh" -#include -#include - -namespace raft::random { - -/** - * @brief GPU-equivalent of sklearn.datasets.make_blobs - * - * @tparam DataT output data type - * @tparam IdxT indexing arithmetic type - * - * @param[out] out generated data [on device] - * [dim = n_rows x n_cols] - * @param[out] labels labels for the generated data [on device] - * [len = n_rows] - * @param[in] n_rows number of rows in the generated data - * @param[in] n_cols number of columns in the generated data - * @param[in] n_clusters number of clusters (or classes) to generate - * @param[in] stream cuda stream to schedule the work on - * @param[in] row_major whether input `centers` and output `out` - * buffers are to be stored in row or column - * major layout - * @param[in] centers centers of each of the cluster, pass a nullptr - * if you need this also to be generated randomly - * [on device] [dim = n_clusters x n_cols] - * @param[in] cluster_std standard deviation of each cluster center, - * pass a nullptr if this is to be read from the - * `cluster_std_scalar`. [on device] - * [len = n_clusters] - * @param[in] cluster_std_scalar if 'cluster_std' is nullptr, then use this as - * the std-dev across all dimensions. - * @param[in] shuffle shuffle the generated dataset and labels - * @param[in] center_box_min min value of box from which to pick cluster - * centers. Useful only if 'centers' is nullptr - * @param[in] center_box_max max value of box from which to pick cluster - * centers. Useful only if 'centers' is nullptr - * @param[in] seed seed for the RNG - * @param[in] type RNG type - */ -template -void make_blobs(DataT* out, - IdxT* labels, - IdxT n_rows, - IdxT n_cols, - IdxT n_clusters, - cudaStream_t stream, - bool row_major = true, - const DataT* centers = nullptr, - const DataT* cluster_std = nullptr, - const DataT cluster_std_scalar = (DataT)1.0, - bool shuffle = true, - DataT center_box_min = (DataT)-10.0, - DataT center_box_max = (DataT)10.0, - uint64_t seed = 0ULL, - GeneratorType type = GenPhilox) -{ - detail::make_blobs_caller(out, - labels, - n_rows, - n_cols, - n_clusters, - stream, - row_major, - centers, - cluster_std, - cluster_std_scalar, - shuffle, - center_box_min, - center_box_max, - seed, - type); -} - -/** - * @brief GPU-equivalent of sklearn.datasets.make_blobs - * - * @tparam DataT output data type - * @tparam IdxT indexing arithmetic type - * - * @param[in] handle raft handle for managing expensive resources - * @param[out] out generated data [on device] - * [dim = n_rows x n_cols] - * @param[out] labels labels for the generated data [on device] - * [len = n_rows] - * @param[in] n_clusters number of clusters (or classes) to generate - * @param[in] centers centers of each of the cluster, pass a nullptr - * if you need this also to be generated randomly - * [on device] [dim = n_clusters x n_cols] - * @param[in] cluster_std standard deviation of each cluster center, - * pass a nullptr if this is to be read from the - * `cluster_std_scalar`. [on device] - * [len = n_clusters] - * @param[in] cluster_std_scalar if 'cluster_std' is nullptr, then use this as - * the std-dev across all dimensions. - * @param[in] shuffle shuffle the generated dataset and labels - * @param[in] center_box_min min value of box from which to pick cluster - * centers. Useful only if 'centers' is nullptr - * @param[in] center_box_max max value of box from which to pick cluster - * centers. Useful only if 'centers' is nullptr - * @param[in] seed seed for the RNG - * @param[in] type RNG type - */ -template -void make_blobs(raft::handle_t const& handle, - raft::device_matrix_view out, - raft::device_vector_view labels, - IdxT n_clusters = 5, - std::optional> centers = std::nullopt, - std::optional> const cluster_std = std::nullopt, - const DataT cluster_std_scalar = (DataT)1.0, - bool shuffle = true, - DataT center_box_min = (DataT)-10.0, - DataT center_box_max = (DataT)10.0, - uint64_t seed = 0ULL, - GeneratorType type = GenPhilox) -{ - if (centers.has_value()) { - RAFT_EXPECTS(centers.value().extent(0) == (std::size_t)n_clusters, - "n_centers must equal size of centers"); - } - - if (cluster_std.has_value()) { - RAFT_EXPECTS(cluster_std.value().extent(0) == (std::size_t)n_clusters, - "n_centers must equal size of cluster_std"); - } - - RAFT_EXPECTS(out.extent(0) == labels.extent(0), - "Number of labels must equal the number of row in output matrix"); - - RAFT_EXPECTS(out.is_contiguous(), "Output must be contiguous."); - - bool row_major = std::is_same::value; - - auto prm_centers = centers.has_value() ? centers.value().data() : nullptr; - auto prm_cluster_std = cluster_std.has_value() ? cluster_std.value().data() : nullptr; - - detail::make_blobs_caller(out.data(), - labels.data(), - (IdxT)out.extent(0), - (IdxT)out.extent(1), - n_clusters, - handle.get_stream(), - row_major, - prm_centers, - prm_cluster_std, - cluster_std_scalar, - shuffle, - center_box_min, - center_box_max, - seed, - type); -} -} // end namespace raft::random - -#endif \ No newline at end of file +#include "make_blobs.cuh" \ No newline at end of file diff --git a/cpp/include/raft/random/make_regression.hpp b/cpp/include/raft/random/make_regression.hpp index c050a447ed..4f6b2717f6 100644 --- a/cpp/include/raft/random/make_regression.hpp +++ b/cpp/include/raft/random/make_regression.hpp @@ -19,7 +19,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/random/multi_variable_gaussian.hpp b/cpp/include/raft/random/multi_variable_gaussian.hpp index fd1de4aadd..6b85ec6a14 100644 --- a/cpp/include/raft/random/multi_variable_gaussian.hpp +++ b/cpp/include/raft/random/multi_variable_gaussian.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/random/permute.hpp b/cpp/include/raft/random/permute.hpp index 3507d66cc3..26e22e403b 100644 --- a/cpp/include/raft/random/permute.hpp +++ b/cpp/include/raft/random/permute.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/random/rng.hpp b/cpp/include/raft/random/rng.hpp index 2d1af6a97e..519325f6d3 100644 --- a/cpp/include/raft/random/rng.hpp +++ b/cpp/include/raft/random/rng.hpp @@ -14,371 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __RNG_H -#define __RNG_H - #pragma once -#include "detail/rng_impl.cuh" - -namespace raft { -namespace random { - -using detail::RngState; - -using detail::GeneratorType; -using detail::GenPC; -using detail::GenPhilox; - -using detail::PCGenerator; -using detail::PhiloxGenerator; - -using detail::BernoulliDistParams; -using detail::ExponentialDistParams; -using detail::GumbelDistParams; -using detail::InvariantDistParams; -using detail::LaplaceDistParams; -using detail::LogisticDistParams; -using detail::LogNormalDistParams; -using detail::NormalDistParams; -using detail::NormalIntDistParams; -using detail::NormalTableDistParams; -using detail::RayleighDistParams; -using detail::SamplingParams; -using detail::ScaledBernoulliDistParams; -using detail::UniformDistParams; -using detail::UniformIntDistParams; - -// Not strictly needed due to C++ ADL rules -using detail::custom_next; - -/** - * @brief Helper method to compute Box Muller transform - * - * @tparam Type data type - * - * @param[inout] val1 first value - * @param[inout] val2 second value - * @param[in] sigma1 standard deviation of output gaussian for first value - * @param[in] mu1 mean of output gaussian for first value - * @param[in] sigma2 standard deviation of output gaussian for second value - * @param[in] mu2 mean of output gaussian for second value - * @{ - */ -template -DI void box_muller_transform(Type& val1, Type& val2, Type sigma1, Type mu1, Type sigma2, Type mu2) -{ - detail::box_muller_transform(val1, val2, sigma1, mu1, sigma2, mu2); -} - -template -DI void box_muller_transform(Type& val1, Type& val2, Type sigma1, Type mu1) -{ - detail::box_muller_transform(val1, val2, sigma1, mu1); -} -/** @} */ - -class Rng : public detail::RngImpl { - public: - /** - * @brief ctor - * @param _s 64b seed used to initialize the RNG - * @param _t backend device RNG generator type - * @note Refer to the `Rng::seed` method for details about seeding the engine - */ - Rng(uint64_t _s, GeneratorType _t = GenPhilox) : detail::RngImpl(_s, _t) {} - - /** - * @brief Generates the 'a' and 'b' parameters for a modulo affine - * transformation equation: `(ax + b) % n` - * - * @tparam IdxT integer type - * - * @param[in] n the modulo range - * @param[out] a slope parameter - * @param[out] b intercept parameter - */ - template - void affine_transform_params(IdxT n, IdxT& a, IdxT& b) - { - detail::RngImpl::affine_transform_params(n, a, b); - } - - /** - * @brief Generate uniformly distributed numbers in the given range - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output array - * @param len the number of elements in the output - * @param start start of the range - * @param end end of the range - * @param stream stream where to launch the kernel - * @{ - */ - template - void uniform(OutType* ptr, LenType len, OutType start, OutType end, cudaStream_t stream) - { - detail::RngImpl::uniform(ptr, len, start, end, stream); - } - - template - void uniformInt(OutType* ptr, LenType len, OutType start, OutType end, cudaStream_t stream) - { - detail::RngImpl::uniformInt(ptr, len, start, end, stream); - } - /** @} */ - - /** - * @brief Generate normal distributed numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output array - * @param len the number of elements in the output - * @param mu mean of the distribution - * @param sigma std-dev of the distribution - * @param stream stream where to launch the kernel - * @{ - */ - template - void normal(OutType* ptr, LenType len, OutType mu, OutType sigma, cudaStream_t stream) - { - detail::RngImpl::normal(ptr, len, mu, sigma, stream); - } - - template - void normalInt(IntType* ptr, LenType len, IntType mu, IntType sigma, cudaStream_t stream) - { - detail::RngImpl::normalInt(ptr, len, mu, sigma, stream); - } - /** @} */ - - /** - * @brief Generate normal distributed table according to the given set of - * means and scalar standard deviations. - * - * Each row in this table conforms to a normally distributed n-dim vector - * whose mean is the input vector and standard deviation is the corresponding - * vector or scalar. Correlations among the dimensions itself is assumed to - * be absent. - * - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output table (dim = n_rows x n_cols) - * @param n_rows number of rows in the table - * @param n_cols number of columns in the table - * @param mu_vec mean vector (dim = n_cols x 1). - * @param sigma_vec std-dev vector of each component (dim = n_cols x 1). Pass - * a nullptr to use the same scalar 'sigma' across all components - * @param sigma scalar sigma to be used if 'sigma_vec' is nullptr - * @param stream stream where to launch the kernel - */ - template - void normalTable(OutType* ptr, - LenType n_rows, - LenType n_cols, - const OutType* mu_vec, - const OutType* sigma_vec, - OutType sigma, - cudaStream_t stream) - { - detail::RngImpl::normalTable(ptr, n_rows, n_cols, mu_vec, sigma_vec, sigma, stream); - } - - /** - * @brief Fill an array with the given value - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output array - * @param len the number of elements in the output - * @param val value to be filled - * @param stream stream where to launch the kernel - */ - template - void fill(OutType* ptr, LenType len, OutType val, cudaStream_t stream) - { - detail::RngImpl::fill(ptr, len, val, stream); - } - - /** - * @brief Generate bernoulli distributed boolean array - * - * @tparam Type data type in which to compute the probabilities - * @tparam OutType output data type - * @tparam LenType data type used to represent length of the arrays - * - * @param[out] ptr the output array - * @param[in] len the number of elements in the output - * @param[in] prob coin-toss probability for heads - * @param[in] stream stream where to launch the kernel - */ - template - void bernoulli(OutType* ptr, LenType len, Type prob, cudaStream_t stream) - { - detail::RngImpl::bernoulli(ptr, len, prob, stream); - } - - /** - * @brief Generate bernoulli distributed array and applies scale - * @tparam Type data type in which to compute the probabilities - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output array - * @param len the number of elements in the output - * @param prob coin-toss probability for heads - * @param scale scaling factor - * @param stream stream where to launch the kernel - */ - template - void scaled_bernoulli(OutType* ptr, LenType len, OutType prob, OutType scale, cudaStream_t stream) - { - detail::RngImpl::scaled_bernoulli(ptr, len, prob, scale, stream); - } - - /** - * @brief Generate Gumbel distributed random numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr output array - * @param len number of elements in the output array - * @param mu mean value - * @param beta scale value - * @param stream stream where to launch the kernel - * @note https://en.wikipedia.org/wiki/Gumbel_distribution - */ - template - void gumbel(OutType* ptr, LenType len, OutType mu, OutType beta, cudaStream_t stream) - { - detail::RngImpl::gumbel(ptr, len, mu, beta, stream); - } - - /** - * @brief Generate lognormal distributed numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr the output array - * @param len the number of elements in the output - * @param mu mean of the distribution - * @param sigma std-dev of the distribution - * @param stream stream where to launch the kernel - */ - template - void lognormal(OutType* ptr, LenType len, OutType mu, OutType sigma, cudaStream_t stream) - { - detail::RngImpl::lognormal(ptr, len, mu, sigma, stream); - } - - /** - * @brief Generate logistic distributed random numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr output array - * @param len number of elements in the output array - * @param mu mean value - * @param scale scale value - * @param stream stream where to launch the kernel - */ - template - void logistic(OutType* ptr, LenType len, OutType mu, OutType scale, cudaStream_t stream) - { - detail::RngImpl::logistic(ptr, len, mu, scale, stream); - } - - /** - * @brief Generate exponentially distributed random numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr output array - * @param len number of elements in the output array - * @param lambda the lambda - * @param stream stream where to launch the kernel - */ - template - void exponential(OutType* ptr, LenType len, OutType lambda, cudaStream_t stream) - { - detail::RngImpl::exponential(ptr, len, lambda, stream); - } - - /** - * @brief Generate rayleigh distributed random numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr output array - * @param len number of elements in the output array - * @param sigma the sigma - * @param stream stream where to launch the kernel - */ - template - void rayleigh(OutType* ptr, LenType len, OutType sigma, cudaStream_t stream) - { - detail::RngImpl::rayleigh(ptr, len, sigma, stream); - } - - /** - * @brief Generate laplace distributed random numbers - * @tparam Type data type of output random number - * @tparam LenType data type used to represent length of the arrays - * @param ptr output array - * @param len number of elements in the output array - * @param mu the mean - * @param scale the scale - * @param stream stream where to launch the kernel - */ - template - void laplace(OutType* ptr, LenType len, OutType mu, OutType scale, cudaStream_t stream) - { - detail::RngImpl::laplace(ptr, len, mu, scale, stream); - } - - void advance(uint64_t max_streams, uint64_t max_calls_per_subsequence) - { - detail::RngImpl::advance(max_streams, max_calls_per_subsequence); - } - - /** - * @brief Sample the input array without replacement, optionally based on the - * input weight vector for each element in the array - * - * Implementation here is based on the `one-pass sampling` algo described here: - * https://www.ethz.ch/content/dam/ethz/special-interest/baug/ivt/ivt-dam/vpl/reports/1101-1200/ab1141.pdf - * - * @note In the sampled array the elements which are picked will always appear - * in the increasing order of their weights as computed using the exponential - * distribution. So, if you're particular about the order (for eg. array - * permutations), then this might not be the right choice! - * - * @tparam DataT data type - * @tparam WeightsT weights type - * @tparam IdxT index type - * @param handle - * @param out output sampled array (of length 'sampledLen') - * @param outIdx indices of the sampled array (of length 'sampledLen'). Pass - * a nullptr if this is not required. - * @param in input array to be sampled (of length 'len') - * @param wts weights array (of length 'len'). Pass a nullptr if uniform - * sampling is desired - * @param sampledLen output sampled array length - * @param len input array length - * @param stream cuda stream - */ - template - void sampleWithoutReplacement(const raft::handle_t& handle, - DataT* out, - IdxT* outIdx, - const DataT* in, - const WeightsT* wts, - IdxT sampledLen, - IdxT len, - cudaStream_t stream) - { - detail::RngImpl::sampleWithoutReplacement( - handle, out, outIdx, in, wts, sampledLen, len, stream); - } -}; - -}; // end namespace random -}; // end namespace raft - -#endif \ No newline at end of file +#include "rng.cuh" \ No newline at end of file diff --git a/cpp/include/raft/sparse/convert/coo.hpp b/cpp/include/raft/sparse/convert/coo.hpp index 009a19a563..697452db09 100644 --- a/cpp/include/raft/sparse/convert/coo.hpp +++ b/cpp/include/raft/sparse/convert/coo.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/convert/csr.hpp b/cpp/include/raft/sparse/convert/csr.hpp index 6a9a99d014..cd5d89bf71 100644 --- a/cpp/include/raft/sparse/convert/csr.hpp +++ b/cpp/include/raft/sparse/convert/csr.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/convert/dense.hpp b/cpp/include/raft/sparse/convert/dense.hpp index 1bdfa26732..f8338536c8 100644 --- a/cpp/include/raft/sparse/convert/dense.hpp +++ b/cpp/include/raft/sparse/convert/dense.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/csr.hpp b/cpp/include/raft/sparse/csr.hpp index ca0e6537e4..49fe980646 100644 --- a/cpp/include/raft/sparse/csr.hpp +++ b/cpp/include/raft/sparse/csr.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ using WeakCCState = detail::WeakCCState; * @param filter_op an optional filtering function to determine which points * should get considered for labeling. It gets global indexes (not batch-wide!) */ -template bool> +template void weak_cc_batched(Index_* labels, const Index_* row_ind, const Index_* row_ind_ptr, @@ -129,7 +129,7 @@ void weak_cc_batched(Index_* labels, * @param filter_op an optional filtering function to determine which points * should get considered for labeling. It gets global indexes (not batch-wide!) */ -template bool> +template void weak_cc(Index_* labels, const Index_* row_ind, const Index_* row_ind_ptr, diff --git a/cpp/include/raft/sparse/distance/distance.hpp b/cpp/include/raft/sparse/distance/distance.hpp index cba419e53a..86d4db81d2 100644 --- a/cpp/include/raft/sparse/distance/distance.hpp +++ b/cpp/include/raft/sparse/distance/distance.hpp @@ -14,128 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __SPARSE_DIST_H -#define __SPARSE_DIST_H - #pragma once -#include -#include - -#include - -#include -#include -#include -#include - -namespace raft { -namespace sparse { -namespace distance { - -static const std::unordered_set supportedDistance{ - raft::distance::DistanceType::L2Expanded, - raft::distance::DistanceType::L2Unexpanded, - raft::distance::DistanceType::L2SqrtExpanded, - raft::distance::DistanceType::L2SqrtUnexpanded, - raft::distance::DistanceType::InnerProduct, - raft::distance::DistanceType::L1, - raft::distance::DistanceType::Canberra, - raft::distance::DistanceType::Linf, - raft::distance::DistanceType::LpUnexpanded, - raft::distance::DistanceType::JaccardExpanded, - raft::distance::DistanceType::CosineExpanded, - raft::distance::DistanceType::HellingerExpanded, - raft::distance::DistanceType::DiceExpanded, - raft::distance::DistanceType::CorrelationExpanded, - raft::distance::DistanceType::RusselRaoExpanded, - raft::distance::DistanceType::HammingUnexpanded, - raft::distance::DistanceType::JensenShannon, - raft::distance::DistanceType::KLDivergence}; - -/** - * Compute pairwise distances between A and B, using the provided - * input configuration and distance function. - * - * @tparam value_idx index type - * @tparam value_t value type - * @param[out] out dense output array (size A.nrows * B.nrows) - * @param[in] input_config input argument configuration - * @param[in] metric distance metric to use - * @param[in] metric_arg metric argument (used for Minkowski distance) - */ -template -void pairwiseDistance(value_t* out, - distances_config_t input_config, - raft::distance::DistanceType metric, - float metric_arg) -{ - switch (metric) { - case raft::distance::DistanceType::L2Expanded: - detail::l2_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::L2SqrtExpanded: - detail::l2_sqrt_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::InnerProduct: - detail::ip_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::L2Unexpanded: - detail::l2_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::L2SqrtUnexpanded: - detail::l2_sqrt_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::L1: - detail::l1_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::LpUnexpanded: - detail::lp_unexpanded_distances_t(input_config, metric_arg).compute(out); - break; - case raft::distance::DistanceType::Linf: - detail::linf_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::Canberra: - detail::canberra_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::JaccardExpanded: - detail::jaccard_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::CosineExpanded: - detail::cosine_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::HellingerExpanded: - detail::hellinger_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::DiceExpanded: - detail::dice_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::CorrelationExpanded: - detail::correlation_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::RusselRaoExpanded: - detail::russelrao_expanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::HammingUnexpanded: - detail::hamming_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::JensenShannon: - detail::jensen_shannon_unexpanded_distances_t(input_config).compute(out); - break; - case raft::distance::DistanceType::KLDivergence: - detail::kl_divergence_unexpanded_distances_t(input_config).compute(out); - break; - - default: THROW("Unsupported distance: %d", metric); - } -} - -}; // namespace distance -}; // namespace sparse -}; // namespace raft - -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/cpp/include/raft/sparse/hierarchy/single_linkage.hpp b/cpp/include/raft/sparse/hierarchy/single_linkage.hpp index e7a37b7bf5..80c3c3c521 100644 --- a/cpp/include/raft/sparse/hierarchy/single_linkage.hpp +++ b/cpp/include/raft/sparse/hierarchy/single_linkage.hpp @@ -14,57 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __SINGLE_LINKAGE_H -#define __SINGLE_LINKAGE_H - #pragma once -#include -#include - -namespace raft { -namespace hierarchy { - -/** - * Single-linkage clustering, capable of constructing a KNN graph to - * scale the algorithm beyond the n^2 memory consumption of implementations - * that use the fully-connected graph of pairwise distances by connecting - * a knn graph when k is not large enough to connect it. - - * @tparam value_idx - * @tparam value_t - * @tparam dist_type method to use for constructing connectivities graph - * @param[in] handle raft handle - * @param[in] X dense input matrix in row-major layout - * @param[in] m number of rows in X - * @param[in] n number of columns in X - * @param[in] metric distance metrix to use when constructing connectivities graph - * @param[out] out struct containing output dendrogram and cluster assignments - * @param[in] c a constant used when constructing connectivities from knn graph. Allows the indirect - control - * of k. The algorithm will set `k = log(n) + c` - * @param[in] n_clusters number of clusters to assign data samples - */ -template -void single_linkage(const raft::handle_t& handle, - const value_t* X, - size_t m, - size_t n, - raft::distance::DistanceType metric, - linkage_output* out, - int c, - size_t n_clusters) -{ - detail::single_linkage( - handle, X, m, n, metric, out, c, n_clusters); -} -}; // namespace hierarchy -}; // namespace raft - -#endif \ No newline at end of file +#include diff --git a/cpp/include/raft/sparse/linalg/add.hpp b/cpp/include/raft/sparse/linalg/add.hpp index 33259cb39f..39ab2d6450 100644 --- a/cpp/include/raft/sparse/linalg/add.hpp +++ b/cpp/include/raft/sparse/linalg/add.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/linalg/degree.hpp b/cpp/include/raft/sparse/linalg/degree.hpp index 0c6af596ce..7cece7908e 100644 --- a/cpp/include/raft/sparse/linalg/degree.hpp +++ b/cpp/include/raft/sparse/linalg/degree.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/linalg/norm.hpp b/cpp/include/raft/sparse/linalg/norm.hpp index 196951bac7..1f054e63ab 100644 --- a/cpp/include/raft/sparse/linalg/norm.hpp +++ b/cpp/include/raft/sparse/linalg/norm.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/linalg/spectral.hpp b/cpp/include/raft/sparse/linalg/spectral.hpp index 9daa6e07b0..ff400f1f0f 100644 --- a/cpp/include/raft/sparse/linalg/spectral.hpp +++ b/cpp/include/raft/sparse/linalg/spectral.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/linalg/symmetrize.cuh b/cpp/include/raft/sparse/linalg/symmetrize.cuh index d41540c0b3..a01145376a 100644 --- a/cpp/include/raft/sparse/linalg/symmetrize.cuh +++ b/cpp/include/raft/sparse/linalg/symmetrize.cuh @@ -57,12 +57,12 @@ void coo_symmetrize(COO* in, * @param row_sizes2: Input empty row sum 2 array(n) for faster reduction */ template -__global__ static void symmetric_find_size(const value_t* __restrict__ data, - const value_idx* __restrict__ indices, - const value_idx n, - const int k, - value_idx* __restrict__ row_sizes, - value_idx* __restrict__ row_sizes2) +__global__ void symmetric_find_size(const value_t __restrict__* data, + const value_idx __restrict__* indices, + const value_idx n, + const int k, + value_idx __restrict__* row_sizes, + value_idx __restrict__* row_sizes2) { detail::symmetric_find_size(data, indices, n, k, row_sizes, row_sizes2); } @@ -78,10 +78,10 @@ __global__ static void symmetric_find_size(const value_t* __restrict__ data, * @param row_sizes2: Input row sum 2 array(n) for faster reduction */ template -__global__ static void reduce_find_size(const value_idx n, - const int k, - value_idx* __restrict__ row_sizes, - const value_idx* __restrict__ row_sizes2) +__global__ void reduce_find_size(const value_idx n, + const int k, + value_idx __restrict__* row_sizes, + const value_idx __restrict__* row_sizes2) { detail::reduce_find_size(n, k, row_sizes, row_sizes2); } @@ -103,14 +103,14 @@ __global__ static void reduce_find_size(const value_idx n, * @param k: Number of n_neighbors */ template -__global__ static void symmetric_sum(value_idx* __restrict__ edges, - const value_t* __restrict__ data, - const value_idx* __restrict__ indices, - value_t* __restrict__ VAL, - value_idx* __restrict__ COL, - value_idx* __restrict__ ROW, - const value_idx n, - const int k) +__global__ void symmetric_sum(value_idx* __restrict__ edges, + const value_t* __restrict__ data, + const value_idx* __restrict__ indices, + value_t* __restrict__ VAL, + value_idx* __restrict__ COL, + value_idx* __restrict__ ROW, + const value_idx n, + const int k) { detail::symmetric_sum(edges, data, indices, VAL, COL, ROW, n, k); } diff --git a/cpp/include/raft/sparse/linalg/symmetrize.hpp b/cpp/include/raft/sparse/linalg/symmetrize.hpp index 4d8520dabf..6e1d3b4fa1 100644 --- a/cpp/include/raft/sparse/linalg/symmetrize.hpp +++ b/cpp/include/raft/sparse/linalg/symmetrize.hpp @@ -14,160 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __SYMMETRIZE_H -#define __SYMMETRIZE_H - #pragma once -#include -#include - -namespace raft { -namespace sparse { -namespace linalg { - -/** - * @brief takes a COO matrix which may not be symmetric and symmetrizes - * it, running a custom reduction function against the each value - * and its transposed value. - * - * @param in: Input COO matrix - * @param out: Output symmetrized COO matrix - * @param reduction_op: a custom reduction function - * @param stream: cuda stream to use - */ -template -void coo_symmetrize(COO* in, - COO* out, - Lambda reduction_op, // two-argument reducer - cudaStream_t stream) -{ - detail::coo_symmetrize(in, out, reduction_op, stream); -} - -/** - * @brief Find how much space needed in each row. - * We look through all datapoints and increment the count for each row. - * - * TODO: This isn't generalized. Remove in place of `symmetrize()` - * @param data: Input knn distances(n, k) - * @param indices: Input knn indices(n, k) - * @param n: Number of rows - * @param k: Number of n_neighbors - * @param row_sizes: Input empty row sum 1 array(n) - * @param row_sizes2: Input empty row sum 2 array(n) for faster reduction - */ -template -__global__ static void symmetric_find_size(const value_t* __restrict__ data, - const value_idx* __restrict__ indices, - const value_idx n, - const int k, - value_idx* __restrict__ row_sizes, - value_idx* __restrict__ row_sizes2) -{ - detail::symmetric_find_size(data, indices, n, k, row_sizes, row_sizes2); -} - -/** - * @brief Reduce sum(row_sizes) + k - * Reduction for symmetric_find_size kernel. Allows algo to be faster. - * - * TODO: This isn't generalized. Remove in place of `symmetrize()` - * @param n: Number of rows - * @param k: Number of n_neighbors - * @param row_sizes: Input row sum 1 array(n) - * @param row_sizes2: Input row sum 2 array(n) for faster reduction - */ -template -__global__ static void reduce_find_size(const value_idx n, - const int k, - value_idx* __restrict__ row_sizes, - const value_idx* __restrict__ row_sizes2) -{ - detail::reduce_find_size(n, k, row_sizes, row_sizes2); -} - -/** - * @brief Perform data + data.T operation. - * Can only run once row_sizes from the CSR matrix of data + data.T has been - * determined. - * - * TODO: This isn't generalized. Remove in place of `symmetrize()` - * - * @param edges: Input row sum array(n) after reduction - * @param data: Input knn distances(n, k) - * @param indices: Input knn indices(n, k) - * @param VAL: Output values for data + data.T - * @param COL: Output column indices for data + data.T - * @param ROW: Output row indices for data + data.T - * @param n: Number of rows - * @param k: Number of n_neighbors - */ -template -__global__ static void symmetric_sum(value_idx* __restrict__ edges, - const value_t* __restrict__ data, - const value_idx* __restrict__ indices, - value_t* __restrict__ VAL, - value_idx* __restrict__ COL, - value_idx* __restrict__ ROW, - const value_idx n, - const int k) -{ - detail::symmetric_sum(edges, data, indices, VAL, COL, ROW, n, k); -} - -/** - * @brief Perform data + data.T on raw KNN data. - * The following steps are invoked: - * (1) Find how much space needed in each row - * (2) Compute final space needed (n*k + sum(row_sizes)) == 2*n*k - * (3) Allocate new space - * (4) Prepare edges for each new row - * (5) Perform final data + data.T operation - * (6) Return summed up VAL, COL, ROW - * - * TODO: This isn't generalized. Remove in place of `symmetrize()` - * - * @param knn_indices: Input knn distances(n, k) - * @param knn_dists: Input knn indices(n, k) - * @param n: Number of rows - * @param k: Number of n_neighbors - * @param out: Output COO Matrix class - * @param stream: Input cuda stream - */ -template -void from_knn_symmetrize_matrix(const value_idx* __restrict__ knn_indices, - const value_t* __restrict__ knn_dists, - const value_idx n, - const int k, - COO* out, - cudaStream_t stream) -{ - detail::from_knn_symmetrize_matrix(knn_indices, knn_dists, n, k, out, stream); -} - -/** - * Symmetrizes a COO matrix - */ -template -void symmetrize(const raft::handle_t& handle, - const value_idx* rows, - const value_idx* cols, - const value_t* vals, - size_t m, - size_t n, - size_t nnz, - raft::sparse::COO& out) -{ - detail::symmetrize(handle, rows, cols, vals, m, n, nnz, out); -} - -}; // end NAMESPACE linalg -}; // end NAMESPACE sparse -}; // end NAMESPACE raft - -#endif +#include diff --git a/cpp/include/raft/sparse/linalg/transpose.hpp b/cpp/include/raft/sparse/linalg/transpose.hpp index 0aea254803..c709c20473 100644 --- a/cpp/include/raft/sparse/linalg/transpose.hpp +++ b/cpp/include/raft/sparse/linalg/transpose.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/mst/mst.hpp b/cpp/include/raft/sparse/mst/mst.hpp index ac4cf21b64..5a66e8c815 100644 --- a/cpp/include/raft/sparse/mst/mst.hpp +++ b/cpp/include/raft/sparse/mst/mst.hpp @@ -16,48 +16,9 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ - -#ifndef __MST_H -#define __MST_H - #pragma once -#include "mst_solver.cuh" - -namespace raft { -namespace mst { - -template -raft::Graph_COO mst(const raft::handle_t& handle, - edge_t const* offsets, - vertex_t const* indices, - weight_t const* weights, - vertex_t const v, - edge_t const e, - vertex_t* color, - cudaStream_t stream, - bool symmetrize_output = true, - bool initialize_colors = true, - int iterations = 0) -{ - MST_solver mst_solver(handle, - offsets, - indices, - weights, - v, - e, - color, - stream, - symmetrize_output, - initialize_colors, - iterations); - return mst_solver.solve(); -} - -} // namespace mst -} // namespace raft - -#endif \ No newline at end of file +#include "mst.cuh" \ No newline at end of file diff --git a/cpp/include/raft/sparse/op/filter.hpp b/cpp/include/raft/sparse/op/filter.hpp index b67084f18a..3821d963b0 100644 --- a/cpp/include/raft/sparse/op/filter.hpp +++ b/cpp/include/raft/sparse/op/filter.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/op/reduce.hpp b/cpp/include/raft/sparse/op/reduce.hpp index a7e771d157..bb7560fa3d 100644 --- a/cpp/include/raft/sparse/op/reduce.hpp +++ b/cpp/include/raft/sparse/op/reduce.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/op/row_op.hpp b/cpp/include/raft/sparse/op/row_op.hpp index b3eafafa66..ac12432e92 100644 --- a/cpp/include/raft/sparse/op/row_op.hpp +++ b/cpp/include/raft/sparse/op/row_op.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/op/slice.hpp b/cpp/include/raft/sparse/op/slice.hpp index b4e0622ced..75b7e478e5 100644 --- a/cpp/include/raft/sparse/op/slice.hpp +++ b/cpp/include/raft/sparse/op/slice.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/op/sort.hpp b/cpp/include/raft/sparse/op/sort.hpp index 12a4a77ca9..cd363582fb 100644 --- a/cpp/include/raft/sparse/op/sort.hpp +++ b/cpp/include/raft/sparse/op/sort.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/selection/connect_components.hpp b/cpp/include/raft/sparse/selection/connect_components.hpp index 83d8fce8ba..25d71367db 100644 --- a/cpp/include/raft/sparse/selection/connect_components.hpp +++ b/cpp/include/raft/sparse/selection/connect_components.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/selection/knn.hpp b/cpp/include/raft/sparse/selection/knn.hpp index 4158bd40c2..bd6dd39fdf 100644 --- a/cpp/include/raft/sparse/selection/knn.hpp +++ b/cpp/include/raft/sparse/selection/knn.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/sparse/selection/knn_graph.hpp b/cpp/include/raft/sparse/selection/knn_graph.hpp index eb035390ce..be47a6a9ef 100644 --- a/cpp/include/raft/sparse/selection/knn_graph.hpp +++ b/cpp/include/raft/sparse/selection/knn_graph.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spatial/knn/ann.hpp b/cpp/include/raft/spatial/knn/ann.hpp index bb11a2b11b..b6d3ca2976 100644 --- a/cpp/include/raft/spatial/knn/ann.hpp +++ b/cpp/include/raft/spatial/knn/ann.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spatial/knn/ball_cover.hpp b/cpp/include/raft/spatial/knn/ball_cover.hpp index 26c2c1fb2e..a7c483493e 100644 --- a/cpp/include/raft/spatial/knn/ball_cover.hpp +++ b/cpp/include/raft/spatial/knn/ball_cover.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spatial/knn/epsilon_neighborhood.hpp b/cpp/include/raft/spatial/knn/epsilon_neighborhood.hpp index b3ba0fc442..7674ac0d46 100644 --- a/cpp/include/raft/spatial/knn/epsilon_neighborhood.hpp +++ b/cpp/include/raft/spatial/knn/epsilon_neighborhood.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spatial/knn/knn.hpp b/cpp/include/raft/spatial/knn/knn.hpp index da18e891d4..c7b21f16ad 100644 --- a/cpp/include/raft/spatial/knn/knn.hpp +++ b/cpp/include/raft/spatial/knn/knn.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spatial/knn/specializations.hpp b/cpp/include/raft/spatial/knn/specializations.hpp index 538e1b1380..13721a975f 100644 --- a/cpp/include/raft/spatial/knn/specializations.hpp +++ b/cpp/include/raft/spatial/knn/specializations.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spectral/cluster_solvers.hpp b/cpp/include/raft/spectral/cluster_solvers.hpp index c6b166bb4f..9cb773cce2 100644 --- a/cpp/include/raft/spectral/cluster_solvers.hpp +++ b/cpp/include/raft/spectral/cluster_solvers.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spectral/eigen_solvers.hpp b/cpp/include/raft/spectral/eigen_solvers.hpp index d55ddf952a..e6b37f29ec 100644 --- a/cpp/include/raft/spectral/eigen_solvers.hpp +++ b/cpp/include/raft/spectral/eigen_solvers.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/spectral/modularity_maximization.cuh b/cpp/include/raft/spectral/modularity_maximization.cuh index c8221e434c..61d85aefaa 100644 --- a/cpp/include/raft/spectral/modularity_maximization.cuh +++ b/cpp/include/raft/spectral/modularity_maximization.cuh @@ -31,24 +31,17 @@ namespace spectral { /** Compute partition for a weighted undirected graph. This * partition attempts to minimize the cost function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) + * Cost = \f$sum_i\f$ (Edges cut by ith partition)/(Vertices in ith partition) * - * @param G Weighted graph in CSR format - * @param nClusters Number of partitions. - * @param nEigVecs Number of eigenvectors to compute. - * @param maxIter_lanczos Maximum number of Lanczos iterations. - * @param restartIter_lanczos Maximum size of Lanczos system before - * implicit restart. - * @param tol_lanczos Convergence tolerance for Lanczos method. - * @param maxIter_kmeans Maximum number of k-means iterations. - * @param tol_kmeans Convergence tolerance for k-means algorithm. - * @param clusters (Output, device memory, n entries) Cluster + * @param handle raft handle for managing expensive resources + * @param csr_m Weighted graph in CSR format + * @param eigen_solver Eigensolver implementation + * @param cluster_solver Cluster solver implementation + * @param clusters (Output, device memory, n entries) Partition * assignments. - * @param iters_lanczos On exit, number of Lanczos iterations - * performed. - * @param iters_kmeans On exit, number of k-means iterations - * performed. - * @return error flag. + * @param eigVals Output eigenvalue array pointer on device + * @param eigVecs Output eigenvector array pointer on device + * @return statistics: number of eigensolver iterations, . */ template std::tuple modularity_maximization( @@ -70,7 +63,8 @@ std::tuple modularity_maximization( /// Compute modularity /** This function determines the modularity based on a graph and cluster assignments - * @param G Weighted graph in CSR format + * @param handle raft handle for managing expensive resources + * @param csr_m Weighted graph in CSR format * @param nClusters Number of clusters. * @param clusters (Input, device memory, n entries) Cluster assignments. * @param modularity On exit, modularity diff --git a/cpp/include/raft/spectral/modularity_maximization.hpp b/cpp/include/raft/spectral/modularity_maximization.hpp index d1c3ea00f7..1bc003e711 100644 --- a/cpp/include/raft/spectral/modularity_maximization.hpp +++ b/cpp/include/raft/spectral/modularity_maximization.hpp @@ -14,84 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __MODULARITY_MAXIMIZATION_H -#define __MODULARITY_MAXIMIZATION_H - #pragma once -#include - -#include - -namespace raft { -namespace spectral { - -// ========================================================= -// Spectral modularity_maximization -// ========================================================= - -/** Compute partition for a weighted undirected graph. This - * partition attempts to minimize the cost function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) - * - * @param G Weighted graph in CSR format - * @param nClusters Number of partitions. - * @param nEigVecs Number of eigenvectors to compute. - * @param maxIter_lanczos Maximum number of Lanczos iterations. - * @param restartIter_lanczos Maximum size of Lanczos system before - * implicit restart. - * @param tol_lanczos Convergence tolerance for Lanczos method. - * @param maxIter_kmeans Maximum number of k-means iterations. - * @param tol_kmeans Convergence tolerance for k-means algorithm. - * @param clusters (Output, device memory, n entries) Cluster - * assignments. - * @param iters_lanczos On exit, number of Lanczos iterations - * performed. - * @param iters_kmeans On exit, number of k-means iterations - * performed. - * @return error flag. - */ -template -std::tuple modularity_maximization( - handle_t const& handle, - matrix::sparse_matrix_t const& csr_m, - EigenSolver const& eigen_solver, - ClusterSolver const& cluster_solver, - vertex_t* __restrict__ clusters, - weight_t* eigVals, - weight_t* eigVecs) -{ - return raft::spectral::detail:: - modularity_maximization( - handle, csr_m, eigen_solver, cluster_solver, clusters, eigVals, eigVecs); -} -//=================================================== -// Analysis of graph partition -// ========================================================= - -/// Compute modularity -/** This function determines the modularity based on a graph and cluster assignments - * @param G Weighted graph in CSR format - * @param nClusters Number of clusters. - * @param clusters (Input, device memory, n entries) Cluster assignments. - * @param modularity On exit, modularity - */ -template -void analyzeModularity(handle_t const& handle, - matrix::sparse_matrix_t const& csr_m, - vertex_t nClusters, - vertex_t const* __restrict__ clusters, - weight_t& modularity) -{ - raft::spectral::detail::analyzeModularity( - handle, csr_m, nClusters, clusters, modularity); -} - -} // namespace spectral -} // namespace raft - -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/cpp/include/raft/spectral/partition.cuh b/cpp/include/raft/spectral/partition.cuh index 9ccc21c868..2d21f2223c 100644 --- a/cpp/include/raft/spectral/partition.cuh +++ b/cpp/include/raft/spectral/partition.cuh @@ -33,23 +33,16 @@ namespace spectral { /// Compute spectral graph partition /** Compute partition for a weighted undirected graph. This * partition attempts to minimize the cost function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) + * Cost = \f$sum_i\f$ (Edges cut by ith partition)/(Vertices in ith partition) * - * @param G Weighted graph in CSR format - * @param nClusters Number of partitions. - * @param nEigVecs Number of eigenvectors to compute. - * @param maxIter_lanczos Maximum number of Lanczos iterations. - * @param restartIter_lanczos Maximum size of Lanczos system before - * implicit restart. - * @param tol_lanczos Convergence tolerance for Lanczos method. - * @param maxIter_kmeans Maximum number of k-means iterations. - * @param tol_kmeans Convergence tolerance for k-means algorithm. + * @param handle raft handle for managing expensive resources + * @param csr_m Weighted graph in CSR format + * @param eigen_solver Eigensolver implementation + * @param cluster_solver Cluster solver implementation * @param clusters (Output, device memory, n entries) Partition * assignments. - * @param iters_lanczos On exit, number of Lanczos iterations - * performed. - * @param iters_kmeans On exit, number of k-means iterations - * performed. + * @param eigVals Output eigenvalue array pointer on device + * @param eigVecs Output eigenvector array pointer on device * @return statistics: number of eigensolver iterations, . */ template @@ -73,16 +66,16 @@ std::tuple partition( /// Compute cost function for partition /** This function determines the edges cut by a partition and a cost * function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) + * Cost = \f$sum_i\f$ (Edges cut by ith partition)/(Vertices in ith partition) * Graph is assumed to be weighted and undirected. * - * @param G Weighted graph in CSR format + * @param handle raft handle for managing expensive resources + * @param csr_m Weighted graph in CSR format * @param nClusters Number of partitions. * @param clusters (Input, device memory, n entries) Partition * assignments. * @param edgeCut On exit, weight of edges cut by partition. * @param cost On exit, partition cost function. - * @return error flag. */ template void analyzePartition(handle_t const& handle, diff --git a/cpp/include/raft/spectral/partition.hpp b/cpp/include/raft/spectral/partition.hpp index fde2e6572b..27f204d055 100644 --- a/cpp/include/raft/spectral/partition.hpp +++ b/cpp/include/raft/spectral/partition.hpp @@ -14,93 +14,10 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ -#ifndef __PARTITION_H -#define __PARTITION_H - #pragma once -#include - -#include - -namespace raft { -namespace spectral { - -// ========================================================= -// Spectral partitioner -// ========================================================= - -/// Compute spectral graph partition -/** Compute partition for a weighted undirected graph. This - * partition attempts to minimize the cost function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) - * - * @param G Weighted graph in CSR format - * @param nClusters Number of partitions. - * @param nEigVecs Number of eigenvectors to compute. - * @param maxIter_lanczos Maximum number of Lanczos iterations. - * @param restartIter_lanczos Maximum size of Lanczos system before - * implicit restart. - * @param tol_lanczos Convergence tolerance for Lanczos method. - * @param maxIter_kmeans Maximum number of k-means iterations. - * @param tol_kmeans Convergence tolerance for k-means algorithm. - * @param clusters (Output, device memory, n entries) Partition - * assignments. - * @param iters_lanczos On exit, number of Lanczos iterations - * performed. - * @param iters_kmeans On exit, number of k-means iterations - * performed. - * @return statistics: number of eigensolver iterations, . - */ -template -std::tuple partition( - handle_t const& handle, - matrix::sparse_matrix_t const& csr_m, - EigenSolver const& eigen_solver, - ClusterSolver const& cluster_solver, - vertex_t* __restrict__ clusters, - weight_t* eigVals, - weight_t* eigVecs) -{ - return raft::spectral::detail::partition( - handle, csr_m, eigen_solver, cluster_solver, clusters, eigVals, eigVecs); -} - -// ========================================================= -// Analysis of graph partition -// ========================================================= - -/// Compute cost function for partition -/** This function determines the edges cut by a partition and a cost - * function: - * Cost = \sum_i (Edges cut by ith partition)/(Vertices in ith partition) - * Graph is assumed to be weighted and undirected. - * - * @param G Weighted graph in CSR format - * @param nClusters Number of partitions. - * @param clusters (Input, device memory, n entries) Partition - * assignments. - * @param edgeCut On exit, weight of edges cut by partition. - * @param cost On exit, partition cost function. - * @return error flag. - */ -template -void analyzePartition(handle_t const& handle, - matrix::sparse_matrix_t const& csr_m, - vertex_t nClusters, - const vertex_t* __restrict__ clusters, - weight_t& edgeCut, - weight_t& cost) -{ - raft::spectral::detail::analyzePartition( - handle, csr_m, nClusters, clusters, edgeCut, cost); -} - -} // namespace spectral -} // namespace raft - -#endif \ No newline at end of file +#include diff --git a/cpp/include/raft/stats/accuracy.hpp b/cpp/include/raft/stats/accuracy.hpp index eefe96b2d1..8cbb0f719e 100644 --- a/cpp/include/raft/stats/accuracy.hpp +++ b/cpp/include/raft/stats/accuracy.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/adjusted_rand_index.hpp b/cpp/include/raft/stats/adjusted_rand_index.hpp index cbf6112000..bc836eed86 100644 --- a/cpp/include/raft/stats/adjusted_rand_index.hpp +++ b/cpp/include/raft/stats/adjusted_rand_index.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/completeness_score.hpp b/cpp/include/raft/stats/completeness_score.hpp index 01ed0d66b9..0dd97e9782 100644 --- a/cpp/include/raft/stats/completeness_score.hpp +++ b/cpp/include/raft/stats/completeness_score.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/contingency_matrix.hpp b/cpp/include/raft/stats/contingency_matrix.hpp index 6fa4a314f9..70800be1e6 100644 --- a/cpp/include/raft/stats/contingency_matrix.hpp +++ b/cpp/include/raft/stats/contingency_matrix.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/cov.hpp b/cpp/include/raft/stats/cov.hpp index 27b4ede876..a584dedc95 100644 --- a/cpp/include/raft/stats/cov.hpp +++ b/cpp/include/raft/stats/cov.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/dispersion.hpp b/cpp/include/raft/stats/dispersion.hpp index 5958551e87..7fabf07992 100644 --- a/cpp/include/raft/stats/dispersion.hpp +++ b/cpp/include/raft/stats/dispersion.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/entropy.hpp b/cpp/include/raft/stats/entropy.hpp index eb1fee2949..37dc2b700c 100644 --- a/cpp/include/raft/stats/entropy.hpp +++ b/cpp/include/raft/stats/entropy.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/histogram.hpp b/cpp/include/raft/stats/histogram.hpp index 828719236b..627026c219 100644 --- a/cpp/include/raft/stats/histogram.hpp +++ b/cpp/include/raft/stats/histogram.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/homogeneity_score.hpp b/cpp/include/raft/stats/homogeneity_score.hpp index 49baea0c19..4e119f2bc7 100644 --- a/cpp/include/raft/stats/homogeneity_score.hpp +++ b/cpp/include/raft/stats/homogeneity_score.hpp @@ -15,7 +15,7 @@ */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/information_criterion.hpp b/cpp/include/raft/stats/information_criterion.hpp index f6dd69aa08..3a39e56c41 100644 --- a/cpp/include/raft/stats/information_criterion.hpp +++ b/cpp/include/raft/stats/information_criterion.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/kl_divergence.hpp b/cpp/include/raft/stats/kl_divergence.hpp index 9d7c0b1e46..59db77246f 100644 --- a/cpp/include/raft/stats/kl_divergence.hpp +++ b/cpp/include/raft/stats/kl_divergence.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/mean.hpp b/cpp/include/raft/stats/mean.hpp index add9e47569..2767b632e6 100644 --- a/cpp/include/raft/stats/mean.hpp +++ b/cpp/include/raft/stats/mean.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/mean_center.hpp b/cpp/include/raft/stats/mean_center.hpp index 69ce79338b..e219891cab 100644 --- a/cpp/include/raft/stats/mean_center.hpp +++ b/cpp/include/raft/stats/mean_center.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/meanvar.hpp b/cpp/include/raft/stats/meanvar.hpp index a6809170e7..d7ef935fbc 100644 --- a/cpp/include/raft/stats/meanvar.hpp +++ b/cpp/include/raft/stats/meanvar.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/minmax.hpp b/cpp/include/raft/stats/minmax.hpp index 669b3c5837..97f06129fa 100644 --- a/cpp/include/raft/stats/minmax.hpp +++ b/cpp/include/raft/stats/minmax.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/mutual_info_score.hpp b/cpp/include/raft/stats/mutual_info_score.hpp index c900f9ce5b..a080211c36 100644 --- a/cpp/include/raft/stats/mutual_info_score.hpp +++ b/cpp/include/raft/stats/mutual_info_score.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/r2_score.hpp b/cpp/include/raft/stats/r2_score.hpp index 4e126d903b..c88a1822ec 100644 --- a/cpp/include/raft/stats/r2_score.hpp +++ b/cpp/include/raft/stats/r2_score.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/rand_index.hpp b/cpp/include/raft/stats/rand_index.hpp index c94e4fa8db..e8c3089371 100644 --- a/cpp/include/raft/stats/rand_index.hpp +++ b/cpp/include/raft/stats/rand_index.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/regression_metrics.hpp b/cpp/include/raft/stats/regression_metrics.hpp index b8868bdb33..f65ad524ef 100644 --- a/cpp/include/raft/stats/regression_metrics.hpp +++ b/cpp/include/raft/stats/regression_metrics.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/silhouette_score.hpp b/cpp/include/raft/stats/silhouette_score.hpp index 7506d9a733..e6c84855c6 100644 --- a/cpp/include/raft/stats/silhouette_score.hpp +++ b/cpp/include/raft/stats/silhouette_score.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/specializations.hpp b/cpp/include/raft/stats/specializations.hpp index 87301deccc..3929b3124c 100644 --- a/cpp/include/raft/stats/specializations.hpp +++ b/cpp/include/raft/stats/specializations.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/stddev.hpp b/cpp/include/raft/stats/stddev.hpp index e038fecc02..f496b1fd30 100644 --- a/cpp/include/raft/stats/stddev.hpp +++ b/cpp/include/raft/stats/stddev.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/sum.hpp b/cpp/include/raft/stats/sum.hpp index c2b93b79db..e1c8c67777 100644 --- a/cpp/include/raft/stats/sum.hpp +++ b/cpp/include/raft/stats/sum.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/trustworthiness_score.hpp b/cpp/include/raft/stats/trustworthiness_score.hpp index 81ca4eb5b7..81edf2ea04 100644 --- a/cpp/include/raft/stats/trustworthiness_score.hpp +++ b/cpp/include/raft/stats/trustworthiness_score.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/v_measure.hpp b/cpp/include/raft/stats/v_measure.hpp index 925171c2d2..a137af844d 100644 --- a/cpp/include/raft/stats/v_measure.hpp +++ b/cpp/include/raft/stats/v_measure.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/cpp/include/raft/stats/weighted_mean.hpp b/cpp/include/raft/stats/weighted_mean.hpp index 4f53067e65..5b3f4678d8 100644 --- a/cpp/include/raft/stats/weighted_mean.hpp +++ b/cpp/include/raft/stats/weighted_mean.hpp @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * @warning This file is deprecated and will be removed in release 22.06. + * This file is deprecated and will be removed in release 22.06. * Please use the cuh version instead. */ diff --git a/docs/source/conf.py b/docs/source/conf.py index 6fd7e3d702..bb9f0c1a84 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -25,6 +25,7 @@ # absolute, like shown here. sys.path.insert(0, os.path.abspath('sphinxext')) sys.path.insert(0, os.path.abspath('../../python/raft')) +sys.path.insert(0, os.path.abspath('../../python/pylibraft')) from github_link import make_linkcode_resolve # noqa diff --git a/docs/source/cpp_api.rst b/docs/source/cpp_api.rst index 6d951587d9..db139031a2 100644 --- a/docs/source/cpp_api.rst +++ b/docs/source/cpp_api.rst @@ -9,6 +9,11 @@ RAFT C++ API Reference :maxdepth: 4 cpp_api/core.rst + cpp_api/clustering.rst + cpp_api/linalg.rst + cpp_api/matrix.rst + cpp_api/optimization.rst + cpp_api/random.rst cpp_api/spatial.rst - cpp_api/nn.rst - cpp_api/sparse.rst \ No newline at end of file + cpp_api/sparse.rst + cpp_api/stats.rst \ No newline at end of file diff --git a/docs/source/cpp_api/clustering.rst b/docs/source/cpp_api/clustering.rst new file mode 100644 index 0000000000..715275b59a --- /dev/null +++ b/docs/source/cpp_api/clustering.rst @@ -0,0 +1,25 @@ +Clustering +========== + +This page provides C++ class references for the publicly-exposed elements of the clustering package. + +K-Means +####### + +.. doxygennamespace:: raft::cluster + :project: RAFT + :members: + +Spectral +######## + +.. doxygennamespace:: raft::spectral + :project: RAFT + :members: + +Hierarchical +############ + +.. doxygennamespace:: raft::hierarchy + :project: RAFT + :members: diff --git a/docs/source/cpp_api/core.rst b/docs/source/cpp_api/core.rst index bae39e3282..ef6270556e 100644 --- a/docs/source/cpp_api/core.rst +++ b/docs/source/cpp_api/core.rst @@ -14,8 +14,41 @@ handle_t interruptible -######## +############# .. doxygenclass:: raft::interruptible :project: RAFT :members: + + +mdarray +####### + +.. doxygenclass:: raft::mdarray + :project: RAFT + :members: + + +span +#### + +.. doxygenclass:: raft::span + :project: RAFT + :members: + + +logger +###### + +.. doxygenclass:: raft::logger + :project: RAFT + :members: + + +Multi-node Multi-GPU +#################### + +.. doxygennamespace:: raft::comms + :project: RAFT + :members: + diff --git a/docs/source/cpp_api/distributed.rst b/docs/source/cpp_api/distributed.rst deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/source/cpp_api/linalg.rst b/docs/source/cpp_api/linalg.rst index e69de29bb2..f9986fd2ce 100644 --- a/docs/source/cpp_api/linalg.rst +++ b/docs/source/cpp_api/linalg.rst @@ -0,0 +1,8 @@ +Linear Algebra +============== + +This page provides C++ class references for the publicly-exposed elements of the (dense) linear algebra package. + +.. doxygennamespace:: raft::linalg + :project: RAFT + :members: diff --git a/docs/source/cpp_api/matrix.rst b/docs/source/cpp_api/matrix.rst new file mode 100644 index 0000000000..65534aa6ee --- /dev/null +++ b/docs/source/cpp_api/matrix.rst @@ -0,0 +1,8 @@ +Matrix +====== + +This page provides C++ class references for the publicly-exposed elements of the matrix package. + +.. doxygennamespace:: raft::matrix + :project: RAFT + :members: diff --git a/docs/source/cpp_api/nn.rst b/docs/source/cpp_api/nn.rst deleted file mode 100644 index 79d8dd1ad3..0000000000 --- a/docs/source/cpp_api/nn.rst +++ /dev/null @@ -1,14 +0,0 @@ -Nearest Neighbors -================= - -This page provides C++ class references for the publicly-exposed elements of the nearest neighbors package. - - - -nearest neighbors -################# - -.. doxygennamespace:: raft::spatial::knn - :project: RAFT - :members: - diff --git a/docs/source/cpp_api/optimization.rst b/docs/source/cpp_api/optimization.rst new file mode 100644 index 0000000000..75cec2494e --- /dev/null +++ b/docs/source/cpp_api/optimization.rst @@ -0,0 +1,19 @@ +Optimization +============ + +This page provides C++ class references for the publicly-exposed elements of the optimization package. + + +Linear Assignment Problem +######################### + +.. doxygenclass:: raft::lap::LinearAssignmentProblem + :project: RAFT + :members: + +Minimum Spanning Tree +##################### + +.. doxygennamespace:: raft::mst + :project: RAFT + :members: diff --git a/docs/source/cpp_api/random.rst b/docs/source/cpp_api/random.rst new file mode 100644 index 0000000000..8635855484 --- /dev/null +++ b/docs/source/cpp_api/random.rst @@ -0,0 +1,12 @@ +Random +====== + +This page provides C++ class references for the publicly-exposed elements of the random package. + +.. doxygennamespace:: raft::random + :project: RAFT + :members: + +.. doxygenclass:: raft::random::Rng + :project: RAFT + :members: diff --git a/docs/source/cpp_api/sparse.rst b/docs/source/cpp_api/sparse.rst index 91e553426b..c0ea61c6f7 100644 --- a/docs/source/cpp_api/sparse.rst +++ b/docs/source/cpp_api/sparse.rst @@ -5,10 +5,41 @@ This page provides C++ class references for the publicly-exposed elements of the -raft::sparse -############ +Conversion +########## -.. doxygennamespace:: raft::sparse +.. doxygennamespace:: raft::sparse::convert :project: RAFT :members: +Distance +######## + +.. doxygennamespace:: raft::sparse::distance + :project: RAFT + :members: + +Linear Algebra +############## + +.. doxygennamespace:: raft::sparse::linalg + :project: RAFT + :members: + +Misc Operations +############### + +.. doxygennamespace:: raft::sparse::op + :project: RAFT + :members: + +Selection +######### + +.. doxygennamespace:: raft::sparse::selection + :project: RAFT + :members: + +.. doxygennamespace:: raft::linkage + :project: RAFT + :members: diff --git a/docs/source/cpp_api/spatial.rst b/docs/source/cpp_api/spatial.rst index 410267e528..5065fa5af0 100644 --- a/docs/source/cpp_api/spatial.rst +++ b/docs/source/cpp_api/spatial.rst @@ -3,11 +3,16 @@ Spatial This page provides C++ class references for the publicly-exposed elements of the spatial package. - - -distance +Distance ######## .. doxygennamespace:: raft::distance :project: RAFT + +Nearest Neighbors +################# + +.. doxygennamespace:: raft::spatial::knn + :project: RAFT + :members: diff --git a/docs/source/cpp_api/stats.rst b/docs/source/cpp_api/stats.rst index e69de29bb2..8ad8b8a604 100644 --- a/docs/source/cpp_api/stats.rst +++ b/docs/source/cpp_api/stats.rst @@ -0,0 +1,8 @@ +Stats +===== + +This page provides C++ class references for the publicly-exposed elements of the stats package. + +.. doxygennamespace:: raft::stats + :project: RAFT + :members: diff --git a/docs/source/cuda_cpp.rst b/docs/source/cuda_cpp.rst index 3737875a27..30e8903f29 100644 --- a/docs/source/cuda_cpp.rst +++ b/docs/source/cuda_cpp.rst @@ -8,4 +8,4 @@ RAFT is header-only but provides optional shared libraries to speed up compile t .. toctree:: :maxdepth: 4 - cpp_api.rst + cpp_api.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 85798a9b47..d047543c13 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,19 +1,15 @@ Welcome to RAFT's documentation! ================================= - -RAFT (RAPIDS Analytics Framework Toolkit) is a Python and CUDA/C++ library containing building-blocks, mathematical primitives, and utilities for accelerating the composition of RAPIDS analytics. - - +RAFT contains fundamental widely-used algorithms and primitives for data science, graph and machine learning. .. toctree:: :maxdepth: 2 :caption: Contents: - raft_intro.rst cpp_api.rst - python_api.rst - + pyraft_api.rst + pylibraft_api.rst Indices and tables diff --git a/docs/source/pylibraft_api.rst b/docs/source/pylibraft_api.rst new file mode 100644 index 0000000000..4df0d9d01c --- /dev/null +++ b/docs/source/pylibraft_api.rst @@ -0,0 +1,13 @@ +~~~~~~~~~~~~~~~~~~~~~~~ +PyLibRAFT API Reference +~~~~~~~~~~~~~~~~~~~~~~~ + +.. role:: py(code) + :language: python + :class: highlight + + +Pairwise Distances +================== + +.. autofunction:: pylibraft.distance.pairwise_distance \ No newline at end of file diff --git a/docs/source/pyraft_api.rst b/docs/source/pyraft_api.rst new file mode 100644 index 0000000000..c763c9a0f7 --- /dev/null +++ b/docs/source/pyraft_api.rst @@ -0,0 +1,20 @@ +~~~~~~~~~~~~~~~~~~~~ +PyRAFT API Reference +~~~~~~~~~~~~~~~~~~~~ + +.. role:: py(code) + :language: python + :class: highlight + + +RAFT Handle +----------- + +.. autoclass:: raft.common.handle.Handle + :members: + +Dask-based Multi-Node Multi-GPU Communicator +-------------------------------------------- + +.. autoclass:: raft.dask.common.Comms + :members: diff --git a/docs/source/python.rst b/docs/source/python.rst index 3909403ff0..0ae9f88398 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -1,11 +1,10 @@ -Python API -========== - - +RAFT Python APIs +================ .. toctree:: :maxdepth: 2 :caption: Contents: - python_api.rst + pyraft_api.rst + pylibraft_api.rst diff --git a/docs/source/python_api.rst b/docs/source/python_api.rst deleted file mode 100644 index fb8be78c7a..0000000000 --- a/docs/source/python_api.rst +++ /dev/null @@ -1,17 +0,0 @@ -~~~~~~~~~~~~~~~~~~~ -RAFT API Reference -~~~~~~~~~~~~~~~~~~~ - -.. role:: py(code) - :language: python - :class: highlight - - -Multi-Node Multi-GPU Infrastructure -=================================== - -Dask-based Communicator ------------------------ - -.. autoclass:: raft.dask.common.Comms - :members: diff --git a/python/pylibraft/pylibraft/distance/distance_type.pxd b/python/pylibraft/pylibraft/distance/distance_type.pxd index 2c01e42e53..ab865670bb 100644 --- a/python/pylibraft/pylibraft/distance/distance_type.pxd +++ b/python/pylibraft/pylibraft/distance/distance_type.pxd @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# cython: profile=False +# distutils: language = c++ +# cython: embedsignature = True +# cython: language_level = 3 cdef extern from "raft/distance/distance_type.hpp" namespace "raft::distance": diff --git a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx index 713a1d57d4..e667015ac8 100644 --- a/python/pylibraft/pylibraft/distance/pairwise_distance.pyx +++ b/python/pylibraft/pylibraft/distance/pairwise_distance.pyx @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# cython: profile=False +# distutils: language = c++ +# cython: embedsignature = True +# cython: language_level = 3 + import numpy as np from libc.stdint cimport uintptr_t @@ -74,14 +79,39 @@ def distance(X, Y, dists, metric="euclidean"): """ Compute pairwise distances between X and Y + Valid values for metric: + ["euclidean", "l2", "l1", "cityblock", "inner_product", + "chebyshev", "canberra", "lp", "hellinger", "jensenshannon", + "kl_divergence", "russellrao"] + Parameters ---------- X : CUDA array interface compliant matrix shape (m, k) Y : CUDA array interface compliant matrix shape (n, k) dists : Writable CUDA array interface matrix shape (m, n) - metric : string denoting the metric type - """ + metric : string denoting the metric type (default="euclidean") + + Examples + -------- + + .. code-block:: python + + import cupy as cp + + from pylibraft.distance import pairwise_distance + + n_samples = 5000 + n_features = 50 + + in1 = cp.random.random_sample((n_samples, n_features), + dtype=cp.float32) + in2 = cp.random.random_sample((n_samples, n_features), + dtype=cp.float32) + output = cp.empty((n_samples, n_samples), dtype=cp.float32) + + pairwise_distance(in1, in2, output, metric="euclidean") + """ # TODO: Validate inputs, shapes, etc... x_cai = X.__cuda_array_interface__