Skip to content
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

[AutoScheduler] Update layout rewrite option setting for measuring #7156

Merged
merged 14 commits into from Dec 28, 2020

Conversation

jcf94
Copy link
Contributor

@jcf94 jcf94 commented Dec 23, 2020

AutoScheduler uses a cost model to guide the search search.

We now have NO_REWRITE, INSERT_TRANSFORM_STAGE, REWRITE_FOR_PRE_TRANSFORMED three options when applying schedule from AutoScheduler.
In my tests, if we set REWRITE_FOR_PRE_TRANSFORMED in program measuring, the final schedule we get will trend to perform better in REWRITE_FOR_PRE_TRANSFORMED mode. Though this schedule also works in other options, it will not perform the best performance if we would like to get a kernel with NO_REWRITE.

This PR:

  1. Add a layout rewrite option for SearchTask, which will be passed to program measuring.
  2. This option will be set to NO_REWRITE in default, and REWRITE_FOR_PRE_TRANSFORMED when working in a end to end network task.
  3. Update the schedule for the inserted transform stage in option INSERT_TRANSFORM_STAGE, according to python/tvm/topi/x86/injective.py.

cc @merrymercy @comaniac

@jcf94
Copy link
Contributor Author

jcf94 commented Dec 23, 2020

Will update the log version after #7144 since this PR has modified the log structure of SearchTask.

@jcf94 jcf94 requested review from merrymercy and comaniac and removed request for merrymercy December 23, 2020 08:26
python/tvm/auto_scheduler/compute_dag.py Outdated Show resolved Hide resolved
python/tvm/auto_scheduler/search_task.py Outdated Show resolved Hide resolved
@@ -245,15 +254,18 @@ def tune(self, tuning_options, search_policy=None):

_ffi_api.AutoSchedule(search_policy, tuning_options)

def apply_best(self, log_file, layout_rewrite_option=None):
def apply_best(self, log_file, layout_rewrite_option=LayoutRewriteOption.NO_REWRITE):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope: Is it possible to maintain the layout rewrite option in the record? This semantic indicates that you need to know the right layout rewrite option when you want to apply a tuned log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emm ... Then we should also add this to maybe MeasureInput? I'm thinking this may not be so necessary, since we'll always try to apply layout rewrite on network, and this API may only be used in the replying of standalone ops. The user of this API should know what this means.

src/auto_scheduler/measure_record.cc Outdated Show resolved Hide resolved
python/tvm/auto_scheduler/search_task.py Show resolved Hide resolved
@jcf94 jcf94 force-pushed the update_layout_rewrite_option branch from a80dec7 to cee5dd0 Compare December 24, 2020 12:02
Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

python/tvm/auto_scheduler/search_task.py Outdated Show resolved Hide resolved
Comment on lines +1036 to +1037
new_attrs.Set("ori_placeholder_layout", tvm::String(origin_layout));
new_attrs.Set("new_placeholder_layout", tvm::String(new_layout));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to get the layout information when exporting the kernel to run in an environment outside the tvm.
Emm... it's also fine to remove them here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. We can leave them here

python/tvm/auto_scheduler/search_task.py Outdated Show resolved Hide resolved
include/tvm/auto_scheduler/search_task.h Outdated Show resolved Hide resolved
src/auto_scheduler/measure_record.cc Show resolved Hide resolved
@jcf94 jcf94 merged commit 2dec2dd into apache:main Dec 28, 2020
tkonolige pushed a commit to tkonolige/incubator-tvm that referenced this pull request Jan 11, 2021
…pache#7156)

* Add layout rewrite options for measure

* Update schedule for inserted transform stage

* Set layout rewrite when tuning for network

* Update the log version
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Jan 20, 2021
…pache#7156)

* Add layout rewrite options for measure

* Update schedule for inserted transform stage

* Set layout rewrite when tuning for network

* Update the log version
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jan 21, 2021
…pache#7156)

* Add layout rewrite options for measure

* Update schedule for inserted transform stage

* Set layout rewrite when tuning for network

* Update the log version
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
…pache#7156)

* Add layout rewrite options for measure

* Update schedule for inserted transform stage

* Set layout rewrite when tuning for network

* Update the log version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants