-
Notifications
You must be signed in to change notification settings - Fork 310
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
Define a selection primtive API #2586
Merged
rapids-bot
merged 8 commits into
rapidsai:branch-22.10
from
seunghwak:fea_selection_primitive_api
Aug 25, 2022
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2d48288
add a selection primitive API
seunghwak 56b0bb8
fix documentation
seunghwak 2449ef7
more documentation fixes
seunghwak 1047aa3
add a selection primitive for uniform neighbor sampling
seunghwak ec6fd17
fix an error in input parameter types
seunghwak c76da95
Merge branch 'branch-22.10' of github.com:rapidsai/cugraph into fea_s…
seunghwak 738bbc8
Merge branch 'branch-22.10' of github.com:rapidsai/cugraph into fea_s…
seunghwak 5eb397e
primitive function renaming
seunghwak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
170 changes: 170 additions & 0 deletions
170
cpp/src/prims/per_v_random_select_and_transform_outgoine_e.cuh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* | ||
* Copyright (c) 2022, 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 cugraph { | ||
|
||
/** | ||
* @brief Randomly select and transform the input (tagged-)vertices' outgoing edges with biases. | ||
* | ||
* @tparam GraphViewType Type of the passed non-owning graph object. | ||
* @tparam VertexFrontierBucketType Type of the vertex frontier bucket class which abstracts the | ||
* current (tagged-)vertex frontier. | ||
* @tparam EdgeSrcValueInputWrapper Type of the wrapper for edge source property values. | ||
* @tparam EdgeDstValueInputWrapper Type of the wrapper for edge destination property values. | ||
* @tparam EdgeBiasOp Type of the quaternary (or quinary) edge operator to set-up selection bias | ||
* values. | ||
* @tparam EdgeOp Type of the quaternary (or quinary) edge operator. | ||
* @tparam T Type of the selected and transformed edge output values. | ||
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and | ||
* handles to various CUDA libraries) to run graph algorithms. | ||
* @param graph_view Non-owning graph object. | ||
* @param frontier VertexFrontierBucketType class object to store the (tagged-)vertex list to sample | ||
* outgoing edges. | ||
* @param edge_src_value_input Wrapper used to access source input property values (for the edge | ||
* sources assigned to this process in multi-GPU). Use either cugraph::edge_src_property_t::view() | ||
* (if @p e_op needs to access source property values) or cugraph::edge_src_dummy_property_t::view() | ||
* (if @p e_op does not access source property values). Use update_edge_src_property to fill the | ||
* wrapper. | ||
* @param edge_dst_value_input Wrapper used to access destination input property values (for the | ||
* edge destinations assigned to this process in multi-GPU). Use either | ||
* cugraph::edge_dst_property_t::view() (if @p e_op needs to access destination property values) or | ||
* cugraph::edge_dst_dummy_property_t::view() (if @p e_op does not access destination property | ||
* values). Use update_edge_dst_property to fill the wrapper. | ||
* @param e_bias_op Quaternary (or quinary) operator takes edge source, edge destination, (optional | ||
* edge weight), property values for the source, and property values for the destination and returns | ||
* a graph weight type bias value to be used in biased random selection. | ||
* @param e_op Quaternary (or quinary) operator takes edge source, edge destination, (optional edge | ||
* weight), property values for the source, and property values for the destination and returns a | ||
* value to be collected in the output. This function is called only for the selected edges. | ||
* @param K Number of outgoing edges to select per (tagged-)vertex. | ||
* @param with_replacement A flag to specify whether a single outgoing edge can be selected multiple | ||
* times (if @p with_replacement = true) or can be selected only once (if @p with_replacement = | ||
* false). | ||
* @param invalid_value If @p invalid_value.has_value() is true, this value is used to fill the | ||
* output vector for the zero out-degree vertices (if @p with_replacement = true) or the vertices | ||
* with their out-degrees smaller than @p K (if @p with_replacement = false). If @p | ||
* invalid_value.has_value() is false, fewer than @p K values can be returned for the vertices with | ||
* fewer than @p K selected edges. See the return value section for additional details. | ||
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). | ||
* @return std::tuple Tuple of an optional offset vector of type | ||
* std::optional<rmm::device_uvector<size_t>> and a dataframe buffer storing the output values of | ||
* type @p T from the selected edges. If @p invalid_value is std::nullopt, the offset vector is | ||
* valid and has the size of @p frontier.size() + 1. If @p invalid_value.has_value() is true, | ||
* std::nullopt is returned (the dataframe buffer will store @p frontier.size() * @p K elements). | ||
*/ | ||
template <typename GraphViewType, | ||
typename VertexFrontierBucketType, | ||
typename EdgeSrcValueInputWrapper, | ||
typename EdgeDstValueInputWrapper, | ||
typename EdgeBiasOp, | ||
typename EdgeOp, | ||
typename T> | ||
std::tuple<std::optional<rmm::device_uvector<size_t>>, | ||
decltype(allocate_dataframe_buffer<T>(size_t{0}, rmm::cuda_stream_view{}))> | ||
per_v_random_select_and_transform_outgoing_e(raft::handle_t const& handle, | ||
GraphViewType const& graph_view, | ||
VertexFrontierBucketType const& frontier, | ||
EdgeSrcValueInputWrapper edge_src_value_input, | ||
EdgeDstValueInputWrapper edge_dst_value_input, | ||
#if 0 // FIXME: This will be necessary to include edge IDs in the output. | ||
// Primitives API should be updated to support this in a consistent way. | ||
EdgeValueInputWrapper egde_value_input, | ||
#endif | ||
EdgeBiasOp e_bias_op, | ||
EdgeOp e_op, | ||
size_t K, | ||
bool with_replacement, | ||
std::optional<T> invalid_value, | ||
bool do_expensive_check = false) | ||
{ | ||
static_assert(false, "unimplemented."); | ||
} | ||
|
||
/** | ||
* @brief Randomly select and transform the input (tagged-)vertices' outgoing edges. | ||
* | ||
* This function assumes that every outgoing edge of a given vertex has the same odd to be selected | ||
* (uniform neighbor sampling). | ||
* | ||
* @tparam GraphViewType Type of the passed non-owning graph object. | ||
* @tparam VertexFrontierBucketType Type of the vertex frontier bucket class which abstracts the | ||
* current (tagged-)vertex frontier. | ||
* @tparam EdgeSrcValueInputWrapper Type of the wrapper for edge source property values. | ||
* @tparam EdgeDstValueInputWrapper Type of the wrapper for edge destination property values. | ||
* @tparam EdgeOp Type of the quaternary (or quinary) edge operator. | ||
* @tparam T Type of the selected and transformed edge output values. | ||
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and | ||
* handles to various CUDA libraries) to run graph algorithms. | ||
* @param graph_view Non-owning graph object. | ||
* @param frontier VertexFrontierBucketType class object to store the (tagged-)vertex list to sample | ||
* outgoing edges. | ||
* @param edge_src_value_input Wrapper used to access source input property values (for the edge | ||
* sources assigned to this process in multi-GPU). Use either cugraph::edge_src_property_t::view() | ||
* (if @p e_op needs to access source property values) or cugraph::edge_src_dummy_property_t::view() | ||
* (if @p e_op does not access source property values). Use update_edge_src_property to fill the | ||
* wrapper. | ||
* @param edge_dst_value_input Wrapper used to access destination input property values (for the | ||
* edge destinations assigned to this process in multi-GPU). Use either | ||
* cugraph::edge_dst_property_t::view() (if @p e_op needs to access destination property values) or | ||
* cugraph::edge_dst_dummy_property_t::view() (if @p e_op does not access destination property | ||
* values). Use update_edge_dst_property to fill the wrapper. | ||
* @param e_op Quaternary (or quinary) operator takes edge source, edge destination, (optional edge | ||
* weight), property values for the source, and property values for the destination and returns a | ||
* value to be collected in the output. This function is called only for the selected edges. | ||
* @param K Number of outgoing edges to select per (tagged-)vertex. | ||
* @param with_replacement A flag to specify whether a single outgoing edge can be selected multiple | ||
* times (if @p with_replacement = true) or can be selected only once (if @p with_replacement = | ||
* false). | ||
* @param invalid_value If @p invalid_value.has_value() is true, this value is used to fill the | ||
* output vector for the zero out-degree vertices (if @p with_replacement = true) or the vertices | ||
* with their out-degrees smaller than @p K (if @p with_replacement = false). If @p | ||
* invalid_value.has_value() is false, fewer than @p K values can be returned for the vertices with | ||
* fewer than @p K selected edges. See the return value section for additional details. | ||
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`). | ||
* @return std::tuple Tuple of an optional offset vector of type | ||
* std::optional<rmm::device_uvector<size_t>> and a dataframe buffer storing the output values of | ||
* type @p T from the selected edges. If @p invalid_value is std::nullopt, the offset vector is | ||
* valid and has the size of @p frontier.size() + 1. If @p invalid_value.has_value() is true, | ||
* std::nullopt is returned (the dataframe buffer will store @p frontier.size() * @p K elements). | ||
*/ | ||
template <typename GraphViewType, | ||
typename VertexFrontierBucketType, | ||
typename EdgeSrcValueInputWrapper, | ||
typename EdgeDstValueInputWrapper, | ||
typename EdgeOp, | ||
typename T> | ||
std::tuple<std::optional<rmm::device_uvector<size_t>>, | ||
decltype(allocate_dataframe_buffer<T>(size_t{0}, rmm::cuda_stream_view{}))> | ||
per_v_random_select_and_transform_outgoing_e(raft::handle_t const& handle, | ||
GraphViewType const& graph_view, | ||
VertexFrontierBucketType const& frontier, | ||
EdgeSrcValueInputWrapper edge_src_value_input, | ||
EdgeDstValueInputWrapper edge_dst_value_input, | ||
#if 0 // FIXME: This will be necessary to include edge IDs in the output. | ||
// Primitives API should be updated to support this in a consistent way. | ||
EdgeValueInputWrapper egde_value_input, | ||
#endif | ||
EdgeOp e_op, | ||
size_t K, | ||
bool with_replacement, | ||
std::optional<T> invalid_value, | ||
bool do_expensive_check = false) | ||
{ | ||
static_assert(false, "unimplemented."); | ||
} | ||
|
||
} // namespace cugraph |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChuckHastings What do you think about
select_and_transfrom
vsselect_transform
in the primitive name?I initially picked former but now getting more inclined to the latter as it is less verbose and more in line with other std:: thrust:: functions like
partitoin_copy
,transform_reduce
, and so on. I guess removingand
here won't cause much confusion?I have a similar issue in naming
extract_and_transform_if...
primitives (a modification of the existingextract_if_e
primitive to allow not just extracting an edge (source, destination, weight) triplets but to allow including edge IDs and types and so on... I feel likeextract_transform
may work better thanextract_and_transform
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think removing the
_and
from the name is reasonable. As you observe, the thrust model doesn't include and conjunctions, they are implied.