Skip to content

Commit

Permalink
Adding SLHC prims. (#140)
Browse files Browse the repository at this point in the history
The dense pairwise distances API in cuML currently relies on CUTLASS and will soon be re-written to remove that dependency. Until then, the SLHC implementation in RAFT cannot depend on that API. In the meantime, I've abstracted that piece out to make it pluggable on the cuML side.

This PR depends on the changes in #139.

Authors:
  - Corey J. Nolet (@cjnolet)
  - Divye Gala (@divyegala)

Approvers:
  - Divye Gala (@divyegala)
  - Dante Gama Dessavre (@dantegd)

URL: #140
  • Loading branch information
cjnolet authored Mar 16, 2021
1 parent 5ea9795 commit fc46618
Show file tree
Hide file tree
Showing 15 changed files with 2,874 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ if(BUILD_RAFT_TESTS)
test/sparse/add.cu
test/sparse/convert_coo.cu
test/sparse/convert_csr.cu
test/sparse/connect_components.cu
test/sparse/csr_row_slice.cu
test/sparse/csr_to_dense.cu
test/sparse/csr_transpose.cu
Expand All @@ -291,6 +292,8 @@ if(BUILD_RAFT_TESTS)
test/sparse/distance.cu
test/sparse/filter.cu
test/sparse/knn.cu
test/sparse/knn_graph.cu
test/sparse/linkage.cu
test/sparse/norm.cu
test/sparse/row_op.cu
test/sparse/selection.cu
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(NOT CUB_IS_PART_OF_CTK)
set(CUB_DIR ${CMAKE_CURRENT_BINARY_DIR}/cub CACHE STRING "Path to cub repo")
ExternalProject_Add(cub
GIT_REPOSITORY https://github.com/thrust/cub.git
GIT_TAG 1.8.0
GIT_TAG 1.12.0
PREFIX ${CUB_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
48 changes: 48 additions & 0 deletions cpp/include/raft/sparse/hierarchy/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2021, 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

namespace raft {
namespace hierarchy {

enum LinkageDistance { PAIRWISE = 0, KNN_GRAPH = 1 };

/**
* Simple POCO for consolidating linkage results. This closely
* mirrors the trained instance variables populated in
* Scikit-learn's AgglomerativeClustering estimator.
* @tparam value_idx
* @tparam value_t
*/
template <typename value_idx, typename value_t>
struct linkage_output {
value_idx m;
value_idx n_clusters;

value_idx n_leaves;
value_idx n_connected_components;

value_idx *labels; // size: m

value_idx *children; // size: (m-1, 2)
};

struct linkage_output_int_float : public linkage_output<int, float> {};
struct linkage_output__int64_float : public linkage_output<int64_t, float> {};

}; // namespace hierarchy
}; // namespace raft
Loading

0 comments on commit fc46618

Please sign in to comment.