[Mlir-commits] [mlir] [mlir][tosa] Allow conv ops zero point to be variable (PR #128533)

Luke Hutton llvmlistbot at llvm.org
Mon Feb 24 08:27:18 PST 2025


https://github.com/lhutton1 created https://github.com/llvm/llvm-project/pull/128533

The TOSA specification allows the zero point of conv ops to be variable when the dynamic extension is being used, but information about which extensions are in use is only known when the validation pass is run. A variable zero point should be allowed in the conv ops verifiers.

In terms of testing, there didn't seem to be an existing set of tests for the verifiers to add this check to, so the opportunity has been taken to run the verifiers on the tests in `ops.mlir`. Since the conv2d test there had variable zero points, this change in functionality is being tested.

>From 63eedd900b7c3780ef87c8a2b0ff8836b66e9583 Mon Sep 17 00:00:00 2001
From: Luke Hutton <luke.hutton at arm.com>
Date: Mon, 24 Feb 2025 13:05:12 +0000
Subject: [PATCH] [mlir][tosa] Allow conv ops zero point to be variable

The TOSA specification allows the zero point of conv ops to be
variable when the dynamic extension is being used, but information
about which extensions are in use is only known when the validation
pass is run. A variable zero point should be allowed in the conv ops
verifiers.

In terms of testing, there didn't seem to be an existing set of tests
for the verififers to add this check to, so the opportunity has been
taken to run the verifiers on the tests in `ops.mlir`. Since the conv2d
test there had variable zero points, this change in functionality is
being tested.

Change-Id: I2cb5533a6a059290641f2e145f28c712eada0dd7
Signed-off-by: Luke Hutton <luke.hutton at arm.com>
---
 mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 6 ++----
 mlir/test/Dialect/Tosa/ops.mlir      | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index e9c33e1b1bf10..295b010da0ee0 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -291,12 +291,10 @@ static LogicalResult verifyConvOp(T op) {
   ElementsAttr weightZpAttr;
   if (!matchPattern(op.getInputZp(), m_Constant(&inputZpAttr)) ||
       !matchPattern(op.getWeightZp(), m_Constant(&weightZpAttr))) {
-    op.emitOpError(
-        "bail out if the actual value of zero points cannot be determined");
-    return failure();
+    return success();
   }
 
-  // Get and verify explicit zero points.
+  // Get and verify explicit constant zero points.
   int64_t inputZpVal;
   int64_t weightZpVal;
 
diff --git a/mlir/test/Dialect/Tosa/ops.mlir b/mlir/test/Dialect/Tosa/ops.mlir
index cd73377c7f587..27132fa71fda4 100644
--- a/mlir/test/Dialect/Tosa/ops.mlir
+++ b/mlir/test/Dialect/Tosa/ops.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s | mlir-opt | FileCheck %s
+// RUN: mlir-opt %s --verify-each | mlir-opt | FileCheck %s
 // RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s
 
 



More information about the Mlir-commits mailing list