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
ec7c59f0
Commit
ec7c59f0
authored
Aug 10, 2021
by
rusty1s
Browse files
initialize random seed
parent
84b46170
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
0 deletions
+10
-0
csrc/cpu/ego_sample_cpu.cpp
csrc/cpu/ego_sample_cpu.cpp
+2
-0
csrc/cpu/hgt_sample_cpu.cpp
csrc/cpu/hgt_sample_cpu.cpp
+2
-0
csrc/cpu/neighbor_sample_cpu.cpp
csrc/cpu/neighbor_sample_cpu.cpp
+4
-0
csrc/cpu/sample_cpu.cpp
csrc/cpu/sample_cpu.cpp
+2
-0
No files found.
csrc/cpu/ego_sample_cpu.cpp
View file @
ec7c59f0
...
@@ -15,6 +15,8 @@ ego_k_hop_sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col,
...
@@ -15,6 +15,8 @@ ego_k_hop_sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col,
torch
::
Tensor
idx
,
int64_t
depth
,
torch
::
Tensor
idx
,
int64_t
depth
,
int64_t
num_neighbors
,
bool
replace
)
{
int64_t
num_neighbors
,
bool
replace
)
{
srand
(
time
(
NULL
)
+
1000
*
getpid
());
// Initialize random seed.
std
::
vector
<
torch
::
Tensor
>
out_rowptrs
(
idx
.
numel
()
+
1
);
std
::
vector
<
torch
::
Tensor
>
out_rowptrs
(
idx
.
numel
()
+
1
);
std
::
vector
<
torch
::
Tensor
>
out_cols
(
idx
.
numel
());
std
::
vector
<
torch
::
Tensor
>
out_cols
(
idx
.
numel
());
std
::
vector
<
torch
::
Tensor
>
out_n_ids
(
idx
.
numel
());
std
::
vector
<
torch
::
Tensor
>
out_n_ids
(
idx
.
numel
());
...
...
csrc/cpu/hgt_sample_cpu.cpp
View file @
ec7c59f0
...
@@ -101,6 +101,8 @@ hgt_sample_cpu(const c10::Dict<rel_t, torch::Tensor> &colptr_dict,
...
@@ -101,6 +101,8 @@ hgt_sample_cpu(const c10::Dict<rel_t, torch::Tensor> &colptr_dict,
const
c10
::
Dict
<
node_t
,
vector
<
int64_t
>>
&
num_samples_dict
,
const
c10
::
Dict
<
node_t
,
vector
<
int64_t
>>
&
num_samples_dict
,
const
int64_t
num_hops
)
{
const
int64_t
num_hops
)
{
srand
(
time
(
NULL
)
+
1000
*
getpid
());
// Initialize random seed.
// Create a mapping to convert single string relations to edge type triplets:
// Create a mapping to convert single string relations to edge type triplets:
unordered_map
<
rel_t
,
edge_t
>
to_edge_type
;
unordered_map
<
rel_t
,
edge_t
>
to_edge_type
;
for
(
const
auto
&
kv
:
colptr_dict
)
{
for
(
const
auto
&
kv
:
colptr_dict
)
{
...
...
csrc/cpu/neighbor_sample_cpu.cpp
View file @
ec7c59f0
...
@@ -11,6 +11,8 @@ tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
...
@@ -11,6 +11,8 @@ tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
sample
(
const
torch
::
Tensor
&
colptr
,
const
torch
::
Tensor
&
row
,
sample
(
const
torch
::
Tensor
&
colptr
,
const
torch
::
Tensor
&
row
,
const
torch
::
Tensor
&
input_node
,
const
vector
<
int64_t
>
num_neighbors
)
{
const
torch
::
Tensor
&
input_node
,
const
vector
<
int64_t
>
num_neighbors
)
{
srand
(
time
(
NULL
)
+
1000
*
getpid
());
// Initialize random seed.
// Initialize some data structures for the sampling process:
// Initialize some data structures for the sampling process:
vector
<
int64_t
>
samples
;
vector
<
int64_t
>
samples
;
unordered_map
<
int64_t
,
int64_t
>
to_local_node
;
unordered_map
<
int64_t
,
int64_t
>
to_local_node
;
...
@@ -121,6 +123,8 @@ hetero_sample(const vector<node_t> &node_types,
...
@@ -121,6 +123,8 @@ hetero_sample(const vector<node_t> &node_types,
const
c10
::
Dict
<
rel_t
,
vector
<
int64_t
>>
&
num_neighbors_dict
,
const
c10
::
Dict
<
rel_t
,
vector
<
int64_t
>>
&
num_neighbors_dict
,
const
int64_t
num_hops
)
{
const
int64_t
num_hops
)
{
srand
(
time
(
NULL
)
+
1000
*
getpid
());
// Initialize random seed.
// Create a mapping to convert single string relations to edge type triplets:
// Create a mapping to convert single string relations to edge type triplets:
unordered_map
<
rel_t
,
edge_t
>
to_edge_type
;
unordered_map
<
rel_t
,
edge_t
>
to_edge_type
;
for
(
const
auto
&
k
:
edge_types
)
for
(
const
auto
&
k
:
edge_types
)
...
...
csrc/cpu/sample_cpu.cpp
View file @
ec7c59f0
...
@@ -11,6 +11,8 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
...
@@ -11,6 +11,8 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
CHECK_CPU
(
idx
);
CHECK_CPU
(
idx
);
CHECK_INPUT
(
idx
.
dim
()
==
1
);
CHECK_INPUT
(
idx
.
dim
()
==
1
);
srand
(
time
(
NULL
)
+
1000
*
getpid
());
// Initialize random seed.
auto
rowptr_data
=
rowptr
.
data_ptr
<
int64_t
>
();
auto
rowptr_data
=
rowptr
.
data_ptr
<
int64_t
>
();
auto
col_data
=
col
.
data_ptr
<
int64_t
>
();
auto
col_data
=
col
.
data_ptr
<
int64_t
>
();
auto
idx_data
=
idx
.
data_ptr
<
int64_t
>
();
auto
idx_data
=
idx
.
data_ptr
<
int64_t
>
();
...
...
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