-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][Presburger] Add enum based dispatch for isEmpty #93010
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
Open
Groverkss
wants to merge
3
commits into
llvm:main
Choose a base branch
from
Groverkss:presburger-equality-enum
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,20 @@ struct SymbolicLexOpt; | |
/// The type of bound: equal, lower bound or upper bound. | ||
enum class BoundType { EQ, LB, UB }; | ||
|
||
/// The kind of solver to use for emptiness check. | ||
/// TODO: We should have some docs to explain the user what kind of solver | ||
/// should fit best for their use case. | ||
enum class SolverKind { | ||
// Integer Exact algorithm. | ||
IntegerSimplex, | ||
// Rational Exact algorithm. | ||
RationalSimplex, | ||
// Rationly Exact algorithm. | ||
FourierMotzkin, | ||
// Fast heuristic based algorithm (no guarantees). | ||
FastHeuristics | ||
}; | ||
|
||
/// An IntegerRelation represents the set of points from a PresburgerSpace that | ||
/// satisfy a list of affine constraints. Affine constraints can be inequalities | ||
/// or equalities in the form: | ||
|
@@ -366,26 +380,9 @@ class IntegerRelation { | |
SmallVectorImpl<unsigned> *eqIndices = nullptr, | ||
unsigned offset = 0, unsigned num = 0) const; | ||
|
||
/// Checks for emptiness by performing variable elimination on all | ||
/// variables, running the GCD test on each equality constraint, and | ||
/// checking for invalid constraints. Returns true if the GCD test fails for | ||
/// any equality, or if any invalid constraints are discovered on any row. | ||
/// Returns false otherwise. | ||
bool isEmpty() const; | ||
|
||
/// Performs GCD checks and invalid constraint checks. | ||
bool isObviouslyEmpty() const; | ||
|
||
/// Runs the GCD test on all equality constraints. Returns true if this test | ||
/// fails on any equality. Returns false otherwise. | ||
/// This test can be used to disprove the existence of a solution. If it | ||
/// returns true, no integer solution to the equality constraints can exist. | ||
bool isEmptyByGCDTest() const; | ||
|
||
/// Returns true if the set of constraints is found to have no solution, | ||
/// false if a solution exists. Uses the same algorithm as | ||
/// `findIntegerSample`. | ||
bool isIntegerEmpty() const; | ||
/// Check if the given relation/polyhedron is empty. The emptiness guarantees | ||
/// depend on the solver used. | ||
bool isEmpty(SolverKind kind) const; | ||
|
||
/// Returns a matrix where each row is a vector along which the polytope is | ||
/// bounded. The span of the returned vectors is guaranteed to contain all | ||
|
@@ -754,6 +751,30 @@ class IntegerRelation { | |
return computeConstantLowerOrUpperBound<isLower>(pos).map(int64FromMPInt); | ||
} | ||
|
||
/// Checks for emptiness by performing variable elimination on all | ||
/// variables, running the GCD test on each equality constraint, and | ||
/// checking for invalid constraints. Returns true if the GCD test fails for | ||
/// any equality, or if any invalid constraints are discovered on any row. | ||
/// Returns false otherwise. | ||
bool isEmptyByFMTest() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can some of these tests conservatively return "false" or "true" if no certain decision could be made? I.e., false positives / negatives? If so, can we explicitly mention that for each of the function calls? |
||
|
||
/// Performs GCD checks and invalid constraint checks. | ||
bool isObviouslyEmpty() const; | ||
|
||
/// Runs the GCD test on all equality constraints. Returns true if this test | ||
/// fails on any equality. Returns false otherwise. | ||
/// This test can be used to disprove the existence of a solution. If it | ||
/// returns true, no integer solution to the equality constraints can exist. | ||
bool isEmptyByGCDTest() const; | ||
|
||
/// Returns true if the set of constraints is found to have no integer | ||
/// solution, false if a solution exists. | ||
bool isIntegerEmpty() const; | ||
|
||
/// Returns true if the set of constraints is found to have no rational | ||
/// solution, false if a solution exists. | ||
bool isRationalEmpty() const; | ||
|
||
/// Eliminates a single variable at `position` from equality and inequality | ||
/// constraints. Returns `success` if the variable was eliminated, and | ||
/// `failure` otherwise. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?