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

Mario Camillo llvmlistbot at llvm.org
Mon Sep 1 05:19:30 PDT 2025


https://github.com/mariocamillo-IMG created https://github.com/llvm/llvm-project/pull/156321

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.

>From 05c95ea5bccbf712c4084ec44625dd519382085f Mon Sep 17 00:00:00 2001
From: Mario Camillo <mario.camillo at imgtec.com>
Date: Mon, 1 Sep 2025 13:00:39 +0100
Subject: [PATCH] [mlir][tosa] handle unranked tensors in tosa::table::verify

---
 mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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";
 



More information about the Mlir-commits mailing list