From 8276a46b55633885258b688e958854705cf09c5f Mon Sep 17 00:00:00 2001 From: aamijar Date: Tue, 3 Feb 2026 06:43:11 +0000 Subject: [PATCH 1/6] raft-deprecated-headers --- cpp/bench/prims/core/copy.cu | 4 +- cpp/include/raft.hpp | 27 -- cpp/include/raft/common/cub_wrappers.cuh | 23 - .../raft/common/device_loads_stores.cuh | 22 - cpp/include/raft/common/nvtx.hpp | 13 - cpp/include/raft/common/scatter.cuh | 22 - cpp/include/raft/common/seive.hpp | 22 - cpp/include/raft/comms/comms.hpp | 12 - cpp/include/raft/comms/comms_test.hpp | 4 +- cpp/include/raft/comms/detail/mpi_comms.hpp | 4 +- cpp/include/raft/comms/detail/std_comms.hpp | 4 +- cpp/include/raft/comms/detail/test.hpp | 4 +- cpp/include/raft/comms/mpi_comms.hpp | 4 +- cpp/include/raft/comms/std_comms.hpp | 4 +- cpp/include/raft/core/cudart_utils.hpp | 12 - cpp/include/raft/core/detail/copy.hpp | 4 +- cpp/include/raft/core/nvtx.hpp | 6 +- cpp/include/raft/lap/lap.cuh | 29 -- cpp/include/raft/lap/lap.hpp | 22 - cpp/include/raft/linalg/cublas_macros.h | 12 - cpp/include/raft/linalg/cusolver_macros.h | 12 - .../raft/linalg/detail/{gemm.hpp => gemm.cuh} | 8 +- cpp/include/raft/linalg/detail/lstsq.cuh | 5 +- cpp/include/raft/linalg/detail/rsvd.cuh | 14 +- cpp/include/raft/linalg/detail/svd.cuh | 15 +- cpp/include/raft/linalg/gemm.cuh | 113 ++++- cpp/include/raft/linalg/gemm.hpp | 119 ----- cpp/include/raft/linalg/matrix_vector.cuh | 31 +- cpp/include/raft/matrix/detail/gather.cuh | 4 +- cpp/include/raft/matrix/detail/math.cuh | 8 +- cpp/include/raft/matrix/math.cuh | 455 ------------------ cpp/include/raft/matrix/math.hpp | 12 - cpp/include/raft/matrix/matrix.cuh | 299 ------------ cpp/include/raft/matrix/matrix.hpp | 22 - cpp/include/raft/matrix/ratio.cuh | 37 +- cpp/include/raft/matrix/specializations.cuh | 13 - cpp/include/raft/matrix/sqrt.cuh | 4 +- cpp/include/raft/random/device/sample.cuh | 4 +- .../raft/sparse/detail/cusparse_macros.h | 12 - .../raft/sparse/linalg/detail/norm.cuh | 4 +- .../raft/sparse/linalg/masked_matmul.hpp | 22 - cpp/include/raft/sparse/linalg/spmm.cuh | 13 - cpp/include/raft/sparse/mst/mst.cuh | 24 - cpp/include/raft/sparse/mst/mst.hpp | 20 - cpp/include/raft/sparse/mst/mst_solver.cuh | 27 -- .../raft/sparse/solver/detail/lanczos.cuh | 4 +- cpp/include/raft/stats/specializations.cuh | 13 - cpp/include/raft/util/cuda_utils.cuh | 3 +- cpp/include/raft/util/reduction.cuh | 4 +- cpp/include/raft/util/warp_primitives.cuh | 4 +- cpp/tests/CMakeLists.txt | 3 +- cpp/tests/core/interruptible.cu | 4 +- cpp/tests/linalg/gemm_basic.cpp | 4 +- cpp/tests/linalg/gemm_layout.cu | 4 +- cpp/tests/linalg/randomized_svd.cu | 4 +- cpp/tests/matrix/gather.cu | 4 +- cpp/tests/matrix/scatter.cu | 3 +- cpp/tests/sparse/mst.cu | 18 +- cpp/tests/stats/meanvar.cu | 3 +- cpp/tests/stats/stddev.cu | 10 +- cpp/tests/test.cpp | 16 - docs/source/cpp_api/linalg_blas.rst | 2 +- 62 files changed, 261 insertions(+), 1393 deletions(-) delete mode 100644 cpp/include/raft.hpp delete mode 100644 cpp/include/raft/common/cub_wrappers.cuh delete mode 100644 cpp/include/raft/common/device_loads_stores.cuh delete mode 100644 cpp/include/raft/common/nvtx.hpp delete mode 100644 cpp/include/raft/common/scatter.cuh delete mode 100644 cpp/include/raft/common/seive.hpp delete mode 100644 cpp/include/raft/comms/comms.hpp delete mode 100644 cpp/include/raft/core/cudart_utils.hpp delete mode 100644 cpp/include/raft/lap/lap.cuh delete mode 100644 cpp/include/raft/lap/lap.hpp delete mode 100644 cpp/include/raft/linalg/cublas_macros.h delete mode 100644 cpp/include/raft/linalg/cusolver_macros.h rename cpp/include/raft/linalg/detail/{gemm.hpp => gemm.cuh} (93%) delete mode 100644 cpp/include/raft/linalg/gemm.hpp delete mode 100644 cpp/include/raft/matrix/math.cuh delete mode 100644 cpp/include/raft/matrix/math.hpp delete mode 100644 cpp/include/raft/matrix/matrix.cuh delete mode 100644 cpp/include/raft/matrix/matrix.hpp delete mode 100644 cpp/include/raft/matrix/specializations.cuh delete mode 100644 cpp/include/raft/sparse/detail/cusparse_macros.h delete mode 100644 cpp/include/raft/sparse/linalg/masked_matmul.hpp delete mode 100644 cpp/include/raft/sparse/linalg/spmm.cuh delete mode 100644 cpp/include/raft/sparse/mst/mst.cuh delete mode 100644 cpp/include/raft/sparse/mst/mst.hpp delete mode 100644 cpp/include/raft/sparse/mst/mst_solver.cuh delete mode 100644 cpp/include/raft/stats/specializations.cuh delete mode 100644 cpp/tests/test.cpp diff --git a/cpp/bench/prims/core/copy.cu b/cpp/bench/prims/core/copy.cu index ce760d396d..2b2ad53470 100644 --- a/cpp/bench/prims/core/copy.cu +++ b/cpp/bench/prims/core/copy.cu @@ -1,16 +1,16 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include #include -#include #include #include #include #include #include +#include #include diff --git a/cpp/include/raft.hpp b/cpp/include/raft.hpp deleted file mode 100644 index 18b54c0fea..0000000000 --- a/cpp/include/raft.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in a future release. - */ -#include "raft/core/device_mdarray.hpp" -#include "raft/core/device_mdspan.hpp" -#include "raft/core/device_span.hpp" -#include "raft/core/handle.hpp" - -#include - -namespace raft { - -/* Function for testing RAFT include - * - * @return message indicating RAFT has been included successfully*/ -inline std::string test_raft() -{ - std::string status = "RAFT Setup successfully"; - return status; -} - -} // namespace raft diff --git a/cpp/include/raft/common/cub_wrappers.cuh b/cpp/include/raft/common/cub_wrappers.cuh deleted file mode 100644 index 9f0957357f..0000000000 --- a/cpp/include/raft/common/cub_wrappers.cuh +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lanczos.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please note that there is no equivalent in RAFT's public API" - " so this file will eventually be removed altogether.") -#endif - -#include diff --git a/cpp/include/raft/common/device_loads_stores.cuh b/cpp/include/raft/common/device_loads_stores.cuh deleted file mode 100644 index 1ef72e1388..0000000000 --- a/cpp/include/raft/common/device_loads_stores.cuh +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lap.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/util version instead.") -#endif - -#include diff --git a/cpp/include/raft/common/nvtx.hpp b/cpp/include/raft/common/nvtx.hpp deleted file mode 100644 index 7c27f67af0..0000000000 --- a/cpp/include/raft/common/nvtx.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2021-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in release 22.08. - * Please use the include/core/nvtx.hpp instead. - */ - -#pragma once - -#include diff --git a/cpp/include/raft/common/scatter.cuh b/cpp/include/raft/common/scatter.cuh deleted file mode 100644 index 9309c06337..0000000000 --- a/cpp/include/raft/common/scatter.cuh +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lap.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/matrix version instead.") -#endif - -#include diff --git a/cpp/include/raft/common/seive.hpp b/cpp/include/raft/common/seive.hpp deleted file mode 100644 index 14b910ff6a..0000000000 --- a/cpp/include/raft/common/seive.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lap.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/util version instead.") -#endif - -#include diff --git a/cpp/include/raft/comms/comms.hpp b/cpp/include/raft/comms/comms.hpp deleted file mode 100644 index c07f0196b2..0000000000 --- a/cpp/include/raft/comms/comms.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2021-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use core/comms.hpp instead. - */ - -#pragma once - -#include diff --git a/cpp/include/raft/comms/comms_test.hpp b/cpp/include/raft/comms/comms_test.hpp index 4cecb1d6c3..e71080cb74 100644 --- a/cpp/include/raft/comms/comms_test.hpp +++ b/cpp/include/raft/comms/comms_test.hpp @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include +#include #include namespace raft { diff --git a/cpp/include/raft/comms/detail/mpi_comms.hpp b/cpp/include/raft/comms/detail/mpi_comms.hpp index 2ca9569b35..d0de62c461 100644 --- a/cpp/include/raft/comms/detail/mpi_comms.hpp +++ b/cpp/include/raft/comms/detail/mpi_comms.hpp @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include +#include #include #include #include diff --git a/cpp/include/raft/comms/detail/std_comms.hpp b/cpp/include/raft/comms/detail/std_comms.hpp index a04564af9c..40ac0cbc51 100644 --- a/cpp/include/raft/comms/detail/std_comms.hpp +++ b/cpp/include/raft/comms/detail/std_comms.hpp @@ -1,13 +1,13 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include +#include #include #include #include diff --git a/cpp/include/raft/comms/detail/test.hpp b/cpp/include/raft/comms/detail/test.hpp index 3e9ef7d50b..83306b6204 100644 --- a/cpp/include/raft/comms/detail/test.hpp +++ b/cpp/include/raft/comms/detail/test.hpp @@ -1,11 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include +#include #include #include #include diff --git a/cpp/include/raft/comms/mpi_comms.hpp b/cpp/include/raft/comms/mpi_comms.hpp index 459c6620c0..999035ec18 100644 --- a/cpp/include/raft/comms/mpi_comms.hpp +++ b/cpp/include/raft/comms/mpi_comms.hpp @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include +#include #include #include diff --git a/cpp/include/raft/comms/std_comms.hpp b/cpp/include/raft/comms/std_comms.hpp index 2420284350..e09f70f158 100644 --- a/cpp/include/raft/comms/std_comms.hpp +++ b/cpp/include/raft/comms/std_comms.hpp @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include +#include #include #include #include diff --git a/cpp/include/raft/core/cudart_utils.hpp b/cpp/include/raft/core/cudart_utils.hpp deleted file mode 100644 index b06d08091e..0000000000 --- a/cpp/include/raft/core/cudart_utils.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2019-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in release 22.06. - * Please use util/cudart_utils.hpp instead. - */ - -#pragma once -#include diff --git a/cpp/include/raft/core/detail/copy.hpp b/cpp/include/raft/core/detail/copy.hpp index 79c9caa809..8905f4c29b 100644 --- a/cpp/include/raft/core/detail/copy.hpp +++ b/cpp/include/raft/core/detail/copy.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -16,10 +16,10 @@ #include #include #ifndef RAFT_DISABLE_CUDA -#include #include #include #include +#include #ifdef __CUDACC__ #include #include diff --git a/cpp/include/raft/core/nvtx.hpp b/cpp/include/raft/core/nvtx.hpp index 805ff7d293..002668e261 100644 --- a/cpp/include/raft/core/nvtx.hpp +++ b/cpp/include/raft/core/nvtx.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,7 @@ * the whole function, while the range `epoch_scope` spans an iteration * (and appears 5 times in the timeline). * \code{.cpp} - * #include + * #include * void some_function(int k){ * // Begins a NVTX range with the message "some_function_{k}" * // The range ends when some_function() returns @@ -41,7 +41,7 @@ * * The example below defines a domain and uses it in a function. * \code{.cpp} - * #include + * #include * * struct my_app_domain { * static constexpr char const* name{"my application"}; diff --git a/cpp/include/raft/lap/lap.cuh b/cpp/include/raft/lap/lap.cuh deleted file mode 100644 index 0695e036e8..0000000000 --- a/cpp/include/raft/lap/lap.cuh +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lap.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/solver version instead.") -#endif - -#include - -using raft::solver::VertexData; -using raft::solver::Vertices; - -namespace raft::lap { -using raft::solver::LinearAssignmentProblem; -} diff --git a/cpp/include/raft/lap/lap.hpp b/cpp/include/raft/lap/lap.hpp deleted file mode 100644 index 2cfbd3b22b..0000000000 --- a/cpp/include/raft/lap/lap.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use lap.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the cuh version instead.") -#endif - -#include diff --git a/cpp/include/raft/linalg/cublas_macros.h b/cpp/include/raft/linalg/cublas_macros.h deleted file mode 100644 index f25920fb1c..0000000000 --- a/cpp/include/raft/linalg/cublas_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use core/cublas_macros.hpp instead. - */ - -#pragma once - -#include diff --git a/cpp/include/raft/linalg/cusolver_macros.h b/cpp/include/raft/linalg/cusolver_macros.h deleted file mode 100644 index 7625b408f7..0000000000 --- a/cpp/include/raft/linalg/cusolver_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use core/cusolver_macros.hpp instead. - */ - -#pragma once - -#include diff --git a/cpp/include/raft/linalg/detail/gemm.hpp b/cpp/include/raft/linalg/detail/gemm.cuh similarity index 93% rename from cpp/include/raft/linalg/detail/gemm.hpp rename to cpp/include/raft/linalg/detail/gemm.cuh index 42ebefaeb7..f3bfdf03d4 100644 --- a/cpp/include/raft/linalg/detail/gemm.hpp +++ b/cpp/include/raft/linalg/detail/gemm.cuh @@ -1,15 +1,9 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Use cublaslt_wrappers.hpp if you really need this low-level api.") -#endif - #include "cublaslt_wrappers.hpp" #include diff --git a/cpp/include/raft/linalg/detail/lstsq.cuh b/cpp/include/raft/linalg/detail/lstsq.cuh index 4a2aeb8d4c..90b1f12a9c 100644 --- a/cpp/include/raft/linalg/detail/lstsq.cuh +++ b/cpp/include/raft/linalg/detail/lstsq.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,7 +7,7 @@ #include -#include +#include #include #include #include @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/cpp/include/raft/linalg/detail/rsvd.cuh b/cpp/include/raft/linalg/detail/rsvd.cuh index cc93c57ab5..9dcdd1ed14 100644 --- a/cpp/include/raft/linalg/detail/rsvd.cuh +++ b/cpp/include/raft/linalg/detail/rsvd.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2018-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -14,9 +14,10 @@ #include #include #include -#include +#include #include #include +#include #include #include #include @@ -363,7 +364,8 @@ void rsvdFixedRank(raft::resources const& handle, handle, Uhat_dup.data(), l, l, Uhat.data(), S_vec_tmp.data(), stream, tol, max_sweeps); else raft::linalg::eigDC(handle, Uhat_dup.data(), l, l, Uhat.data(), S_vec_tmp.data(), stream); - raft::matrix::seqRoot(S_vec_tmp.data(), l, stream); + raft::matrix::sqrt(handle, + make_device_matrix_view(S_vec_tmp.data(), 1, l)); auto S_vec_view = make_device_matrix_view(S_vec, 1, k); raft::matrix::slice( @@ -398,7 +400,11 @@ void rsvdFixedRank(raft::resources const& handle, RAFT_CUDA_TRY(cudaMemsetAsync(Sinv.data(), 0, sizeof(math_t) * k * k, stream)); rmm::device_uvector UhatSinv(l * k, stream); RAFT_CUDA_TRY(cudaMemsetAsync(UhatSinv.data(), 0, sizeof(math_t) * l * k, stream)); - raft::matrix::reciprocal(S_vec_tmp.data(), l, stream); + math_t scalar = 1.0; + raft::matrix::reciprocal( + handle, + make_device_matrix_view(S_vec_tmp.data(), l, 1), + make_host_scalar_view(&scalar)); raft::matrix::set_diagonal(handle, make_device_vector_view(S_vec_tmp.data() + p, k), make_device_matrix_view(Sinv.data(), k, k)); diff --git a/cpp/include/raft/linalg/detail/svd.cuh b/cpp/include/raft/linalg/detail/svd.cuh index 19b569398d..48234460c6 100644 --- a/cpp/include/raft/linalg/detail/svd.cuh +++ b/cpp/include/raft/linalg/detail/svd.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,18 +8,19 @@ #include "cublas_wrappers.hpp" #include "cusolver_wrappers.hpp" -#include +#include #include #include #include #include #include #include +#include #include #include -#include #include #include +#include #include #include @@ -139,7 +140,8 @@ void svdEig(raft::resources const& handle, raft::matrix::row_reverse(handle, make_device_matrix_view(S, n_cols, idx_t(1))); - raft::matrix::seqRoot(S, S, alpha, n_cols, stream, true); + raft::matrix::sqrt(handle, + make_device_matrix_view(S, n_cols, idx_t(1))); if (gen_left_vec) { raft::linalg::gemm(handle, @@ -155,7 +157,10 @@ void svdEig(raft::resources const& handle, alpha, beta, stream); - raft::matrix::matrixVectorBinaryDivSkipZero(U, S, n_rows, n_cols, stream); + raft::linalg::binary_div_skip_zero( + handle, + make_device_matrix_view(U, n_rows, n_cols), + make_device_vector_view(S, n_cols)); } } diff --git a/cpp/include/raft/linalg/gemm.cuh b/cpp/include/raft/linalg/gemm.cuh index 90d2567afc..fe2ce5ff5e 100644 --- a/cpp/include/raft/linalg/gemm.cuh +++ b/cpp/include/raft/linalg/gemm.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #ifndef __GEMM_H @@ -7,14 +7,8 @@ #pragma once -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Use raft/linalg/gemm.hpp instead.") -#endif - -#include "detail/gemm.hpp" -#include "gemm.hpp" // Part of the API transferred to the non-deprecated file +#include "detail/cublaslt_wrappers.hpp" +#include "detail/gemm.cuh" #include #include @@ -188,6 +182,107 @@ void gemm(raft::resources const& handle, handle, z, x, y, _M, _N, _K, isZColMajor, isXColMajor, isYColMajor, stream, &alpha, &beta); } +/** + * @defgroup gemm Matrix-Matrix Multiplication + * @{ + */ + +/** + * @brief GEMM function designed for handling all possible + * combinations of operand layouts (raft::row_major or raft::col_major) + * with scalars alpha and beta on the host or device + * It computes the following equation: Z = alpha . X * Y + beta . Z + * If alpha is not provided, it is assumed to be 1.0 + * If beta is not provided, it is assumed to be 0.0 + * @tparam ValueType Data type of input/output matrices (float/double) + * @tparam IndexType Type of index + * @tparam LayoutPolicyX layout of X + * @tparam LayoutPolicyY layout of Y + * @tparam LayoutPolicyZ layout of Z + * @param[in] res raft handle + * @param[in] x input raft::device_matrix_view of size M rows x K columns + * @param[in] y input raft::device_matrix_view of size K rows x N columns + * @param[out] z output raft::device_matrix_view of size M rows x N columns + * @param[in] alpha optional raft::host_scalar_view or raft::device_scalar_view, default 1.0 + * @param[in] beta optional raft::host_scalar_view or raft::device_scalar_view, default 0.0 + */ +template , + typename = std::enable_if_t>, + std::is_same>>>> +void gemm(raft::resources const& res, + raft::device_matrix_view x, + raft::device_matrix_view y, + raft::device_matrix_view z, + std::optional alpha = std::nullopt, + std::optional beta = std::nullopt) +{ + RAFT_EXPECTS(raft::is_row_or_column_major(x), "X is not contiguous"); + RAFT_EXPECTS(raft::is_row_or_column_major(y), "Y is not contiguous"); + RAFT_EXPECTS(raft::is_row_or_column_major(z), "Z is not contiguous"); + + RAFT_EXPECTS(x.extent(0) == z.extent(0), "Number of rows of X and Z should be equal"); + RAFT_EXPECTS(y.extent(1) == z.extent(1), "Number of columns of Y and Z should be equal"); + RAFT_EXPECTS(x.extent(1) == y.extent(0), "Number of columns of X and rows of Y should be equal"); + + constexpr auto kXColMajor = std::is_same_v; + constexpr auto kYColMajor = std::is_same_v; + constexpr auto kZColMajor = std::is_same_v; + + // NB: the function type constraints only ever allow two view types, so using std::is_same_v is + // fine + constexpr auto kDeviceMode = + std::is_same_v>; + + // NB: we rely on the implementation of detail::matmul to set defaults + ValueType* alpha_ptr = nullptr; + ValueType* beta_ptr = nullptr; + if (alpha.has_value()) { alpha_ptr = alpha.value().data_handle(); } + if (beta.has_value()) { beta_ptr = beta.value().data_handle(); } + + if constexpr (kZColMajor) { + return detail::matmul( + res, + !kXColMajor, + !kYColMajor, + static_cast(z.extent(0)), + static_cast(z.extent(1)), + static_cast(x.extent(1)), + alpha_ptr, + x.data_handle(), + static_cast(x.extent(kXColMajor ? 0 : 1)), + y.data_handle(), + static_cast(y.extent(kYColMajor ? 0 : 1)), + beta_ptr, + z.data_handle(), + static_cast(z.extent(0))); + } else { + return detail::matmul( + res, + kYColMajor, + kXColMajor, + static_cast(z.extent(1)), + static_cast(z.extent(0)), + static_cast(x.extent(1)), + alpha_ptr, + y.data_handle(), + static_cast(y.extent(kYColMajor ? 0 : 1)), + x.data_handle(), + static_cast(x.extent(kXColMajor ? 0 : 1)), + beta_ptr, + z.data_handle(), + static_cast(z.extent(1))); + } +} + +/** @} */ // end of gemm + } // namespace raft::linalg #endif diff --git a/cpp/include/raft/linalg/gemm.hpp b/cpp/include/raft/linalg/gemm.hpp deleted file mode 100644 index f3d25b8d3b..0000000000 --- a/cpp/include/raft/linalg/gemm.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include "detail/cublaslt_wrappers.hpp" - -#include -#include -#include -#include -#include -#include - -namespace raft::linalg { - -/** - * @defgroup gemm Matrix-Matrix Multiplication - * @{ - */ - -/** - * @brief GEMM function designed for handling all possible - * combinations of operand layouts (raft::row_major or raft::col_major) - * with scalars alpha and beta on the host or device - * It computes the following equation: Z = alpha . X * Y + beta . Z - * If alpha is not provided, it is assumed to be 1.0 - * If beta is not provided, it is assumed to be 0.0 - * @tparam ValueType Data type of input/output matrices (float/double) - * @tparam IndexType Type of index - * @tparam LayoutPolicyX layout of X - * @tparam LayoutPolicyY layout of Y - * @tparam LayoutPolicyZ layout of Z - * @param[in] res raft handle - * @param[in] x input raft::device_matrix_view of size M rows x K columns - * @param[in] y input raft::device_matrix_view of size K rows x N columns - * @param[out] z output raft::device_matrix_view of size M rows x N columns - * @param[in] alpha optional raft::host_scalar_view or raft::device_scalar_view, default 1.0 - * @param[in] beta optional raft::host_scalar_view or raft::device_scalar_view, default 0.0 - */ -template , - typename = std::enable_if_t>, - std::is_same>>>> -void gemm(raft::resources const& res, - raft::device_matrix_view x, - raft::device_matrix_view y, - raft::device_matrix_view z, - std::optional alpha = std::nullopt, - std::optional beta = std::nullopt) -{ - RAFT_EXPECTS(raft::is_row_or_column_major(x), "X is not contiguous"); - RAFT_EXPECTS(raft::is_row_or_column_major(y), "Y is not contiguous"); - RAFT_EXPECTS(raft::is_row_or_column_major(z), "Z is not contiguous"); - - RAFT_EXPECTS(x.extent(0) == z.extent(0), "Number of rows of X and Z should be equal"); - RAFT_EXPECTS(y.extent(1) == z.extent(1), "Number of columns of Y and Z should be equal"); - RAFT_EXPECTS(x.extent(1) == y.extent(0), "Number of columns of X and rows of Y should be equal"); - - constexpr auto kXColMajor = std::is_same_v; - constexpr auto kYColMajor = std::is_same_v; - constexpr auto kZColMajor = std::is_same_v; - - // NB: the function type constraints only ever allow two view types, so using std::is_same_v is - // fine - constexpr auto kDeviceMode = - std::is_same_v>; - - // NB: we rely on the implementation of detail::matmul to set defaults - ValueType* alpha_ptr = nullptr; - ValueType* beta_ptr = nullptr; - if (alpha.has_value()) { alpha_ptr = alpha.value().data_handle(); } - if (beta.has_value()) { beta_ptr = beta.value().data_handle(); } - - if constexpr (kZColMajor) { - return detail::matmul( - res, - !kXColMajor, - !kYColMajor, - static_cast(z.extent(0)), - static_cast(z.extent(1)), - static_cast(x.extent(1)), - alpha_ptr, - x.data_handle(), - static_cast(x.extent(kXColMajor ? 0 : 1)), - y.data_handle(), - static_cast(y.extent(kYColMajor ? 0 : 1)), - beta_ptr, - z.data_handle(), - static_cast(z.extent(0))); - } else { - return detail::matmul( - res, - kYColMajor, - kXColMajor, - static_cast(z.extent(1)), - static_cast(z.extent(0)), - static_cast(x.extent(1)), - alpha_ptr, - y.data_handle(), - static_cast(y.extent(kYColMajor ? 0 : 1)), - x.data_handle(), - static_cast(x.extent(kXColMajor ? 0 : 1)), - beta_ptr, - z.data_handle(), - static_cast(z.extent(1))); - } -} - -/** @} */ // end of gemm - -} // namespace raft::linalg diff --git a/cpp/include/raft/linalg/matrix_vector.cuh b/cpp/include/raft/linalg/matrix_vector.cuh index 6fca474f3b..5edec9212e 100644 --- a/cpp/include/raft/linalg/matrix_vector.cuh +++ b/cpp/include/raft/linalg/matrix_vector.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,35 @@ namespace raft::linalg { * @{ */ +/** + * @brief multiply each row or column of matrix with vector + * @param[in] handle: raft handle for managing library resources + * @param[inout] data: input matrix, results are in-place + * @param[in] vec: input vector + */ +template +void binary_mult(raft::resources const& handle, + raft::device_matrix_view data, + raft::device_vector_view vec) +{ + constexpr auto row_major = std::is_same_v; + constexpr auto bcast_along_rows = apply == Apply::ALONG_ROWS; + + idx_t vec_size = bcast_along_rows ? data.extent(1) : data.extent(0); + + RAFT_EXPECTS( + vec.extent(0) == vec_size, + "If `bcast_along_rows==true`, vector size must equal number of columns in the matrix." + "If `bcast_along_rows==false`, vector size must equal number of rows in the matrix."); + + matrix::detail::matrixVectorBinaryMult( + data.data_handle(), + vec.data_handle(), + data.extent(0), + data.extent(1), + resource::get_cuda_stream(handle)); +} + /** * @brief multiply each row or column of matrix with vector, skipping zeros in vector * @param [in] handle: raft handle for managing library resources diff --git a/cpp/include/raft/matrix/detail/gather.cuh b/cpp/include/raft/matrix/detail/gather.cuh index 26128074e1..20bbc4271d 100644 --- a/cpp/include/raft/matrix/detail/gather.cuh +++ b/cpp/include/raft/matrix/detail/gather.cuh @@ -1,15 +1,15 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include #include #include +#include #include #include #include diff --git a/cpp/include/raft/matrix/detail/math.cuh b/cpp/include/raft/matrix/detail/math.cuh index 9067ba8da9..298a6ac506 100644 --- a/cpp/include/raft/matrix/detail/math.cuh +++ b/cpp/include/raft/matrix/detail/math.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -58,7 +58,7 @@ void power(math_t* in, math_t* out, int len, cudaStream_t stream) } template -void seqRoot(math_t* in, +void seqRoot(const math_t* in, math_t* out, math_t scalar, IdxType len, @@ -94,7 +94,7 @@ void seqRoot( } template -void seqRoot(math_t* in, math_t* out, IdxType len, cudaStream_t stream) +void seqRoot(const math_t* in, math_t* out, IdxType len, cudaStream_t stream) { math_t scalar = 1.0; seqRoot(in, out, scalar, len, stream); @@ -184,7 +184,7 @@ void setValue(math_t* out, const math_t* in, math_t scalar, int len, cudaStream_ template void ratio( - raft::resources const& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) + raft::resources const& handle, const math_t* src, math_t* dest, IdxType len, cudaStream_t stream) { auto d_src = src; auto d_dest = dest; diff --git a/cpp/include/raft/matrix/math.cuh b/cpp/include/raft/matrix/math.cuh deleted file mode 100644 index d5eb756136..0000000000 --- a/cpp/include/raft/matrix/math.cuh +++ /dev/null @@ -1,455 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in a future release. - * Please use versions in individual header files instead. - */ - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use versions in individual header files instead.") -#endif - -#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( - raft::resources const& handle, math_t* src, math_t* dest, IdxType len, cudaStream_t stream) -{ - detail::ratio(handle, src, dest, len, stream); -} - -/** @} */ - -/** - * @brief Argmin: find the row idx with minimum value for each column - * @param in: input matrix (column-major) - * @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 argmin(const math_t* in, idx_t n_rows, idx_t n_cols, out_t* out, cudaStream_t stream) -{ - detail::argmin(in, n_rows, n_cols, out, stream); -} - -/** - * @brief Argmax: find the row idx with maximum value for each column - * @param in: input matrix (column-major) - * @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, idx_t n_rows, idx_t n_cols, out_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, cudaStream_t stream) -{ - detail::matrixVectorBinaryMult( - data, vec, n_row, n_col, 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, cudaStream_t stream) -{ - detail::matrixVectorBinaryMultSkipZero( - data, vec, n_row, n_col, 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, cudaStream_t stream) -{ - detail::matrixVectorBinaryDiv( - data, vec, n_row, n_col, 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, - cudaStream_t stream, - bool return_zero = false) -{ - detail::matrixVectorBinaryDivSkipZero( - data, vec, n_row, n_col, 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, cudaStream_t stream) -{ - detail::matrixVectorBinaryAdd( - data, vec, n_row, n_col, 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, cudaStream_t stream) -{ - detail::matrixVectorBinarySub( - data, vec, n_row, n_col, stream); -} - -}; // end namespace matrix -}; // end namespace raft - -#endif diff --git a/cpp/include/raft/matrix/math.hpp b/cpp/include/raft/matrix/math.hpp deleted file mode 100644 index 792cf29013..0000000000 --- a/cpp/include/raft/matrix/math.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2018-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -#pragma once - -#include "math.cuh" diff --git a/cpp/include/raft/matrix/matrix.cuh b/cpp/include/raft/matrix/matrix.cuh deleted file mode 100644 index 7a0192a9e4..0000000000 --- a/cpp/include/raft/matrix/matrix.cuh +++ /dev/null @@ -1,299 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in a future release. - * Please use versions in individual header files instead. - */ - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use versions in individual header files instead.") -#endif - -#ifndef __MATRIX_H -#define __MATRIX_H - -#pragma once - -#include "detail/linewise_op.cuh" -#include "detail/matrix.cuh" - -#include -#include -#include - -namespace raft { -namespace matrix { - -using namespace std; - -/** - * @brief Copy selected rows of the input matrix into contiguous space. - * - * On exit out[i + k*n_rows] = in[indices[i] + k*n_rows], - * where i = 0..n_rows_indices-1, and k = 0..n_cols-1. - * - * @param in input matrix - * @param n_rows number of rows of output matrix - * @param n_cols number of columns of output matrix - * @param out output matrix - * @param indices of the rows to be copied - * @param n_rows_indices number of rows to copy - * @param stream cuda stream - * @param rowMajor whether the matrix has row major layout - */ -template -void copyRows(const m_t* in, - idx_t n_rows, - idx_t n_cols, - m_t* out, - const idx_array_t* indices, - idx_t n_rows_indices, - cudaStream_t stream, - bool rowMajor = false) -{ - detail::copyRows(in, n_rows, n_cols, out, indices, n_rows_indices, stream, rowMajor); -} - -/** - * @brief copy matrix operation for column major matrices. - * @param in: input matrix - * @param out: output matrix - * @param n_rows: number of rows of output matrix - * @param n_cols: number of columns of output matrix - * @param stream: cuda stream - */ -template -void copy(const m_t* in, m_t* out, idx_t n_rows, idx_t n_cols, cudaStream_t stream) -{ - raft::copy_async(out, in, n_rows * n_cols, stream); -} - -/** - * @brief copy matrix operation for column major matrices. - * @param[in] handle: raft handle - * @param[in] in: input matrix - * @param[out] out: output matrix - */ -template -void copy(raft::resources const& handle, - raft::device_matrix_view in, - raft::device_matrix_view out) -{ - RAFT_EXPECTS(in.extent(0) == out.extent(0) && in.extent(1) == out.extent(1), - "Input and output matrix shapes must match."); - - raft::copy_async(out.data_handle(), - in.data_handle(), - in.extent(0) * out.extent(1), - resource::get_cuda_stream(handle)); -} - -/** - * @brief copy matrix operation for column major matrices. First n_rows and - * n_cols of input matrix "in" is copied to "out" matrix. - * @param in: input matrix - * @param in_n_rows: number of rows of input matrix - * @param out: output matrix - * @param out_n_rows: number of rows of output matrix - * @param out_n_cols: number of columns of output matrix - * @param stream: cuda stream - */ -template -void truncZeroOrigin( - m_t* in, idx_t in_n_rows, m_t* out, idx_t out_n_rows, idx_t out_n_cols, cudaStream_t stream) -{ - detail::truncZeroOrigin(in, in_n_rows, out, out_n_rows, out_n_cols, stream); -} - -/** - * @brief Columns of a column major matrix is reversed (i.e. first column and - * last column are swapped) - * @param inout: input and output matrix - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param stream: cuda stream - */ -template -void colReverse(m_t* inout, idx_t n_rows, idx_t n_cols, cudaStream_t stream) -{ - detail::colReverse(inout, n_rows, n_cols, stream); -} - -/** - * @brief Rows of a column major matrix is reversed (i.e. first row and last - * row are swapped) - * @param inout: input and output matrix - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param stream: cuda stream - */ -template -void rowReverse(m_t* inout, idx_t n_rows, idx_t n_cols, cudaStream_t stream) -{ - detail::rowReverse(inout, n_rows, n_cols, stream); -} - -/** - * @brief Prints the data stored in GPU memory - * @param in: input matrix - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param h_separator: horizontal separator character - * @param v_separator: vertical separator character - * @param stream: cuda stream - */ -template -void print(const m_t* in, - idx_t n_rows, - idx_t n_cols, - char h_separator = ' ', - char v_separator = '\n', - cudaStream_t stream = rmm::cuda_stream_default) -{ - detail::print(in, n_rows, n_cols, h_separator, v_separator, stream); -} - -/** - * @brief Prints the data stored in CPU memory - * @param in: input matrix - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - */ -template -void printHost(const m_t* in, idx_t n_rows, idx_t n_cols) -{ - detail::printHost(in, n_rows, n_cols); -} - -/** - * @brief Slice a matrix (in-place) - * @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 matrix - * @param x1, y1: coordinate of the top-left point of the wanted area (0-based) - * @param x2, y2: coordinate of the bottom-right point of the wanted area - * (1-based) - * example: Slice the 2nd and 3rd columns of a 4x3 matrix: slice_matrix(M_d, 4, - * 3, 0, 1, 4, 3); - * @param stream: cuda stream - */ -template -void sliceMatrix(m_t* in, - idx_t n_rows, - idx_t n_cols, - m_t* out, - idx_t x1, - idx_t y1, - idx_t x2, - idx_t y2, - cudaStream_t stream) -{ - detail::sliceMatrix(in, n_rows, n_cols, out, x1, y1, x2, y2, false, stream); -} - -/** - * @brief Copy the upper triangular part of a matrix to another - * @param src: input matrix with a size of n_rows x n_cols - * @param dst: output matrix with a size of kxk, k = min(n_rows, n_cols) - * @param n_rows: number of rows of input matrix - * @param n_cols: number of columns of input matrix - * @param stream: cuda stream - */ -template -void copyUpperTriangular(m_t* src, m_t* dst, idx_t n_rows, idx_t n_cols, cudaStream_t stream) -{ - detail::copyUpperTriangular(src, dst, n_rows, n_cols, stream); -} - -/** - * @brief Initialize a diagonal col-major matrix with a vector - * @param vec: vector of length k = min(n_rows, n_cols) - * @param matrix: matrix of size n_rows x n_cols (col-major) - * @param n_rows: number of rows of the matrix - * @param n_cols: number of columns of the matrix - * @param stream: cuda stream - */ -template -void initializeDiagonalMatrix( - m_t* vec, m_t* matrix, idx_t n_rows, idx_t n_cols, cudaStream_t stream) -{ - detail::initializeDiagonalMatrix(vec, matrix, n_rows, n_cols, false, stream); -} - -/** - * @brief Get a square matrix with elements on diagonal reversed (in-place) - * @param in: square input matrix with size len x len - * @param len: size of one side of the matrix - * @param stream: cuda stream - */ -template -void getDiagonalInverseMatrix(m_t* in, idx_t len, cudaStream_t stream) -{ - detail::getDiagonalInverseMatrix(in, len, stream); -} - -/** - * @brief Get the L2/F-norm of a matrix/vector - * @param handle - * @param in: input matrix/vector with totally size elements - * @param size: size of the matrix/vector - * @param stream: cuda stream - */ -template -m_t getL2Norm(raft::resources const& handle, m_t* in, idx_t size, cudaStream_t stream) -{ - return detail::getL2Norm(handle, in, size, stream); -} - -/** - * Run a function over matrix lines (rows or columns) with a variable number - * row-vectors or column-vectors. - * The term `line` here signifies that the lines can be either columns or rows, - * depending on the matrix layout. - * What matters is if the vectors are applied along lines (indices of vectors correspond to - * indices within lines), or across lines (indices of vectors correspond to line numbers). - * - * @tparam alongLines whether vectors are indices along or across lines. - * @param [out] out result of the operation; can be same as `in`; should be aligned the same - * as `in` to allow faster vectorized memory transfers. - * @param [in] in input matrix consisting of `nLines` lines, each `lineLen`-long. - * @param [in] lineLen length of matrix line in elements (`=nCols` in row-major or `=nRows` in - * col-major) - * @param [in] nLines number of matrix lines (`=nRows` in row-major or `=nCols` in col-major) - * @param [in] op the operation applied on each line: - * for i in [0..lineLen) and j in [0..nLines): - * out[i, j] = op(in[i, j], vec1[i], vec2[i], ... veck[i]) if alongLines = true - * out[i, j] = op(in[i, j], vec1[j], vec2[j], ... veck[j]) if alongLines = false - * where matrix indexing is row-major ([i, j] = [i + lineLen * j]). - * @param [in] stream a cuda stream for the kernels - * @param [in] vecs zero or more vectors to be passed as arguments, - * size of each vector is `alongLines ? lineLen : nLines`. - */ -template -void linewiseOp(m_t* out, - const m_t* in, - const idx_t lineLen, - const idx_t nLines, - Lambda op, - cudaStream_t stream, - const Vecs*... vecs) -{ - common::nvtx::range fun_scope("linewiseOp-%c-%zu (%zu, %zu)", - alongLines ? 'l' : 'x', - sizeof...(Vecs), - size_t(lineLen), - size_t(nLines)); - detail::MatrixLinewiseOp<16, 256>::run( - out, in, lineLen, nLines, op, stream, vecs...); -} - -}; // end namespace matrix -}; // end namespace raft - -#endif diff --git a/cpp/include/raft/matrix/matrix.hpp b/cpp/include/raft/matrix/matrix.hpp deleted file mode 100644 index ddabdfda9d..0000000000 --- a/cpp/include/raft/matrix/matrix.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use matrix.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the cuh version instead.") -#endif - -#include "matrix.cuh" diff --git a/cpp/include/raft/matrix/ratio.cuh b/cpp/include/raft/matrix/ratio.cuh index 121fe2f725..ebeddaa5ae 100644 --- a/cpp/include/raft/matrix/ratio.cuh +++ b/cpp/include/raft/matrix/ratio.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -53,6 +53,41 @@ void ratio(raft::resources const& handle, raft::device_matrix_view +void ratio(raft::resources const& handle, + raft::device_vector_view src, + raft::device_vector_view dest) +{ + RAFT_EXPECTS(src.size() == dest.size(), "Input and output vectors must be the same size."); + detail::ratio( + handle, src.data_handle(), dest.data_handle(), src.size(), resource::get_cuda_stream(handle)); +} + +/** + * @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 idx_t integer type used for indexing + * @param[in] handle + * @param[inout] inout: input vector + */ +template +void ratio(raft::resources const& handle, raft::device_vector_view inout) +{ + detail::ratio(handle, + inout.data_handle(), + inout.data_handle(), + inout.size(), + resource::get_cuda_stream(handle)); +} + /** @} */ // end group matrix_ratio } // namespace raft::matrix diff --git a/cpp/include/raft/matrix/specializations.cuh b/cpp/include/raft/matrix/specializations.cuh deleted file mode 100644 index fabf5e02fb..0000000000 --- a/cpp/include/raft/matrix/specializations.cuh +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message( \ - __FILE__ \ - " is deprecated and will be removed." \ - " Including specializations is not necessary any more." \ - " For more information, see: https://docs.rapids.ai/api/raft/nightly/using_libraft.html") -#endif diff --git a/cpp/include/raft/matrix/sqrt.cuh b/cpp/include/raft/matrix/sqrt.cuh index f96ef40b31..8f202c8422 100644 --- a/cpp/include/raft/matrix/sqrt.cuh +++ b/cpp/include/raft/matrix/sqrt.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,7 +8,7 @@ #include #include #include -#include +#include namespace raft::matrix { diff --git a/cpp/include/raft/random/device/sample.cuh b/cpp/include/raft/random/device/sample.cuh index 193671a80d..4682d8771e 100644 --- a/cpp/include/raft/random/device/sample.cuh +++ b/cpp/include/raft/random/device/sample.cuh @@ -1,13 +1,13 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include +#include #include #include diff --git a/cpp/include/raft/sparse/detail/cusparse_macros.h b/cpp/include/raft/sparse/detail/cusparse_macros.h deleted file mode 100644 index 0b7195dc94..0000000000 --- a/cpp/include/raft/sparse/detail/cusparse_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2019-2022, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ - -#pragma once - -#include diff --git a/cpp/include/raft/sparse/linalg/detail/norm.cuh b/cpp/include/raft/sparse/linalg/detail/norm.cuh index f3bb2735bf..0173e1ad82 100644 --- a/cpp/include/raft/sparse/linalg/detail/norm.cuh +++ b/cpp/include/raft/sparse/linalg/detail/norm.cuh @@ -1,11 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include +#include #include #include #include diff --git a/cpp/include/raft/sparse/linalg/masked_matmul.hpp b/cpp/include/raft/sparse/linalg/masked_matmul.hpp deleted file mode 100644 index 8d7f3014b7..0000000000 --- a/cpp/include/raft/sparse/linalg/masked_matmul.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -/** - * This file is deprecated and will be removed in future release. - * Please use the cuh version instead. - */ - -/** - * DISCLAIMER: this file is deprecated: use masked_matmul.cuh instead - */ - -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the cuh version instead.") -#endif - -#include diff --git a/cpp/include/raft/sparse/linalg/spmm.cuh b/cpp/include/raft/sparse/linalg/spmm.cuh deleted file mode 100644 index 395ec681c1..0000000000 --- a/cpp/include/raft/sparse/linalg/spmm.cuh +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the spmm.hpp at the same path instead.") -#endif - -#include diff --git a/cpp/include/raft/sparse/mst/mst.cuh b/cpp/include/raft/sparse/mst/mst.cuh deleted file mode 100644 index c670911b24..0000000000 --- a/cpp/include/raft/sparse/mst/mst.cuh +++ /dev/null @@ -1,24 +0,0 @@ - -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/sparse/solver version instead.") -#endif - -#include -#include - -namespace raft::mst { -using raft::sparse::solver::mst; -} diff --git a/cpp/include/raft/sparse/mst/mst.hpp b/cpp/include/raft/sparse/mst/mst.hpp deleted file mode 100644 index 5e9bc7b3a8..0000000000 --- a/cpp/include/raft/sparse/mst/mst.hpp +++ /dev/null @@ -1,20 +0,0 @@ - -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/sparse/solver version instead.") -#endif - -#include -#include diff --git a/cpp/include/raft/sparse/mst/mst_solver.cuh b/cpp/include/raft/sparse/mst/mst_solver.cuh deleted file mode 100644 index f2a080332d..0000000000 --- a/cpp/include/raft/sparse/mst/mst_solver.cuh +++ /dev/null @@ -1,27 +0,0 @@ - -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * This file is deprecated and will be removed in release 22.06. - * Please use the cuh version instead. - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message(__FILE__ \ - " is deprecated and will be removed in a future release." \ - " Please use the raft/sparse/solver version instead.") -#endif - -#include - -namespace raft { -using raft::sparse::solver::Graph_COO; -} - -namespace raft::mst { -using raft::sparse::solver::MST_solver; -} diff --git a/cpp/include/raft/sparse/solver/detail/lanczos.cuh b/cpp/include/raft/sparse/solver/detail/lanczos.cuh index b0e080356f..c4780d5627 100644 --- a/cpp/include/raft/sparse/solver/detail/lanczos.cuh +++ b/cpp/include/raft/sparse/solver/detail/lanczos.cuh @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ #include #include #include -#include +// include #include #include #include diff --git a/cpp/include/raft/stats/specializations.cuh b/cpp/include/raft/stats/specializations.cuh deleted file mode 100644 index 04af2baf22..0000000000 --- a/cpp/include/raft/stats/specializations.cuh +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#ifndef RAFT_HIDE_DEPRECATION_WARNINGS -#pragma message( \ - __FILE__ \ - " is deprecated and will be removed." \ - " Including specializations is not necessary any more." \ - " For more information, see: https://docs.rapids.ai/api/raft/nightly/using_libraft.html") -#endif diff --git a/cpp/include/raft/util/cuda_utils.cuh b/cpp/include/raft/util/cuda_utils.cuh index 34785704bd..2ec784e242 100644 --- a/cpp/include/raft/util/cuda_utils.cuh +++ b/cpp/include/raft/util/cuda_utils.cuh @@ -1,11 +1,10 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include diff --git a/cpp/include/raft/util/reduction.cuh b/cpp/include/raft/util/reduction.cuh index c2737dc023..6b7ef0825d 100644 --- a/cpp/include/raft/util/reduction.cuh +++ b/cpp/include/raft/util/reduction.cuh @@ -1,13 +1,13 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include +#include #include #include diff --git a/cpp/include/raft/util/warp_primitives.cuh b/cpp/include/raft/util/warp_primitives.cuh index 0f050fa265..d9b31aad13 100644 --- a/cpp/include/raft/util/warp_primitives.cuh +++ b/cpp/include/raft/util/warp_primitives.cuh @@ -1,13 +1,13 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include #include #include +#include #include diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index dff227dd8b..548b0da497 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -1,6 +1,6 @@ # ============================================================================= # cmake-format: off -# SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 # cmake-format: on # ============================================================================= @@ -112,7 +112,6 @@ if(BUILD_TESTS) core/span.cu core/stream_view.cpp core/temporary_device_buffer.cu - test.cpp LIB EXPLICIT_INSTANTIATE_ONLY ) diff --git a/cpp/tests/core/interruptible.cu b/cpp/tests/core/interruptible.cu index a991d26cc1..89a6df4e29 100644 --- a/cpp/tests/core/interruptible.cu +++ b/cpp/tests/core/interruptible.cu @@ -1,11 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ -#include #include #include +#include #include diff --git a/cpp/tests/linalg/gemm_basic.cpp b/cpp/tests/linalg/gemm_basic.cpp index 7cffd7e233..6ab669c1d0 100644 --- a/cpp/tests/linalg/gemm_basic.cpp +++ b/cpp/tests/linalg/gemm_basic.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include diff --git a/cpp/tests/linalg/gemm_layout.cu b/cpp/tests/linalg/gemm_layout.cu index b0d59a9e69..638b5921e3 100644 --- a/cpp/tests/linalg/gemm_layout.cu +++ b/cpp/tests/linalg/gemm_layout.cu @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include "../test_utils.cuh" #include -#include +#include #include #include diff --git a/cpp/tests/linalg/randomized_svd.cu b/cpp/tests/linalg/randomized_svd.cu index 00e6a509c7..abd49ec9f9 100644 --- a/cpp/tests/linalg/randomized_svd.cu +++ b/cpp/tests/linalg/randomized_svd.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,7 @@ #include #include #include -#include +// #include #include #include diff --git a/cpp/tests/matrix/gather.cu b/cpp/tests/matrix/gather.cu index a9e8bf69d1..603676ac5d 100644 --- a/cpp/tests/matrix/gather.cu +++ b/cpp/tests/matrix/gather.cu @@ -1,17 +1,17 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include "../test_utils.cuh" -#include #include #include #include #include #include #include +#include #include #include diff --git a/cpp/tests/matrix/scatter.cu b/cpp/tests/matrix/scatter.cu index cfefacf1c0..b8c7c9398a 100644 --- a/cpp/tests/matrix/scatter.cu +++ b/cpp/tests/matrix/scatter.cu @@ -1,11 +1,10 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include "../test_utils.cuh" -#include #include #include #include diff --git a/cpp/tests/sparse/mst.cu b/cpp/tests/sparse/mst.cu index ad92f3ce3d..9bf1c40a3b 100644 --- a/cpp/tests/sparse/mst.cu +++ b/cpp/tests/sparse/mst.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -111,8 +111,8 @@ weight_t prims(CSRHost& csr_h) template class MSTTest : public ::testing::TestWithParam> { protected: - std::pair, - raft::Graph_COO> + std::pair, + raft::sparse::solver::Graph_COO> mst_gpu() { edge_t* offsets = static_cast(csr_d.offsets.data()); @@ -140,7 +140,7 @@ class MSTTest : public ::testing::TestWithParam symmetric_solver( + raft::sparse::solver::MST_solver symmetric_solver( handle, offsets, indices, @@ -154,7 +154,7 @@ class MSTTest : public ::testing::TestWithParam non_symmetric_solver( + raft::sparse::solver::MST_solver non_symmetric_solver( handle, offsets, indices, @@ -173,7 +173,7 @@ class MSTTest : public ::testing::TestWithParam intermediate_solver( + raft::sparse::solver::MST_solver intermediate_solver( handle, offsets, indices, @@ -187,7 +187,7 @@ class MSTTest : public ::testing::TestWithParam symmetric_solver( + raft::sparse::solver::MST_solver symmetric_solver( handle, offsets, indices, @@ -221,7 +221,7 @@ class MSTTest : public ::testing::TestWithParam non_symmetric_solver( + raft::sparse::solver::MST_solver non_symmetric_solver( handle, offsets, indices, diff --git a/cpp/tests/stats/meanvar.cu b/cpp/tests/stats/meanvar.cu index 086489dbc0..92f133e9c2 100644 --- a/cpp/tests/stats/meanvar.cu +++ b/cpp/tests/stats/meanvar.cu @@ -1,12 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include "../test_utils.cuh" #include -#include #include #include #include diff --git a/cpp/tests/stats/stddev.cu b/cpp/tests/stats/stddev.cu index 47d439877f..fcdb4baca2 100644 --- a/cpp/tests/stats/stddev.cu +++ b/cpp/tests/stats/stddev.cu @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2018-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include "../test_utils.cuh" #include -#include +#include #include #include #include @@ -101,7 +101,11 @@ class StdDevTest : public ::testing::TestWithParam> { raft::make_device_vector_view(vars_act.data(), cols), params.sample); } - raft::matrix::seqRoot(vars_act.data(), T(1), cols, stream); + T scalar = T(1); + raft::matrix::weighted_sqrt( + handle, + make_device_matrix_view(vars_act.data(), 1, cols), + make_host_scalar_view(&scalar)); } protected: diff --git a/cpp/tests/test.cpp b/cpp/tests/test.cpp deleted file mode 100644 index b17a887561..0000000000 --- a/cpp/tests/test.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include - -#include - -namespace raft { - -TEST(Raft, print) { std::cout << test_raft() << std::endl; } - -} // namespace raft diff --git a/docs/source/cpp_api/linalg_blas.rst b/docs/source/cpp_api/linalg_blas.rst index 0251f8fa48..15fa8612c7 100644 --- a/docs/source/cpp_api/linalg_blas.rst +++ b/docs/source/cpp_api/linalg_blas.rst @@ -32,7 +32,7 @@ namespace *raft::linalg* gemm ---- -``#include `` +``#include `` namespace *raft::linalg* From 7480a3a3af419fc4f8fc35b35d66a9e00529de34 Mon Sep 17 00:00:00 2001 From: aamijar Date: Tue, 3 Feb 2026 07:19:46 +0000 Subject: [PATCH 2/6] remove raft.hpp --- cpp/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 59ff9ca88c..2b8c6934f9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -450,13 +450,6 @@ install( DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -# Temporary install of raft.hpp while the file is removed -install( - FILES include/raft.hpp - COMPONENT raft - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/raft -) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/include/raft/version_config.hpp COMPONENT raft From dde196c3357efea8e491d34b69bb5278fe6f4e76 Mon Sep 17 00:00:00 2001 From: aamijar Date: Tue, 3 Feb 2026 07:43:28 +0000 Subject: [PATCH 3/6] include comms.hpp --- cpp/include/raft/comms/detail/util.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/include/raft/comms/detail/util.hpp b/cpp/include/raft/comms/detail/util.hpp index e895c42842..3f68c635c6 100644 --- a/cpp/include/raft/comms/detail/util.hpp +++ b/cpp/include/raft/comms/detail/util.hpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include +#include #include #include From f8d851ead0bdeac14c3f744821f2f58eb1454edd Mon Sep 17 00:00:00 2001 From: aamijar Date: Fri, 13 Feb 2026 17:00:31 +0000 Subject: [PATCH 4/6] removed commented include --- cpp/include/raft/sparse/solver/detail/lanczos.cuh | 1 - cpp/tests/linalg/randomized_svd.cu | 1 - 2 files changed, 2 deletions(-) diff --git a/cpp/include/raft/sparse/solver/detail/lanczos.cuh b/cpp/include/raft/sparse/solver/detail/lanczos.cuh index 8e538a3b8b..c0acf7a975 100644 --- a/cpp/include/raft/sparse/solver/detail/lanczos.cuh +++ b/cpp/include/raft/sparse/solver/detail/lanczos.cuh @@ -41,7 +41,6 @@ #include #include #include -// include #include #include #include diff --git a/cpp/tests/linalg/randomized_svd.cu b/cpp/tests/linalg/randomized_svd.cu index abd49ec9f9..956fa4c1a6 100644 --- a/cpp/tests/linalg/randomized_svd.cu +++ b/cpp/tests/linalg/randomized_svd.cu @@ -9,7 +9,6 @@ #include #include #include -// #include #include #include From 43bda46787027812b7c6d1bc2ea6d28d4b5d0c16 Mon Sep 17 00:00:00 2001 From: aamijar Date: Fri, 13 Feb 2026 23:56:54 +0000 Subject: [PATCH 5/6] remove unused --- cpp/include/raft/linalg/detail/lstsq.cuh | 2 -- 1 file changed, 2 deletions(-) diff --git a/cpp/include/raft/linalg/detail/lstsq.cuh b/cpp/include/raft/linalg/detail/lstsq.cuh index 90b1f12a9c..176c7763ba 100644 --- a/cpp/include/raft/linalg/detail/lstsq.cuh +++ b/cpp/include/raft/linalg/detail/lstsq.cuh @@ -5,8 +5,6 @@ #pragma once -#include - #include #include #include From 29bba0c0605300f7e911d01311c788aa8a75a6f4 Mon Sep 17 00:00:00 2001 From: aamijar Date: Sat, 14 Feb 2026 00:26:38 +0000 Subject: [PATCH 6/6] fix weighted_sqrt --- cpp/include/raft/linalg/detail/svd.cuh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpp/include/raft/linalg/detail/svd.cuh b/cpp/include/raft/linalg/detail/svd.cuh index 48234460c6..ba831822d7 100644 --- a/cpp/include/raft/linalg/detail/svd.cuh +++ b/cpp/include/raft/linalg/detail/svd.cuh @@ -140,8 +140,11 @@ void svdEig(raft::resources const& handle, raft::matrix::row_reverse(handle, make_device_matrix_view(S, n_cols, idx_t(1))); - raft::matrix::sqrt(handle, - make_device_matrix_view(S, n_cols, idx_t(1))); + raft::matrix::weighted_sqrt( + handle, + make_device_matrix_view(S, n_cols, idx_t(1)), + make_host_scalar_view(&alpha), + true); if (gen_left_vec) { raft::linalg::gemm(handle,