Skip to content

Commit

Permalink
[Performance]: Remove indptr correction for CooToCSR (dmlc#2356)
Browse files Browse the repository at this point in the history
  • Loading branch information
IzabelaMazur authored Nov 26, 2020
1 parent 00edb94 commit 6897f55
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/array/cpu/spmat_op_impl_coo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ CSRMatrix COOToCSR(COOMatrix coo) {
} else {
// compute indptr
IdType* Bp = static_cast<IdType*>(ret_indptr->data);
*(Bp++) = 0;
std::fill(Bp, Bp + N, 0);
for (int64_t i = 0; i < NNZ; ++i) {
Bp[row_data[i]]++;
Expand All @@ -352,7 +353,6 @@ CSRMatrix COOToCSR(COOMatrix coo) {
Bp[i] = cumsum;
cumsum += temp;
}
Bp[N] = NNZ;

// compute indices and data
ret_indices = NDArray::Empty({NNZ}, coo.row->dtype, coo.row->ctx);
Expand All @@ -366,13 +366,6 @@ CSRMatrix COOToCSR(COOMatrix coo) {
Bx[Bp[r]] = data? data[i] : i;
Bp[r]++;
}

// correct the indptr
for (int64_t i = 0, last = 0; i <= N; ++i) {
IdType temp = Bp[i];
Bp[i] = last;
last = temp;
}
}

return CSRMatrix(coo.num_rows, coo.num_cols,
Expand Down

0 comments on commit 6897f55

Please sign in to comment.