Skip to content

Commit cfd6ba8

Browse files
committed
[MLIR][Presburger] rename get*LexMin -> find*LexMin
This reflects the fact that we are performing some non-trivial computations here. Also, this is more uniform in line with findIntegerSample.
1 parent ad3b1fe commit cfd6ba8

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ class IntegerPolyhedron : public IntegerRelation {
255255
/// the lexmin is unbounded. Symbols are not supported and will result in
256256
/// assert-failure.
257257
presburger_utils::MaybeOptimum<SmallVector<Fraction, 8>>
258-
getRationalLexMin() const;
258+
findRationalLexMin() const;
259259

260260
/// Same as above, but returns lexicographically minimal integer point.
261261
/// Note: this should be used only when the lexmin is really required.
262262
/// For a generic integer sampling operation, findIntegerSample is more
263263
/// robust and should be preferred.
264264
presburger_utils::MaybeOptimum<SmallVector<int64_t, 8>>
265-
getIntegerLexMin() const;
265+
findIntegerLexMin() const;
266266

267267
/// Swap the posA^th identifier with the posB^th identifier.
268268
virtual void swapId(unsigned posA, unsigned posB);

mlir/include/mlir/Analysis/Presburger/Simplex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,13 @@ class LexSimplex : public SimplexBase {
438438
unsigned getSnapshot() { return SimplexBase::getSnapshotBasis(); }
439439

440440
/// Return the lexicographically minimum rational solution to the constraints.
441-
presburger_utils::MaybeOptimum<SmallVector<Fraction, 8>> getRationalLexMin();
441+
presburger_utils::MaybeOptimum<SmallVector<Fraction, 8>> findRationalLexMin();
442442

443443
/// Return the lexicographically minimum integer solution to the constraints.
444444
///
445445
/// Note: this should be used only when the lexmin is really needed. To obtain
446446
/// any integer sample, use Simplex::findIntegerSample as that is more robust.
447-
presburger_utils::MaybeOptimum<SmallVector<int64_t, 8>> getIntegerLexMin();
447+
presburger_utils::MaybeOptimum<SmallVector<int64_t, 8>> findIntegerLexMin();
448448

449449
protected:
450450
/// Returns the current sample point, which may contain non-integer (rational)

mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ bool IntegerPolyhedron::isSubsetOf(const IntegerPolyhedron &other) const {
7373
}
7474

7575
MaybeOptimum<SmallVector<Fraction, 8>>
76-
IntegerPolyhedron::getRationalLexMin() const {
76+
IntegerPolyhedron::findRationalLexMin() const {
7777
assert(getNumSymbolIds() == 0 && "Symbols are not supported!");
7878
MaybeOptimum<SmallVector<Fraction, 8>> maybeLexMin =
79-
LexSimplex(*this).getRationalLexMin();
79+
LexSimplex(*this).findRationalLexMin();
8080

8181
if (!maybeLexMin.isBounded())
8282
return maybeLexMin;
@@ -93,10 +93,10 @@ IntegerPolyhedron::getRationalLexMin() const {
9393
}
9494

9595
MaybeOptimum<SmallVector<int64_t, 8>>
96-
IntegerPolyhedron::getIntegerLexMin() const {
96+
IntegerPolyhedron::findIntegerLexMin() const {
9797
assert(getNumSymbolIds() == 0 && "Symbols are not supported!");
9898
MaybeOptimum<SmallVector<int64_t, 8>> maybeLexMin =
99-
LexSimplex(*this).getIntegerLexMin();
99+
LexSimplex(*this).findIntegerLexMin();
100100

101101
if (!maybeLexMin.isBounded())
102102
return maybeLexMin.getKind();

mlir/lib/Analysis/Presburger/Simplex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Direction flippedDirection(Direction direction) {
164164
}
165165
} // namespace
166166

167-
MaybeOptimum<SmallVector<Fraction, 8>> LexSimplex::getRationalLexMin() {
167+
MaybeOptimum<SmallVector<Fraction, 8>> LexSimplex::findRationalLexMin() {
168168
restoreRationalConsistency();
169169
return getRationalSample();
170170
}
@@ -194,7 +194,7 @@ Optional<unsigned> LexSimplex::maybeGetNonIntegeralVarRow() const {
194194
return {};
195195
}
196196

197-
MaybeOptimum<SmallVector<int64_t, 8>> LexSimplex::getIntegerLexMin() {
197+
MaybeOptimum<SmallVector<int64_t, 8>> LexSimplex::findIntegerLexMin() {
198198
while (!empty) {
199199
restoreRationalConsistency();
200200
if (empty)

mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void checkSample(bool hasSample, const IntegerPolyhedron &poly,
6161
switch (fn) {
6262
case TestFunction::Sample:
6363
maybeSample = poly.findIntegerSample();
64-
maybeLexMin = poly.getIntegerLexMin();
64+
maybeLexMin = poly.findIntegerLexMin();
6565

6666
if (!hasSample) {
6767
EXPECT_FALSE(maybeSample.hasValue());
@@ -1081,15 +1081,15 @@ TEST(IntegerPolyhedronTest, negativeDividends) {
10811081

10821082
void expectRationalLexMin(const IntegerPolyhedron &poly,
10831083
ArrayRef<Fraction> min) {
1084-
auto lexMin = poly.getRationalLexMin();
1084+
auto lexMin = poly.findRationalLexMin();
10851085
ASSERT_TRUE(lexMin.isBounded());
10861086
EXPECT_EQ(ArrayRef<Fraction>(*lexMin), min);
10871087
}
10881088

10891089
void expectNoRationalLexMin(OptimumKind kind, const IntegerPolyhedron &poly) {
10901090
ASSERT_NE(kind, OptimumKind::Bounded)
10911091
<< "Use expectRationalLexMin for bounded min";
1092-
EXPECT_EQ(poly.getRationalLexMin().getKind(), kind);
1092+
EXPECT_EQ(poly.findRationalLexMin().getKind(), kind);
10931093
}
10941094

10951095
TEST(IntegerPolyhedronTest, getRationalLexMin) {
@@ -1164,15 +1164,15 @@ TEST(IntegerPolyhedronTest, getRationalLexMin) {
11641164
}
11651165

11661166
void expectIntegerLexMin(const IntegerPolyhedron &poly, ArrayRef<int64_t> min) {
1167-
auto lexMin = poly.getIntegerLexMin();
1167+
auto lexMin = poly.findIntegerLexMin();
11681168
ASSERT_TRUE(lexMin.isBounded());
11691169
EXPECT_EQ(ArrayRef<int64_t>(*lexMin), min);
11701170
}
11711171

11721172
void expectNoIntegerLexMin(OptimumKind kind, const IntegerPolyhedron &poly) {
11731173
ASSERT_NE(kind, OptimumKind::Bounded)
11741174
<< "Use expectRationalLexMin for bounded min";
1175-
EXPECT_EQ(poly.getRationalLexMin().getKind(), kind);
1175+
EXPECT_EQ(poly.findRationalLexMin().getKind(), kind);
11761176
}
11771177

11781178
TEST(IntegerPolyhedronTest, getIntegerLexMin) {

0 commit comments

Comments
 (0)