[Mlir-commits] [mlir] [mlir][tosa] Add error if and level checks for COND_IF & WHILE_LOOP (PR #136194)
TatWai Chong
llvmlistbot at llvm.org
Wed Apr 23 22:51:23 PDT 2025
================
@@ -428,6 +428,51 @@ static LogicalResult verifyConvOpModes(T op) {
return success();
}
+// Verify whether same length and type of block arguments and tensor list.
+static LogicalResult errorIfTensorListShapeMismatch(Operation *op,
+ ValueRange blocksArgs,
+ StringRef blockName,
+ ValueRange tensorList,
+ StringRef listName) {
+ if (blocksArgs.size() != tensorList.size())
+ return op->emitOpError() << "require same number of values in " << blockName
+ << " (" << blocksArgs.size() << ") and "
+ << listName << " (" << tensorList.size() << ")";
+
+ for (auto [bbArgType, opArgType] :
+ llvm::zip_equal(blocksArgs.getTypes(), tensorList.getTypes())) {
+ ShapeAdaptor bbShapeAdaptor(bbArgType);
+ ShapeAdaptor opShapeAdaptor(opArgType);
+
+ if (!bbShapeAdaptor.hasRank() || !opShapeAdaptor.hasRank())
+ continue;
+
+ if (!bbShapeAdaptor.hasStaticShape() || !opShapeAdaptor.hasStaticShape())
----------------
tatwaichong wrote:
Nice suggestion.
https://github.com/llvm/llvm-project/pull/136194
More information about the Mlir-commits
mailing list