[Mlir-commits] [mlir] c156268 - [MLIR][Presburger] LinearTransform: rename multiplication functions to be more intuitive

Arjun P llvmlistbot at llvm.org
Mon Jan 24 14:48:27 PST 2022


Author: Arjun P
Date: 2022-01-25T04:18:19+05:30
New Revision: c1562683ee9a3be4246aa2546bf41e40b9cb123c

URL: https://github.com/llvm/llvm-project/commit/c1562683ee9a3be4246aa2546bf41e40b9cb123c
DIFF: https://github.com/llvm/llvm-project/commit/c1562683ee9a3be4246aa2546bf41e40b9cb123c.diff

LOG: [MLIR][Presburger] LinearTransform: rename multiplication functions to be more intuitive

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/Presburger/LinearTransform.h
    mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
    mlir/lib/Analysis/Presburger/LinearTransform.cpp
    mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/Presburger/LinearTransform.h b/mlir/include/mlir/Analysis/Presburger/LinearTransform.h
index 73bea008836f8..54d12173826d0 100644
--- a/mlir/include/mlir/Analysis/Presburger/LinearTransform.h
+++ b/mlir/include/mlir/Analysis/Presburger/LinearTransform.h
@@ -39,11 +39,12 @@ class LinearTransform {
 
   // The given vector is interpreted as a row vector v. Post-multiply v with
   // this transform, say T, and return vT.
-  SmallVector<int64_t, 8> postMultiplyRow(ArrayRef<int64_t> rowVec) const;
+  SmallVector<int64_t, 8> preMultiplyWithRow(ArrayRef<int64_t> rowVec) const;
 
   // The given vector is interpreted as a column vector v. Pre-multiply v with
   // this transform, say T, and return Tv.
-  SmallVector<int64_t, 8> preMultiplyColumn(ArrayRef<int64_t> colVec) const;
+  SmallVector<int64_t, 8>
+  postMultiplyWithColumn(ArrayRef<int64_t> colVec) const;
 
 private:
   Matrix matrix;

diff  --git a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
index 0080756dfb760..96519738a1188 100644
--- a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
@@ -770,7 +770,7 @@ Optional<SmallVector<int64_t, 8>> IntegerPolyhedron::findIntegerSample() const {
   // 6) Return transform * concat(boundedSample, coneSample).
   SmallVector<int64_t, 8> &sample = boundedSample.getValue();
   sample.append(coneSample.begin(), coneSample.end());
-  return transform.preMultiplyColumn(sample);
+  return transform.postMultiplyWithColumn(sample);
 }
 
 /// Helper to evaluate an affine expression at a point.

diff  --git a/mlir/lib/Analysis/Presburger/LinearTransform.cpp b/mlir/lib/Analysis/Presburger/LinearTransform.cpp
index 09d7eb731576e..073b64cf8c337 100644
--- a/mlir/lib/Analysis/Presburger/LinearTransform.cpp
+++ b/mlir/lib/Analysis/Presburger/LinearTransform.cpp
@@ -112,7 +112,7 @@ LinearTransform::makeTransformToColumnEchelon(Matrix m) {
 }
 
 SmallVector<int64_t, 8>
-LinearTransform::postMultiplyRow(ArrayRef<int64_t> rowVec) const {
+LinearTransform::preMultiplyWithRow(ArrayRef<int64_t> rowVec) const {
   assert(rowVec.size() == matrix.getNumRows() &&
          "row vector dimension should match transform output dimension");
 
@@ -124,7 +124,7 @@ LinearTransform::postMultiplyRow(ArrayRef<int64_t> rowVec) const {
 }
 
 SmallVector<int64_t, 8>
-LinearTransform::preMultiplyColumn(ArrayRef<int64_t> colVec) const {
+LinearTransform::postMultiplyWithColumn(ArrayRef<int64_t> colVec) const {
   assert(matrix.getNumColumns() == colVec.size() &&
          "column vector dimension should match transform input dimension");
 
@@ -144,7 +144,7 @@ LinearTransform::applyTo(const IntegerPolyhedron &poly) const {
 
     int64_t c = eq.back();
 
-    SmallVector<int64_t, 8> newEq = postMultiplyRow(eq.drop_back());
+    SmallVector<int64_t, 8> newEq = preMultiplyWithRow(eq.drop_back());
     newEq.push_back(c);
     result.addEquality(newEq);
   }
@@ -154,7 +154,7 @@ LinearTransform::applyTo(const IntegerPolyhedron &poly) const {
 
     int64_t c = ineq.back();
 
-    SmallVector<int64_t, 8> newIneq = postMultiplyRow(ineq.drop_back());
+    SmallVector<int64_t, 8> newIneq = preMultiplyWithRow(ineq.drop_back());
     newIneq.push_back(c);
     result.addInequality(newIneq);
   }

diff  --git a/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp b/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
index 8a6650f609f79..01b6b7fc960ce 100644
--- a/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp
@@ -22,7 +22,8 @@ void testColumnEchelonForm(const Matrix &m, unsigned expectedRank) {
   // In column echelon form, each row's last non-zero value can be at most one
   // column to the right of the last non-zero column among the previous rows.
   for (unsigned row = 0, nRows = m.getNumRows(); row < nRows; ++row) {
-    SmallVector<int64_t, 8> rowVec = transform.postMultiplyRow(m.getRow(row));
+    SmallVector<int64_t, 8> rowVec =
+        transform.preMultiplyWithRow(m.getRow(row));
     for (unsigned col = lastAllowedNonZeroCol + 1, nCols = m.getNumColumns();
          col < nCols; ++col) {
       EXPECT_EQ(rowVec[col], 0);


        


More information about the Mlir-commits mailing list