junrushao1994 commented on code in PR #12048:
URL: https://github.com/apache/tvm/pull/12048#discussion_r922648703
##########
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"]]
Review Comment:
Simply using the actual type
```suggestion
indices: List[Union[ExprDoc, "SliceDoc"]]
```
##########
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]
Review Comment:
ditto
--
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]