Skip to content

Commit

Permalink
add PLC bindings for biased sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHastings committed Jul 17, 2024
1 parent d3ec016 commit aae2357
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 16 deletions.
79 changes: 63 additions & 16 deletions cpp/include/cugraph_c/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,37 @@ typedef struct {
/**
* @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
* @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 [in] default_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,
const cugraph_type_erased_scalar_t* default_property,
cugraph_vertex_property_t** result,
cugraph_error_t** error);

/**
* @brief Create a edge property
* @brief Create an 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
* @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 [in] default_property Device array of vertex 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(
Expand All @@ -91,9 +94,53 @@ cugraph_error_code_t cugraph_edge_property_create(
const cugraph_lookup_container_t* lookup_container,
const cugraph_type_erased_device_array_t* edge_ids,
const cugraph_type_erased_device_array_t* properties,
const cugraph_type_erased_scalar_t* default_property,
cugraph_edge_property_t** result,
cugraph_error_t** error);

/**
* @brief Update an existing vertex property
*
* @param [in] handle Handle for accessing resources
* @param [in] graph Pointer to graph.
* @param [in] vertex_ids Device array of vertex ids to update
* @param [in] property Device array of vertex properties to update
* @param [in/out] result Pointer to the vertex property object to update
* @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_update(
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,
const cugraph_type_erased_scalar_t* default_property,
cugraph_vertex_property_view_t* result,
cugraph_error_t** error);

/**
* @brief Update an existing 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 to update
* @param [in] property Device array of edge properties to update
* @param [in/out] result Pointer to the edge property object to update
* @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_view_t* result,
cugraph_error_t** error);

/**
* @brief Create a vertex_property_view from a vertex property
*
Expand Down
29 changes: 29 additions & 0 deletions python/pylibcugraph/pylibcugraph/_cugraph_c/properties.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.

# Have cython use python 3 syntax
# cython: language_level = 3

cdef extern from "cugraph_c/properties.h":

ctypedef struct cugraph_vertex_property_t:
pass

ctypedef struct cugraph_edge_property_t:
pass

ctypedef struct cugraph_vertex_property_view_t:
pass

ctypedef struct cugraph_edge_property_view_t:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ from pylibcugraph._cugraph_c.array cimport (
cugraph_type_erased_device_array_t,
)

from pylibcugraph._cugraph_c.properties cimport (
cugraph_edge_property_view_t,
)

cdef extern from "cugraph_c/sampling_algorithms.h":
###########################################################################

Expand All @@ -59,6 +63,23 @@ cdef extern from "cugraph_c/sampling_algorithms.h":
cugraph_error_t** error
)

cdef cugraph_error_code_t cugraph_biased_neighbor_sample(
const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
const cugraph_edge_property_view_t* edge_biases,
const cugraph_type_erased_device_array_view_t* start_vertices,
const cugraph_type_erased_device_array_view_t* start_vertex_labels,
const cugraph_type_erased_device_array_view_t* label_list,
const cugraph_type_erased_device_array_view_t* label_to_comm_rank,
const cugraph_type_erased_device_array_view_t* label_offsets,
const cugraph_type_erased_host_array_view_t* fan_out,
cugraph_rng_state_t* rng_state,
const cugraph_sampling_options_t* options,
bool_t do_expensive_check,
cugraph_sample_result_t** result,
cugraph_error_t** error
)

cdef cugraph_error_code_t cugraph_test_uniform_neighborhood_sample_result_create(
const cugraph_resource_handle_t* handle,
const cugraph_type_erased_device_array_view_t* srcs,
Expand Down

0 comments on commit aae2357

Please sign in to comment.