[Mlir-commits] [mlir] [mlir][tosa] handle unranked tensors in tosa::table::verify (PR #156321)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 1 05:20:21 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Mario Camillo (mariocamillo-IMG)

<details>
<summary>Changes</summary>

Seen when running TOSA PRO-INT conformance tests in our SUT. This leads to verify being called with unranked tensors causing exception/error when trying to call getShape on them.
Made some variables const for consistency with other verify functions in same file.

---
Full diff: https://github.com/llvm/llvm-project/pull/156321.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/Tosa/IR/TosaOps.cpp (+6-4) 


``````````diff
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index 3cafb199d2db3..63e99814bf17b 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -1951,11 +1951,13 @@ LogicalResult tosa::TableOp::inferReturnTypeComponents(
 }
 
 LogicalResult tosa::TableOp::verify() {
-  TensorType inputType = getInput1().getType();
-  TensorType outputType = getOutput().getType();
+  const TensorType inputType = getInput1().getType();
+  const TensorType outputType = getOutput().getType();
+
+  if (!inputType.hasRank() || !outputType.hasRank())
+    return success();
 
-  if (inputType.hasRank() && outputType.hasRank() &&
-      inputType.getRank() != outputType.getRank())
+  if (inputType.getRank() != outputType.getRank())
     return emitOpError()
            << "expected input tensor rank to equal result tensor rank";
 

``````````

</details>


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


More information about the Mlir-commits mailing list