[Mlir-commits] [mlir] [mlir][tosa] Add several level checks (PR #128074)

TatWai Chong llvmlistbot at llvm.org
Tue Feb 25 22:50:00 PST 2025


================
@@ -147,107 +152,149 @@ struct TosaValidation : public tosa::impl::TosaValidationBase<TosaValidation> {
     return true;
   }
 
-  bool levelCheckRank(Operation *op, const Value &v,
-                      const std::string &checkDesc) {
+  bool levelCheckListSize(Operation *op, int32_t v,
+                          const std::string &checkDesc) {
+    if (v > tosaLevel.MAX_TENSOR_LIST_SIZE) {
+      op->emitOpError() << "failed level check for MAX_TENSOR_LIST_SIZE: "
+                        << checkDesc;
+      return false;
+    }
+    return true;
+  }
+
+  bool levelCheckRankAndSizes(Operation *op, const Value &v,
+                              const std::string &operandOrResult) {
     if (ShapedType type = dyn_cast<ShapedType>(v.getType())) {
       if (!type.hasRank()) {
         op->emitOpError() << "failed level check: unranked tensor";
----------------
tatwaichong wrote:

Rank 0 tensor also has rank but getRank() == 0. It aim to check unranked tensor that annotate as tensor<*xT>.

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


More information about the Mlir-commits mailing list