[Mlir-commits] [mlir] [mlir][tosa] Fold 'small' constant 1D concat operations (PR #128080)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 20 14:39:12 PST 2025


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 74c6111631ceb14a70bf833da66df9fb5d871436 3b06c48992d0a4bea85665cbdd68f539446e2956 --extensions cpp -- mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
index f31c388f71..16fff2ab97 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
@@ -1230,15 +1230,17 @@ OpFoldResult ConcatOp::fold(FoldAdaptor adaptor) {
   const unsigned int numOperands = getNumOperands();
 
   // Fold concat when all operands are constant and the output is 'small'
-  auto hasAllConstOperands = [](Value v){
-    return llvm::dyn_cast_or_null<tosa::ConstOp>(v.getDefiningOp());};
+  auto hasAllConstOperands = [](Value v) {
+    return llvm::dyn_cast_or_null<tosa::ConstOp>(v.getDefiningOp());
+  };
   if (llvm::all_of(operands, hasAllConstOperands)) {
     const ShapedType outputType = dyn_cast<ShapedType>(getOutput().getType());
     if (!outputType || !outputType.hasStaticShape()) {
       return {};
     }
 
-    // A 'small' output is currently defined as 1D and <= 6 elements (tosa_level_8k MAX_RANK)
+    // A 'small' output is currently defined as 1D and <= 6 elements
+    // (tosa_level_8k MAX_RANK)
     if (outputType.getRank() != 1) {
       return {};
     }
@@ -1250,11 +1252,13 @@ OpFoldResult ConcatOp::fold(FoldAdaptor adaptor) {
     llvm::SmallVector<Attribute> constOperands;
     constOperands.reserve(outputNumElements);
     for (const Attribute operand : adaptor.getOperands()) {
-      const auto elementsAttr = llvm::dyn_cast_if_present<DenseElementsAttr>(operand);
+      const auto elementsAttr =
+          llvm::dyn_cast_if_present<DenseElementsAttr>(operand);
       if (!elementsAttr) {
         return {};
       }
-      constOperands.append(llvm::to_vector(elementsAttr.getValues<Attribute>()));
+      constOperands.append(
+          llvm::to_vector(elementsAttr.getValues<Attribute>()));
     }
 
     return DenseElementsAttr::get(outputType, constOperands);

``````````

</details>


https://github.com/llvm/llvm-project/pull/128080


More information about the Mlir-commits mailing list