-
Notifications
You must be signed in to change notification settings - Fork 309
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 and Implement C API for biased sampling #4535
Merged
rapids-bot
merged 7 commits into
rapidsai:branch-24.08
from
ChuckHastings:c_api_for_biased_sampling
Jul 18, 2024
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
73e22be
Define C API for biased sampling
ChuckHastings 75a9fda
Add implementation and tests for C API (SG and MG) for biased sampling
ChuckHastings dd5be66
rename uniform_neighbor_sampling.cpp, since both uniform and biased s…
ChuckHastings 553ba07
Merge branch 'branch-24.08' into c_api_for_biased_sampling
ChuckHastings d3ec016
missed new header file
ChuckHastings aae2357
add PLC bindings for biased sampling
ChuckHastings 24511c8
Merge branch 'branch-24.08' into c_api_for_biased_sampling
ChuckHastings 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
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
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,146 @@ | ||
/* | ||
* Copyright (c) 2024, 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 | ||
|
||
// | ||
// Speculative description of handling generic vertex and edge properties. | ||
// | ||
// If we have vertex properties and edge properties that we want to apply to an existing graph | ||
// (after it was created) we could use these methods to construct C++ objects to represent these | ||
// properties. | ||
// | ||
// These assume the use of external vertex ids and external edge ids as the mechanism for | ||
// correlating a property to a particular vertex or edge. | ||
// | ||
|
||
#include <cugraph_c/resource_handle.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
int32_t align_; | ||
} cugraph_vertex_property_t; | ||
|
||
typedef struct { | ||
int32_t align_; | ||
} cugraph_edge_property_t; | ||
|
||
typedef struct { | ||
int32_t align_; | ||
} cugraph_vertex_property_view_t; | ||
|
||
typedef struct { | ||
int32_t align_; | ||
} cugraph_edge_property_view_t; | ||
|
||
#if 0 | ||
// Blocking out definition of these since this is speculative work. | ||
|
||
/** | ||
* @brief Create a vertex property | ||
* | ||
* @param [in] handle Handle for accessing resources | ||
* @param [in] graph Pointer to graph. | ||
* @param [in] vertex_ids Device array of vertex ids | ||
* @param [in] property Device array of vertex property | ||
* @param [out] result Pointer to the location to store the pointer to the vertex property object | ||
* @param [out] error Pointer to an error object storing details of any error. Will | ||
* be populated if error code is not CUGRAPH_SUCCESS | ||
* @return error code | ||
*/ | ||
cugraph_error_code_t cugraph_vertex_property_create( | ||
const cugraph_resource_handle_t* handle, | ||
const cugraph_graph_t * graph, | ||
const cugraph_type_erased_device_array_t* vertex_ids, | ||
const cugraph_type_erased_device_array_t* properties, | ||
cugraph_vertex_property_t** result, | ||
cugraph_error_t** error); | ||
|
||
/** | ||
* @brief Create a edge property | ||
* | ||
* @param [in] handle Handle for accessing resources | ||
* @param [in] graph Pointer to graph. | ||
* @param [in] lookup_container Lookup map | ||
* @param [in] edge_ids Device array of edge ids | ||
* @param [in] property Device array of edge property | ||
* @param [out] result Pointer to the location to store the pointer to the edge property object | ||
* @param [out] error Pointer to an error object storing details of any error. Will | ||
* be populated if error code is not CUGRAPH_SUCCESS | ||
* @return error code | ||
*/ | ||
cugraph_error_code_t cugraph_edge_property_create( | ||
const cugraph_resource_handle_t* handle, | ||
const cugraph_graph_t * graph, | ||
const cugraph_lookup_container_t* lookup_container, | ||
const cugraph_type_erased_device_array_t* edge_ids, | ||
const cugraph_type_erased_device_array_t* properties, | ||
cugraph_edge_property_t** result, | ||
cugraph_error_t** error); | ||
|
||
/** | ||
* @brief Create a vertex_property_view from a vertex property | ||
* | ||
* @param [in] vertex_property Pointer to the vertex property object | ||
* @return Pointer to the view of the host array | ||
*/ | ||
cugraph_vertex_property_view_t* cugraph_vertex_property_view( | ||
cugraph_vertex_property_view* vertex_property); | ||
|
||
/** | ||
* @brief Create a edge_property_view from a edge property | ||
* | ||
* @param [in] edge_property Pointer to the edge property object | ||
* @return Pointer to the view of the host array | ||
*/ | ||
cugraph_edge_property_view_t* cugraph_edge_property_view( | ||
cugraph_edge_property_view* edge_property); | ||
|
||
/** | ||
* @brief Destroy a vertex_property object | ||
* | ||
* @param [in] p Pointer to the vertex_property object | ||
*/ | ||
void cugraph_vertex_property_free(cugraph_vertex_property_t* p); | ||
|
||
/** | ||
* @brief Destroy a edge_property object | ||
* | ||
* @param [in] p Pointer to the edge_property object | ||
*/ | ||
void cugraph_edge_property_free(cugraph_edge_property_t* p); | ||
|
||
/** | ||
* @brief Destroy a vertex_property_view object | ||
* | ||
* @param [in] p Pointer to the vertex_property_view object | ||
*/ | ||
void cugraph_vertex_property_view_free(cugraph_vertex_property__viewt* p); | ||
|
||
/** | ||
* @brief Destroy a edge_property_view object | ||
* | ||
* @param [in] p Pointer to the edge_property_view object | ||
*/ | ||
void cugraph_edge_property_view_free(cugraph_edge_property_view_t* p); | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
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
Oops, something went wrong.
Oops, something went wrong.
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.
What happens if edge IDs are provided only for a subset of edges? Will those edges have undefined values? Should we ask for default values?
And no need for an update function? (e.g. update bias values only for a small subset of edges).
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.
Reasonable ideas. I'll look at defining update functions and a mechanism for a default value. I'll add it to both vertex and edge functions.
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.
Just fyi. In the C++ primitives level, we have
fill_edge_property_value
(which sets edge property values for the entire set of edges, we may add a function that works on a subset of the edges in the future) andupdate_edge_property
function that works either on a subset of the edges or the entire set of edges. Following this may make implementing the API easier.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 pushed an update that adds these functions. Plan is to implement them at some point in the future.