[Mlir-commits] [mlir] [mlir][tosa] Add support for CONV2D_BLOCK_SCALED operator (PR #172294)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Dec 15 05:31:15 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 origin/main HEAD --extensions inc,h,cpp -- mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h mlir/lib/Dialect/Tosa/IR/TargetEnv.cpp mlir/lib/Dialect/Tosa/IR/TosaOps.cpp mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
index e452723f1..4d3599490 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
@@ -514,11 +514,16 @@ extensionComplianceMap = {
          SpecificationVersion::V_1_0}}}}},
     {"tosa.conv2d_block_scaled",
      {{{Extension::mxfp_conv},
-       {{{fp4e2m1T, fp8ue8m0T, fp4e2m1T, fp8ue8m0T, fp32T, fp32T}, SpecificationVersion::V_1_1_DRAFT},
-        {{fp6e2m3T, fp8ue8m0T, fp6e2m3T, fp8ue8m0T, fp32T, fp32T}, SpecificationVersion::V_1_1_DRAFT},
-        {{fp6e3m2T, fp8ue8m0T, fp6e3m2T, fp8ue8m0T, fp32T, fp32T}, SpecificationVersion::V_1_1_DRAFT},
-        {{fp8e4m3T, fp8ue8m0T, fp8e4m3T, fp8ue8m0T, fp32T, fp32T}, SpecificationVersion::V_1_1_DRAFT},
-        {{fp8e5m2T, fp8ue8m0T, fp8e5m2T, fp8ue8m0T, fp32T, fp32T}, SpecificationVersion::V_1_1_DRAFT}}}}},
+       {{{fp4e2m1T, fp8ue8m0T, fp4e2m1T, fp8ue8m0T, fp32T, fp32T},
+         SpecificationVersion::V_1_1_DRAFT},
+        {{fp6e2m3T, fp8ue8m0T, fp6e2m3T, fp8ue8m0T, fp32T, fp32T},
+         SpecificationVersion::V_1_1_DRAFT},
+        {{fp6e3m2T, fp8ue8m0T, fp6e3m2T, fp8ue8m0T, fp32T, fp32T},
+         SpecificationVersion::V_1_1_DRAFT},
+        {{fp8e4m3T, fp8ue8m0T, fp8e4m3T, fp8ue8m0T, fp32T, fp32T},
+         SpecificationVersion::V_1_1_DRAFT},
+        {{fp8e5m2T, fp8ue8m0T, fp8e5m2T, fp8ue8m0T, fp32T, fp32T},
+         SpecificationVersion::V_1_1_DRAFT}}}}},
     {"tosa.conv3d",
      {{{Extension::int4},
        {{{i8T, i4T, i32T, i8T, i4T, i32T, i32T}, SpecificationVersion::V_1_0}}},
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index 6382c28ed..7849ff58d 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -3558,8 +3558,10 @@ LogicalResult Conv2DBlockScaledOp::inferReturnTypeComponents(
   SmallVector<int64_t> strideValues;
   SmallVector<int64_t> dilationValues;
   if (!tosa::getConstShapeValues(adaptor.getPad().getDefiningOp(), padValues) ||
-      !tosa::getConstShapeValues(adaptor.getStride().getDefiningOp(), strideValues) ||
-      !tosa::getConstShapeValues(adaptor.getDilation().getDefiningOp(), dilationValues)) {
+      !tosa::getConstShapeValues(adaptor.getStride().getDefiningOp(),
+                                 strideValues) ||
+      !tosa::getConstShapeValues(adaptor.getDilation().getDefiningOp(),
+                                 dilationValues)) {
     inferredReturnShapes.push_back(ShapedTypeComponents(outShape));
     return success();
   }
@@ -3664,26 +3666,28 @@ LogicalResult Conv2DBlockScaledOp::verify() {
   if (tosa::getConstShapeValues(getPad().getDefiningOp(), padValues)) {
     if (llvm::any_of(padValues, [](int64_t p) { return p < 0; }))
       return emitOpError("expect all padding values to be >= 0, got ")
-            << padValues;
+             << padValues;
   }
 
   SmallVector<int64_t> strideValues;
   if (tosa::getConstShapeValues(getStride().getDefiningOp(), strideValues)) {
     if (llvm::any_of(strideValues, [](int64_t s) { return s < 1; }))
       return emitOpError("expect all stride values to be >= 1, got ")
-            << strideValues;
+             << strideValues;
   }
 
   SmallVector<int64_t> dilationValues;
-  if (tosa::getConstShapeValues(getDilation().getDefiningOp(), dilationValues)) {
+  if (tosa::getConstShapeValues(getDilation().getDefiningOp(),
+                                dilationValues)) {
     if (llvm::any_of(dilationValues, [](int64_t d) { return d < 1; }))
-    return emitOpError("expect all dilation values to be >= 1, got ")
-           << dilationValues;
+      return emitOpError("expect all dilation values to be >= 1, got ")
+             << dilationValues;
   }
 
   // Verify output shape compatibility
   const ShapeAdaptor outputShape(getOutput().getType());
-  if (!padValues.empty() && !strideValues.empty() && !dilationValues.empty() && outputShape.hasRank()) {
+  if (!padValues.empty() && !strideValues.empty() && !dilationValues.empty() &&
+      outputShape.hasRank()) {
     if (failed(verifyConvOutputSize(*this, IH, KH, outputShape.getDimSize(1),
                                     padValues[0], padValues[1], strideValues[0],
                                     dilationValues[0], "height", "y", "top",

``````````

</details>


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


More information about the Mlir-commits mailing list