"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "56bea6b4a110e7e976b8881eb39a21158c2fa705"
Unverified Commit 27e0e547 authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by GitHub
Browse files

[BUG] Graceful handling of random walking with no successors (#433)

parent d3c24cc2
...@@ -504,27 +504,27 @@ IdArray SamplerOp::RandomWalk( ...@@ -504,27 +504,27 @@ IdArray SamplerOp::RandomWalk(
DLContext{kDLCPU, 0}); DLContext{kDLCPU, 0});
dgl_id_t *trace_data = static_cast<dgl_id_t *>(traces->data); dgl_id_t *trace_data = static_cast<dgl_id_t *>(traces->data);
#pragma omp parallel // FIXME: does OpenMP work with exceptions? Especially without throwing SIGABRT?
{ unsigned int random_seed = time(nullptr);
// get per-thread seed
unsigned int random_seed = time(nullptr) ^ omp_get_thread_num(); for (int i = 0; i < num_nodes; ++i) {
const dgl_id_t seed_id = seed_ids[i];
#pragma omp for
for (int i = 0; i < num_nodes; ++i) { for (int j = 0; j < num_traces; ++j) {
const dgl_id_t seed_id = seed_ids[i]; dgl_id_t cur = seed_id;
const int kmax = num_hops + 1;
for (int j = 0; j < num_traces; ++j) {
dgl_id_t cur = seed_id; for (int k = 0; k < kmax; ++k) {
const int kmax = num_hops + 1; const size_t offset = ((size_t)i * num_traces + j) * kmax + k;
trace_data[offset] = cur;
for (int k = 0; k < kmax; ++k) {
const size_t offset = ((size_t)i * num_traces + j) * kmax + k; const auto succ = gptr->SuccVec(cur);
trace_data[offset] = cur; const size_t size = succ.size();
if (size == 0) {
const auto succ = gptr->SuccVec(cur); LOG(FATAL) << "no successors from vertex " << cur;
const size_t size = succ.size(); return traces;
cur = succ[rand_r(&random_seed) % size];
} }
cur = succ[rand_r(&random_seed) % size];
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment