Skip to content

Spectral Embedding #6581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: branch-25.06
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ if(BUILD_CUML_CPP_LIBRARY)
if(all_algo OR spectralclustering_algo)
target_sources(${CUML_CPP_TARGET}
PRIVATE
src/spectral/spectral.cu)
src/spectral/spectral.cu
src/spectral/spectral_embedding.cu)
endif()

if(all_algo OR svm_algo)
Expand Down
26 changes: 26 additions & 0 deletions cpp/include/cuml/manifold/spectral_embedding.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <cuml/manifold/spectral_embedding_types.hpp>

#include <raft/core/device_mdspan.hpp>
#include <raft/core/resources.hpp>

// template <typename IndexTypeT, typename ValueTypeT>
auto spectral_embedding_cuml(raft::resources const& handle,
raft::device_matrix_view<float, int, raft::row_major> nums,
raft::device_matrix_view<float, int, raft::col_major> embedding,
ML::spectral_embedding_config config) -> int;
36 changes: 36 additions & 0 deletions cpp/include/cuml/manifold/spectral_embedding_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <cstdint>

namespace ML {

struct spectral_embedding_config {
/** The number of components to reduce the data to. */
int n_components;
/** The number of neighbors to use for the nearest neighbors graph. */
int n_neighbors;
/** Whether to normalize the Laplacian matrix. */
bool norm_laplacian;
/** Whether to drop the first eigenvector. */
bool drop_first;
/** random seed */
uint64_t seed;
};

} // namespace ML
Loading