MasterJH5574 commented on code in PR #16316:
URL: https://github.com/apache/tvm/pull/16316#discussion_r1438767858


##########
python/tvm/relax/frontend/nn/core.py:
##########
@@ -274,6 +279,22 @@ def to(self, dtype: Optional[str] = None) -> None:  # 
pylint: disable=invalid-na
             )._expr
 
 
+class Object:
+    """A wrapper on top of relax.Expr whose struct_info is the base
+    ObjectStructInfo (rather than any its subclass). Object effectively
+    represents non-tensor frontend components such as KV caches.
+    """
+
+    _expr: rx.Var
+
+    def __init__(self, *, _expr: rx.Expr, _name: str) -> None:
+        """Private constructor. Object is never supposed to be constructed 
directly by users."""
+        if not isinstance(_expr, rx.Var):
+            _expr = BlockBuilder.current().emit(_expr, _name)

Review Comment:
   Ah I allowed it to be non-Var so that it helps emit non-Var Exprs 
https://github.com/apache/tvm/blob/f671711e6c7e603a0ecc3621f7ea831beb3ade75/python/tvm/relax/frontend/nn/modules.py#L718-L723.
 After a second thought, I think it would be semantics-wise clearer to only 
accept Var here, and emit the non-Var Expr on caller side. How does this sound?



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