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
bd91e285
Commit
bd91e285
authored
May 22, 2020
by
rusty1s
Browse files
allow sampling of all nodes
parent
8fb5428b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
csrc/cpu/sample_cpu.cpp
csrc/cpu/sample_cpu.cpp
+24
-1
No files found.
csrc/cpu/sample_cpu.cpp
View file @
bd91e285
...
@@ -32,7 +32,30 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor rowcount,
...
@@ -32,7 +32,30 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor rowcount,
n_ids
.
push_back
(
i
);
n_ids
.
push_back
(
i
);
}
}
if
(
replace
)
{
// Sample with replacement ====================================
if
(
num_neighbors
<
0
)
{
// No sampling ======================================
int64_t
r
,
c
,
e
,
offset
=
0
;
for
(
int64_t
i
=
0
;
i
<
idx
.
size
(
0
);
i
++
)
{
r
=
idx_data
[
i
];
for
(
int64_t
j
=
0
;
j
<
rowcount_data
[
r
];
j
++
)
{
e
=
rowptr_data
[
r
]
+
j
;
c
=
col_data
[
e
];
if
(
n_id_map
.
count
(
c
)
==
0
)
{
n_id_map
[
c
]
=
n_ids
.
size
();
n_ids
.
push_back
(
c
);
}
cols
.
push_back
(
n_id_map
[
c
]);
e_ids
.
push_back
(
e
);
}
offset
=
cols
.
size
();
out_rowptr_data
[
i
+
1
]
=
offset
;
}
}
else
if
(
replace
)
{
// Sample with replacement ===============================
int64_t
r
,
c
,
e
,
offset
=
0
;
int64_t
r
,
c
,
e
,
offset
=
0
;
for
(
int64_t
i
=
0
;
i
<
idx
.
size
(
0
);
i
++
)
{
for
(
int64_t
i
=
0
;
i
<
idx
.
size
(
0
);
i
++
)
{
...
...
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