junrushao1994 commented on a change in pull request #10368:
URL: https://github.com/apache/tvm/pull/10368#discussion_r817416165
##########
File path: python/tvm/meta_schedule/task_scheduler/task_scheduler.py
##########
@@ -187,10 +160,114 @@ def f_join_running_task(task_id: int) -> None:
database,
cost_model,
measure_callbacks,
- f_tune,
- f_initialize_task,
- f_set_task_stopped,
- f_is_task_running,
- f_join_running_task,
- f_next_task_id,
+ *methods,
)
+
+
+class PyTaskScheduler:
+ """
+ An abstract task scheduler with customized methods on the python-side.
+ This is the user facing class for function overloading inheritance.
+
+ Note: @derived_object is required for proper usage of any inherited class.
+ """
+
+ _tvm_metadata = {
+ "cls": _PyTaskScheduler,
+ "members": [
+ "tasks",
+ "builder",
+ "runner",
+ "database",
+ "cost_model",
+ "measure_callbacks",
+ ],
+ "methods": [
+ "tune",
+ "initialize_task",
+ "set_task_stopped",
+ "is_task_running",
+ "join_running_task",
+ "next_task_id",
+ ],
+ }
+
+ def __init__(
+ self,
+ tasks: List[TuneContext],
+ builder: Builder,
+ runner: Runner,
+ database: Database,
+ cost_model: Optional[CostModel] = None,
+ measure_callbacks: Optional[List[MeasureCallback]] = None,
+ ):
+ self.tasks = tasks
+ self.builder = builder
+ self.runner = runner
+ self.database = database
+ self.cost_model = cost_model
+ self.measure_callbacks = measure_callbacks
+
+ def tune(self) -> None:
+ """Auto-tuning."""
+ # Using self._outer to replace the self pointer
+ _ffi_api.TaskSchedulerTune(self._outer()) # type: ignore # pylint:
disable=no-member
Review comment:
I don't think we should use the weakref dark magic
--
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]