[Mlir-commits] [mlir] [MLIR][Presburger] Fix ParamPoint to be column-wise instead of row-wise (PR #77232)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Jan 7 02:41:50 PST 2024


https://github.com/Abhinav271828 updated https://github.com/llvm/llvm-project/pull/77232

>From 0511fcb3d1b4bd2db8e62d6fadde8fb558a9826a Mon Sep 17 00:00:00 2001
From: Abhinav271828 <abhinav.m at research.iiit.ac.in>
Date: Sun, 7 Jan 2024 16:05:32 +0530
Subject: [PATCH 1/2] Change GF from rows to columns

---
 .../Analysis/Presburger/GeneratingFunction.h     |  2 +-
 .../Presburger/GeneratingFunctionTest.cpp        | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h b/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
index 4dd692c251563b..35f237d345b824 100644
--- a/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
+++ b/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
@@ -56,7 +56,7 @@ class GeneratingFunction {
       : numParam(numParam), signs(signs), numerators(nums), denominators(dens) {
 #ifndef NDEBUG
     for (const ParamPoint &term : numerators)
-      assert(term.getNumColumns() == numParam + 1 &&
+      assert(term.getNumRows() == numParam + 1 &&
              "dimensionality of numerator exponents does not match number of "
              "parameters!");
 #endif // NDEBUG
diff --git a/mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp b/mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp
index 5df1a5a0f64c05..3fc68cddaad007 100644
--- a/mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp
@@ -17,21 +17,21 @@ using namespace mlir::presburger::detail;
 
 TEST(GeneratingFunctionTest, sum) {
   GeneratingFunction gf1(2, {1, -1},
-                         {makeFracMatrix(2, 3, {{1, 2, 5}, {7, 2, 6}}),
-                          makeFracMatrix(2, 3, {{5, 2, 5}, {3, 7, 2}})},
+                         {makeFracMatrix(3, 2, {{1, 2}, {5, 7}, {2, 6}}),
+                          makeFracMatrix(3, 2, {{5, 2}, {5, 3}, {7, 2}})},
                          {{{3, 6}, {7, 2}}, {{2, 8}, {6, 3}}});
   GeneratingFunction gf2(2, {1, 1},
-                         {makeFracMatrix(2, 3, {{6, 2, 1}, {4, 2, 6}}),
-                          makeFracMatrix(2, 3, {{3, 2, 6}, {9, 2, 5}})},
+                         {makeFracMatrix(3, 2, {{6, 2}, {1, 4}, {2, 6}}),
+                          makeFracMatrix(3, 2, {{3, 2}, {6, 9}, {2, 5}})},
                          {{{3, 7}, {5, 1}}, {{5, 2}, {6, 2}}});
 
   GeneratingFunction sum = gf1 + gf2;
   EXPECT_EQ_REPR_GENERATINGFUNCTION(
       sum, GeneratingFunction(2, {1, -1, 1, 1},
-                              {makeFracMatrix(2, 3, {{1, 2, 5}, {7, 2, 6}}),
-                               makeFracMatrix(2, 3, {{5, 2, 5}, {3, 7, 2}}),
-                               makeFracMatrix(2, 3, {{6, 2, 1}, {4, 2, 6}}),
-                               makeFracMatrix(2, 3, {{3, 2, 6}, {9, 2, 5}})},
+                              {makeFracMatrix(3, 2, {{1, 2}, {5, 7}, {2, 6}}),
+                               makeFracMatrix(3, 2, {{5, 2}, {5, 3}, {7, 2}}),
+                               makeFracMatrix(3, 2, {{6, 2}, {1, 4}, {2, 6}}),
+                               makeFracMatrix(3, 2, {{3, 2}, {6, 9}, {2, 5}})},
                               {{{3, 6}, {7, 2}},
                                {{2, 8}, {6, 3}},
                                {{3, 7}, {5, 1}},

>From f5f6e9c27d20792f5546046112095ab6bbf55311 Mon Sep 17 00:00:00 2001
From: Abhinav271828 <abhinav.m at research.iiit.ac.in>
Date: Sun, 7 Jan 2024 16:11:39 +0530
Subject: [PATCH 2/2] Fix documentation

---
 mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h b/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
index 35f237d345b824..eaf0449fe8a118 100644
--- a/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
+++ b/mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
@@ -22,7 +22,7 @@ namespace presburger {
 namespace detail {
 
 // A parametric point is a vector, each of whose elements
-// is an affine function of n parameters. Each row
+// is an affine function of n parameters. Each column
 // in the matrix represents the affine function and
 // has n+1 elements.
 using ParamPoint = FracMatrix;



More information about the Mlir-commits mailing list