Skip to content

Commit

Permalink
[mlir][tosa] Allow conv ops zero point to be variable (#128533)
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Luke Hutton <[email protected]>
Co-authored-by: Georgios Pinitas <[email protected]>
  • Loading branch information
lhutton1 and GeorgeARM authored Feb 25, 2025
1 parent 87dc245 commit a4656bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Dialect/Tosa/ops.mlir
Original file line number Diff line number Diff line change
@@ -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


Expand Down

0 comments on commit a4656bb

Please sign in to comment.