-
Notifications
You must be signed in to change notification settings - Fork 0
[Meta Schedule] Evolutionary Search #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
junrushao
merged 14 commits into
tlc-pack:meta-schedule-refactor
from
zxybazh:tensorir-infra/upstream/2021-11-18/evolutionary-search
Dec 7, 2021
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4eb75ce
Checkpoint.
zxybazh 0062446
Squashed commit
junrushao 69e38c8
[TensorIR] GetProducer, GetConsumer (#506)
junrushao e0c9e66
[MetaScheduleRefactor] Annotate&Unannotate (#505)
spectrometerHBH f653621
[MetaSchedule] Rewrite Cooperative-Fetching / Unbound-Block / Reducti…
junrushao 8d829c2
Blockize & Tensorize (#514)
vinx13 e171f01
Checkpoint.
zxybazh c184547
Fix TuneContext.
zxybazh eb8a4ae
Fix haash & stuff.
zxybazh eb86feb
Modifyy shash.
zxybazh ece4c4f
Remove trace field.
zxybazh 3351e73
Minor fix.
zxybazh 9f1db1e
Fix cbmask.
zxybazh 1949b04
Fix numbers.
zxybazh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
python/tvm/meta_schedule/search_strategy/evolutionary_search.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| """Evolutionary Search Strategy""" | ||
|
|
||
| from typing import TYPE_CHECKING, Dict | ||
|
|
||
| from tvm._ffi import register_object | ||
|
|
||
| from .search_strategy import SearchStrategy | ||
| from ..mutator import Mutator | ||
| from ..database import Database | ||
|
|
||
| from .. import _ffi_api | ||
|
|
||
| if TYPE_CHECKING: | ||
| from ..cost_model import CostModel | ||
|
|
||
|
|
||
| @register_object("meta_schedule.EvolutionarySearch") | ||
| class EvolutionarySearch(SearchStrategy): | ||
| """ | ||
| Replay Trace Search Strategy is a search strategy that always replays the trace by removing its | ||
| decisions so that the decisions would be randomly re-generated. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| num_trials_per_iter : int | ||
| Number of trials per iteration. | ||
| num_trials_total : int | ||
| Total number of trials. | ||
| population : int | ||
| The initial population of traces from measured samples and randomly generated samples. | ||
| max_replay_fail_cnt : int | ||
| The maximum number to fail trace replaying. | ||
| init_measured_ratio : int | ||
| The ratio of measured samples in the initial population. | ||
| genetic_algo_iters : int | ||
| The number of iterations for genetic algorithm. | ||
| max_evolve_fail_cnt : int | ||
| The maximum number to retry mutation. | ||
| p_mutate : float | ||
| The probability of mutation. | ||
| eps_greedy : float | ||
| The ratio of greedy selected samples in the final picks. | ||
| database : Database | ||
| The database used in the search. | ||
| cost_model : CostModel | ||
| The cost model used in the search. | ||
| """ | ||
|
|
||
| num_trials_per_iter: int | ||
| num_trials_total: int | ||
| population: int | ||
| init_measured_ratio: int | ||
| genetic_algo_iters: int | ||
| max_replay_fail_cnt: int | ||
| max_evolve_fail_cnt: int | ||
| p_mutate: float | ||
| eps_greedy: float | ||
| database: Database | ||
| cost_model: "CostModel" | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| num_trials_per_iter: int, | ||
| num_trials_total: int, | ||
| database: Database, | ||
| cost_model: "CostModel", | ||
| population: int = 2048, | ||
| max_replay_fail_cnt: int = 64, | ||
| init_measured_ratio: float = 0.2, | ||
| genetic_algo_iters: int = 10, | ||
| max_evolve_fail_cnt: int = 10, | ||
| p_mutate: float = 0.85, | ||
| eps_greedy: float = 0.25, | ||
| ): | ||
| """Constructor""" | ||
| self.__init_handle_by_constructor__( | ||
| _ffi_api.SearchStrategyEvolutionarySearch, # type: ignore # pylint: disable=no-member | ||
| num_trials_per_iter, | ||
| num_trials_total, | ||
| population, | ||
| max_replay_fail_cnt, | ||
| init_measured_ratio, | ||
| genetic_algo_iters, | ||
| max_evolve_fail_cnt, | ||
| p_mutate, | ||
| eps_greedy, | ||
| database, | ||
| cost_model, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.