Skip to content
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

Fix bug Random Walk in array sizes #2089

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cpp/src/sampling/random_walks.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,10 @@ random_walks_impl(raft::handle_t const& handle,

// pre-allocate num_paths * max_depth;
//
auto coalesced_sz = num_paths * max_depth;
device_vec_t<vertex_t> d_coalesced_v(coalesced_sz, stream); // coalesced vertex set
device_vec_t<weight_t> d_coalesced_w(coalesced_sz, stream); // coalesced weight set
device_vec_t<index_t> d_paths_sz(num_paths, stream); // paths sizes
device_vec_t<vertex_t> d_coalesced_v(num_paths * max_depth, stream); // coalesced vertex set
device_vec_t<weight_t> d_coalesced_w(num_paths * (max_depth - 1),
stream); // coalesced weight set
device_vec_t<index_t> d_paths_sz(num_paths, stream); // paths sizes

// traversal policy:
//
Expand Down
13 changes: 13 additions & 0 deletions cpp/tests/c_api/node2vec_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ int generic_node2vec_test(vertex_t* h_src,
p_handle, (byte_t*)h_weights, weights, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "copy_to_host failed.");

TEST_ASSERT(test_ret_value,
cugraph_type_erased_device_array_view_size(paths) ==
(cugraph_type_erased_device_array_view_size(weights) + num_seeds),
"paths and weights sizes are not consistent");

// We can easily validate that the results of node2vec
// are feasible by converting the sparse (h_src,h_dst,h_wgt)
// into a dense host matrix and check each path.
Expand All @@ -114,6 +119,14 @@ int generic_node2vec_test(vertex_t* h_src,
p_handle, (byte_t*)h_path_sizes, path_sizes, &ret_error);
TEST_ASSERT(test_ret_value, ret_code == CUGRAPH_SUCCESS, "copy_to_host failed.");

edge_t path_size = 0;
for (int i = 0; i < num_seeds; ++i)
path_size += h_path_sizes[i];

TEST_ASSERT(test_ret_value,
cugraph_type_erased_device_array_view_size(paths) == path_size,
"compressed paths size does not match expected size");

h_path_offsets[0] = 0;
for (int i = 0; i < num_seeds; ++i)
h_path_offsets[i + 1] = h_path_offsets[i] + h_path_sizes[i];
Expand Down