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

Fix clang tidy #819

Closed
wants to merge 3 commits into from
Closed

Fix clang tidy #819

wants to merge 3 commits into from

Conversation

makslevental
Copy link
Contributor

No description provided.

Copy link
Contributor

github-actions bot commented Dec 2, 2023

C/C++ code formatter, clang-format found issues in your code.

You can test this locally with the following command:
git-clang-format --diff 900efbaa4c26243266708f4796fddfb949ba225d e658b7e079b35537b77128c26bb895343953afcc -- /home/runner/work/mlir-aie/mlir-aie/lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp /home/runner/work/mlir-aie/mlir-aie/lib/Dialect/AIE/IR/AIEDialect.cpp
View the diff from clang-format here.
diff --git a/lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp b/lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp
index 0d42a13..c6e76a7 100644
--- a/lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp
+++ b/lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp
@@ -29,7 +29,7 @@ namespace xilinx::aievec {
 struct BufferParams {
   uint32_t start;
   uint32_t offsets;
-        uint32_t offsets_hi;
+  uint32_t offsets_hi;
   uint32_t step;
   uint32_t square;
 };
@@ -390,9 +390,9 @@ public:
       // Determine the load size
       // TODO: no examples of 1024-bit output vectors: doesn't feel right
       // to attempt a 512-bit load to do an update like this
-            int loadSize = vecSizeInBits == 256   ? 128
-                           : vecSizeInBits == 512 ? 256
-                                                  : 512;
+      int loadSize = vecSizeInBits == 256   ? 128
+                     : vecSizeInBits == 512 ? 256
+                                            : 512;
 
       // Create a vectorType for the load proper
       // Load half of the final result vector
@@ -718,7 +718,7 @@ class MatMulOpConversion
   using ConvertOpToLLVMPattern<aievec::MatMulOp>::ConvertOpToLLVMPattern;
 
   struct DecodedMatMulOp {
-        typedef enum { I32, I64, BF16 } Kind;
+    typedef enum { I32, I64, BF16 } Kind;
 
     Kind kind;
     Value lhs;
@@ -776,25 +776,25 @@ class MatMulOpConversion
     unsigned rhsBitWidth = rhsScaTy.getWidth();
     auto accScaTy = cast<IntegerType>(accVecTy.getElementType());
     unsigned accBitWidth = accScaTy.getWidth();
-          if (accBitWidth == 32) {
-            if (lhsBitWidth == 8) {
-              if (rhsBitWidth == 4) {
-                // <4x16xi8> x <16x8xi4> + <4x8xi32>
-                return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf};
-              } else {
-                // <4x8xi8> x <8x8xi8> + <4x8xi32>
-                return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
-              }
-            } else {
-              if (rhsBitWidth == 8) {
-                // <4x4xi16> x <4x8xi8> + <4x8xi32>
-                return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 16};
-              } else {
-                // <4x2xi16> x <2x8xi16> + <4x8xi32>
-                return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
-              }
-            }
-          }
+    if (accBitWidth == 32) {
+      if (lhsBitWidth == 8) {
+        if (rhsBitWidth == 4) {
+          // <4x16xi8> x <16x8xi4> + <4x8xi32>
+          return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf};
+        } else {
+          // <4x8xi8> x <8x8xi8> + <4x8xi32>
+          return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
+        }
+      } else {
+        if (rhsBitWidth == 8) {
+          // <4x4xi16> x <4x8xi8> + <4x8xi32>
+          return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 16};
+        } else {
+          // <4x2xi16> x <2x8xi16> + <4x8xi32>
+          return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
+        }
+      }
+    }
 
     if (lhsBitWidth == 16) {
       if (rhsBitWidth == 8) {

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

@@ -718,7 +718,7 @@
using ConvertOpToLLVMPattern<aievec::MatMulOp>::ConvertOpToLLVMPattern;

struct DecodedMatMulOp {
typedef enum { I32, I64, BF16 } Kind;
typedef enum { I32, I64, BF16 } Kind;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ modernize-use-using ⚠️
use using instead of typedef

Suggested change
typedef enum { I32, I64, BF16 } Kind;
using Kind = enum { I32, I64, BF16 };

Comment on lines +784 to +785
} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ llvm-else-after-return ⚠️
do not use else after return

Suggested change
} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
} // <4x8xi8> x <8x8xi8> + <4x8xi32>

} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ llvm-else-after-return ⚠️
do not use else after return

Suggested change
}

Comment on lines +792 to +793
} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ llvm-else-after-return ⚠️
do not use else after return

Suggested change
} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
} // <4x2xi16> x <2x8xi16> + <4x8xi32>

} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ llvm-else-after-return ⚠️
do not use else after return

Suggested change
}

@makslevental makslevental force-pushed the fix_clang_tidy branch 2 times, most recently from 275ebda to e658b7e Compare December 2, 2023 10:32
Copy link
Contributor

github-actions bot commented Dec 2, 2023

Coverage Report

Created: 2023-12-02 11:19

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp 80.65% 89.84% 77.14% 64.55%
Dialect/AIE/IR/AIEDialect.cpp 92.79% 83.83% 86.14% 75.44%
Totals 90.14% 85.88% 84.47% 73.68%
Generated by llvm-cov -- llvm version 14.0.0

@Xilinx Xilinx deleted a comment from github-actions bot Dec 2, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

@@ -29,7 +29,7 @@ namespace xilinx::aievec {
struct BufferParams {
uint32_t start;
uint32_t offsets;
uint32_t offsets_hi;
uint32_t offsets_hi;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ readability-identifier-naming ⚠️
invalid case style for member offsets_hi

Suggested change
uint32_t offsets_hi;
uint32_t offsetsHi;

@makslevental makslevental force-pushed the fix_clang_tidy branch 6 times, most recently from cf674cb to dd863ab Compare December 2, 2023 11:08
@@ -29,7 +29,7 @@ namespace xilinx::aievec {
struct BufferParams {
uint32_t start;
uint32_t offsets;
uint32_t offsets_hi;
uint32_t offsets_hi;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
uint32_t offsets_hi;
uint32_t offsets_hi;

Comment on lines +393 to +395
int loadSize = vecSizeInBits == 256 ? 128
: vecSizeInBits == 512 ? 256
: 512;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
int loadSize = vecSizeInBits == 256 ? 128
: vecSizeInBits == 512 ? 256
: 512;
int loadSize = vecSizeInBits == 256 ? 128
: vecSizeInBits == 512 ? 256
: 512;

@@ -718,7 +718,7 @@ class MatMulOpConversion
using ConvertOpToLLVMPattern<aievec::MatMulOp>::ConvertOpToLLVMPattern;

struct DecodedMatMulOp {
typedef enum { I32, I64, BF16 } Kind;
typedef enum { I32, I64, BF16 } Kind;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
typedef enum { I32, I64, BF16 } Kind;
typedef enum { I32, I64, BF16 } Kind;

Comment on lines +779 to +797
if (accBitWidth == 32) {
if (lhsBitWidth == 8) {
if (rhsBitWidth == 4) {
// <4x16xi8> x <16x8xi4> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf};
} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
}
} else {
if (rhsBitWidth == 8) {
// <4x4xi16> x <4x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 16};
} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
if (accBitWidth == 32) {
if (lhsBitWidth == 8) {
if (rhsBitWidth == 4) {
// <4x16xi8> x <16x8xi4> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf};
} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
}
} else {
if (rhsBitWidth == 8) {
// <4x4xi16> x <4x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 16};
} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
}
}
}
if (accBitWidth == 32) {
if (lhsBitWidth == 8) {
if (rhsBitWidth == 4) {
// <4x16xi8> x <16x8xi4> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf};
} else {
// <4x8xi8> x <8x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 8};
}
} else {
if (rhsBitWidth == 8) {
// <4x4xi16> x <4x8xi8> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 16};
} else {
// <4x2xi16> x <2x8xi16> + <4x8xi32>
return {DecodedMatMulOp::Kind::I32, lhs, rhs, acc, signConf | 2};
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant