From 15476ecfba08e922f42e33ea3fe863d2579c9473 Mon Sep 17 00:00:00 2001 From: divyegala Date: Mon, 7 Nov 2022 09:39:00 -0800 Subject: [PATCH 1/5] changing overload style --- cpp/include/raft/linalg/rsvd.cuh | 303 ++++++++++++------------------- 1 file changed, 117 insertions(+), 186 deletions(-) diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index e465ee6fa2..dd35486e24 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -152,20 +152,24 @@ void rsvdPerc(const raft::handle_t& handle, * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template -void rsvd_fixed_rank( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) +template +void rsvd_fixed_rank(const raft::handle_t& handle, + raft::device_matrix_view M, + raft::device_vector_view S_vec, + IndexType p, + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -202,22 +206,10 @@ void rsvd_fixed_rank( * * Please see above for documentation of `rsvd_fixed_rank`. */ -template -void rsvd_fixed_rank(const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_fixed_rank(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_fixed_rank(handle, M, S_vec, p, tol, max_sweeps, U_optional, V_optional); + rsvd_fixed_rank(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -233,15 +225,20 @@ void rsvd_fixed_rank(const raft::handle_t& handle, * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template +template void rsvd_fixed_rank_symmetric( const raft::handle_t& handle, raft::device_matrix_view M, raft::device_vector_view S_vec, IndexType p, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -278,23 +275,10 @@ void rsvd_fixed_rank_symmetric( * * Please see above for documentation of `rsvd_fixed_rank_symmetric`. */ -template -void rsvd_fixed_rank_symmetric( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_fixed_rank_symmetric(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_fixed_rank_symmetric(handle, M, S_vec, p, tol, max_sweeps, U_optional, V_optional); + rsvd_fixed_rank_symmetric(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -312,17 +296,21 @@ void rsvd_fixed_rank_symmetric( * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template -void rsvd_fixed_rank_jacobi( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - ValueType tol, - int max_sweeps, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) +template +void rsvd_fixed_rank_jacobi(const raft::handle_t& handle, + raft::device_matrix_view M, + raft::device_vector_view S_vec, + IndexType p, + ValueType tol, + int max_sweeps, + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -359,22 +347,10 @@ void rsvd_fixed_rank_jacobi( * * Please see above for documentation of `rsvd_fixed_rank_jacobi`. */ -template -void rsvd_fixed_rank_jacobi(const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_fixed_rank_jacobi(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_fixed_rank_sjacobi(handle, M, S_vec, p, tol, max_sweeps, U_optional, V_optional); + rsvd_fixed_rank_jacobi(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -392,7 +368,7 @@ void rsvd_fixed_rank_jacobi(const raft::handle_t& handle, * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template +template void rsvd_fixed_rank_symmetric_jacobi( const raft::handle_t& handle, raft::device_matrix_view M, @@ -400,9 +376,14 @@ void rsvd_fixed_rank_symmetric_jacobi( IndexType p, ValueType tol, int max_sweeps, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -439,23 +420,10 @@ void rsvd_fixed_rank_symmetric_jacobi( * * Please see above for documentation of `rsvd_fixed_rank_symmetric_jacobi`. */ -template -void rsvd_fixed_rank_symmetric_jacobi( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - IndexType p, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_fixed_rank_symmetric_jacobi(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_fixed_rank_symmetric_jacobi(handle, M, S_vec, p, tol, max_sweeps, U_optional, V_optional); + rsvd_fixed_rank_symmetric_jacobi(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -472,16 +440,20 @@ void rsvd_fixed_rank_symmetric_jacobi( * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template -void rsvd_perc( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) +template +void rsvd_perc(const raft::handle_t& handle, + raft::device_matrix_view M, + raft::device_vector_view S_vec, + ValueType PC_perc, + ValueType UpS_perc, + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -518,23 +490,10 @@ void rsvd_perc( * * Please see above for documentation of `rsvd_perc`. */ -template -void rsvd_perc(const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_perc(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_perc(handle, M, S_vec, PC_perc, UpS_perc, tol, max_sweeps, U_optional, V_optional); + rsvd_perc(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -551,16 +510,20 @@ void rsvd_perc(const raft::handle_t& handle, * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template -void rsvd_perc_symmetric( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) +template +void rsvd_perc_symmetric(const raft::handle_t& handle, + raft::device_matrix_view M, + raft::device_vector_view S_vec, + ValueType PC_perc, + ValueType UpS_perc, + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -597,23 +560,10 @@ void rsvd_perc_symmetric( * * Please see above for documentation of `rsvd_perc_symmetric`. */ -template -void rsvd_perc_symmetric(const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_perc_symmetric(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_perc_symmetric(handle, M, S_vec, PC_perc, UpS_perc, tol, max_sweeps, U_optional, V_optional); + rsvd_perc_symmetric(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -632,18 +582,22 @@ void rsvd_perc_symmetric(const raft::handle_t& handle, * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template -void rsvd_perc_jacobi( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - ValueType tol, - int max_sweeps, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) +template +void rsvd_perc_jacobi(const raft::handle_t& handle, + raft::device_matrix_view M, + raft::device_vector_view S_vec, + ValueType PC_perc, + ValueType UpS_perc, + ValueType tol, + int max_sweeps, + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -680,23 +634,10 @@ void rsvd_perc_jacobi( * * Please see above for documentation of `rsvd_perc_jacobi`. */ -template -void rsvd_perc_jacobi(const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_perc_jacobi(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_perc_jacobi(handle, M, S_vec, PC_perc, UpS_perc, tol, max_sweeps, U_optional, V_optional); + rsvd_perc_jacobi(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -715,7 +656,7 @@ void rsvd_perc_jacobi(const raft::handle_t& handle, * @param[out] V optional right singular values of raft::device_matrix_view with layout * raft::col_major */ -template +template void rsvd_perc_symmetric_jacobi( const raft::handle_t& handle, raft::device_matrix_view M, @@ -724,9 +665,14 @@ void rsvd_perc_symmetric_jacobi( ValueType UpS_perc, ValueType tol, int max_sweeps, - std::optional> U = std::nullopt, - std::optional> V = std::nullopt) + UType&& U_in, + VType&& V_in) { + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + if (U) { RAFT_EXPECTS(M.extent(0) == U.value().extent(0), "Number of rows in M should be equal to U"); RAFT_EXPECTS(S_vec.extent(0) == U.value().extent(1), @@ -763,25 +709,10 @@ void rsvd_perc_symmetric_jacobi( * * Please see above for documentation of `rsvd_perc_symmetric_jacobi`. */ -template -void rsvd_perc_symmetric_jacobi( - const raft::handle_t& handle, - raft::device_matrix_view M, - raft::device_vector_view S_vec, - ValueType PC_perc, - ValueType UpS_perc, - ValueType tol, - int max_sweeps, - UType&& U, - VType&& V) +template > +void rsvd_perc_symmetric_jacobi(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - rsvd_perc_symmetric_jacobi( - handle, M, S_vec, PC_perc, UpS_perc, tol, max_sweeps, U_optional, V_optional); + rsvd_perc_symmetric_jacobi(std::forward(args)..., std::nullopt, std::nullopt); } /** @} */ // end of group rsvd From 21acf0adda7a88f1a5c90ab6c59af2c5ab08f550 Mon Sep 17 00:00:00 2001 From: divyegala Date: Mon, 7 Nov 2022 13:55:21 -0800 Subject: [PATCH 2/5] svd --- cpp/include/raft/linalg/rsvd.cuh | 28 ++++---- cpp/include/raft/linalg/svd.cuh | 108 +++++++++++++------------------ 2 files changed, 59 insertions(+), 77 deletions(-) diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index dd35486e24..be2f5f0286 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -220,9 +220,9 @@ void rsvd_fixed_rank(Args... args) * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -291,9 +291,9 @@ void rsvd_fixed_rank_symmetric(Args... args) * @param[in] p no. of upsamples * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -363,9 +363,9 @@ void rsvd_fixed_rank_jacobi(Args... args) * @param[in] p no. of upsamples * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -435,9 +435,9 @@ void rsvd_fixed_rank_symmetric_jacobi(Args... args) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed * @param[in] UpS_perc upsampling percentage - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -505,9 +505,9 @@ void rsvd_perc(Args... args) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed * @param[in] UpS_perc upsampling percentage - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -577,9 +577,9 @@ void rsvd_perc_symmetric(Args... args) * @param[in] UpS_perc upsampling percentage * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -651,9 +651,9 @@ void rsvd_perc_jacobi(Args... args) * @param[in] UpS_perc upsampling percentage * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template diff --git a/cpp/include/raft/linalg/svd.cuh b/cpp/include/raft/linalg/svd.cuh index 0026ec1f7d..fb30f17477 100644 --- a/cpp/include/raft/linalg/svd.cuh +++ b/cpp/include/raft/linalg/svd.cuh @@ -192,29 +192,29 @@ bool evaluateSVDByL2Norm(const raft::handle_t& handle, * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) - * @param[out] left_sing_vecs optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major and dimensions (m, n) - * @param[out] right_sing_vecs optional right singular values of raft::device_matrix_view with + * @param[out] V_in optional right singular values of raft::device_matrix_view with * layout raft::col_major and dimensions (n, n) */ -template -void svd_qr( - const raft::handle_t& handle, - raft::device_matrix_view in, - raft::device_vector_view sing_vals, - std::optional> left_sing_vecs = - std::nullopt, - std::optional> right_sing_vecs = - std::nullopt) +template +void svd_qr(const raft::handle_t& handle, + raft::device_matrix_view in, + raft::device_vector_view sing_vals, + UType&& U_in, + VType&& V_in) { - if (left_sing_vecs) { - RAFT_EXPECTS(in.extent(0) == left_sing_vecs.value().extent(0) && - in.extent(1) == left_sing_vecs.value().extent(1), + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + + if (U) { + RAFT_EXPECTS(in.extent(0) == U.value().extent(0) && in.extent(1) == U.value().extent(1), "U should have dimensions m * n"); } - if (right_sing_vecs) { - RAFT_EXPECTS(in.extent(1) == right_sing_vecs.value().extent(0) && - in.extent(1) == right_sing_vecs.value().extent(1), + if (V) { + RAFT_EXPECTS(in.extent(1) == V.value().extent(0) && in.extent(1) == V.value().extent(1), "V should have dimensions n * n"); } svdQR(handle, @@ -222,11 +222,11 @@ void svd_qr( in.extent(0), in.extent(1), sing_vals.data_handle(), - left_sing_vecs.value().data_handle(), - right_sing_vecs.value().data_handle(), + U.value().data_handle(), + V.value().data_handle(), false, - left_sing_vecs.has_value(), - right_sing_vecs.has_value(), + U.has_value(), + V.has_value(), handle.get_stream()); } @@ -237,19 +237,10 @@ void svd_qr( * * Please see above for documentation of `svd_qr`. */ -template -void svd_qr(const raft::handle_t& handle, - raft::device_matrix_view in, - raft::device_vector_view sing_vals, - UType&& U, - VType&& V) +template > +void svd_qr(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - svd_qr(handle, in, sing_vals, U_optional, V_optional); + svd_qr(std::forward(args)..., std::nullopt, std::nullopt); } /** @@ -258,29 +249,30 @@ void svd_qr(const raft::handle_t& handle, * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) - * @param[out] left_sing_vecs optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in optional left singular values of raft::device_matrix_view with layout * raft::col_major and dimensions (m, n) - * @param[out] right_sing_vecs optional right singular values of raft::device_matrix_view with + * @param[out] V_in optional right singular values of raft::device_matrix_view with * layout raft::col_major and dimensions (n, n) */ -template +template void svd_qr_transpose_right_vec( const raft::handle_t& handle, raft::device_matrix_view in, raft::device_vector_view sing_vals, - std::optional> left_sing_vecs = - std::nullopt, - std::optional> right_sing_vecs = - std::nullopt) + UType&& U_in, + VType&& V_in) { - if (left_sing_vecs) { - RAFT_EXPECTS(in.extent(0) == left_sing_vecs.value().extent(0) && - in.extent(1) == left_sing_vecs.value().extent(1), + std::optional> U = + std::forward(U_in); + std::optional> V = + std::forward(V_in); + + if (U) { + RAFT_EXPECTS(in.extent(0) == U.value().extent(0) && in.extent(1) == U.value().extent(1), "U should have dimensions m * n"); } - if (right_sing_vecs) { - RAFT_EXPECTS(in.extent(1) == right_sing_vecs.value().extent(0) && - in.extent(1) == right_sing_vecs.value().extent(1), + if (V) { + RAFT_EXPECTS(in.extent(1) == V.value().extent(0) && in.extent(1) == V.value().extent(1), "V should have dimensions n * n"); } svdQR(handle, @@ -288,11 +280,11 @@ void svd_qr_transpose_right_vec( in.extent(0), in.extent(1), sing_vals.data_handle(), - left_sing_vecs.value().data_handle(), - right_sing_vecs.value().data_handle(), + U.value().data_handle(), + V.value().data_handle(), true, - left_sing_vecs.has_value(), - right_sing_vecs.has_value(), + U.has_value(), + V.has_value(), handle.get_stream()); } @@ -303,20 +295,10 @@ void svd_qr_transpose_right_vec( * * Please see above for documentation of `svd_qr_transpose_right_vec`. */ -template -void svd_qr_transpose_right_vec( - const raft::handle_t& handle, - raft::device_matrix_view in, - raft::device_vector_view sing_vals, - UType&& U, - VType&& V) +template > +void svd_qr_transpose_right_vec(Args... args) { - std::optional> U_optional = - std::forward(U); - std::optional> V_optional = - std::forward(V); - - svd_qr_transpose_right_vec(handle, in, sing_vals, U_optional, V_optional); + svd_qr_transpose_right_vec(std::forward(args)..., std::nullopt, std::nullopt); } /** From 6b40d8098460306d23eda532f8bc07ad980eb688 Mon Sep 17 00:00:00 2001 From: divyegala Date: Tue, 8 Nov 2022 08:57:24 -0800 Subject: [PATCH 3/5] finalizing overloads --- cpp/include/raft/linalg/rsvd.cuh | 8 +- cpp/include/raft/linalg/svd.cuh | 4 +- cpp/include/raft/matrix/col_wise_sort.cuh | 44 +++-------- cpp/include/raft/random/rng.cuh | 76 +++++++++---------- cpp/include/raft/stats/contingency_matrix.cuh | 36 ++++----- 5 files changed, 67 insertions(+), 101 deletions(-) diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index be2f5f0286..452941804e 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -490,7 +490,7 @@ void rsvd_perc(const raft::handle_t& handle, * * Please see above for documentation of `rsvd_perc`. */ -template > +template > void rsvd_perc(Args... args) { rsvd_perc(std::forward(args)..., std::nullopt, std::nullopt); @@ -560,7 +560,7 @@ void rsvd_perc_symmetric(const raft::handle_t& handle, * * Please see above for documentation of `rsvd_perc_symmetric`. */ -template > +template > void rsvd_perc_symmetric(Args... args) { rsvd_perc_symmetric(std::forward(args)..., std::nullopt, std::nullopt); @@ -634,7 +634,7 @@ void rsvd_perc_jacobi(const raft::handle_t& handle, * * Please see above for documentation of `rsvd_perc_jacobi`. */ -template > +template > void rsvd_perc_jacobi(Args... args) { rsvd_perc_jacobi(std::forward(args)..., std::nullopt, std::nullopt); @@ -709,7 +709,7 @@ void rsvd_perc_symmetric_jacobi( * * Please see above for documentation of `rsvd_perc_symmetric_jacobi`. */ -template > +template > void rsvd_perc_symmetric_jacobi(Args... args) { rsvd_perc_symmetric_jacobi(std::forward(args)..., std::nullopt, std::nullopt); diff --git a/cpp/include/raft/linalg/svd.cuh b/cpp/include/raft/linalg/svd.cuh index fb30f17477..0ad441d5f0 100644 --- a/cpp/include/raft/linalg/svd.cuh +++ b/cpp/include/raft/linalg/svd.cuh @@ -237,7 +237,7 @@ void svd_qr(const raft::handle_t& handle, * * Please see above for documentation of `svd_qr`. */ -template > +template > void svd_qr(Args... args) { svd_qr(std::forward(args)..., std::nullopt, std::nullopt); @@ -295,7 +295,7 @@ void svd_qr_transpose_right_vec( * * Please see above for documentation of `svd_qr_transpose_right_vec`. */ -template > +template > void svd_qr_transpose_right_vec(Args... args) { svd_qr_transpose_right_vec(std::forward(args)..., std::nullopt, std::nullopt); diff --git a/cpp/include/raft/matrix/col_wise_sort.cuh b/cpp/include/raft/matrix/col_wise_sort.cuh index d26f5f73cf..40f95834e6 100644 --- a/cpp/include/raft/matrix/col_wise_sort.cuh +++ b/cpp/include/raft/matrix/col_wise_sort.cuh @@ -61,15 +61,17 @@ void sort_cols_per_row(const InType* in, * @param[in] handle: raft handle * @param[in] in: input matrix * @param[out] out: output value(index) matrix - * @param[out] sorted_keys: Optional, output matrix for sorted keys (input) + * @param[out] sorted_keys_opt: Optional, output matrix for sorted keys (input) */ -template +template void sort_cols_per_row(const raft::handle_t& handle, raft::device_matrix_view in, raft::device_matrix_view out, - std::optional> - sorted_keys = std::nullopt) + sorted_keys_t&& sorted_keys_opt) { + std::optional> sorted_keys = + std::forward(sorted_keys_opt); + RAFT_EXPECTS(in.extent(1) == out.extent(1) && in.extent(0) == out.extent(0), "Input and output matrices must have the same shape."); @@ -109,26 +111,6 @@ void sort_cols_per_row(const raft::handle_t& handle, } } -namespace sort_cols_per_row_impl { -template -struct sorted_keys_alias { -}; - -template <> -struct sorted_keys_alias { - using type = double; -}; - -template -struct sorted_keys_alias< - std::optional>> { - using type = typename raft::device_matrix_view::value_type; -}; - -template -using sorted_keys_t = typename sorted_keys_alias::type; -} // namespace sort_cols_per_row_impl - /** * @brief Overload of `sort_keys_per_row` to help the * compiler find the above overload, in case users pass in @@ -136,18 +118,10 @@ using sorted_keys_t = typename sorted_keys_alias::type; * * Please see above for documentation of `sort_keys_per_row`. */ -template -void sort_cols_per_row(const raft::handle_t& handle, - raft::device_matrix_view in, - raft::device_matrix_view out, - sorted_keys_vector_type sorted_keys) +template > +void sort_cols_per_row(Args... args) { - using sorted_keys_type = sort_cols_per_row_impl::sorted_keys_t< - std::remove_const_t>>; - std::optional> sorted_keys_opt = - std::forward(sorted_keys); - - sort_cols_per_row(handle, in, out, sorted_keys_opt); + sort_cols_per_row(std::forward(args)..., std::nullopt); } }; // end namespace raft::matrix diff --git a/cpp/include/raft/random/rng.cuh b/cpp/include/raft/random/rng.cuh index 8ea985b559..9bf2b961b2 100644 --- a/cpp/include/raft/random/rng.cuh +++ b/cpp/include/raft/random/rng.cuh @@ -703,6 +703,25 @@ void laplace(const raft::handle_t& handle, detail::laplace(rng_state, ptr, len, mu, scale, handle.get_stream()); } +namespace sample_without_replacement_impl { +template +struct weight_alias { +}; + +template <> +struct weight_alias { + using type = double; +}; + +template +struct weight_alias>> { + using type = typename raft::device_vector_view::value_type; +}; + +template +using weight_t = typename weight_alias::type; +} // namespace sample_without_replacement_impl + /** * @brief Sample the input vector without replacement, optionally based on the * input weight vector for each element in the array. @@ -730,10 +749,10 @@ void laplace(const raft::handle_t& handle, * the CUDA stream on which to run. * @param[inout] rng_state Pseudorandom number generator state. * @param[in] in Input vector to be sampled. - * @param[in] wts Optional weights vector. + * @param[in] weights_opt Optional weights vector. * If not provided, uniform sampling will be used. * @param[out] out Vector of samples from the input vector. - * @param[out] outIdx If provided, vector of the indices + * @param[out] outIdx_opt If provided, vector of the indices * sampled from the input array. * * @pre The number of samples `out.extent(0)` @@ -742,14 +761,22 @@ void laplace(const raft::handle_t& handle, * @pre The number of weights `wts.extent(0)` * equals the number of inputs `in.extent(0)`. */ -template +template void sample_without_replacement(const raft::handle_t& handle, RngState& rng_state, raft::device_vector_view in, - std::optional> wts, + WeightsVectorType&& weights_opt, raft::device_vector_view out, - std::optional> outIdx) + OutIndexVectorType&& outIdx_opt) { + using weight_type = sample_without_replacement_impl::weight_t< + std::remove_const_t>>; + + std::optional> wts = + std::forward(weights_opt); + std::optional> outIdx = + std::forward(outIdx_opt); + static_assert(std::is_integral::value, "IdxT must be an integral type."); const IdxT sampledLen = out.extent(0); const IdxT len = in.extent(0); @@ -777,7 +804,7 @@ void sample_without_replacement(const raft::handle_t& handle, "sampleWithoutReplacement: " "If wts is provided, its extent(0) must equal in.extent(0)"); } - const WeightsT* wts_ptr = wts_has_value ? (*wts).data_handle() : nullptr; + const weight_type* wts_ptr = wts_has_value ? (*wts).data_handle() : nullptr; detail::sampleWithoutReplacement(rng_state, out.data_handle(), @@ -789,25 +816,6 @@ void sample_without_replacement(const raft::handle_t& handle, handle.get_stream()); } -namespace sample_without_replacement_impl { -template -struct weight_alias { -}; - -template <> -struct weight_alias { - using type = double; -}; - -template -struct weight_alias>> { - using type = typename raft::device_vector_view::value_type; -}; - -template -using weight_t = typename weight_alias::type; -} // namespace sample_without_replacement_impl - /** * @brief Overload of `sample_without_replacement` to help the * compiler find the above overload, in case users pass in @@ -815,22 +823,10 @@ using weight_t = typename weight_alias::type; * * Please see above for documentation of `sample_without_replacement`. */ -template -void sample_without_replacement(const raft::handle_t& handle, - RngState& rng_state, - raft::device_vector_view in, - WeightsVectorType&& wts, - raft::device_vector_view out, - OutIndexVectorType&& outIdx) +template > +void sample_without_replacement(Args... args) { - using weight_type = sample_without_replacement_impl::weight_t< - std::remove_const_t>>; - std::optional> weights = - std::forward(wts); - std::optional> output_indices = - std::forward(outIdx); - - sample_without_replacement(handle, rng_state, in, weights, out, output_indices); + sample_without_replacement(std::forward(args)..., std::nullopt); } /** diff --git a/cpp/include/raft/stats/contingency_matrix.cuh b/cpp/include/raft/stats/contingency_matrix.cuh index 10dedc44eb..b1e4031709 100644 --- a/cpp/include/raft/stats/contingency_matrix.cuh +++ b/cpp/include/raft/stats/contingency_matrix.cuh @@ -142,17 +142,25 @@ void contingencyMatrix(const T* groundTruth, * @param[in] ground_truth: device 1-d array for ground truth (num of rows) * @param[in] predicted_label: device 1-d array for prediction (num of columns) * @param[out] out_mat: output buffer for contingency matrix - * @param[in] min_label: Optional, min value in input ground truth array - * @param[in] max_label: Optional, max value in input ground truth array + * @param[in] opt_min_label: Optional, min value in input ground truth array + * @param[in] opt_max_label: Optional, max value in input ground truth array */ -template +template void contingency_matrix(const raft::handle_t& handle, raft::device_vector_view ground_truth, raft::device_vector_view predicted_label, raft::device_matrix_view out_mat, - std::optional min_label = std::nullopt, - std::optional max_label = std::nullopt) + opt_min_label_t&& opt_min_label, + opt_max_label_t&& opt_max_label) { + std::optional min_label = std::forward(opt_min_label); + std::optional max_label = std::forward(opt_max_label); + RAFT_EXPECTS(ground_truth.size() == predicted_label.size(), "Size mismatch"); RAFT_EXPECTS(ground_truth.is_exhaustive(), "ground_truth must be contiguous"); RAFT_EXPECTS(predicted_label.is_exhaustive(), "predicted_label must be contiguous"); @@ -188,22 +196,10 @@ void contingency_matrix(const raft::handle_t& handle, * * Please see above for documentation of `contingency_matrix`. */ -template -void contingency_matrix(const raft::handle_t& handle, - raft::device_vector_view ground_truth, - raft::device_vector_view predicted_label, - raft::device_matrix_view out_mat, - opt_min_label_t&& min_label = std::nullopt, - opt_max_label_t&& max_label = std::nullopt) +template > +void contingency_matrix(Args... args) { - std::optional opt_min_label = std::forward(min_label); - std::optional opt_max_label = std::forward(max_label); - contingency_matrix(handle, ground_truth, predicted_label, out_mat, opt_min_label, opt_max_label); + contingency_matrix(std::forward(args)..., std::nullopt, std::nullopt); } }; // namespace stats }; // namespace raft From a4eb3d674b054e0cf1990a697462e64b08508ccd Mon Sep 17 00:00:00 2001 From: divyegala Date: Tue, 8 Nov 2022 11:19:03 -0800 Subject: [PATCH 4/5] clarify docs --- cpp/include/raft/linalg/rsvd.cuh | 32 +++++++++---------- cpp/include/raft/linalg/svd.cuh | 8 ++--- cpp/include/raft/matrix/col_wise_sort.cuh | 2 +- cpp/include/raft/random/rng.cuh | 4 +-- cpp/include/raft/stats/contingency_matrix.cuh | 4 +-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index 452941804e..e5d9064ce0 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -152,9 +152,9 @@ void rsvdPerc(const raft::handle_t& handle, * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -220,9 +220,9 @@ void rsvd_fixed_rank(Args... args) * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] p no. of upsamples - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -291,9 +291,9 @@ void rsvd_fixed_rank_symmetric(Args... args) * @param[in] p no. of upsamples * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -363,9 +363,9 @@ void rsvd_fixed_rank_jacobi(Args... args) * @param[in] p no. of upsamples * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -435,9 +435,9 @@ void rsvd_fixed_rank_symmetric_jacobi(Args... args) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed * @param[in] UpS_perc upsampling percentage - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -505,9 +505,9 @@ void rsvd_perc(Args... args) * @param[out] S_vec singular values raft::device_vector_view of shape (K) * @param[in] PC_perc percentage of singular values to be computed * @param[in] UpS_perc upsampling percentage - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -577,9 +577,9 @@ void rsvd_perc_symmetric(Args... args) * @param[in] UpS_perc upsampling percentage * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template @@ -651,9 +651,9 @@ void rsvd_perc_jacobi(Args... args) * @param[in] UpS_perc upsampling percentage * @param[in] tol tolerance for Jacobi-based solvers * @param[in] max_sweeps maximum number of sweeps for Jacobi-based solvers - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major - * @param[out] V_in optional right singular values of raft::device_matrix_view with layout + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with layout * raft::col_major */ template diff --git a/cpp/include/raft/linalg/svd.cuh b/cpp/include/raft/linalg/svd.cuh index 0ad441d5f0..8fe55243fa 100644 --- a/cpp/include/raft/linalg/svd.cuh +++ b/cpp/include/raft/linalg/svd.cuh @@ -192,9 +192,9 @@ bool evaluateSVDByL2Norm(const raft::handle_t& handle, * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major and dimensions (m, n) - * @param[out] V_in optional right singular values of raft::device_matrix_view with + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with * layout raft::col_major and dimensions (n, n) */ template @@ -249,9 +249,9 @@ void svd_qr(Args... args) * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) - * @param[out] U_in optional left singular values of raft::device_matrix_view with layout + * @param[out] U_in std::optional left singular values of raft::device_matrix_view with layout * raft::col_major and dimensions (m, n) - * @param[out] V_in optional right singular values of raft::device_matrix_view with + * @param[out] V_in std::optional right singular values of raft::device_matrix_view with * layout raft::col_major and dimensions (n, n) */ template diff --git a/cpp/include/raft/matrix/col_wise_sort.cuh b/cpp/include/raft/matrix/col_wise_sort.cuh index 40f95834e6..467f3c0525 100644 --- a/cpp/include/raft/matrix/col_wise_sort.cuh +++ b/cpp/include/raft/matrix/col_wise_sort.cuh @@ -61,7 +61,7 @@ void sort_cols_per_row(const InType* in, * @param[in] handle: raft handle * @param[in] in: input matrix * @param[out] out: output value(index) matrix - * @param[out] sorted_keys_opt: Optional, output matrix for sorted keys (input) + * @param[out] sorted_keys_opt: std::optional, output matrix for sorted keys (input) */ template void sort_cols_per_row(const raft::handle_t& handle, diff --git a/cpp/include/raft/random/rng.cuh b/cpp/include/raft/random/rng.cuh index 9bf2b961b2..930ea786ca 100644 --- a/cpp/include/raft/random/rng.cuh +++ b/cpp/include/raft/random/rng.cuh @@ -749,10 +749,10 @@ using weight_t = typename weight_alias::type; * the CUDA stream on which to run. * @param[inout] rng_state Pseudorandom number generator state. * @param[in] in Input vector to be sampled. - * @param[in] weights_opt Optional weights vector. + * @param[in] weights_opt std::optional weights vector. * If not provided, uniform sampling will be used. * @param[out] out Vector of samples from the input vector. - * @param[out] outIdx_opt If provided, vector of the indices + * @param[out] outIdx_opt std::optional vector of the indices * sampled from the input array. * * @pre The number of samples `out.extent(0)` diff --git a/cpp/include/raft/stats/contingency_matrix.cuh b/cpp/include/raft/stats/contingency_matrix.cuh index b1e4031709..6b5778cae7 100644 --- a/cpp/include/raft/stats/contingency_matrix.cuh +++ b/cpp/include/raft/stats/contingency_matrix.cuh @@ -142,8 +142,8 @@ void contingencyMatrix(const T* groundTruth, * @param[in] ground_truth: device 1-d array for ground truth (num of rows) * @param[in] predicted_label: device 1-d array for prediction (num of columns) * @param[out] out_mat: output buffer for contingency matrix - * @param[in] opt_min_label: Optional, min value in input ground truth array - * @param[in] opt_max_label: Optional, max value in input ground truth array + * @param[in] opt_min_label: std::optional, min value in input ground truth array + * @param[in] opt_max_label: std::optional, max value in input ground truth array */ template Date: Thu, 10 Nov 2022 09:42:05 -0800 Subject: [PATCH 5/5] making docs clearer --- cpp/include/raft/linalg/rsvd.cuh | 48 +++++++++++++++++++ cpp/include/raft/linalg/svd.cuh | 12 +++++ cpp/include/raft/matrix/col_wise_sort.cuh | 2 + cpp/include/raft/random/rng.cuh | 5 +- cpp/include/raft/stats/contingency_matrix.cuh | 2 + 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/cpp/include/raft/linalg/rsvd.cuh b/cpp/include/raft/linalg/rsvd.cuh index e5d9064ce0..6f0315642b 100644 --- a/cpp/include/raft/linalg/rsvd.cuh +++ b/cpp/include/raft/linalg/rsvd.cuh @@ -148,6 +148,12 @@ void rsvdPerc(const raft::handle_t& handle, * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using QR decomposition, by specifying no. of PCs and * upsamples directly + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -216,6 +222,12 @@ void rsvd_fixed_rank(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using symmetric Eigen decomposition, by specifying no. of PCs and * upsamples directly. The rectangular input matrix is made square and symmetric using B @ B^T + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -285,6 +297,12 @@ void rsvd_fixed_rank_symmetric(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using Jacobi method, by specifying no. of PCs and * upsamples directly + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -357,6 +375,12 @@ void rsvd_fixed_rank_jacobi(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using Jacobi method, by specifying no. of PCs and * upsamples directly. The rectangular input matrix is made square and symmetric using B @ B^T + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -430,6 +454,12 @@ void rsvd_fixed_rank_symmetric_jacobi(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using QR decomposition, by specifying the PC and upsampling * ratio + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -500,6 +530,12 @@ void rsvd_perc(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using symmetric Eigen decomposition, by specifying the PC and upsampling * ratio. The rectangular input matrix is made square and symmetric using B @ B^T + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -570,6 +606,12 @@ void rsvd_perc_symmetric(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using Jacobi method, by specifying the PC and upsampling * ratio + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) @@ -644,6 +686,12 @@ void rsvd_perc_jacobi(Args... args) * @brief randomized singular value decomposition (RSVD) on a column major * rectangular matrix using Jacobi method, by specifying the PC and upsampling * ratio. The rectangular input matrix is made square and symmetric using B @ B^T + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] M input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] S_vec singular values raft::device_vector_view of shape (K) diff --git a/cpp/include/raft/linalg/svd.cuh b/cpp/include/raft/linalg/svd.cuh index 8fe55243fa..7be1b9d63c 100644 --- a/cpp/include/raft/linalg/svd.cuh +++ b/cpp/include/raft/linalg/svd.cuh @@ -189,6 +189,12 @@ bool evaluateSVDByL2Norm(const raft::handle_t& handle, /** * @brief singular value decomposition (SVD) on a column major * matrix using QR decomposition + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) @@ -246,6 +252,12 @@ void svd_qr(Args... args) /** * @brief singular value decomposition (SVD) on a column major * matrix using QR decomposition. Right singular vector matrix is transposed before returning + * @tparam ValueType value type of parameters + * @tparam IndexType index type of parameters + * @tparam UType std::optional> @c + * U_in + * @tparam VType std::optional> @c + * V_in * @param[in] handle raft::handle_t * @param[in] in input raft::device_matrix_view with layout raft::col_major of shape (M, N) * @param[out] sing_vals singular values raft::device_vector_view of shape (K) diff --git a/cpp/include/raft/matrix/col_wise_sort.cuh b/cpp/include/raft/matrix/col_wise_sort.cuh index 467f3c0525..5f9b3ab848 100644 --- a/cpp/include/raft/matrix/col_wise_sort.cuh +++ b/cpp/include/raft/matrix/col_wise_sort.cuh @@ -58,6 +58,8 @@ void sort_cols_per_row(const InType* in, * @tparam in_t: element type of input matrix * @tparam out_t: element type of output matrix * @tparam matrix_idx_t: integer type for matrix indexing + * @tparam sorted_keys_t: std::optional> @c sorted_keys_opt * @param[in] handle: raft handle * @param[in] in: input matrix * @param[out] out: output value(index) matrix diff --git a/cpp/include/raft/random/rng.cuh b/cpp/include/raft/random/rng.cuh index 930ea786ca..27672b077f 100644 --- a/cpp/include/raft/random/rng.cuh +++ b/cpp/include/raft/random/rng.cuh @@ -740,7 +740,10 @@ using weight_t = typename weight_alias::type; * * @tparam DataT type of each element of the input array @c in * @tparam IdxT type of the dimensions of the arrays; output index type - * @tparam WeightsT type of each elements of the weights array @c wts + * @tparam WeightsVectorType std::optional> of + * each elements of the weights array @c weights_opt + * @tparam OutIndexVectorType std::optional> of output indices + * @c outIdx_opt * * @note Please do not specify template parameters explicitly, * as the compiler can deduce them from the arguments. diff --git a/cpp/include/raft/stats/contingency_matrix.cuh b/cpp/include/raft/stats/contingency_matrix.cuh index 6b5778cae7..8cb79f4f1d 100644 --- a/cpp/include/raft/stats/contingency_matrix.cuh +++ b/cpp/include/raft/stats/contingency_matrix.cuh @@ -138,6 +138,8 @@ void contingencyMatrix(const T* groundTruth, * @tparam out_t output matrix type * @tparam idx_t Index type of matrix extent. * @tparam layout_t Layout type of the input data. + * @tparam opt_min_label_t std::optional @c opt_min_label + * @tparam opt_max_label_t std::optional @c opt_max_label * @param[in] handle: the raft handle. * @param[in] ground_truth: device 1-d array for ground truth (num of rows) * @param[in] predicted_label: device 1-d array for prediction (num of columns)