diff --git a/cpp/include/cugraph/sampling_functions.hpp b/cpp/include/cugraph/sampling_functions.hpp index 29904450562..35dbf08a6c9 100644 --- a/cpp/include/cugraph/sampling_functions.hpp +++ b/cpp/include/cugraph/sampling_functions.hpp @@ -178,6 +178,7 @@ uniform_neighbor_sample( * @tparam edge_t Type of edge identifiers. Needs to be an integral type. * @tparam weight_t Type of edge weights. Needs to be a floating point type. * @tparam edge_type_t Type of edge type. Needs to be an integral type. + * @tparam bias_t Type of bias. Needs to be an integral type. * @tparam label_t Type of label. Needs to be an integral type. * @tparam store_transposed Flag indicating whether sources (if false) or destinations (if * true) are major indices @@ -250,80 +251,6 @@ biased_neighbor_sample( bool dedupe_sources = false, bool do_expensive_check = false); -/** - * @brief Heterogeneous Neighborhood Sampling. - * - * This function traverses from a set of starting vertices, traversing outgoing edges and - * randomly selects (with edge biases or not) from these outgoing neighbors to extract a subgraph. - * The branching out to select outgoing neighbors is performed with homogeneous fanouts. - * - * Output from this function is a tuple of vectors (src, dst, weight, edge_id, edge_type, hop, - * label, offsets), identifying the randomly selected edges. src is the source vertex, dst is the - * destination vertex, weight (optional) is the edge weight, edge_id (optional) identifies the edge - * id, edge_type (optional) identifies the edge type, hop identifies which hop the edge was - * encountered in. The label output (optional) identifes the vertex label. The offsets array - * (optional) will be described below and is dependent upon the input parameters. - * - * If @p starting_vertex_labels is not specified then no organization is applied to the output, the - * label and offsets values in the return set will be std::nullopt. - * - * If @p starting_vertex_labels is specified and @p label_to_output_comm_rank is not specified then - * the label output has values. This will also result in the output being sorted by vertex label. - * The offsets array in the return will be a CSR-style offsets array to identify the beginning of - * each label range in the data. `labels.size() == (offsets.size() - 1)`. - * - * If @p starting_vertex_labels is specified and @p label_to_output_comm_rank is specified then the - * label output has values. This will also result in the output being sorted by vertex label. The - * offsets array in the return will be a CSR-style offsets array to identify the beginning of each - * label range in the data. `labels.size() == (offsets.size() - 1)`. Additionally, the data will - * be shuffled so that all data with a particular label will be on the specified rank. - * - * @tparam vertex_t Type of vertex identifiers. Needs to be an integral type. - * @tparam edge_t Type of edge identifiers. Needs to be an integral type. - * @tparam weight_t Type of edge weights. Needs to be a floating point type. - * @tparam edge_type_t Type of edge type. Needs to be an integral type. - * @tparam label_t Type of label. Needs to be an integral type. - * @tparam store_transposed Flag indicating whether sources (if false) or destinations (if - * true) are major indices - * @tparam multi_gpu Flag indicating whether template instantiation should target single-GPU (false) - * @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and - * handles to various CUDA libraries) to run graph algorithms. - * * @param rng_state A pre-initialized raft::RngState object for generating random numbers - * @param graph_view Graph View object to generate NBR Sampling on. - * @param edge_weight_view Optional view object holding edge weights for @p graph_view. - * @param edge_id_view Optional view object holding edge ids for @p graph_view. - * @param edge_type_view Optional view object holding edge types for @p graph_view. - * @param edge_bias_view Optional view object holding edge biases (to be used in biased sampling) for @p - * graph_view. Bias values should be non-negative and the sum of edge bias values from any vertex - * should not exceed std::numeric_limits::max(). 0 bias value indicates that the - * corresponding edge can never be selected. passing std::nullopt as the edge biases will result in - * uniform sampling. - * @param starting_vertices Device span of starting vertex IDs for the sampling. - * In a multi-gpu context the starting vertices should be local to this GPU. - * @param starting_vertex_labels Optional device span of labels associted with each starting vertex - * for the sampling. - * @param label_to_output_comm_rank Optional tuple of device spans mapping label to a particular - * output rank. Element 0 of the tuple identifes the label, Element 1 of the tuple identifies the - * output rank. The label span must be sorted in ascending order. - * @param heterogeneous_fan_out Tuple of host spans defining branching out (fan-out) degree per - * source vertex for each level in CSR style format. The first element of the tuple is the offset - * array per edge type id and the second element corresponds to the fanout values. - * The sampling method can use different fan_out values for each edge type. - * The fan-out offsets size must be proportional to the number of edge types and fan_out values. - * @param return_hops boolean flag specifying if the hop information should be returned. - * @param prior_sources_behavior Enum type defining how to handle prior sources, (defaults to - * DEFAULT) - * @param dedupe_sources boolean flag, if true then if a vertex v appears as a destination in hop X - * multiple times with the same label, it will only be passed once (for each label) as a source - * for the next hop. Default is false. - * @param with_replacement boolean flag specifying if random sampling is done with replacement - * (true); or, without replacement (false); default = true; - * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). - * @return tuple device vectors (vertex_t source_vertex, vertex_t destination_vertex, - * optional weight_t weight, optional edge_t edge id, optional edge_type_t edge type, - * optional int32_t hop, optional label_t label, optional size_t offsets) - */ - struct sampling_flags_t { /** * Specifies how to handle prior sources. Default is DEFAULT. @@ -349,77 +276,12 @@ struct sampling_flags_t { bool with_replacement{true}; }; -template -std::tuple, - rmm::device_uvector, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>> -heterogeneous_neighbor_sample( - raft::handle_t const& handle, - raft::random::RngState& rng_state, - graph_view_t const& graph_view, - std::optional> edge_weight_view, - std::optional> edge_id_view, - std::optional> edge_type_view, - std::optional> edge_bias_view, - raft::device_span starting_vertices, - std::optional> starting_vertex_labels, - std::optional, raft::device_span>> - label_to_output_comm_rank, - std::tuple, raft::host_span> - heterogeneous_fan_out, - bool return_hops, - bool with_replacement = true, - prior_sources_behavior_t prior_sources_behavior = prior_sources_behavior_t::DEFAULT, - bool dedupe_sources = false, - bool do_expensive_check = false); - /** - * @brief Homogeneous Neighborhood Sampling. + * @brief Heterogeneous Neighborhood Sampling. * * This function traverses from a set of starting vertices, traversing outgoing edges and * randomly selects (with edge biases or not) from these outgoing neighbors to extract a subgraph. - * The branching out to select outgoing neighbors is performed with homogeneous fanouts - * - * Output from this function is a tuple of vectors (src, dst, weight, edge_id, edge_type, hop, - * label, offsets), identifying the randomly selected edges. src is the source vertex, dst is the - * destination vertex, weight (optional) is the edge weight, edge_id (optional) identifies the edge - * id, edge_type (optional) identifies the edge type, hop identifies which hop the edge was - * encountered in. The label output (optional) identifes the vertex label. The offsets array - * (optional) will be described below and is dependent upon the input parameters. - * - * If @p starting_vertex_labels is not specified then no organization is applied to the output, the - * label and offsets values in the return set will be std::nullopt. - * - * If @p starting_vertex_labels is specified and @p label_to_output_comm_rank is not specified then - * the label output has values. This will also result in the output being sorted by vertex label. - * The offsets array in the return will be a CSR-style offsets array to identify the beginning of - * each label range in the data. `labels.size() == (offsets.size() - 1)`. - * - * If @p starting_vertex_labels is specified and @p label_to_output_comm_rank is specified then the - * label output has values. This will also result in the output being sorted by vertex label. The - * offsets array in the return will be a CSR-style offsets array to identify the beginning of each - * label range in the data. `labels.size() == (offsets.size() - 1)`. Additionally, the data will - * be shuffled so that all data with a particular label will be on the specified rank. - * @brief Defines flags for sampling - */ - -/** - * @brief Uniform Neighborhood Sampling. - * - * This function traverses from a set of starting vertices, traversing outgoing edges and - * randomly selects from these outgoing neighbors to extract a subgraph. + * The branching out to select outgoing neighbors is performed with homogeneous fanouts. * * Output from this function is a tuple of vectors (src, dst, weight, edge_id, edge_type, hop, * offsets), identifying the randomly selected edges. src is the source vertex, dst is the @@ -442,6 +304,7 @@ heterogeneous_neighbor_sample( * @tparam edge_t Type of edge identifiers. Needs to be an integral type. * @tparam weight_t Type of edge weights. Needs to be a floating point type. * @tparam edge_type_t Type of edge type. Needs to be an integral type. + * @tparam bias_t Type of bias. Needs to be an integral type. * @tparam store_transposed Flag indicating whether sources (if false) or destinations (if * true) are major indices * @tparam multi_gpu Flag indicating whether template instantiation should target single-GPU (false) @@ -452,6 +315,11 @@ heterogeneous_neighbor_sample( * @param edge_weight_view Optional view object holding edge weights for @p graph_view. * @param edge_id_view Optional view object holding edge ids for @p graph_view. * @param edge_type_view Optional view object holding edge types for @p graph_view. + * @param edge_bias_view Optional view object holding edge biases (to be used in biased sampling) for @p + * graph_view. Bias values should be non-negative and the sum of edge bias values from any vertex + * should not exceed std::numeric_limits::max(). 0 bias value indicates that the + * corresponding edge can never be selected. passing std::nullopt as the edge biases will result in + * uniform sampling. * @param starting_vertices Device span of starting vertex IDs for the sampling. * In a multi-gpu context the starting vertices should be local to this GPU. * @param starting_vertex_offsets Optional device span of offsets identifying the range of @@ -460,16 +328,17 @@ heterogeneous_neighbor_sample( * vertex label. This should be the same on each rank. * @param fan_out Host span defining branching out (fan-out) degree per source vertex for each * level - * @param flags A set of flags indicating which sampling features should be used.l + * @param flags A set of flags indicating which sampling features should be used. * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). * @return tuple device vectors (vertex_t source_vertex, vertex_t destination_vertex, * optional weight_t weight, optional edge_t edge id, optional edge_type_t edge type, - * optional int32_t hop, optional size_t offsets) + * optional int32_t hop, optional label_t label, optional size_t offsets) */ template std::tuple, @@ -479,25 +348,28 @@ std::tuple, std::optional>, std::optional>, std::optional>> -homogeneous_uniform_neighbor_sample( +heterogeneous_neighbor_sample( raft::handle_t const& handle, raft::random::RngState& rng_state, graph_view_t const& graph_view, std::optional> edge_weight_view, std::optional> edge_id_view, std::optional> edge_type_view, + std::optional> edge_bias_view, raft::device_span starting_vertices, std::optional> starting_vertex_offsets, std::optional> label_to_output_comm_rank, - raft::host_span fan_out, + std::tuple, raft::host_span> + heterogeneous_fan_out, sampling_flags_t sampling_flags, bool do_expensive_check = false); /** - * @brief Biased Neighborhood Sampling. + * @brief Homogeneous Neighborhood Sampling. * * This function traverses from a set of starting vertices, traversing outgoing edges and - * randomly selects (with edge biases) from these outgoing neighbors to extract a subgraph. + * randomly selects (with edge biases or not) from these outgoing neighbors to extract a subgraph. + * The branching out to select outgoing neighbors is performed with homogeneous fanouts * * Output from this function is a tuple of vectors (src, dst, weight, edge_id, edge_type, hop, * offsets), identifying the randomly selected edges. src is the source vertex, dst is the @@ -512,10 +384,15 @@ homogeneous_uniform_neighbor_sample( * in the return will be a CSR-style offsets array to identify the beginning of each label range in * the output vectors. * + * If @p label_to_output_comm_rank is specified then the data will be shuffled so that all entries + * for a particular label are returned on the specified rank. This will result in the offsets array + * on other GPUs indicating that there are no entries for that label (`offsets[i] == offsets[i+1]`). + * * @tparam vertex_t Type of vertex identifiers. Needs to be an integral type. * @tparam edge_t Type of edge identifiers. Needs to be an integral type. * @tparam weight_t Type of edge weights. Needs to be a floating point type. * @tparam edge_type_t Type of edge type. Needs to be an integral type. + * @tparam bias_t Type of bias. Needs to be an integral type. * @tparam store_transposed Flag indicating whether sources (if false) or destinations (if * true) are major indices * @tparam multi_gpu Flag indicating whether template instantiation should target single-GPU (false) @@ -526,24 +403,26 @@ homogeneous_uniform_neighbor_sample( * @param edge_weight_view Optional view object holding edge weights for @p graph_view. * @param edge_id_view Optional view object holding edge ids for @p graph_view. * @param edge_type_view Optional view object holding edge types for @p graph_view. - * @param edge_bias_view View object holding edge biases (to be used in biased sampling) for @p + * @param edge_bias_view Optional view object holding edge biases (to be used in biased sampling) for @p * graph_view. Bias values should be non-negative and the sum of edge bias values from any vertex * should not exceed std::numeric_limits::max(). 0 bias value indicates that the - * corresponding edge can never be selected. + * corresponding edge can never be selected. passing std::nullopt as the edge biases will result in + * uniform sampling. * @param starting_vertices Device span of starting vertex IDs for the sampling. * In a multi-gpu context the starting vertices should be local to this GPU. - * @param starting_vertex_offsets Optional device span of offsets identifying the range of + * @param starting_vertex_offsets Optional device span of offsets identifying the range of * starting vertex values for this label. * @param label_to_output_comm_rank Optional device span identifying which rank should get each * vertex label. This should be the same on each rank. * @param fan_out Host span defining branching out (fan-out) degree per source vertex for each * level - * @param flags A set of flags indicating which sampling features should be used.l + * @param flags A set of flags indicating which sampling features should be used. * @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). * @return tuple device vectors (vertex_t source_vertex, vertex_t destination_vertex, * optional weight_t weight, optional edge_t edge id, optional edge_type_t edge type, - * optional int32_t hop, optional size_t offsets) + * optional int32_t hop, optional label_t label, optional size_t offsets) */ + template , std::optional>, std::optional>, std::optional>> -homogeneous_biased_neighbor_sample( +homogeneous_neighbor_sample( raft::handle_t const& handle, raft::random::RngState& rng_state, graph_view_t const& graph_view, std::optional> edge_weight_view, std::optional> edge_id_view, std::optional> edge_type_view, - edge_property_view_t edge_bias_view, + std::optional> edge_bias_view, raft::device_span starting_vertices, std::optional> starting_vertex_offsets, std::optional> label_to_output_comm_rank, diff --git a/cpp/src/sampling/neighbor_sampling_impl.hpp b/cpp/src/sampling/neighbor_sampling_impl.hpp index 8f220272f4a..eb09053feec 100644 --- a/cpp/src/sampling/neighbor_sampling_impl.hpp +++ b/cpp/src/sampling/neighbor_sampling_impl.hpp @@ -552,6 +552,7 @@ template std::tuple, @@ -561,22 +562,24 @@ std::tuple, std::optional>, std::optional>, std::optional>> -homogeneous_uniform_neighbor_sample( +heterogeneous_neighbor_sample( raft::handle_t const& handle, raft::random::RngState& rng_state, graph_view_t const& graph_view, std::optional> edge_weight_view, std::optional> edge_id_view, std::optional> edge_type_view, + std::optional> edge_bias_view, raft::device_span starting_vertices, std::optional> starting_vertex_offsets, std::optional> label_to_output_comm_rank, - raft::host_span fan_out, + std::tuple, raft::host_span> + heterogeneous_fan_out, sampling_flags_t sampling_flags, bool do_expensive_check) { using bias_t = weight_t; // dummy - + rmm::device_uvector starting_vertex_labels(0, handle.get_stream()); if (starting_vertex_offsets) @@ -590,7 +593,7 @@ homogeneous_uniform_neighbor_sample( edge_weight_view, edge_id_view, edge_type_view, - std::nullopt, + edge_bias_view, starting_vertices, starting_vertex_offsets ? std::make_optional(raft::device_span{ starting_vertex_labels.data(), starting_vertex_labels.size()}) @@ -618,14 +621,14 @@ std::tuple, std::optional>, std::optional>, std::optional>> -homogeneous_biased_neighbor_sample( +homogeneous_neighbor_sample( raft::handle_t const& handle, raft::random::RngState& rng_state, graph_view_t const& graph_view, std::optional> edge_weight_view, std::optional> edge_id_view, std::optional> edge_type_view, - edge_property_view_t edge_bias_view, + std::optional> edge_bias_view, raft::device_span starting_vertices, std::optional> starting_vertex_offsets, std::optional> label_to_output_comm_rank, @@ -633,6 +636,7 @@ homogeneous_biased_neighbor_sample( sampling_flags_t sampling_flags, bool do_expensive_check) { + rmm::device_uvector starting_vertex_labels(0, handle.get_stream()); if (starting_vertex_offsets) @@ -641,7 +645,6 @@ homogeneous_biased_neighbor_sample( return detail::neighbor_sample_impl( handle, - rng_state, graph_view, edge_weight_view, edge_id_view, @@ -653,378 +656,6 @@ homogeneous_biased_neighbor_sample( : std::nullopt, label_to_output_comm_rank, fan_out, - sampling_flags.return_hops, - sampling_flags.with_replacement, - sampling_flags.prior_sources_behavior, - sampling_flags.dedupe_sources, - do_expensive_check); -} - -template -std::tuple, - rmm::device_uvector, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>> -heterogeneous_neighbor_sample( - raft::handle_t const& handle, - raft::random::RngState& rng_state, - graph_view_t const& graph_view, - std::optional> edge_weight_view, - std::optional> edge_id_view, - std::optional> edge_type_view, - std::optional> edge_bias_view, - raft::device_span starting_vertices, - std::optional> starting_vertex_labels, - std::optional, raft::device_span>> - label_to_output_comm_rank, - std::tuple, raft::host_span> - heterogeneous_fan_out, - bool return_hops, - bool with_replacement, - prior_sources_behavior_t prior_sources_behavior, - bool dedupe_sources, - bool do_expensive_check) -{ - // for loop : over the number of edgetypes / - // inside the loop, create an edge mask and update the edge mask to mask out all the irrelevant edges - // adn call neighborhood sampling - - // before this, there is a reordering constrain. - // 10 labels amd 100 seeds, 3 edge type. For each seed, you provide sample of each edge type (0, 1, 2) - // soritng criterial, label , seed, edge tyope - // label, edge type, seed - - // Pick how to sort - requries assembling? if the natural output order based on this scheme if it doesn't meet the requirement, needs to shuffle - // shuffling, label to be the primiary key? if you loop over the edge tyoe, edge type will be the primary key. - - // Goal: reorder the sample at the end - Label is the primary key? then label? then seed? - // stable sort? to not mess up the internal order? "Use scatter operation to be more efficient?" - - // Iterate over all edge types - - cugraph::edge_property_t, bool> edge_mask(handle, graph_view); - cugraph::fill_edge_property(handle, graph_view, edge_mask.mutable_view(), bool{true}); - - - std::vector> level_result_src_vectors{}; - std::vector> level_result_dst_vectors{}; - auto level_result_weight_vectors = - edge_weight_view ? std::make_optional(std::vector>{}) - : std::nullopt; - auto level_result_edge_id_vectors = - edge_id_view ? std::make_optional(std::vector>{}) : std::nullopt; - auto level_result_edge_type_vectors = - edge_type_view ? std::make_optional(std::vector>{}) - : std::nullopt; - auto level_result_label_vectors = - starting_vertex_labels ? std::make_optional(std::vector>{}) - : std::nullopt; - - level_result_src_vectors.reserve(std::get<0>(heterogeneous_fan_out).size() - 1); - level_result_dst_vectors.reserve(std::get<0>(heterogeneous_fan_out).size() - 1); - if (level_result_weight_vectors) { (*level_result_weight_vectors).reserve(std::get<0>(heterogeneous_fan_out).size() - 1); } - if (level_result_edge_id_vectors) { (*level_result_edge_id_vectors).reserve(std::get<0>(heterogeneous_fan_out).size() - 1); } - if (level_result_edge_type_vectors) { - (*level_result_edge_type_vectors).reserve(std::get<0>(heterogeneous_fan_out).size() - 1); - } - if (level_result_label_vectors) { (*level_result_label_vectors).reserve(std::get<0>(heterogeneous_fan_out).size() - 1); } - - - - - - - - - - - - std::vector level_sizes{}; - for (int i = 0; i < std::get<0>(heterogeneous_fan_out).size() - 1; i++) { - - cugraph::transform_e( - handle, - graph_view, - cugraph::edge_src_dummy_property_t{}.view(), - cugraph::edge_dst_dummy_property_t{}.view(), - *edge_type_view, - [valid_edge_type = i] __device__(auto src, auto dst, thrust::nullopt_t, thrust::nullopt_t, auto edge_type) { - return edge_type == valid_edge_type; - }, - edge_mask.mutable_view(), - false); - - auto [ - level_result_srcs, - level_result_dsts, - level_result_weights, - level_result_edge_ids, - level_result_edge_types, - level_result_hops, - level_result_labels, - label_to_output_comm_rank_ // unused - ] = detail::neighbor_sample_impl( - handle, - graph_view, - edge_weight_view, - edge_id_view, - edge_type_view, - edge_bias_view, - starting_vertices, - starting_vertex_labels, - label_to_output_comm_rank, - std::nullopt, - heterogeneous_fan_out, - return_hops, - with_replacement, - prior_sources_behavior, - dedupe_sources, - rng_state, - do_expensive_check); - - level_sizes.push_back(level_result_srcs.size()); - - level_result_src_vectors.push_back(std::move(level_result_srcs)); - level_result_dst_vectors.push_back(std::move(level_result_dsts)); - if (level_result_weights) { (*level_result_weight_vectors).push_back(std::move(*level_result_weights)); } - if (level_result_edge_ids) { (*level_result_edge_id_vectors).push_back(std::move(*level_result_edge_ids)); } - if (level_result_edge_types) { (*level_result_edge_type_vectors).push_back(std::move(*level_result_edge_types)); } - if (level_result_labels) { (*level_result_label_vectors).push_back(std::move(*level_result_labels)); } - } - - - auto result_size = std::reduce(level_sizes.begin(), level_sizes.end()); - - size_t output_offset{}; - - rmm::device_uvector result_srcs(result_size, handle.get_stream()); - output_offset = 0; - for (size_t i = 0; i < level_result_src_vectors.size(); ++i) { - raft::copy(result_srcs.begin() + output_offset, - level_result_src_vectors[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_src_vectors.clear(); - level_result_src_vectors.shrink_to_fit(); - - rmm::device_uvector result_dsts(result_size, handle.get_stream()); - output_offset = 0; - for (size_t i = 0; i < level_result_dst_vectors.size(); ++i) { - raft::copy(result_dsts.begin() + output_offset, - level_result_dst_vectors[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_dst_vectors.clear(); - level_result_dst_vectors.shrink_to_fit(); - - auto result_weights = - level_result_weight_vectors - ? std::make_optional(rmm::device_uvector(result_size, handle.get_stream())) - : std::nullopt; - if (result_weights) { - output_offset = 0; - for (size_t i = 0; i < (*level_result_weight_vectors).size(); ++i) { - raft::copy((*result_weights).begin() + output_offset, - (*level_result_weight_vectors)[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_weight_vectors = std::nullopt; - } - - auto result_edge_ids = - level_result_edge_id_vectors - ? std::make_optional(rmm::device_uvector(result_size, handle.get_stream())) - : std::nullopt; - if (result_edge_ids) { - output_offset = 0; - for (size_t i = 0; i < (*level_result_edge_id_vectors).size(); ++i) { - raft::copy((*result_edge_ids).begin() + output_offset, - (*level_result_edge_id_vectors)[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_edge_id_vectors = std::nullopt; - } - - auto result_edge_types = - level_result_edge_type_vectors - ? std::make_optional(rmm::device_uvector(result_size, handle.get_stream())) - : std::nullopt; - if (result_edge_types) { - output_offset = 0; - for (size_t i = 0; i < (*level_result_edge_type_vectors).size(); ++i) { - raft::copy((*result_edge_types).begin() + output_offset, - (*level_result_edge_type_vectors)[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_edge_type_vectors = std::nullopt; - } - - std::optional> result_hops{std::nullopt}; - - if (return_hops) { - result_hops = rmm::device_uvector(result_size, handle.get_stream()); - output_offset = 0; - for (size_t i = 0; i < std::get<0>(heterogeneous_fan_out).size() - 1; ++i) { - detail::scalar_fill( - handle, result_hops->data() + output_offset, level_sizes[i], static_cast(i)); - output_offset += level_sizes[i]; - } - } - - auto result_labels = - level_result_label_vectors - ? std::make_optional(rmm::device_uvector(result_size, handle.get_stream())) - : std::nullopt; - if (result_labels) { - output_offset = 0; - for (size_t i = 0; i < (*level_result_label_vectors).size(); ++i) { - raft::copy((*result_labels).begin() + output_offset, - (*level_result_label_vectors)[i].begin(), - level_sizes[i], - handle.get_stream()); - output_offset += level_sizes[i]; - } - level_result_label_vectors = std::nullopt; - } - - // - - /* - return std::make_tuple( - 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), - //offsets - //std::move(label_to_output_comm_rank) - ); - */ - - // Remove and pick the one on top - return detail::neighbor_sample_impl( - handle, - graph_view, - edge_weight_view, - edge_id_view, - edge_type_view, - edge_bias_view, - starting_vertices, - starting_vertex_labels, - label_to_output_comm_rank, - std::nullopt, - heterogeneous_fan_out, - return_hops, - with_replacement, - prior_sources_behavior, - dedupe_sources, - rng_state, - do_expensive_check); - - - - - - - -} - - /* - return detail::neighbor_sample_impl( - handle, - graph_view, - edge_weight_view, - edge_id_view, - edge_type_view, - edge_bias_view, - starting_vertices, - starting_vertex_labels, - label_to_output_comm_rank, - std::nullopt, - heterogeneous_fan_out, - return_hops, - with_replacement, - prior_sources_behavior, - dedupe_sources, - rng_state, - do_expensive_check); -//} -*/ - - - - - - -template -std::tuple, - rmm::device_uvector, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>, - std::optional>> -homogeneous_neighbor_sample( - raft::handle_t const& handle, - raft::random::RngState& rng_state, - graph_view_t const& graph_view, - std::optional> edge_weight_view, - std::optional> edge_id_view, - std::optional> edge_type_view, - std::optional> edge_bias_view, - raft::device_span starting_vertices, - std::optional> starting_vertex_labels, - std::optional, raft::device_span>> - label_to_output_comm_rank, - raft::host_span fan_out, - bool return_hops, - bool with_replacement, - prior_sources_behavior_t prior_sources_behavior, - bool dedupe_sources, - bool do_expensive_check) -{ - return detail::neighbor_sample_impl( - handle, - graph_view, - edge_weight_view, - edge_id_view, - edge_type_view, - edge_bias_view, - starting_vertices, - starting_vertex_labels, - label_to_output_comm_rank, - fan_out, std::nullopt, return_hops, with_replacement, @@ -1034,14 +665,4 @@ homogeneous_neighbor_sample( do_expensive_check); } - - - - - - - - - - } // namespace cugraph