Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Validation #770

Draft
wants to merge 30 commits into
base: develop
Choose a base branch
from
Draft

Conversation

greole
Copy link
Collaborator

@greole greole commented May 20, 2021

This PR implements data validation strategies as outlined in #746. The aim is to provide a set of validation functions, to evaluate the validity of matrices for debug builds.

The implementation is done in several stages:

  • Free functions checking:

    • If a given matrix is symmetric.
    • If a given matrix has a non-zero diagonal.
    • If given indices are ordered.
    • If given indices are within given bounds.
    • If given indices are unique.
    • If given values are finite.
    • If differences in indices are below given value.
    • If matrix is triangular.
  • Matrices:

    • Coo: Values are finite, bounded indices (row,column), row pointers are ordered.
    • Csr: Values are finite, indices are within bounds, row_ptr are sorted and unique.
    • Ell: Values are finite, column index is within bounds
    • Diagonal: Values are finite.
    • Dense: Values are finite.
    • Fbcsr: Values are finite, indices are within bounds, row_ptr are sorted and unique.
    • Hybrid: The underlying Coo and Ell matrix are valid.
    • Permutation: indices are unique wrt the permutation.
    • Sellp: Slice offsets are non-descending, slice lengths are consistent with slice offsets.
  • Factorizations:

    • Check if output is valid and has non-zero diagonal
    • IC: check if diagonal entries are >0 and if input matrix is symmetric
  • Preconditioners:

    • Jacobi: The block pointers need to be ascending with gaps smaller than max_block_size
    • Jacobi: The blocks must be invertible/inverted blocks must contain finite values
    • Ic: The system matrix must be symmetric
    • Ilu:
    • Isai: The output must be a valid Csr matrix
  • Solvers:

    • All solvers: system matrix is valid
    • Iterative solvers: preconditioner is valid
    • CG: system matrix is symmetric.
    • Upper/LowerTrs: system matrix needs to be triangular with non-zero diagonal entries.

greole added 13 commits May 8, 2021 11:17
- reuse CALL_AND_RETURN_IF_CASTABLE macro
- generalise GKO_CALL_FOR_EACH_(NON_COMPLEX)_VALUE_AND_INDEX_TYPE
* add prefixed macro definition

* Data validation macro generalisation fix windows (#2)

* check if linebreak causes windows build to break

* check if linebreak causes windows build to break

* check if empty macro arg causes windows build to break

* test if removing VA_ARGS resolves msvc error

* test PASS_ON hack

* Add missing PASS_ON

* Add tests for complex values is_finite tests

* Refactor macro expansion macro

* Test if PASS_ON is needed when calling GKO_APPLY_MACRO

* Refactor CALL_AND_RETURN_IF_CASTABLE macro

* Moves GKO_CALL_FOR_... macros to types.hpp
@greole greole added is:enhancement An improvement of an existing feature. mod:core This is related to the core module. type:solver This is related to the solvers type:preconditioner This is related to the preconditioners type:matrix-format This is related to the Matrix formats 1:ST:WIP This PR is a work in progress. Not ready for review. type:factorization This is related to the Factorizations labels May 20, 2021
@greole greole self-assigned this May 20, 2021
- includes unit tests for is_*_triangular
- unit tests for matrix validation function are testing for Coo and Csr
- some minor fixes
@upsj upsj added this to the Ginkgo 1.4.0 milestone May 22, 2021
1. Unit tests are simplified and are only based on Coo, because the
validation helpers rely on matrix_data and conversion to the specific
matrix data type is tested elsewhere.

2. The predicate for all_of has been corrected by inverting it.

3. The non_zero_diagonal now also tests for missing elements.
@greole greole linked an issue May 25, 2021 that may be closed by this pull request
@upsj upsj removed this from the Ginkgo 1.4.0 milestone May 31, 2021
@greole greole added 1:ST:ready-to-merge This PR is ready to merge. 1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. 1:ST:WIP This PR is a work in progress. Not ready for review. and removed 1:ST:WIP This PR is a work in progress. Not ready for review. 1:ST:ready-to-merge This PR is ready to merge. 1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. labels Nov 2, 2021
@upsj upsj mentioned this pull request Feb 22, 2022
1 task
@tcojean tcojean removed this from the Ginkgo 1.5.0 milestone Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:WIP This PR is a work in progress. Not ready for review. is:enhancement An improvement of an existing feature. mod:core This is related to the core module. type:factorization This is related to the Factorizations type:matrix-format This is related to the Matrix formats type:preconditioner This is related to the preconditioners type:solver This is related to the solvers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data validation and invariants
3 participants