dpnp.scipy.sparse.csr_matrix.check_format

method

csr_matrix.check_format()[source]

Validate the CSR structure, raising ValueError if invalid.

oneMKL trusts indptr / indices and indexes the value array with them directly, so malformed input is an out-of-bounds device read rather than a clean error. The checks mirror scipy.sparse.csr_matrix.check_format():

  • indptr[0] == 0 and indptr non-decreasing,

  • indptr[-1] <= nnz (a larger value reads past data),

  • every column index within [0, N).

Called once automatically before the oneMKL handle is built (see _ensure_spmv_handle); the result is cached, so repeated matvecs on the same matrix re-validate nothing. Calling it directly is only needed to validate a matrix ahead of its first matvec.

Raises:
ValueError

If the CSR structure is malformed.