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
5931f37b
Commit
5931f37b
authored
Nov 11, 2020
by
rusty1s
Browse files
slightly faster sampling
parent
fe35bc61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
csrc/cpu/sample_cpu.cpp
csrc/cpu/sample_cpu.cpp
+8
-7
No files found.
csrc/cpu/sample_cpu.cpp
View file @
5931f37b
...
...
@@ -19,7 +19,7 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
auto
out_rowptr_data
=
out_rowptr
.
data_ptr
<
int64_t
>
();
out_rowptr_data
[
0
]
=
0
;
std
::
vector
<
std
::
multiset
<
int64_t
>>
cols
;
std
::
vector
<
std
::
vector
<
int64_t
>>
cols
;
std
::
vector
<
int64_t
>
n_ids
;
std
::
unordered_map
<
int64_t
,
int64_t
>
n_id_map
;
std
::
vector
<
int64_t
>
e_ids
;
...
...
@@ -27,7 +27,7 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
int64_t
i
;
for
(
int64_t
n
=
0
;
n
<
idx
.
numel
();
n
++
)
{
i
=
idx_data
[
n
];
cols
.
push_back
(
std
::
multiset
<
int64_t
>
());
cols
.
push_back
(
std
::
vector
<
int64_t
>
());
n_id_map
[
i
]
=
n
;
n_ids
.
push_back
(
i
);
}
...
...
@@ -50,7 +50,7 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
n_ids
.
push_back
(
c
);
}
cols
[
i
].
insert
(
n_id_map
[
c
]);
cols
[
i
].
push_back
(
n_id_map
[
c
]);
e_ids
.
push_back
(
e
);
}
out_rowptr_data
[
i
+
1
]
=
out_rowptr_data
[
i
]
+
cols
[
i
].
size
();
...
...
@@ -73,7 +73,7 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
n_ids
.
push_back
(
c
);
}
cols
[
i
].
insert
(
n_id_map
[
c
]);
cols
[
i
].
push_back
(
n_id_map
[
c
]);
e_ids
.
push_back
(
c
);
}
out_rowptr_data
[
i
+
1
]
=
out_rowptr_data
[
i
]
+
cols
[
i
].
size
();
...
...
@@ -107,7 +107,7 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
n_ids
.
push_back
(
c
);
}
cols
[
i
].
insert
(
n_id_map
[
c
]);
cols
[
i
].
push_back
(
n_id_map
[
c
]);
e_ids
.
push_back
(
c
);
}
out_rowptr_data
[
i
+
1
]
=
out_rowptr_data
[
i
]
+
cols
[
i
].
size
();
...
...
@@ -122,8 +122,9 @@ sample_adj_cpu(torch::Tensor rowptr, torch::Tensor col, torch::Tensor idx,
auto
out_col_data
=
out_col
.
data_ptr
<
int64_t
>
();
i
=
0
;
for
(
const
std
::
multiset
<
int64_t
>
&
col_set
:
cols
)
{
for
(
const
int64_t
&
c
:
col_set
)
{
for
(
std
::
vector
<
int64_t
>
&
col_vec
:
cols
)
{
std
::
sort
(
col_vec
.
begin
(),
col_vec
.
end
());
for
(
const
int64_t
&
c
:
col_vec
)
{
out_col_data
[
i
]
=
c
;
i
+=
1
;
}
...
...
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