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-cluster
Commits
e465ac09
Unverified
Commit
e465ac09
authored
Jun 14, 2019
by
Matthias Fey
Committed by
GitHub
Jun 14, 2019
Browse files
Merge pull request #23 from Dawars/patch-2
Fixes breakage with PyTorch nightly #22
parents
f7e9e8fd
88a60c40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
cpu/sampler.cpp
cpu/sampler.cpp
+3
-7
No files found.
cpu/sampler.cpp
View file @
e465ac09
#include <
TH/THRandom
.h>
#include <
ATen/CPUGenerator
.h>
#include <torch/extension.h>
#include <TH/THGenerator.hpp>
at
::
Tensor
neighbor_sampler
(
at
::
Tensor
start
,
at
::
Tensor
cumdeg
,
size_t
size
,
float
factor
)
{
TH
Generator
*
generator
=
TH
Generator
_new
();
CPU
Generator
*
generator
=
at
::
detail
::
getDefaultCPU
Generator
();
auto
start_ptr
=
start
.
data
<
int64_t
>
();
auto
cumdeg_ptr
=
cumdeg
.
data
<
int64_t
>
();
...
...
@@ -26,7 +24,7 @@ at::Tensor neighbor_sampler(at::Tensor start, at::Tensor cumdeg, size_t size,
std
::
unordered_set
<
int64_t
>
set
;
if
(
size_i
<
0.7
*
float
(
num_neighbors
))
{
while
(
set
.
size
()
<
size_i
)
{
int64_t
z
=
THRandom_random
(
generator
)
%
num_neighbors
;
int64_t
z
=
generator
->
random
(
)
%
num_neighbors
;
set
.
insert
(
z
+
low
);
}
std
::
vector
<
int64_t
>
v
(
set
.
begin
(),
set
.
end
());
...
...
@@ -40,8 +38,6 @@ at::Tensor neighbor_sampler(at::Tensor start, at::Tensor cumdeg, size_t size,
}
}
THGenerator_free
(
generator
);
int64_t
len
=
e_ids
.
size
();
auto
e_id
=
torch
::
from_blob
(
e_ids
.
data
(),
{
len
},
start
.
options
()).
clone
();
return
e_id
;
...
...
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