[Mlir-commits] [mlir] [MLIR][Presburger] Implement Matrix::moveColumns (PR #68362)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 5 15:41:02 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5e159972917fb7d02347f98d7431f1d02bee33b6 d38897639f3d5d30504a1dcf729a9099462ee284 -- mlir/include/mlir/Analysis/Presburger/Matrix.h mlir/lib/Analysis/Presburger/Matrix.cpp mlir/unittests/Analysis/Presburger/MatrixTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Analysis/Presburger/Matrix.cpp b/mlir/lib/Analysis/Presburger/Matrix.cpp
index 4c8d63055fc5..8d500588ab4d 100644
--- a/mlir/lib/Analysis/Presburger/Matrix.cpp
+++ b/mlir/lib/Analysis/Presburger/Matrix.cpp
@@ -192,11 +192,12 @@ template <typename T> void Matrix<T>::fillRow(unsigned row, const T &value) {
at(row, col) = value;
}
-template <typename T> void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, int offset) {
+template <typename T>
+void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, int offset) {
assert(num != 0 && "num must be non-zero");
assert(offset != 0 && "offset must be non-zero");
assert(0 <= srcPos + offset && srcPos + num + offset <= getNumColumns() &&
- "invalid move offset");
+ "invalid move offset");
unsigned insertCount = offset > 0 ? offset : -offset,
insertPos = offset > 0 ? srcPos : srcPos + num,
@@ -205,11 +206,11 @@ template <typename T> void Matrix<T>::moveColumns(unsigned srcPos, unsigned num,
// be moved.
insertColumns(insertPos, insertCount);
// Update deletePos if insertion of new columns invalidates it.
- if(insertPos < deletePos)
+ if (insertPos < deletePos)
deletePos += insertCount;
// Swap the adjacent columns with inserted zero columns.
- for(unsigned i = 0; i < insertCount; i++)
+ for (unsigned i = 0; i < insertCount; i++)
swapColumns(insertPos + i, deletePos + i);
// Delete the now redundant zero columns.
diff --git a/mlir/unittests/Analysis/Presburger/MatrixTest.cpp b/mlir/unittests/Analysis/Presburger/MatrixTest.cpp
index 57e0fe627bec..8a7cb4d989b1 100644
--- a/mlir/unittests/Analysis/Presburger/MatrixTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/MatrixTest.cpp
@@ -258,36 +258,28 @@ TEST(MatrixTest, computeHermiteNormalForm) {
}
TEST(MatrixTest, moveColumns) {
- IntMatrix mat = makeIntMatrix(3, 4,
- {{0, 1, 2, 3},
- {4, 5, 6, 7},
- {8, 9, 4, 2}});
+ IntMatrix mat =
+ makeIntMatrix(3, 4, {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 4, 2}});
{
- IntMatrix movedMat = makeIntMatrix(3, 4,
- {{0, 3, 1, 2},
- {4, 7, 5, 6},
- {8, 2, 9, 4}});
+ IntMatrix movedMat =
+ makeIntMatrix(3, 4, {{0, 3, 1, 2}, {4, 7, 5, 6}, {8, 2, 9, 4}});
movedMat.moveColumns(2, 2, -1);
checkMatEqual(mat, movedMat);
}
{
- IntMatrix movedMat = makeIntMatrix(3, 4,
- {{0, 3, 1, 2},
- {4, 7, 5, 6},
- {8, 2, 9, 4}});
+ IntMatrix movedMat =
+ makeIntMatrix(3, 4, {{0, 3, 1, 2}, {4, 7, 5, 6}, {8, 2, 9, 4}});
movedMat.moveColumns(1, 1, 2);
checkMatEqual(mat, movedMat);
}
{
- IntMatrix movedMat = makeIntMatrix(3, 4,
- {{1, 2, 0, 3},
- {5, 6, 4, 7},
- {9, 4, 8, 2}});
+ IntMatrix movedMat =
+ makeIntMatrix(3, 4, {{1, 2, 0, 3}, {5, 6, 4, 7}, {9, 4, 8, 2}});
movedMat.moveColumns(0, 2, 1);
checkMatEqual(mat, movedMat);
``````````
</details>
https://github.com/llvm/llvm-project/pull/68362
More information about the Mlir-commits
mailing list