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
ac74233c
Unverified
Commit
ac74233c
authored
Mar 07, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Mar 07, 2020
Browse files
fix csrtocoo (#1324)
parent
9caff617
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
src/array/cpu/spmat_op_impl.cc
src/array/cpu/spmat_op_impl.cc
+3
-4
No files found.
src/array/cpu/spmat_op_impl.cc
View file @
ac74233c
...
...
@@ -392,14 +392,13 @@ template COOMatrix CSRToCOO<kDLCPU, int64_t>(CSRMatrix csr);
// complexity: time O(NNZ), space O(1)
template
<
DLDeviceType
XPU
,
typename
IdType
>
COOMatrix
CSRToCOODataAsOrder
(
CSRMatrix
csr
)
{
CHECK
(
CSRHasData
(
csr
))
<<
"missing data array."
;
const
int64_t
N
=
csr
.
num_rows
;
const
int64_t
M
=
csr
.
num_cols
;
const
int64_t
nnz
=
csr
.
indices
->
shape
[
0
];
const
IdType
*
indptr_data
=
static_cast
<
IdType
*>
(
csr
.
indptr
->
data
);
const
IdType
*
indices_data
=
static_cast
<
IdType
*>
(
csr
.
indices
->
data
);
// data array should have the same type as the indices arrays
const
IdType
*
data
=
static_cast
<
IdType
*>
(
csr
.
data
->
data
);
const
IdType
*
data
=
CSRHasData
(
csr
)
?
static_cast
<
IdType
*>
(
csr
.
data
->
data
)
:
nullptr
;
NDArray
ret_row
=
NDArray
::
Empty
({
nnz
},
csr
.
indices
->
dtype
,
csr
.
indices
->
ctx
);
NDArray
ret_col
=
NDArray
::
Empty
({
nnz
},
csr
.
indices
->
dtype
,
csr
.
indices
->
ctx
);
IdType
*
ret_row_data
=
static_cast
<
IdType
*>
(
ret_row
->
data
);
...
...
@@ -408,8 +407,8 @@ COOMatrix CSRToCOODataAsOrder(CSRMatrix csr) {
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
[
j
]
]
=
row
;
ret_col_data
[
data
[
j
]
]
=
col
;
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