Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-sparse
Commits
2f3ecc3e
"tests/python/common/test_heterograph-kernel.py" did not exist on "dd65ee211ea5ec1c876d323c4387f066bee41a77"
Commit
2f3ecc3e
authored
Aug 26, 2021
by
rusty1s
Browse files
fix sample with replacement in case of isolated nodes
parent
87c88d95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
csrc/cpu/sample_cpu.cpp
csrc/cpu/sample_cpu.cpp
+10
-8
No files found.
csrc/cpu/sample_cpu.cpp
View file @
2f3ecc3e
...
@@ -63,15 +63,17 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
...
@@ -63,15 +63,17 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
row_start
=
rowptr_data
[
n
],
row_end
=
rowptr_data
[
n
+
1
];
row_start
=
rowptr_data
[
n
],
row_end
=
rowptr_data
[
n
+
1
];
row_count
=
row_end
-
row_start
;
row_count
=
row_end
-
row_start
;
for
(
int64_t
j
=
0
;
j
<
num_neighbors
;
j
++
)
{
if
(
row_count
>
0
)
{
e
=
row_start
+
rand
()
%
row_count
;
for
(
int64_t
j
=
0
;
j
<
num_neighbors
;
j
++
)
{
c
=
col_data
[
e
];
e
=
row_start
+
rand
()
%
row_count
;
c
=
col_data
[
e
];
if
(
n_id_map
.
count
(
c
)
==
0
)
{
n_id_map
[
c
]
=
n_ids
.
size
();
if
(
n_id_map
.
count
(
c
)
==
0
)
{
n_ids
.
push_back
(
c
);
n_id_map
[
c
]
=
n_ids
.
size
();
n_ids
.
push_back
(
c
);
}
cols
[
i
].
push_back
(
std
::
make_tuple
(
n_id_map
[
c
],
e
));
}
}
cols
[
i
].
push_back
(
std
::
make_tuple
(
n_id_map
[
c
],
e
));
}
}
out_rowptr_data
[
i
+
1
]
=
out_rowptr_data
[
i
]
+
cols
[
i
].
size
();
out_rowptr_data
[
i
+
1
]
=
out_rowptr_data
[
i
]
+
cols
[
i
].
size
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment