diff --git a/python/tvm/meta_schedule/space_generator/__init__.py b/python/tvm/meta_schedule/space_generator/__init__.py index fc08cd491de76..007fa6da4559d 100644 --- a/python/tvm/meta_schedule/space_generator/__init__.py +++ b/python/tvm/meta_schedule/space_generator/__init__.py @@ -19,7 +19,7 @@ Meta Schedule design space generators that generates design space for generation of measure candidates. """ -from .space_generator import SpaceGenerator, PySpaceGenerator -from .space_generator_union import SpaceGeneratorUnion -from .schedule_fn import ScheduleFn from .post_order_apply import PostOrderApply +from .schedule_fn import SCH_FN_TYPE, ScheduleFn +from .space_generator import PySpaceGenerator, SpaceGenerator +from .space_generator_union import SpaceGeneratorUnion diff --git a/python/tvm/meta_schedule/space_generator/schedule_fn.py b/python/tvm/meta_schedule/space_generator/schedule_fn.py index ffc13eecca260..97498bcbf59d4 100644 --- a/python/tvm/meta_schedule/space_generator/schedule_fn.py +++ b/python/tvm/meta_schedule/space_generator/schedule_fn.py @@ -30,18 +30,17 @@ if TYPE_CHECKING: from ..tune_context import TuneContext +SCH_FN_TYPE = Union[ # pylint: disable=invalid-name + Callable[[Schedule], None], # No output + Callable[[Schedule], Schedule], # Single output + Callable[[Schedule], List[Schedule]], # Multiple outputs +] + @derived_object class ScheduleFn(PySpaceGenerator): """A design space generator with design spaces specified by a schedule function.""" - # Multiple cases of schedule functions supported - SCH_FN_TYPE = Union[ - Callable[[Schedule], None], # No output - Callable[[Schedule], Schedule], # Single output - Callable[[Schedule], List[Schedule]], # Multiple outputs - ] - def __init__(self, sch_fn: SCH_FN_TYPE): """Constructor. diff --git a/python/tvm/meta_schedule/tune.py b/python/tvm/meta_schedule/tune.py index 9ee02aa2bbc62..0622b8d773b7a 100644 --- a/python/tvm/meta_schedule/tune.py +++ b/python/tvm/meta_schedule/tune.py @@ -88,7 +88,7 @@ class TuneConfig(NamedTuple): search_strategy_config: Optional[Dict[str, Any]] = None logger_config: Optional[Dict[str, Any]] = None - def create_strategy(self, **kwargs): + def create_strategy(self): """Create search strategy from configuration""" cls_tbl = { "evolutionary": EvolutionarySearch, @@ -111,7 +111,6 @@ def create_strategy(self, **kwargs): return cls_tbl[self.strategy]( num_trials_per_iter=self.num_trials_per_iter, max_trials_per_task=max_trials_per_task, - **kwargs, **config, ) diff --git a/python/tvm/meta_schedule/tune_context.py b/python/tvm/meta_schedule/tune_context.py index 78fd3d659fafa..8694b79206ee8 100644 --- a/python/tvm/meta_schedule/tune_context.py +++ b/python/tvm/meta_schedule/tune_context.py @@ -17,7 +17,7 @@ """Meta Schedule tuning context.""" import logging -from typing import TYPE_CHECKING, Dict, List, Optional +from typing import TYPE_CHECKING, Dict, List, Optional, Union from tvm import IRModule from tvm._ffi import register_object @@ -36,7 +36,8 @@ from .runner import RunnerResult from .schedule_rule import ScheduleRule from .search_strategy import MeasureCandidate, SearchStrategy - from .space_generator import SpaceGenerator + from .space_generator import SCH_FN_TYPE, ScheduleFn, SpaceGenerator + from .tune import TuneConfig @register_object("meta_schedule.TuneContext") @@ -54,16 +55,24 @@ class TuneContext(Object): The workload to be optimized. target : Optional[Target] = None The target to be optimized for. - space_generator : Optional[SpaceGenerator] = None + space_generator : Union[None, SCH_FN_TYPE, SpaceGenerator] = None The design space generator. - search_strategy : Optional[SearchStrategy] = None + search_strategy : Union[None, TuneConfig, SearchStrategy] = None The search strategy. - sch_rules: Optional[List[ScheduleRule]] = None, + if None, the strategy is left blank. + If TuneConfig, the strategy is initialized with the TuneConfig.create_strategy(). + sch_rules: Union[None, str, List[ScheduleRule]] = None, The schedule rules. - postprocs: Optional[List[Postproc"]] = None, + If None, use an empty list of rules. + if "default", use target-default rules. + postprocs: Union[None, str, List[Postproc"]] = None, The postprocessors. - mutator_probs: Optional[Dict[Mutator, float]] + If None, use an empty list of rules. + if "default", use target-default rules. + mutator_probs: Union[None, str, Dict[Mutator, float]] Mutators and their probability mass. + If None, use an empty list of rules. + if "default", use target-default rules. task_name : Optional[str] = None The name of the tuning task. logger : logging.Logger @@ -99,24 +108,53 @@ def __init__( mod: Optional[IRModule] = None, *, target: Optional[Target] = None, - space_generator: Optional["SpaceGenerator"] = None, - search_strategy: Optional["SearchStrategy"] = None, - sch_rules: Optional[List["ScheduleRule"]] = None, - postprocs: Optional[List["Postproc"]] = None, - mutator_probs: Optional[Dict["Mutator", float]] = None, + space_generator: Union[None, "SCH_FN_TYPE", "ScheduleFn", "SpaceGenerator"] = None, + search_strategy: Union[None, "SearchStrategy", "TuneConfig"] = None, + sch_rules: Union[None, str, List["ScheduleRule"]] = None, + postprocs: Union[None, str, List["Postproc"]] = None, + mutator_probs: Union[None, str, Dict["Mutator", float]] = None, task_name: str = "main", logger: Optional[logging.Logger] = None, rand_state: int = -1, num_threads: Optional[int] = None, ): + # pylint: disable=import-outside-toplevel + from . import default_config + from .space_generator import ScheduleFn + from .tune import TuneConfig + + # pylint: enable=import-outside-toplevel if isinstance(mod, PrimFunc): mod = IRModule.from_expr(mod) - if num_threads is None: - num_threads = cpu_count() + if callable(space_generator): + space_generator = ScheduleFn(space_generator) + if isinstance(search_strategy, TuneConfig): + search_strategy = search_strategy.create_strategy() + if isinstance(sch_rules, str): + if sch_rules == "default": + if target is None: + raise ValueError("target is required when sch_rules is 'default'") + sch_rules = default_config.schedule_rules(None, target) + else: + raise ValueError("sch_rules should be a list of ScheduleRule or 'default'") + if isinstance(postprocs, str): + if postprocs == "default": + if target is None: + raise ValueError("target is required when postprocs is 'default'") + postprocs = default_config.postproc(None, target) + else: + raise ValueError("postprocs should be a list of Postproc or 'default'") + if isinstance(mutator_probs, str): + if mutator_probs == "default": + if target is None: + raise ValueError("target is required when mutator_probs is 'default'") + mutator_probs = default_config.mutator_probs(None, target) if logger is None: self.logger = logging.getLogger(__name__) else: self.logger = None + if num_threads is None: + num_threads = cpu_count() self.__init_handle_by_constructor__( _ffi_api.TuneContext, # type: ignore # pylint: disable=no-member mod, @@ -131,9 +169,6 @@ def __init__( rand_state, num_threads, ) - - def initialize(self): - """Initialize the tuning context""" _ffi_api.TuneContextInitialize(self) # type: ignore # pylint: disable=no-member def generate_design_space(self) -> List[Schedule]: @@ -157,7 +192,7 @@ def generate_design_space(self) -> List[Schedule]: def pre_tuning( self, - design_spaces: List[Schedule], + design_spaces: Optional[List[Schedule]] = None, database: Optional["Database"] = None, cost_model: Optional["CostModel"] = None, ) -> None: @@ -167,7 +202,7 @@ def pre_tuning( Parameters ---------- - design_spaces : List[Schedule] + design_spaces : Optional[List[Schedule]] The design spaces used during tuning process. database : Optional[Database] = None The database used during tuning process. @@ -179,6 +214,8 @@ def pre_tuning( "search_strategy is not provided." "Please construct TuneContext with search_strategy" ) + if design_spaces is None: + design_spaces = self.generate_design_space() return self.search_strategy.pre_tuning(design_spaces, database, cost_model) def post_tuning(self) -> None: @@ -191,7 +228,7 @@ def post_tuning(self) -> None: "search_strategy is not provided." "Please construct TuneContext with search_strategy" ) - _ffi_api.SearchStrategyPostTuning(self) # type: ignore # pylint: disable=no-member + return self.search_strategy.post_tuning() def generate_measure_candidates(self) -> Optional[List["MeasureCandidate"]]: """Generate a batch of measure candidates from design spaces for measurement. @@ -208,7 +245,7 @@ def generate_measure_candidates(self) -> Optional[List["MeasureCandidate"]]: "search_strategy is not provided." "Please construct TuneContext with search_strategy" ) - return _ffi_api.SearchStrategyGenerateMeasureCandidates(self) # type: ignore # pylint: disable=no-member + return self.search_strategy.generate_measure_candidates() def notify_runner_results( self, @@ -231,8 +268,4 @@ def notify_runner_results( "search_strategy is not provided." "Please construct TuneContext with search_strategy" ) - _ffi_api.SearchStrategyNotifyRunnerResults( # type: ignore # pylint: disable=no-member - self, - measure_candidates, - results, - ) + return self.search_strategy.notify_runner_results(measure_candidates, results) diff --git a/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cpu.py b/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cpu.py index 31b8b81829955..69408a2e901ac 100644 --- a/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cpu.py +++ b/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cpu.py @@ -173,7 +173,6 @@ def test_conv2d_winograd_cpu(): target, ), ) - context.initialize() post_order_apply = context.space_generator (sch,) = post_order_apply.generate_design_space(mod) decisions = dict( diff --git a/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cuda.py b/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cuda.py index f8fdb79a1ded4..958baabedb6d5 100644 --- a/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cuda.py +++ b/tests/python/unittest/test_meta_schedule_custom_rule_winograd_cuda.py @@ -290,7 +290,6 @@ def test_conv2d_winograd_cuda(): None, Target("cuda") ), ) - context.initialize() post_order_apply = context.space_generator (sch,) = post_order_apply.generate_design_space(mod) decisions = dict( diff --git a/tests/python/unittest/test_meta_schedule_integration.py b/tests/python/unittest/test_meta_schedule_integration.py index 155d6aa235fd0..f2802b41ebb52 100644 --- a/tests/python/unittest/test_meta_schedule_integration.py +++ b/tests/python/unittest/test_meta_schedule_integration.py @@ -221,7 +221,7 @@ def traverse(t): mod, target="llvm", params=params, - filter_func=filter_func, + te_filter_func=filter_func, ) expected_task_names = [ "fused_" + s diff --git a/tests/python/unittest/test_meta_schedule_mutator_mutate_compute_location.py b/tests/python/unittest/test_meta_schedule_mutator_mutate_compute_location.py index 882655c17f5ac..3d4a9966cb90f 100644 --- a/tests/python/unittest/test_meta_schedule_mutator_mutate_compute_location.py +++ b/tests/python/unittest/test_meta_schedule_mutator_mutate_compute_location.py @@ -69,7 +69,6 @@ def _make_mutator(target: Target) -> Mutator: MutateComputeLocation(): 1.0, }, ) - ctx.initialize() return list(ctx.mutator_probs.keys())[0] diff --git a/tests/python/unittest/test_meta_schedule_mutator_mutate_parallel.py b/tests/python/unittest/test_meta_schedule_mutator_mutate_parallel.py index 42e8ffd678f54..b517c3ed490a5 100644 --- a/tests/python/unittest/test_meta_schedule_mutator_mutate_parallel.py +++ b/tests/python/unittest/test_meta_schedule_mutator_mutate_parallel.py @@ -87,7 +87,6 @@ def _make_mutator(target: Target, max_jobs_per_core: int) -> Mutator: MutateParallel(max_jobs_per_core): 1.0, }, ) - ctx.initialize() return list(ctx.mutator_probs.keys())[0] diff --git a/tests/python/unittest/test_meta_schedule_mutator_mutate_thread_binding.py b/tests/python/unittest/test_meta_schedule_mutator_mutate_thread_binding.py index 10bbdb366c8f7..1dc7588edd7d2 100644 --- a/tests/python/unittest/test_meta_schedule_mutator_mutate_thread_binding.py +++ b/tests/python/unittest/test_meta_schedule_mutator_mutate_thread_binding.py @@ -70,7 +70,6 @@ def _make_mutator(target: Target) -> Mutator: MutateThreadBinding(): 1.0, }, ) - ctx.initialize() return list(ctx.mutator_probs.keys())[0] diff --git a/tests/python/unittest/test_meta_schedule_mutator_mutate_tile_size.py b/tests/python/unittest/test_meta_schedule_mutator_mutate_tile_size.py index 47b386447b02b..00b190a75de72 100644 --- a/tests/python/unittest/test_meta_schedule_mutator_mutate_tile_size.py +++ b/tests/python/unittest/test_meta_schedule_mutator_mutate_tile_size.py @@ -73,7 +73,6 @@ def _make_mutator(target: Target) -> Mutator: target=target, mutator_probs={MutateTileSize(): 1.0}, ) - ctx.initialize() return list(ctx.mutator_probs.keys())[0] diff --git a/tests/python/unittest/test_meta_schedule_mutator_mutate_unroll.py b/tests/python/unittest/test_meta_schedule_mutator_mutate_unroll.py index dece8a8bc1ec9..7bed83f522326 100644 --- a/tests/python/unittest/test_meta_schedule_mutator_mutate_unroll.py +++ b/tests/python/unittest/test_meta_schedule_mutator_mutate_unroll.py @@ -92,7 +92,6 @@ def _make_mutator(target: Target) -> Mutator: MutateUnroll(): 1.0, }, ) - ctx.initialize() return list(ctx.mutator_probs.keys())[0] diff --git a/tests/python/unittest/test_meta_schedule_post_order_apply.py b/tests/python/unittest/test_meta_schedule_post_order_apply.py index 4300e66aa567f..2609d2be9d3f6 100644 --- a/tests/python/unittest/test_meta_schedule_post_order_apply.py +++ b/tests/python/unittest/test_meta_schedule_post_order_apply.py @@ -223,7 +223,6 @@ def test_meta_schedule_post_order_apply(): space_generator=PostOrderApply(), sch_rules=[WowSoFancyScheduleRule()], ) - context.initialize() post_order_apply = context.space_generator schs = post_order_apply.generate_design_space(mod) assert len(schs) == 1 @@ -240,7 +239,6 @@ def test_meta_schedule_post_order_apply_double(): space_generator=PostOrderApply(), sch_rules=[DoubleScheduleRule()], ) - context.initialize() post_order_apply = context.space_generator schs = post_order_apply.generate_design_space(mod) assert len(schs) == 2 @@ -258,7 +256,6 @@ def test_meta_schedule_post_order_apply_multiple(): space_generator=PostOrderApply(), sch_rules=[DoubleScheduleRule(), ReorderScheduleRule()], ) - context.initialize() post_order_apply = context.space_generator schs = post_order_apply.generate_design_space(mod) assert len(schs) == 4 @@ -276,7 +273,6 @@ def test_meta_schedule_post_order_apply_duplicate_matmul(): space_generator=PostOrderApply(), sch_rules=[WowSoFancyScheduleRule()], ) - context.initialize() post_order_apply = context.space_generator with pytest.raises( TVMError, @@ -348,7 +344,6 @@ def correct_trace(a, b, c, d): space_generator=PostOrderApply(), sch_rules=[RemoveBlock(), TrinityDouble()], ) - context.initialize() post_order_apply = context.space_generator schs = post_order_apply.generate_design_space(mod) assert len(schs) == 4 @@ -376,7 +371,6 @@ def test_meta_schedule_custom_search_space(): space_generator=PostOrderApply(), sch_rules=[], ) - context.initialize() post_order_apply = context.space_generator post_order_apply.generate_design_space(mod) called = False diff --git a/tests/python/unittest/test_meta_schedule_postproc_disallow_dynamic_loop.py b/tests/python/unittest/test_meta_schedule_postproc_disallow_dynamic_loop.py index 906519cd36eb5..92c669ca1febb 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_disallow_dynamic_loop.py +++ b/tests/python/unittest/test_meta_schedule_postproc_disallow_dynamic_loop.py @@ -37,7 +37,6 @@ def _create_context(mod, target) -> TuneContext: ], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_postproc_rewrite_cooperative_fetch.py b/tests/python/unittest/test_meta_schedule_postproc_rewrite_cooperative_fetch.py index e31e912ae4a9a..5460c5900946b 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_rewrite_cooperative_fetch.py +++ b/tests/python/unittest/test_meta_schedule_postproc_rewrite_cooperative_fetch.py @@ -39,7 +39,6 @@ def _create_context(mod, target) -> TuneContext: ], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_postproc_rewrite_reduction_block.py b/tests/python/unittest/test_meta_schedule_postproc_rewrite_reduction_block.py index c7b6e89727a10..24d1229b3ac69 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_rewrite_reduction_block.py +++ b/tests/python/unittest/test_meta_schedule_postproc_rewrite_reduction_block.py @@ -37,7 +37,6 @@ def _create_context(mod, target) -> TuneContext: ], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_postproc_rewrite_tensorize.py b/tests/python/unittest/test_meta_schedule_postproc_rewrite_tensorize.py index 51bf2226d3e1a..6fae11c7fd547 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_rewrite_tensorize.py +++ b/tests/python/unittest/test_meta_schedule_postproc_rewrite_tensorize.py @@ -457,7 +457,6 @@ def _create_context(mod, target, postprocs): postprocs=postprocs, task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_postproc_rewrite_unbound_block.py b/tests/python/unittest/test_meta_schedule_postproc_rewrite_unbound_block.py index d797bc9d154d0..ebc435a02e8bd 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_rewrite_unbound_block.py +++ b/tests/python/unittest/test_meta_schedule_postproc_rewrite_unbound_block.py @@ -38,7 +38,6 @@ def _create_context(mod, target) -> TuneContext: ], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py b/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py index c91f7bfd1daea..aacb889cb5771 100644 --- a/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py +++ b/tests/python/unittest/test_meta_schedule_postproc_verify_gpu_code.py @@ -41,7 +41,6 @@ def _create_context(mod, target) -> TuneContext: ], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_add_rfactor.py b/tests/python/unittest/test_meta_schedule_schedule_rule_add_rfactor.py index 7f7f52d1f8a28..09daea094520e 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_add_rfactor.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_add_rfactor.py @@ -33,7 +33,6 @@ def _create_context(mod, target, rule) -> TuneContext: sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_auto_bind.py b/tests/python/unittest/test_meta_schedule_schedule_rule_auto_bind.py index 2cedd2051dc82..9c43c23a3e07d 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_auto_bind.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_auto_bind.py @@ -68,7 +68,6 @@ def _create_context(mod, target, rule) -> TuneContext: sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_auto_inline.py b/tests/python/unittest/test_meta_schedule_schedule_rule_auto_inline.py index 5e6690d88e830..2a8a1e5fe12aa 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_auto_inline.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_auto_inline.py @@ -252,7 +252,6 @@ def _create_context(mod, target, rule): sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_cross_thread_reduction.py b/tests/python/unittest/test_meta_schedule_schedule_rule_cross_thread_reduction.py index 79d53cebe45fa..8b21d11a37714 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_cross_thread_reduction.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_cross_thread_reduction.py @@ -67,7 +67,6 @@ def _create_context(mod, target, rule) -> TuneContext: sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_multi_level_tiling.py b/tests/python/unittest/test_meta_schedule_schedule_rule_multi_level_tiling.py index 029dbc52efd1d..51f62f8bd83b1 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_multi_level_tiling.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_multi_level_tiling.py @@ -38,7 +38,6 @@ def _create_context(mod, target, rule) -> TuneContext: sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_parallel_vectorize_unroll.py b/tests/python/unittest/test_meta_schedule_schedule_rule_parallel_vectorize_unroll.py index 752bf5e04c4e8..02b55350b7d5e 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_parallel_vectorize_unroll.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_parallel_vectorize_unroll.py @@ -232,7 +232,6 @@ def _create_context(mod, target, rule): sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_schedule_rule_random_compute_location.py b/tests/python/unittest/test_meta_schedule_schedule_rule_random_compute_location.py index 379fb4675aa50..b2df408e9d016 100644 --- a/tests/python/unittest/test_meta_schedule_schedule_rule_random_compute_location.py +++ b/tests/python/unittest/test_meta_schedule_schedule_rule_random_compute_location.py @@ -63,7 +63,6 @@ def _create_context(mod, target, rule): sch_rules=[rule], task_name="test", ) - ctx.initialize() return ctx diff --git a/tests/python/unittest/test_meta_schedule_search_strategy.py b/tests/python/unittest/test_meta_schedule_search_strategy.py index 1201e4100a979..7433f001c0ebb 100644 --- a/tests/python/unittest/test_meta_schedule_search_strategy.py +++ b/tests/python/unittest/test_meta_schedule_search_strategy.py @@ -89,7 +89,6 @@ def test_meta_schedule_replay_func( num_trials_per_iter=num_trials_per_iter, max_trials_per_task=max_trials_per_task ), ) - context.initialize() strategy = context.search_strategy spaces = context.space_generator.generate_design_space(context.mod) strategy.pre_tuning(spaces) @@ -154,7 +153,6 @@ def _schedule_matmul_small(sch: Schedule): target=tvm.target.Target("llvm"), num_threads=1, # because we are using a mutator from the python side ) - context.initialize() strategy = context.search_strategy strategy.pre_tuning( context.space_generator.generate_design_space(context.mod), @@ -218,7 +216,6 @@ def _schedule_matmul_empty(sch: Schedule): target=tvm.target.Target("llvm"), num_threads=1, ) - context.initialize() strategy = context.search_strategy strategy.pre_tuning( context.space_generator.generate_design_space(context.mod),