junrushao1994 commented on a change in pull request #7330:
URL: https://github.com/apache/tvm/pull/7330#discussion_r563975690



##########
File path: include/tvm/node/container.h
##########
@@ -1449,6 +1449,19 @@ namespace runtime {
 // Additional overloads for PackedFunc checking.
 template <typename T>
 struct ObjectTypeChecker<Array<T>> {
+  static Optional<String> CheckAndGetMismatch(const Object* ptr) {
+    if (ptr == nullptr) return NullOpt;
+    if (!ptr->IsInstance<ArrayNode>()) return String(ptr->GetTypeKey());
+    const ArrayNode* n = static_cast<const ArrayNode*>(ptr);
+    for (size_t i = 0; i < n->size(); i++) {
+      const ObjectRef& p = (*n)[i];
+      Optional<String> check_subtype = 
ObjectTypeChecker<T>::CheckAndGetMismatch(p.get());
+      if (check_subtype.defined()) {
+        return String("Array[index " + std::to_string(i) + ": " + 
check_subtype.value() + "]");

Review comment:
       Hey, I just wonder, if there is a variable `x` typed as nested 
`Array<Array<SomeType>>`, and some checking fails on like `x[0][1]`, in this 
case, what the error message could be?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to