tqchen commented on a change in pull request #8623:
URL: https://github.com/apache/tvm/pull/8623#discussion_r682597491



##########
File path: python/tvm/tir/schedule/schedule.py
##########
@@ -63,7 +63,37 @@ def __init__(self) -> None:
 RAND_VAR_TYPE = Union[ExprRV, BlockRV, LoopRV]  # pylint: disable=invalid-name
 
 # Update to `Literal["detail", "fast", "none"]` once upgraded to python3.8
-ERROR_RENDER_LEVEL_CANDIDATES = Union[str]  # pylint: disable=invalid-name
+_ERROR_RENDER_LEVEL = {
+    "detail": 0,
+    "fast": 1,
+    "none": 2,
+}
+
+
+def _preprocess_constructor_arguments(
+    mod: Union[PrimFunc, IRModule],
+    debug_mode: Union[bool, int] = False,
+    error_render_level: str = "detail",
+) -> Tuple[IRModule, int, int]:
+    # preprocess `mod`
+    if isinstance(mod, PrimFunc):
+        mod = IRModule({"main": mod})
+    # preprocess `debug_mode`
+    if isinstance(debug_mode, bool):
+        if debug_mode:
+            debug_mode = -1

Review comment:
       Another possible alternative would be provide EnumInt.
   
   e.g. `debug_mask=tir.DebugMask.ALL `

##########
File path: python/tvm/tir/schedule/schedule.py
##########
@@ -63,7 +63,37 @@ def __init__(self) -> None:
 RAND_VAR_TYPE = Union[ExprRV, BlockRV, LoopRV]  # pylint: disable=invalid-name
 
 # Update to `Literal["detail", "fast", "none"]` once upgraded to python3.8
-ERROR_RENDER_LEVEL_CANDIDATES = Union[str]  # pylint: disable=invalid-name
+_ERROR_RENDER_LEVEL = {
+    "detail": 0,
+    "fast": 1,
+    "none": 2,
+}
+
+
+def _preprocess_constructor_arguments(
+    mod: Union[PrimFunc, IRModule],
+    debug_mode: Union[bool, int] = False,
+    error_render_level: str = "detail",
+) -> Tuple[IRModule, int, int]:
+    # preprocess `mod`
+    if isinstance(mod, PrimFunc):
+        mod = IRModule({"main": mod})
+    # preprocess `debug_mode`
+    if isinstance(debug_mode, bool):
+        if debug_mode:
+            debug_mode = -1

Review comment:
       Another possible alternative would be provide EnumInt.
   
   e.g. `debug_mask=tir.DebugMask.ALL`, `debug_mask=tir.NONE`

##########
File path: python/tvm/tir/schedule/schedule.py
##########
@@ -63,7 +63,37 @@ def __init__(self) -> None:
 RAND_VAR_TYPE = Union[ExprRV, BlockRV, LoopRV]  # pylint: disable=invalid-name
 
 # Update to `Literal["detail", "fast", "none"]` once upgraded to python3.8
-ERROR_RENDER_LEVEL_CANDIDATES = Union[str]  # pylint: disable=invalid-name
+_ERROR_RENDER_LEVEL = {
+    "detail": 0,
+    "fast": 1,
+    "none": 2,
+}
+
+
+def _preprocess_constructor_arguments(
+    mod: Union[PrimFunc, IRModule],
+    debug_mode: Union[bool, int] = False,
+    error_render_level: str = "detail",
+) -> Tuple[IRModule, int, int]:
+    # preprocess `mod`
+    if isinstance(mod, PrimFunc):
+        mod = IRModule({"main": mod})
+    # preprocess `debug_mode`
+    if isinstance(debug_mode, bool):
+        if debug_mode:
+            debug_mode = -1

Review comment:
       My understanding is that this is a pythonic wrapper to makes it friendly 
to python ecosystem, while c++ side will have its own set of c++ focused API




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