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
dgl
Commits
05c53ca3
Unverified
Commit
05c53ca3
authored
Apr 05, 2021
by
Quan (Andy) Gan
Committed by
GitHub
Apr 05, 2021
Browse files
[Performance] Prefer parallelized conversion to CSC from COO instead of transposing CSR (#2793)
* fix coo2csr speed * add comments
parent
86229d42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/graph/unit_graph.cc
src/graph/unit_graph.cc
+13
-9
No files found.
src/graph/unit_graph.cc
View file @
05c53ca3
...
@@ -1310,18 +1310,20 @@ UnitGraph::CSRPtr UnitGraph::GetInCSR(bool inplace) const {
...
@@ -1310,18 +1310,20 @@ UnitGraph::CSRPtr UnitGraph::GetInCSR(bool inplace) const {
LOG
(
FATAL
)
<<
"The graph have restricted sparse format "
<<
LOG
(
FATAL
)
<<
"The graph have restricted sparse format "
<<
CodeToStr
(
formats_
)
<<
", cannot create CSC matrix."
;
CodeToStr
(
formats_
)
<<
", cannot create CSC matrix."
;
CSRPtr
ret
=
in_csr_
;
CSRPtr
ret
=
in_csr_
;
// Prefers converting from COO since it is parallelized.
// TODO(BarclayII): need benchmarking.
if
(
!
in_csr_
->
defined
())
{
if
(
!
in_csr_
->
defined
())
{
if
(
out_csr_
->
defined
())
{
if
(
coo_
->
defined
())
{
const
auto
&
newadj
=
aten
::
CSRTranspose
(
out_csr_
->
adj
());
const
auto
&
newadj
=
aten
::
COOToCSR
(
aten
::
COOTranspose
(
coo_
->
adj
()));
if
(
inplace
)
if
(
inplace
)
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
in_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
in_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
else
else
ret
=
std
::
make_shared
<
CSR
>
(
meta_graph
(),
newadj
);
ret
=
std
::
make_shared
<
CSR
>
(
meta_graph
(),
newadj
);
}
else
{
}
else
{
CHECK
(
coo_
->
defined
())
<<
"None of CSR, COO exist"
;
CHECK
(
out_csr_
->
defined
())
<<
"None of CSR, COO exist"
;
const
auto
&
newadj
=
aten
::
COOToCSR
(
const
auto
&
newadj
=
aten
::
CSRTranspose
(
out_csr_
->
adj
());
aten
::
COOTranspose
(
coo_
->
adj
()));
if
(
inplace
)
if
(
inplace
)
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
in_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
in_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
...
@@ -1339,17 +1341,19 @@ UnitGraph::CSRPtr UnitGraph::GetOutCSR(bool inplace) const {
...
@@ -1339,17 +1341,19 @@ UnitGraph::CSRPtr UnitGraph::GetOutCSR(bool inplace) const {
LOG
(
FATAL
)
<<
"The graph have restricted sparse format "
<<
LOG
(
FATAL
)
<<
"The graph have restricted sparse format "
<<
CodeToStr
(
formats_
)
<<
", cannot create CSR matrix."
;
CodeToStr
(
formats_
)
<<
", cannot create CSR matrix."
;
CSRPtr
ret
=
out_csr_
;
CSRPtr
ret
=
out_csr_
;
// Prefers converting from COO since it is parallelized.
// TODO(BarclayII): need benchmarking.
if
(
!
out_csr_
->
defined
())
{
if
(
!
out_csr_
->
defined
())
{
if
(
in_csr
_
->
defined
())
{
if
(
coo
_
->
defined
())
{
const
auto
&
newadj
=
aten
::
C
SRTranspose
(
in_csr
_
->
adj
());
const
auto
&
newadj
=
aten
::
C
OOToCSR
(
coo
_
->
adj
());
if
(
inplace
)
if
(
inplace
)
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
out_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
out_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
else
else
ret
=
std
::
make_shared
<
CSR
>
(
meta_graph
(),
newadj
);
ret
=
std
::
make_shared
<
CSR
>
(
meta_graph
(),
newadj
);
}
else
{
}
else
{
CHECK
(
coo
_
->
defined
())
<<
"None of CSR, COO exist"
;
CHECK
(
in_csr
_
->
defined
())
<<
"None of CSR, COO exist"
;
const
auto
&
newadj
=
aten
::
C
OOToCSR
(
coo
_
->
adj
());
const
auto
&
newadj
=
aten
::
C
SRTranspose
(
in_csr
_
->
adj
());
if
(
inplace
)
if
(
inplace
)
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
out_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
*
(
const_cast
<
UnitGraph
*>
(
this
)
->
out_csr_
)
=
CSR
(
meta_graph
(),
newadj
);
...
...
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