From 3501a453c7ba1f246077abba672f8f5f602fc651 Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Thu, 21 Nov 2024 16:56:15 -0800 Subject: [PATCH] fix style --- cpp/src/c_api/neighbor_sampling.cpp | 64 +++++++++---------- cpp/src/sampling/neighbor_sampling_impl.hpp | 56 ++++++++-------- .../pylibcugraph/_cugraph_c/algorithms.pxd | 2 +- .../internal_types/sampling_result.pyx | 2 +- 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/cpp/src/c_api/neighbor_sampling.cpp b/cpp/src/c_api/neighbor_sampling.cpp index cd6cdaf2bb..c343adc228 100644 --- a/cpp/src/c_api/neighbor_sampling.cpp +++ b/cpp/src/c_api/neighbor_sampling.cpp @@ -1012,8 +1012,8 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { options_.with_replacement_}, do_expensive_check_); } else { - - raft::print_device_vector("labels", (*start_vertex_labels).data(), (*start_vertex_labels).size(), std::cout); + raft::print_device_vector( + "labels", (*start_vertex_labels).data(), (*start_vertex_labels).size(), std::cout); std::tie(src, dst, wgt, edge_id, edge_type, hop, offsets) = cugraph::heterogeneous_uniform_neighbor_sample( handle_, @@ -1129,7 +1129,7 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { } if (options_.renumber_results_) { - if (src.size() > 0) { // Only renumber if there are edgelist to renumber + if (src.size() > 0) { // Only renumber if there are edgelist to renumber if (num_edge_types_ == 1) { // homogeneous renumbering if (options_.compression_type_ == cugraph_compression_type_t::COO) { // COO @@ -1137,13 +1137,13 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { rmm::device_uvector output_majors(0, handle_.get_stream()); rmm::device_uvector output_renumber_map(0, handle_.get_stream()); std::tie(output_majors, - minors, - wgt, - edge_id, - edge_type, - label_hop_offsets, - output_renumber_map, - renumber_map_offsets) = + minors, + wgt, + edge_id, + edge_type, + label_hop_offsets, + output_renumber_map, + renumber_map_offsets) = cugraph::renumber_and_sort_sampled_edgelist( handle_, std::move(src), @@ -1181,14 +1181,14 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { rmm::device_uvector output_renumber_map(0, handle_.get_stream()); std::tie(majors, - output_major_offsets, - minors, - wgt, - edge_id, - edge_type, - label_hop_offsets, - output_renumber_map, - renumber_map_offsets) = + output_major_offsets, + minors, + wgt, + edge_id, + edge_type, + label_hop_offsets, + output_renumber_map, + renumber_map_offsets) = cugraph::renumber_and_compress_sampled_edgelist( handle_, std::move(src), @@ -1230,10 +1230,10 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { rmm::device_uvector vertex_type_offsets(2, handle_.get_stream()); cugraph::detail::stride_fill(handle_.get_stream(), - vertex_type_offsets.begin(), - vertex_type_offsets.size(), - vertex_t{0}, - vertex_t{graph_view.local_vertex_partition_range_size()} + vertex_type_offsets.begin(), + vertex_type_offsets.size(), + vertex_t{0}, + vertex_t{graph_view.local_vertex_partition_range_size()} ); @@ -1241,14 +1241,14 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor { rmm::device_uvector output_renumber_map(0, handle_.get_stream()); std::tie(output_majors, - minors, - wgt, - edge_id, - label_type_hop_offsets, // Contains information about the type and hop offsets - output_renumber_map, - renumber_map_offsets, - renumbered_and_sorted_edge_id_renumber_map, - renumbered_and_sorted_edge_id_renumber_map_label_type_offsets) = + minors, + wgt, + edge_id, + label_type_hop_offsets, // Contains information about the type and hop offsets + output_renumber_map, + renumber_map_offsets, + renumbered_and_sorted_edge_id_renumber_map, + renumbered_and_sorted_edge_id_renumber_map_label_type_offsets) = cugraph::heterogeneous_renumber_and_sort_sampled_edgelist( handle_, std::move(src), @@ -1569,8 +1569,8 @@ extern "C" cugraph_type_erased_device_array_view_t* cugraph_sample_result_get_la : NULL; } -extern "C" cugraph_type_erased_device_array_view_t* cugraph_sample_result_get_label_type_hop_offsets( - const cugraph_sample_result_t* result) +extern "C" cugraph_type_erased_device_array_view_t* +cugraph_sample_result_get_label_type_hop_offsets(const cugraph_sample_result_t* result) { auto internal_pointer = reinterpret_cast(result); return internal_pointer->label_type_hop_offsets_ != nullptr diff --git a/cpp/src/sampling/neighbor_sampling_impl.hpp b/cpp/src/sampling/neighbor_sampling_impl.hpp index 79451a38d4..0a5d65ea1e 100644 --- a/cpp/src/sampling/neighbor_sampling_impl.hpp +++ b/cpp/src/sampling/neighbor_sampling_impl.hpp @@ -104,7 +104,7 @@ neighbor_sample_impl(raft::handle_t const& handle, edge_masks_vector{}; graph_view_t modified_graph_view = graph_view; edge_masks_vector.reserve(num_edge_types); - + label_t num_labels = 0; if (starting_vertex_labels) { @@ -370,34 +370,36 @@ neighbor_sample_impl(raft::handle_t const& handle, } std::optional> result_offsets{std::nullopt}; - - std::tie(result_srcs, result_dsts, result_weights, result_edge_ids, - result_edge_types, result_hops, result_labels, result_offsets) - = detail::shuffle_and_organize_output(handle, - std::move(result_srcs), - std::move(result_dsts), - std::move(result_weights), - std::move(result_edge_ids), - std::move(result_edge_types), - std::move(result_hops), - std::move(result_labels), - label_to_output_comm_rank); - - if (result_srcs.size() == 0){ + + std::tie(result_srcs, + result_dsts, + result_weights, + result_edge_ids, + result_edge_types, + result_hops, + result_labels, + result_offsets) = detail::shuffle_and_organize_output(handle, + std::move(result_srcs), + std::move(result_dsts), + std::move(result_weights), + std::move(result_edge_ids), + std::move(result_edge_types), + std::move(result_hops), + std::move(result_labels), + label_to_output_comm_rank); + + if (result_srcs.size() == 0) { // Update the 'edgelist_label_offsets' array to be proportional to the // number of labels - result_offsets->resize(num_labels + 1 ,handle.get_stream()); - - thrust::transform( - handle.get_thrust_policy(), - thrust::make_counting_iterator(0), - thrust::make_counting_iterator(result_offsets->size()), - result_offsets->begin(), - [] __device__(auto idx) { - return 0; - }); - } - + result_offsets->resize(num_labels + 1, handle.get_stream()); + + thrust::transform(handle.get_thrust_policy(), + thrust::make_counting_iterator(0), + thrust::make_counting_iterator(result_offsets->size()), + result_offsets->begin(), + [] __device__(auto idx) { return 0; }); + } + return std::make_tuple(std::move(result_srcs), std::move(result_dsts), std::move(result_weights), diff --git a/python/pylibcugraph/pylibcugraph/_cugraph_c/algorithms.pxd b/python/pylibcugraph/pylibcugraph/_cugraph_c/algorithms.pxd index 149d34473b..38781614b2 100644 --- a/python/pylibcugraph/pylibcugraph/_cugraph_c/algorithms.pxd +++ b/python/pylibcugraph/pylibcugraph/_cugraph_c/algorithms.pxd @@ -244,7 +244,7 @@ cdef extern from "cugraph_c/algorithms.h": cugraph_sample_result_get_label_hop_offsets( const cugraph_sample_result_t* result ) - + cdef cugraph_type_erased_device_array_view_t* \ cugraph_sample_result_get_label_type_hop_offsets( const cugraph_sample_result_t* result diff --git a/python/pylibcugraph/pylibcugraph/internal_types/sampling_result.pyx b/python/pylibcugraph/pylibcugraph/internal_types/sampling_result.pyx index 9e53d0aed9..a2ea7cb971 100644 --- a/python/pylibcugraph/pylibcugraph/internal_types/sampling_result.pyx +++ b/python/pylibcugraph/pylibcugraph/internal_types/sampling_result.pyx @@ -206,7 +206,7 @@ cdef class SamplingResult: return create_cupy_array_view_for_device_ptr(device_array_view_ptr, self) - + def get_label_type_hop_offsets(self): if self.c_sample_result_ptr is NULL: raise ValueError("pointer not set, must call set_ptr() with a "