From 57b1572c3c49be51635fcea7bf403516b1da932e Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 08:03:37 +0000 Subject: [PATCH 01/12] 1 --- src/array/cpu/spmat_op_impl_coo.cc | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index ae486219a4b9..34822f372866 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -323,6 +324,17 @@ template CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const data = COOHasData(coo) ? static_cast(coo.data->data) : nullptr; @@ -418,6 +430,17 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -542,6 +565,17 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -637,6 +671,17 @@ template CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *row_data = static_cast(coo.row->data); const IdType *col_data = static_cast(coo.col->data); const IdType *data = From 73dc41336ee6b88e5db17b6a0651e5e55fb10f31 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 08:12:55 +0000 Subject: [PATCH 02/12] lint --- src/array/cpu/spmat_op_impl_coo.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 34822f372866..414de8c57477 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -325,7 +325,7 @@ CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -431,7 +431,7 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -566,7 +566,7 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -672,7 +672,7 @@ CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. From fbb319d5dd920c840978a04311b25bd15fbd3f3e Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 10:10:09 +0000 Subject: [PATCH 03/12] rm --- src/array/cpu/spmat_op_impl_coo.cc | 45 ------------------------------ 1 file changed, 45 deletions(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 414de8c57477..ae486219a4b9 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -324,17 +323,6 @@ template CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const data = COOHasData(coo) ? static_cast(coo.data->data) : nullptr; @@ -430,17 +418,6 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -565,17 +542,6 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -671,17 +637,6 @@ template CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *row_data = static_cast(coo.row->data); const IdType *col_data = static_cast(coo.col->data); const IdType *data = From 1b0b40c5af8d6e56cefa349d96990d835c73050a Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 10:30:09 +0000 Subject: [PATCH 04/12] use macro --- src/array/cpu/spmat_op_impl_coo.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index ae486219a4b9..1d4c6525cbb1 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -746,6 +746,9 @@ inline COOToCSRAlg WhichCOOToCSR(const COOMatrix &coo) { template CSRMatrix COOToCSR(COOMatrix coo) { + if (std::is_same::value) { + CHECK_NO_OVERFLOW(coo.row->dtype, coo.row->shape[0]); + } switch (WhichCOOToCSR(coo)) { case COOToCSRAlg::sorted: return SortedCOOToCSR(coo); From 7c1fd12329dca79812be6f0d9c7d98457a0f36c8 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 11:33:48 +0000 Subject: [PATCH 05/12] add check in cuda file --- src/array/cuda/coo2csr.cu | 1 + 1 file changed, 1 insertion(+) diff --git a/src/array/cuda/coo2csr.cu b/src/array/cuda/coo2csr.cu index 1105adef6c82..237a35a26b3e 100644 --- a/src/array/cuda/coo2csr.cu +++ b/src/array/cuda/coo2csr.cu @@ -40,6 +40,7 @@ CSRMatrix COOToCSR(COOMatrix coo) { } const int64_t nnz = coo.row->shape[0]; + CHECK_NO_OVERFLOW(coo.row->dtype, nnz); // TODO(minjie): Many of our current implementation assumes that CSR must have // a data array. This is a temporary workaround. Remove this after: // - The old immutable graph implementation is deprecated. From e0ea0f93d8906c6e77d93addc209e1361aca2a6f Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 08:03:37 +0000 Subject: [PATCH 06/12] 1 --- src/array/cpu/spmat_op_impl_coo.cc | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index ae486219a4b9..34822f372866 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -323,6 +324,17 @@ template CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const data = COOHasData(coo) ? static_cast(coo.data->data) : nullptr; @@ -418,6 +430,17 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -542,6 +565,17 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -637,6 +671,17 @@ template CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; + + // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // exceed INT32_MAX, preventing overflow issues that could lead to undefined + // behavior or incorrect results. Later we need to suppoort larger values of + // NNZ. + if (std::is_same::value && + NNZ > std::numeric_limits::max()) { + LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " + "can be represented by int32_t for IdType int32_t."; + } + const IdType *row_data = static_cast(coo.row->data); const IdType *col_data = static_cast(coo.col->data); const IdType *data = From fae0f4ea479eae0fd5985dc821928ef1da311083 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 08:12:55 +0000 Subject: [PATCH 07/12] lint --- src/array/cpu/spmat_op_impl_coo.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 34822f372866..414de8c57477 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -325,7 +325,7 @@ CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -431,7 +431,7 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -566,7 +566,7 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. @@ -672,7 +672,7 @@ CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - // TODO[Mingbang]: This is just a temporary check to ensure that NNZ does not + // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not // exceed INT32_MAX, preventing overflow issues that could lead to undefined // behavior or incorrect results. Later we need to suppoort larger values of // NNZ. From bb9d2f1c85672a1ce9d7f9e03708465589c47071 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 10:10:09 +0000 Subject: [PATCH 08/12] rm --- src/array/cpu/spmat_op_impl_coo.cc | 45 ------------------------------ 1 file changed, 45 deletions(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 414de8c57477..ae486219a4b9 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -324,17 +323,6 @@ template CSRMatrix SortedCOOToCSR(const COOMatrix &coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const data = COOHasData(coo) ? static_cast(coo.data->data) : nullptr; @@ -430,17 +418,6 @@ CSRMatrix UnSortedSparseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -565,17 +542,6 @@ CSRMatrix UnSortedDenseCOOToCSR(const COOMatrix &coo) { const UIdType N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *const row_data = static_cast(coo.row->data); const IdType *const col_data = static_cast(coo.col->data); const IdType *const data = @@ -671,17 +637,6 @@ template CSRMatrix UnSortedSmallCOOToCSR(COOMatrix coo) { const int64_t N = coo.num_rows; const int64_t NNZ = coo.row->shape[0]; - - // TODO(Mingbang): This is just a temporary check to ensure that NNZ does not - // exceed INT32_MAX, preventing overflow issues that could lead to undefined - // behavior or incorrect results. Later we need to suppoort larger values of - // NNZ. - if (std::is_same::value && - NNZ > std::numeric_limits::max()) { - LOG(FATAL) << "Number of non zero elements exceeds the maximum value that " - "can be represented by int32_t for IdType int32_t."; - } - const IdType *row_data = static_cast(coo.row->data); const IdType *col_data = static_cast(coo.col->data); const IdType *data = From 14ac2efa5bd04af63578a95c6824b764289cd071 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 10:30:09 +0000 Subject: [PATCH 09/12] use macro --- src/array/cpu/spmat_op_impl_coo.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index ae486219a4b9..1d4c6525cbb1 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -746,6 +746,9 @@ inline COOToCSRAlg WhichCOOToCSR(const COOMatrix &coo) { template CSRMatrix COOToCSR(COOMatrix coo) { + if (std::is_same::value) { + CHECK_NO_OVERFLOW(coo.row->dtype, coo.row->shape[0]); + } switch (WhichCOOToCSR(coo)) { case COOToCSRAlg::sorted: return SortedCOOToCSR(coo); From 86f8846ab0b4c5f54ae8732d8a39e331079ca596 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Thu, 13 Jun 2024 11:33:48 +0000 Subject: [PATCH 10/12] add check in cuda file --- src/array/cuda/coo2csr.cu | 1 + 1 file changed, 1 insertion(+) diff --git a/src/array/cuda/coo2csr.cu b/src/array/cuda/coo2csr.cu index 1105adef6c82..237a35a26b3e 100644 --- a/src/array/cuda/coo2csr.cu +++ b/src/array/cuda/coo2csr.cu @@ -40,6 +40,7 @@ CSRMatrix COOToCSR(COOMatrix coo) { } const int64_t nnz = coo.row->shape[0]; + CHECK_NO_OVERFLOW(coo.row->dtype, nnz); // TODO(minjie): Many of our current implementation assumes that CSR must have // a data array. This is a temporary workaround. Remove this after: // - The old immutable graph implementation is deprecated. From 55d82c4fcf5a8b028cfa9ea13cf9f81ef8a74ec9 Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Fri, 14 Jun 2024 08:58:05 +0000 Subject: [PATCH 11/12] constexpr --- src/array/cpu/spmat_op_impl_coo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 1d4c6525cbb1..4cae367110d9 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -746,7 +746,7 @@ inline COOToCSRAlg WhichCOOToCSR(const COOMatrix &coo) { template CSRMatrix COOToCSR(COOMatrix coo) { - if (std::is_same::value) { + if constexpr (std::is_same::value) { CHECK_NO_OVERFLOW(coo.row->dtype, coo.row->shape[0]); } switch (WhichCOOToCSR(coo)) { From f7388fea5c1758241d44908cd21765d296b8b08c Mon Sep 17 00:00:00 2001 From: Skeleton003 <799284168@qq.com> Date: Mon, 17 Jun 2024 02:48:30 +0000 Subject: [PATCH 12/12] remove if --- src/array/cpu/spmat_op_impl_coo.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/array/cpu/spmat_op_impl_coo.cc b/src/array/cpu/spmat_op_impl_coo.cc index 4cae367110d9..e5caf5d3015b 100644 --- a/src/array/cpu/spmat_op_impl_coo.cc +++ b/src/array/cpu/spmat_op_impl_coo.cc @@ -746,9 +746,7 @@ inline COOToCSRAlg WhichCOOToCSR(const COOMatrix &coo) { template CSRMatrix COOToCSR(COOMatrix coo) { - if constexpr (std::is_same::value) { - CHECK_NO_OVERFLOW(coo.row->dtype, coo.row->shape[0]); - } + CHECK_NO_OVERFLOW(coo.row->dtype, coo.row->shape[0]); switch (WhichCOOToCSR(coo)) { case COOToCSRAlg::sorted: return SortedCOOToCSR(coo);