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

[MLIR][Presburger] Fix ParamPoint to be column-wise instead of row-wise #77232

Merged
merged 2 commits into from
Jan 7, 2024

Conversation

Abhinav271828
Copy link
Contributor

The ParamPoint datatype has each column representing an affine function. The code for generating functions is modified to reflect this.

@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2024

@llvm/pr-subscribers-mlir

Author: None (Abhinav271828)

Changes

The ParamPoint datatype has each column representing an affine function. The code for generating functions is modified to reflect this.


Full diff: https://github.com/llvm/llvm-project/pull/77232.diff

2 Files Affected:

  • (modified) mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h (+1-1)
  • (modified) mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp (+8-8)
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}},

@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2024

@llvm/pr-subscribers-mlir-presburger

Author: None (Abhinav271828)

Changes

The ParamPoint datatype has each column representing an affine function. The code for generating functions is modified to reflect this.


Full diff: https://github.com/llvm/llvm-project/pull/77232.diff

2 Files Affected:

  • (modified) mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h (+1-1)
  • (modified) mlir/unittests/Analysis/Presburger/GeneratingFunctionTest.cpp (+8-8)
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}},

@Superty
Copy link
Member

Superty commented Jan 7, 2024

LGTM

@Abhinav271828 Abhinav271828 merged commit 2835be8 into llvm:main Jan 7, 2024
4 checks passed
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…se (llvm#77232)

The ParamPoint datatype has each column representing an affine function.
The code for generating functions is modified to reflect this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants