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
31a81438
Unverified
Commit
31a81438
authored
Jun 06, 2022
by
Quan (Andy) Gan
Committed by
GitHub
Jun 06, 2022
Browse files
parallelize csr2coo (#4081)
Co-authored-by:
Xin Yao
<
xiny@nvidia.com
>
parent
6014623d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
src/array/cpu/spmat_op_impl_csr.cc
src/array/cpu/spmat_op_impl_csr.cc
+15
-11
No files found.
src/array/cpu/spmat_op_impl_csr.cc
View file @
31a81438
...
...
@@ -291,11 +291,13 @@ COOMatrix CSRToCOO(CSRMatrix csr) {
const
IdType
*
indptr_data
=
static_cast
<
IdType
*>
(
csr
.
indptr
->
data
);
NDArray
ret_row
=
NDArray
::
Empty
({
nnz
},
csr
.
indices
->
dtype
,
csr
.
indices
->
ctx
);
IdType
*
ret_row_data
=
static_cast
<
IdType
*>
(
ret_row
->
data
);
for
(
IdType
i
=
0
;
i
<
csr
.
indptr
->
shape
[
0
]
-
1
;
++
i
)
{
std
::
fill
(
ret_row_data
+
indptr_data
[
i
],
ret_row_data
+
indptr_data
[
i
+
1
],
i
);
}
parallel_for
(
0
,
csr
.
indptr
->
shape
[
0
]
-
1
,
10000
,
[
=
](
int64_t
b
,
int64_t
e
)
{
for
(
auto
i
=
b
;
i
<
e
;
++
i
)
{
std
::
fill
(
ret_row_data
+
indptr_data
[
i
],
ret_row_data
+
indptr_data
[
i
+
1
],
i
);
}
});
return
COOMatrix
(
csr
.
num_rows
,
csr
.
num_cols
,
ret_row
,
csr
.
indices
,
csr
.
data
,
true
,
csr
.
sorted
);
...
...
@@ -319,13 +321,15 @@ COOMatrix CSRToCOODataAsOrder(CSRMatrix csr) {
IdType
*
ret_row_data
=
static_cast
<
IdType
*>
(
ret_row
->
data
);
IdType
*
ret_col_data
=
static_cast
<
IdType
*>
(
ret_col
->
data
);
// scatter using the indices in the data array
for
(
IdType
row
=
0
;
row
<
N
;
++
row
)
{
for
(
IdType
j
=
indptr_data
[
row
];
j
<
indptr_data
[
row
+
1
];
++
j
)
{
const
IdType
col
=
indices_data
[
j
];
ret_row_data
[
data
?
data
[
j
]
:
j
]
=
row
;
ret_col_data
[
data
?
data
[
j
]
:
j
]
=
col
;
parallel_for
(
0
,
N
,
10000
,
[
=
](
int64_t
b
,
int64_t
e
)
{
for
(
auto
row
=
b
;
row
<
e
;
++
row
)
{
for
(
IdType
j
=
indptr_data
[
row
];
j
<
indptr_data
[
row
+
1
];
++
j
)
{
const
IdType
col
=
indices_data
[
j
];
ret_row_data
[
data
?
data
[
j
]
:
j
]
=
row
;
ret_col_data
[
data
?
data
[
j
]
:
j
]
=
col
;
}
}
}
}
);
return
COOMatrix
(
N
,
M
,
ret_row
,
ret_col
);
}
...
...
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