junrushao1994 commented on code in PR #12048:
URL: https://github.com/apache/tvm/pull/12048#discussion_r922702289


##########
python/tvm/script/printer/doc.py:
##########
@@ -47,3 +103,171 @@ def __init__(self, value):
             self.__init_handle_by_constructor__(_ffi_api.LiteralDocInt, value) 
 # type: ignore
         else:
             raise TypeError(f"Unsupported type {type(value)} for LiteralDoc")
+
+
+@tvm._ffi.register_object("script.printer.IdDoc")
+class IdDoc(ExprDoc):
+    """Doc that represents identifier"""
+
+    name: str
+
+    def __init__(self, name: str):
+        self.__init_handle_by_constructor__(_ffi_api.IdDoc, name)  # type: 
ignore
+
+
+@tvm._ffi.register_object("script.printer.AttrAccessDoc")
+class AttrAccessDoc(ExprDoc):
+    """Doc that represents attribute access on an expression"""
+
+    value: ExprDoc
+    attr: str
+
+    def __init__(self, value: ExprDoc, attr: str):
+        self.__init_handle_by_constructor__(_ffi_api.AttrAccessDoc, value, 
attr)  # type: ignore
+
+
+@tvm._ffi.register_object("script.printer.IndexDoc")
+class IndexDoc(ExprDoc):
+    """Doc that represents index access on an expression"""
+
+    value: ExprDoc
+    indices: tvm.ir.container.Array  # actual type:  List[Union[ExprDoc, 
"SliceDoc"]]
+
+    def __init__(self, value: ExprDoc, indices: List[Union[ExprDoc, 
"SliceDoc"]]):
+        self.__init_handle_by_constructor__(_ffi_api.IndexDoc, value, indices) 
 # type: ignore
+
+
+@tvm._ffi.register_object("script.printer.CallDoc")
+class CallDoc(ExprDoc):
+    """Doc that represents function call"""
+
+    callee: ExprDoc
+    args: tvm.ir.container.Array  # actual type: List[ExprDoc]
+    kwargs_keys: tvm.ir.container.Array  # actual type: List[str]
+    kwargs_values: tvm.ir.container.Array  # actual type: List[ExprDoc]
+
+    def __init__(self, callee: ExprDoc, *args: Tuple[ExprDoc], **kwargs: 
Dict[str, ExprDoc]):
+        kwargs_keys = list(kwargs.keys())
+        kwargs_values = list(kwargs.values())
+        self.__init_handle_by_constructor__(
+            _ffi_api.CallDoc, callee, args, kwargs_keys, kwargs_values  # 
type: ignore
+        )
+
+
+@unique
+class OperationKind(IntEnum):
+    """
+    This enum represents the kind of operation (operator) in OpeartionDoc
+
+    It's mirrored from OperationDocNode::Kind at 
include/tvm/script/printer/doc.h
+    """
+
+    # The name convention follows https://docs.python.org/3/library/ast.html
+    # pylint: disable=invalid-name
+
+    _UnaryStart = 0
+    USub = auto()
+    Invert = auto()
+    _UnaryEnd = auto()
+
+    _BinaryStart = auto()
+    Add = auto()
+    Sub = auto()
+    Mult = auto()
+    Div = auto()
+    FloorDiv = auto()
+    Mod = auto()
+    Pow = auto()
+    LShift = auto()
+    RShift = auto()
+    BitAnd = auto()
+    BitOr = auto()
+    BitXor = auto()
+    Lt = auto()
+    LtE = auto()
+    Eq = auto()
+    NotEq = auto()
+    Gt = auto()
+    GtE = auto()
+    _BinaryEnd = auto()
+
+    _SpecialStart = auto()
+    IfThenElse = auto()
+    _SpecialEnd = auto()

Review Comment:
   Let's be explicitly consistent with numbering on C++ side. Avoid using `auto`



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to