LeshengJin commented on code in PR #15670:
URL: https://github.com/apache/tvm/pull/15670#discussion_r1318045404


##########
python/tvm/relax/frontend/nn/spec.py:
##########
@@ -59,6 +59,32 @@ def __repr__(self) -> str:
         return f"Tensor([{shape}], '{self.dtype}')"
 
 
+class TupleList:
+    """A tuple input or a list input"""
+
+    name: str
+    elements: Union[List[Union[core.Tensor, "TupleList"]], 
Tuple[Union[core.Tensor, "TupleList"]]]
+
+    def __init__(
+        self,
+        name: str,
+        elements: Union[
+            List[Union[core.Tensor, "TupleList"]], Tuple[Union[core.Tensor, 
"TupleList"]]
+        ],
+    ) -> None:
+        assert type(elements) in [tuple, list], f"Unsupported container type: 
{type(elements)}"
+        for i, e in enumerate(elements):  # pylint: disable=invalid-name
+            assert isinstance(e, (core.Tensor, TupleList)), (
+                f"Expected all elements in the {name} tuple/list to be of type 
Tensor/tuple/list, "
+                f"but found a {type(e)} at index {i}."
+            )
+        self.name = name
+        self.elements = elements

Review Comment:
   We need the type info of `elements`.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to