tkonolige commented on a change in pull request #8623:
URL: https://github.com/apache/tvm/pull/8623#discussion_r681346561
##########
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
+ else:
+ debug_mode = 0
+ if not isinstance(debug_mode, int):
+ raise TypeError(f"`debug_mode` should be integer or boolean, but gets:
{debug_mode}")
Review comment:
```suggestion
raise TypeError(f"`debug_mode` should be integer or boolean, but
got: {debug_mode}")
```
##########
File path: include/tvm/tir/schedule/schedule.h
##########
@@ -299,6 +302,20 @@ class Schedule : public runtime::ObjectRef {
*/
TVM_DLL static Schedule Concrete(IRModule mod, int debug_mode,
ScheduleErrorRenderLevel
error_render_level);
+ /*!
+ * \brief Construct a traced concrete TensorIR schedule from an IRModule
+ * \param mod The IRModule to be scheduled
+ * \param debug_mode Do extra correctness checking after the class creation
+ * and each time after calling the Replace method.
+ * \param error_render_level The level of error rendering
+ * \return The concrete schedule created
+ * \sa ScheduleDebugMask
+ * \note The checks performed include:
+ * 1) VerifySRefTree
+ * 2) VerifyCachedFlags
+ */
+ TVM_DLL static Schedule Traced(IRModule mod, int debug_mode,
Review comment:
ScheduleDebugMask is a uint32_t, yet `debug_mode` is an int. Shouldn't
they be the same type?
##########
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:
Are you assuming two-complement integer representation or unsigned
underflow here? I'd prefer that the mask was set more explicitly.
--
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]