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] Improve the GPU tutorial by deleting measure_ctx earlier #6660

Merged
merged 3 commits into from
Oct 11, 2020

Conversation

merrymercy
Copy link
Member

@merrymercy merrymercy commented Oct 10, 2020

To avoid the confusion in #6570, we call del measure_ctx earlier in the tutorial, just after we finish the search.

measure_ctx overloads the __del__. Ideally, we do not need to call del measure_ctx explicitly.
However, I found __del__ only works for local variables.
If we use measure_ctx as a local variable inside a function, it can be garbage-collected correctly.
But in the tutorial, measure_ctx is a global variable. It thus cannot be garbage-collected correctly.

There are two solutions to this problem.
S1. call del measure_ctx explicitly
S2. use

with measure_ctx:
  tune_options = ...
  s, args = auto_scheduler.auto_schedule(...)

I think S1 is better. In S1, del measure_ctx is only required if measure_ctx is a global variable, which is a rare case (but unfortunately, this happens in the tutorial)

@merrymercy merrymercy requested a review from comaniac October 10, 2020 07:37
@merrymercy
Copy link
Member Author

cc @jcf94 @luchangli03

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

@merrymercy merrymercy merged commit f6657a6 into apache:master Oct 11, 2020
@merrymercy merrymercy deleted the pr-del-measure-ctx branch October 11, 2020 09:51
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
…ier (apache#6660)

* del measurement process in the tutorial

* fix

* trigger CI
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.

2 participants