[Mlir-commits] [mlir] [mlir][tosa] Add error if and level checks for COND_IF & WHILE_LOOP (PR #136194)

Luke Hutton llvmlistbot at llvm.org
Fri Apr 25 06:18:32 PDT 2025


================
@@ -3321,6 +3366,91 @@ void IfOp::print(OpAsmPrinter &p) {
   p.printOptionalAttrDict((*this)->getAttrs());
 }
 
+LogicalResult IfOp::verify() {
+  if (getThenGraph().empty() || getElseGraph().empty())
+    return emitOpError("require `then_graph` and `else_graph` not be empty");
+
+  if (errorIfTensorListShapeMismatch(
+          *this, getThenGraph().front().getArguments(),
+          "`then_graph` arguments", getInputList(), "`input_list`")
+          .failed())
+    return failure();
+
+  if (errorIfTensorListShapeMismatch(
+          *this, getElseGraph().front().getArguments(),
+          "`else_graph` arguments", getInputList(), "`input_list`")
+          .failed())
+    return failure();
+
+  auto thenYield = cast<tosa::YieldOp>(getThenGraph().front().getTerminator());
----------------
lhutton1 wrote:

Thanks - just making sure the cast didn't need checking

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


More information about the Mlir-commits mailing list