[Mlir-commits] [mlir] 2690d4d - [MLIR] Support symbols in emptiness checks for FlatAffineConstraints
Arjun P
llvmlistbot at llvm.org
Thu Apr 8 09:08:53 PDT 2021
Author: Arjun P
Date: 2021-04-08T21:38:47+05:30
New Revision: 2690d4d45a63ecee224a0dce1a5fd557b140df51
URL: https://github.com/llvm/llvm-project/commit/2690d4d45a63ecee224a0dce1a5fd557b140df51
DIFF: https://github.com/llvm/llvm-project/commit/2690d4d45a63ecee224a0dce1a5fd557b140df51.diff
LOG: [MLIR] Support symbols in emptiness checks for FlatAffineConstraints
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D100114
Added:
Modified:
mlir/lib/Analysis/AffineStructures.cpp
mlir/lib/Analysis/LinearTransform.cpp
mlir/unittests/Analysis/AffineStructuresTest.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp
index 30b00bd9b6b6..75bc6b76f5ed 100644
--- a/mlir/lib/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Analysis/AffineStructures.cpp
@@ -1151,14 +1151,14 @@ Matrix FlatAffineConstraints::getBoundedDirections() const {
bool eqInvolvesSuffixDims(const FlatAffineConstraints &fac, unsigned eqIndex,
unsigned numDims) {
- for (unsigned e = fac.getNumDimIds(), j = e - numDims; j < e; ++j)
+ for (unsigned e = fac.getNumIds(), j = e - numDims; j < e; ++j)
if (fac.atEq(eqIndex, j) != 0)
return true;
return false;
}
bool ineqInvolvesSuffixDims(const FlatAffineConstraints &fac,
unsigned ineqIndex, unsigned numDims) {
- for (unsigned e = fac.getNumDimIds(), j = e - numDims; j < e; ++j)
+ for (unsigned e = fac.getNumIds(), j = e - numDims; j < e; ++j)
if (fac.atIneq(ineqIndex, j) != 0)
return true;
return false;
diff --git a/mlir/lib/Analysis/LinearTransform.cpp b/mlir/lib/Analysis/LinearTransform.cpp
index e8b82c1cad4d..c4dc0e746840 100644
--- a/mlir/lib/Analysis/LinearTransform.cpp
+++ b/mlir/lib/Analysis/LinearTransform.cpp
@@ -137,7 +137,7 @@ LinearTransform::preMultiplyColumn(ArrayRef<int64_t> colVec) const {
FlatAffineConstraints
LinearTransform::applyTo(const FlatAffineConstraints &fac) const {
- FlatAffineConstraints result(fac.getNumDimIds());
+ FlatAffineConstraints result(fac.getNumIds());
for (unsigned i = 0, e = fac.getNumEqualities(); i < e; ++i) {
ArrayRef<int64_t> eq = fac.getEquality(i);
diff --git a/mlir/unittests/Analysis/AffineStructuresTest.cpp b/mlir/unittests/Analysis/AffineStructuresTest.cpp
index 1f97d0b268ff..2121fec978d8 100644
--- a/mlir/unittests/Analysis/AffineStructuresTest.cpp
+++ b/mlir/unittests/Analysis/AffineStructuresTest.cpp
@@ -51,9 +51,11 @@ static void checkSample(bool hasSample, const FlatAffineConstraints &fac,
/// Construct a FlatAffineConstraints from a set of inequality and
/// equality constraints.
static FlatAffineConstraints
-makeFACFromConstraints(unsigned dims, ArrayRef<SmallVector<int64_t, 4>> ineqs,
- ArrayRef<SmallVector<int64_t, 4>> eqs) {
- FlatAffineConstraints fac(ineqs.size(), eqs.size(), dims + 1, dims);
+makeFACFromConstraints(unsigned ids, ArrayRef<SmallVector<int64_t, 4>> ineqs,
+ ArrayRef<SmallVector<int64_t, 4>> eqs,
+ unsigned syms = 0) {
+ FlatAffineConstraints fac(ineqs.size(), eqs.size(), ids + 1, ids - syms,
+ syms);
for (const auto &eq : eqs)
fac.addEquality(eq);
for (const auto &ineq : ineqs)
@@ -419,6 +421,17 @@ TEST(FlatAffineConstraintsTest, IsIntegerEmptyTest) {
},
{{2, -3, 0, 0, 0}, {1, -1, 6, 0, -1}, {1, 1, 0, -6, -2}})
.isIntegerEmpty());
+
+ // Set with symbols.
+ FlatAffineConstraints fac6 = makeFACFromConstraints(2,
+ {
+ {1, 1, 0},
+ },
+ {
+ {1, -1, 0},
+ },
+ 1);
+ EXPECT_FALSE(fac6.isIntegerEmpty());
}
TEST(FlatAffineConstraintsTest, removeRedundantConstraintsTest) {
More information about the Mlir-commits
mailing list