Skip to content

Commit

Permalink
Merge pull request #49032 from geetachavan1/cherrypicks_8HGXX
Browse files Browse the repository at this point in the history
Fix crash in `SparseTensorToCSRSparseMatrixCPUFunctor`
  • Loading branch information
mihaimaruseac committed May 10, 2021
2 parents 4940410 + 331bac4 commit c3d2748
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tensorflow/core/kernels/sparse/kernels.cc
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/platform/errors.h"

namespace tensorflow {
namespace functor {
Expand Down Expand Up @@ -63,6 +64,11 @@ Status SparseTensorToCSRSparseMatrixCPUFunctor::operator()(

for (int64 i = 0; i < total_nnz; ++i) {
// For now, the rows pointers store the corresponding row counts.
int64 ix = indices(i, 0) + 1;
if (ix >= csr_row_ptr.size()) {
return errors::InvalidArgument("Got an index ", ix,
" that is outside of csr_row_ptr");
}
csr_row_ptr(indices(i, 0) + 1) += 1;
csr_col_ind(i) = indices(i, 1);
}
Expand Down

0 comments on commit c3d2748

Please sign in to comment.