Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jnke2016 committed Nov 22, 2024
1 parent 535df5d commit 3501a45
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 61 deletions.
64 changes: 32 additions & 32 deletions cpp/src/c_api/neighbor_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down Expand Up @@ -1129,21 +1129,21 @@ 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

rmm::device_uvector<vertex_t> output_majors(0, handle_.get_stream());
rmm::device_uvector<vertex_t> 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<vertex_t>(
handle_,
std::move(src),
Expand Down Expand Up @@ -1181,14 +1181,14 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor {
rmm::device_uvector<vertex_t> 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<vertex_t>(
handle_,
std::move(src),
Expand Down Expand Up @@ -1230,25 +1230,25 @@ struct neighbor_sampling_functor : public cugraph::c_api::abstract_functor {
rmm::device_uvector<vertex_t> 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()}

);

rmm::device_uvector<vertex_t> output_majors(0, handle_.get_stream());
rmm::device_uvector<vertex_t> 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<vertex_t>(
handle_,
std::move(src),
Expand Down Expand Up @@ -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<cugraph::c_api::cugraph_sample_result_t const*>(result);
return internal_pointer->label_type_hop_offsets_ != nullptr
Expand Down
56 changes: 29 additions & 27 deletions cpp/src/sampling/neighbor_sampling_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ neighbor_sample_impl(raft::handle_t const& handle,
edge_masks_vector{};
graph_view_t<vertex_t, edge_t, false, multi_gpu> modified_graph_view = graph_view;
edge_masks_vector.reserve(num_edge_types);

label_t num_labels = 0;

if (starting_vertex_labels) {
Expand Down Expand Up @@ -370,34 +370,36 @@ neighbor_sample_impl(raft::handle_t const& handle,
}

std::optional<rmm::device_uvector<size_t>> 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<edge_t>(0),
thrust::make_counting_iterator<edge_t>(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<edge_t>(0),
thrust::make_counting_iterator<edge_t>(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),
Expand Down
2 changes: 1 addition & 1 deletion python/pylibcugraph/pylibcugraph/_cugraph_c/algorithms.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit 3501a45

Please sign in to comment.